// File: /workspace/github_c_makefile_star2_O0/codeplea[P]tinyexpr/smoke.c
// Function: test_optimize
void test_optimize() {

    test_case cases[] = {
        {"5+5", 10},
        {"pow(2,2)", 4},
        {"sqrt 100", 10},
        {"pi * 2", 6.2832},
    };

    int i;
    for (i = 0; i < sizeof(cases) / sizeof(test_case); ++i) {
        const char *expr = cases[i].expr;
        const double answer = cases[i].answer;

        int err;
        te_expr *ex = te_compile(expr, 0, 0, &err);
        lok(ex);

        /* The answer should be know without
         * even running eval. */
        lfequal(ex->value, answer);
        lfequal(te_eval(ex), answer);

        te_free(ex);
    }
}

// Assembly:
subq $0x88, %rsp
leaq 0x40(%rsp), %rdi
leaq 0x78bd(%rip), %rsi      # 0xe870
movl $0x40, %edx
callq 0x30e0
movl $0x0, 0x3c(%rsp)
movslq 0x3c(%rsp), %rax
cmpq $0x4, %rax
jae 0x71a5
movslq 0x3c(%rsp), %rcx
leaq 0x40(%rsp), %rax
shlq $0x4, %rcx
addq %rcx, %rax
movq (%rax), %rax
movq %rax, 0x30(%rsp)
movslq 0x3c(%rsp), %rcx
leaq 0x40(%rsp), %rax
shlq $0x4, %rcx
addq %rcx, %rax
movsd 0x8(%rax), %xmm0
movsd %xmm0, 0x28(%rsp)
movq 0x30(%rsp), %rdi
xorl %eax, %eax
movl %eax, %esi
xorl %edx, %edx
leaq 0x24(%rsp), %rcx
callq 0x8ff0
movq %rax, 0x18(%rsp)
movl 0x80d3(%rip), %eax      # 0xf0fc
addl $0x1, %eax
movl %eax, 0x80ca(%rip)      # 0xf0fc
cmpq $0x0, 0x18(%rsp)
jne 0x7063
movl 0x80c0(%rip), %eax      # 0xf100
addl $0x1, %eax
movl %eax, 0x80b7(%rip)      # 0xf100
leaq 0x435d(%rip), %rdi      # 0xb3ad
leaq 0x4364(%rip), %rsi      # 0xb3bb
movl $0x234, %edx            # imm = 0x234
movb $0x0, %al
callq 0x3080
jmp 0x7065
jmp 0x7067
movl 0x808f(%rip), %eax      # 0xf0fc
addl $0x1, %eax
movl %eax, 0x8086(%rip)      # 0xf0fc
movq 0x18(%rsp), %rax
movsd 0x8(%rax), %xmm0
subsd 0x28(%rsp), %xmm0
movaps 0x3ff3(%rip), %xmm1     # 0xb080
pand %xmm1, %xmm0
movsd %xmm0, 0x10(%rsp)
movsd 0x10(%rsp), %xmm0
movsd 0x3f63(%rip), %xmm1     # 0xb008
ucomisd %xmm1, %xmm0
ja 0x70bd
movsd 0x10(%rsp), %xmm0
ucomisd 0x10(%rsp), %xmm0
jne 0x70bd
jp 0x70bd
jmp 0x70f6
movl 0x803d(%rip), %eax      # 0xf100
addl $0x1, %eax
movl %eax, 0x8034(%rip)      # 0xf100
movq 0x18(%rsp), %rax
movsd 0x8(%rax), %xmm0
movsd 0x28(%rsp), %xmm1
leaq 0x42e0(%rip), %rdi      # 0xb3c3
leaq 0x42d1(%rip), %rsi      # 0xb3bb
movl $0x238, %edx            # imm = 0x238
movb $0x2, %al
callq 0x3080
jmp 0x70f8
jmp 0x70fa
movl 0x7ffc(%rip), %eax      # 0xf0fc
addl $0x1, %eax
movl %eax, 0x7ff3(%rip)      # 0xf0fc
movq 0x18(%rsp), %rdi
callq 0x8450
subsd 0x28(%rsp), %xmm0
movaps 0x3f60(%rip), %xmm1     # 0xb080
pand %xmm1, %xmm0
movsd %xmm0, 0x8(%rsp)
movsd 0x8(%rsp), %xmm0
movsd 0x3ed0(%rip), %xmm1     # 0xb008
ucomisd %xmm1, %xmm0
ja 0x7150
movsd 0x8(%rsp), %xmm0
ucomisd 0x8(%rsp), %xmm0
jne 0x7150
jp 0x7150
jmp 0x7189
movl 0x7faa(%rip), %eax      # 0xf100
addl $0x1, %eax
movl %eax, 0x7fa1(%rip)      # 0xf100
movq 0x18(%rsp), %rdi
callq 0x8450
movsd 0x28(%rsp), %xmm1
leaq 0x424d(%rip), %rdi      # 0xb3c3
leaq 0x423e(%rip), %rsi      # 0xb3bb
movl $0x239, %edx            # imm = 0x239
movb $0x2, %al
callq 0x3080
jmp 0x718b
movq 0x18(%rsp), %rdi
callq 0x7e40
movl 0x3c(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x3c(%rsp)
jmp 0x6fc5
addq $0x88, %rsp
retq
nopl (%rax)