Skip to content

Instantly share code, notes, and snippets.

@Joshua-Ashton
Last active February 1, 2023 07:20
Show Gist options
  • Save Joshua-Ashton/1f25704b6ccb989c03c1dd60757a6044 to your computer and use it in GitHub Desktop.
Save Joshua-Ashton/1f25704b6ccb989c03c1dd60757a6044 to your computer and use it in GitHub Desktop.
std::isfinite(double):
push rbp
mov rbp, rsp
movsd QWORD PTR [rbp-8], xmm0
movsd xmm0, QWORD PTR [rbp-8]
movq xmm1, QWORD PTR .LC0[rip]
andpd xmm1, xmm0
movsd xmm0, QWORD PTR .LC1[rip]
ucomisd xmm0, xmm1
setb al
xor eax, 1
movzx eax, al
test eax, eax
setne al
pop rbp
ret
std::isnan(double):
push rbp
mov rbp, rsp
movsd QWORD PTR [rbp-8], xmm0
movsd xmm0, QWORD PTR [rbp-8]
ucomisd xmm0, QWORD PTR [rbp-8]
setp al
movzx eax, al
test eax, eax
setne al
pop rbp
ret
double terrible_lerp<double>(double, double, double):
push rbp
mov rbp, rsp
push rbx
sub rsp, 56
movsd QWORD PTR [rbp-40], xmm0
movsd QWORD PTR [rbp-48], xmm1
movsd QWORD PTR [rbp-56], xmm2
mov rax, QWORD PTR [rbp-40]
movq xmm0, rax
call std::isfinite(double)
movzx eax, al
lea ebx, [0+rax*4]
mov rax, QWORD PTR [rbp-48]
movq xmm0, rax
call std::isfinite(double)
movzx eax, al
add eax, eax
or ebx, eax
mov rax, QWORD PTR [rbp-56]
movq xmm0, rax
call std::isfinite(double)
movzx eax, al
or eax, ebx
mov DWORD PTR [rbp-20], eax
cmp DWORD PTR [rbp-20], 7
jne .L8
pxor xmm0, xmm0
comisd xmm0, QWORD PTR [rbp-40]
jb .L9
movsd xmm0, QWORD PTR [rbp-48]
pxor xmm1, xmm1
comisd xmm0, xmm1
jnb .L11
.L9:
movsd xmm0, QWORD PTR [rbp-40]
pxor xmm1, xmm1
comisd xmm0, xmm1
jb .L12
pxor xmm0, xmm0
comisd xmm0, QWORD PTR [rbp-48]
jb .L12
.L11:
movsd xmm0, QWORD PTR [rbp-56]
movapd xmm1, xmm0
mulsd xmm1, QWORD PTR [rbp-48]
movsd xmm0, QWORD PTR .LC3[rip]
subsd xmm0, QWORD PTR [rbp-56]
mulsd xmm0, QWORD PTR [rbp-40]
addsd xmm0, xmm1
jmp .L15
.L12:
movsd xmm0, QWORD PTR .LC3[rip]
ucomisd xmm0, QWORD PTR [rbp-56]
jp .L16
movsd xmm0, QWORD PTR .LC3[rip]
ucomisd xmm0, QWORD PTR [rbp-56]
jne .L16
movsd xmm0, QWORD PTR [rbp-48]
jmp .L15
.L16:
movsd xmm0, QWORD PTR [rbp-48]
subsd xmm0, QWORD PTR [rbp-40]
mulsd xmm0, QWORD PTR [rbp-56]
movsd xmm1, QWORD PTR [rbp-40]
addsd xmm0, xmm1
movsd QWORD PTR [rbp-32], xmm0
movsd xmm0, QWORD PTR [rbp-56]
movsd xmm1, QWORD PTR .LC3[rip]
comisd xmm0, xmm1
seta al
movzx edx, al
movsd xmm0, QWORD PTR [rbp-48]
comisd xmm0, QWORD PTR [rbp-40]
seta al
movzx eax, al
cmp edx, eax
jne .L18
movsd xmm0, QWORD PTR [rbp-48]
comisd xmm0, QWORD PTR [rbp-32]
jbe .L19
movsd xmm0, QWORD PTR [rbp-48]
jmp .L15
.L18:
movsd xmm0, QWORD PTR [rbp-32]
comisd xmm0, QWORD PTR [rbp-48]
jbe .L19
movsd xmm0, QWORD PTR [rbp-48]
jmp .L15
.L19:
movsd xmm0, QWORD PTR [rbp-32]
jmp .L15
.L8:
mov rax, QWORD PTR [rbp-40]
movq xmm0, rax
call std::isnan(double)
test al, al
je .L22
movsd xmm0, QWORD PTR [rbp-40]
jmp .L15
.L22:
mov rax, QWORD PTR [rbp-48]
movq xmm0, rax
call std::isnan(double)
test al, al
je .L23
movsd xmm0, QWORD PTR [rbp-48]
jmp .L15
.L23:
mov rax, QWORD PTR [rbp-56]
movq xmm0, rax
call std::isnan(double)
test al, al
je .L24
movsd xmm0, QWORD PTR [rbp-56]
jmp .L15
.L24:
cmp DWORD PTR [rbp-20], 6
ja .L25
mov eax, DWORD PTR [rbp-20]
mov rax, QWORD PTR .L27[0+rax*8]
jmp rax
.L27:
.quad .L31
.quad .L30
.quad .L26
.quad .L29
.quad .L26
.quad .L28
.quad .L26
.L31:
movsd xmm0, QWORD PTR [rbp-56]
movsd xmm1, QWORD PTR .LC3[rip]
comisd xmm0, xmm1
jb .L61
movsd xmm0, QWORD PTR [rbp-48]
jmp .L15
.L61:
movsd xmm0, QWORD PTR [rbp-40]
jmp .L15
.L26:
movsd xmm0, QWORD PTR [rbp-48]
subsd xmm0, QWORD PTR [rbp-40]
mulsd xmm0, QWORD PTR [rbp-56]
jmp .L15
.L30:
movsd xmm0, QWORD PTR [rbp-40]
ucomisd xmm0, QWORD PTR [rbp-48]
jp .L34
movsd xmm0, QWORD PTR [rbp-40]
ucomisd xmm0, QWORD PTR [rbp-48]
jne .L34
movsd xmm0, QWORD PTR [rbp-40]
jmp .L15
.L34:
pxor xmm0, xmm0
comisd xmm0, QWORD PTR [rbp-56]
jb .L62
movsd xmm0, QWORD PTR [rbp-40]
jmp .L15
.L62:
movsd xmm0, QWORD PTR [rbp-56]
movsd xmm1, QWORD PTR .LC3[rip]
comisd xmm0, xmm1
jb .L63
movsd xmm0, QWORD PTR [rbp-48]
jmp .L15
.L63:
movsd xmm0, QWORD PTR .LC4[rip]
jmp .L15
.L29:
movsd xmm0, QWORD PTR .LC3[rip]
ucomisd xmm0, QWORD PTR [rbp-56]
jp .L40
movsd xmm0, QWORD PTR .LC3[rip]
ucomisd xmm0, QWORD PTR [rbp-56]
jne .L40
movsd xmm0, QWORD PTR [rbp-48]
jmp .L15
.L40:
movsd xmm0, QWORD PTR .LC3[rip]
comisd xmm0, QWORD PTR [rbp-56]
jbe .L64
movsd xmm0, QWORD PTR [rbp-40]
jmp .L15
.L64:
movsd xmm0, QWORD PTR [rbp-40]
movq xmm1, QWORD PTR .LC5[rip]
xorpd xmm0, xmm1
jmp .L15
.L28:
pxor xmm0, xmm0
ucomisd xmm0, QWORD PTR [rbp-56]
jp .L44
pxor xmm0, xmm0
ucomisd xmm0, QWORD PTR [rbp-56]
jne .L44
movsd xmm0, QWORD PTR [rbp-40]
jmp .L15
.L44:
movsd xmm0, QWORD PTR [rbp-56]
pxor xmm1, xmm1
comisd xmm0, xmm1
jbe .L65
movsd xmm0, QWORD PTR [rbp-48]
jmp .L15
.L65:
movsd xmm0, QWORD PTR [rbp-48]
movq xmm1, QWORD PTR .LC5[rip]
xorpd xmm0, xmm1
jmp .L15
.L25:
call abort
.L15:
add rsp, 56
pop rbx
pop rbp
ret
.LC0:
.long 4294967295
.long 2147483647
.long 0
.long 0
.LC1:
.long 4294967295
.long 2146435071
.LC3:
.long 0
.long 1072693248
.LC4:
.long 0
.long 2146959360
.LC5:
.long 0
.long -2147483648
.long 0
.long 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment