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

    double x, f;
    te_variable lookup[] = {
        {"x", &x},
        {"f", &f},
        {"sum0", sum0, TE_FUNCTION0},
        {"sum1", sum1, TE_FUNCTION1},
        {"sum2", sum2, TE_FUNCTION2},
        {"sum3", sum3, TE_FUNCTION3},
        {"sum4", sum4, TE_FUNCTION4},
        {"sum5", sum5, TE_FUNCTION5},
        {"sum6", sum6, TE_FUNCTION6},
        {"sum7", sum7, TE_FUNCTION7},
    };

    test_case cases[] = {
        {"x", 2},
        {"f+x", 7},
        {"x+x", 4},
        {"x+f", 7},
        {"f+f", 10},
        {"f+sum0", 11},
        {"sum0+sum0", 12},
        {"sum0()+sum0", 12},
        {"sum0+sum0()", 12},
        {"sum0()+(0)+sum0()", 12},
        {"sum1 sum0", 12},
        {"sum1(sum0)", 12},
        {"sum1 f", 10},
        {"sum1 x", 4},
        {"sum2 (sum0, x)", 8},
        {"sum3 (sum0, x, 2)", 10},
        {"sum2(2,3)", 5},
        {"sum3(2,3,4)", 9},
        {"sum4(2,3,4,5)", 14},
        {"sum5(2,3,4,5,6)", 20},
        {"sum6(2,3,4,5,6,7)", 27},
        {"sum7(2,3,4,5,6,7,8)", 35},
    };

    x = 2;
    f = 5;

    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, lookup, sizeof(lookup)/sizeof(te_variable), &err);
        lok(ex);
        lfequal(te_eval(ex), answer);
        te_free(ex);
    }
}

// Assembly:
subq $0x2e8, %rsp            # imm = 0x2E8
leaq 0x5031(%rip), %rax      # 0xb58f
movq %rax, 0x190(%rsp)
leaq 0x2e0(%rsp), %rax
movq %rax, 0x198(%rsp)
movl $0x0, 0x1a0(%rsp)
movq $0x0, 0x1a8(%rsp)
leaq 0x50ae(%rip), %rax      # 0xb642
movq %rax, 0x1b0(%rsp)
leaq 0x2d8(%rsp), %rax
movq %rax, 0x1b8(%rsp)
movl $0x0, 0x1c0(%rsp)
movq $0x0, 0x1c8(%rsp)
leaq 0x5063(%rip), %rax      # 0xb62d
movq %rax, 0x1d0(%rsp)
leaq -0x239(%rip), %rax      # 0x63a0
movq %rax, 0x1d8(%rsp)
movl $0x8, 0x1e0(%rsp)
movq $0x0, 0x1e8(%rsp)
leaq 0x4fbb(%rip), %rax      # 0xb5ba
movq %rax, 0x1f0(%rsp)
leaq -0x25e(%rip), %rax      # 0x63b0
movq %rax, 0x1f8(%rsp)
movl $0x9, 0x200(%rsp)
movq $0x0, 0x208(%rsp)
leaq 0x4f8b(%rip), %rax      # 0xb5bf
movq %rax, 0x210(%rsp)
leaq -0x273(%rip), %rax      # 0x63d0
movq %rax, 0x218(%rsp)
movl $0xa, 0x220(%rsp)
movq $0x0, 0x228(%rsp)
leaq 0x4f5b(%rip), %rax      # 0xb5c4
movq %rax, 0x230(%rsp)
leaq -0x288(%rip), %rax      # 0x63f0
movq %rax, 0x238(%rsp)
movl $0xb, 0x240(%rsp)
movq $0x0, 0x248(%rsp)
leaq 0x4f2b(%rip), %rax      # 0xb5c9
movq %rax, 0x250(%rsp)
leaq -0x28d(%rip), %rax      # 0x6420
movq %rax, 0x258(%rsp)
movl $0xc, 0x260(%rsp)
movq $0x0, 0x268(%rsp)
leaq 0x4efb(%rip), %rax      # 0xb5ce
movq %rax, 0x270(%rsp)
leaq -0x282(%rip), %rax      # 0x6460
movq %rax, 0x278(%rsp)
movl $0xd, 0x280(%rsp)
movq $0x0, 0x288(%rsp)
leaq 0x4ecb(%rip), %rax      # 0xb5d3
movq %rax, 0x290(%rsp)
leaq -0x277(%rip), %rax      # 0x64a0
movq %rax, 0x298(%rsp)
movl $0xe, 0x2a0(%rsp)
movq $0x0, 0x2a8(%rsp)
leaq 0x4e9b(%rip), %rax      # 0xb5d8
movq %rax, 0x2b0(%rsp)
leaq -0x25c(%rip), %rax      # 0x64f0
movq %rax, 0x2b8(%rsp)
movl $0xf, 0x2c0(%rsp)
movq $0x0, 0x2c8(%rsp)
leaq 0x30(%rsp), %rdi
leaq 0x7f29(%rip), %rsi      # 0xe6a0
movl $0x160, %edx            # imm = 0x160
callq 0x30e0
movsd 0x488f(%rip), %xmm0     # 0xb018
movsd %xmm0, 0x2e0(%rsp)
movsd 0x488e(%rip), %xmm0     # 0xb028
movsd %xmm0, 0x2d8(%rsp)
movl $0x0, 0x2c(%rsp)
movslq 0x2c(%rsp), %rax
cmpq $0x16, %rax
jae 0x68fb
movslq 0x2c(%rsp), %rcx
leaq 0x30(%rsp), %rax
shlq $0x4, %rcx
addq %rcx, %rax
movq (%rax), %rax
movq %rax, 0x20(%rsp)
movslq 0x2c(%rsp), %rcx
leaq 0x30(%rsp), %rax
shlq $0x4, %rcx
addq %rcx, %rax
movsd 0x8(%rax), %xmm0
movsd %xmm0, 0x18(%rsp)
movq 0x20(%rsp), %rdi
leaq 0x190(%rsp), %rsi
movl $0xa, %edx
leaq 0x14(%rsp), %rcx
callq 0x8ff0
movq %rax, 0x8(%rsp)
movl 0x88e6(%rip), %eax      # 0xf0fc
addl $0x1, %eax
movl %eax, 0x88dd(%rip)      # 0xf0fc
cmpq $0x0, 0x8(%rsp)
jne 0x6850
movl 0x88d3(%rip), %eax      # 0xf100
addl $0x1, %eax
movl %eax, 0x88ca(%rip)      # 0xf100
leaq 0x4b70(%rip), %rdi      # 0xb3ad
leaq 0x4b77(%rip), %rsi      # 0xb3bb
movl $0x1d3, %edx            # imm = 0x1D3
movb $0x0, %al
callq 0x3080
jmp 0x6852
jmp 0x6854
movl 0x88a2(%rip), %eax      # 0xf0fc
addl $0x1, %eax
movl %eax, 0x8899(%rip)      # 0xf0fc
movq 0x8(%rsp), %rdi
callq 0x8450
subsd 0x18(%rsp), %xmm0
movaps 0x4806(%rip), %xmm1     # 0xb080
pand %xmm1, %xmm0
movsd %xmm0, (%rsp)
movsd (%rsp), %xmm0
movsd 0x4778(%rip), %xmm1     # 0xb008
ucomisd %xmm1, %xmm0
ja 0x68a6
movsd (%rsp), %xmm0
ucomisd (%rsp), %xmm0
jne 0x68a6
jp 0x68a6
jmp 0x68df
movl 0x8854(%rip), %eax      # 0xf100
addl $0x1, %eax
movl %eax, 0x884b(%rip)      # 0xf100
movq 0x8(%rsp), %rdi
callq 0x8450
movsd 0x18(%rsp), %xmm1
leaq 0x4af7(%rip), %rdi      # 0xb3c3
leaq 0x4ae8(%rip), %rsi      # 0xb3bb
movl $0x1d4, %edx            # imm = 0x1D4
movb $0x2, %al
callq 0x3080
jmp 0x68e1
movq 0x8(%rsp), %rdi
callq 0x7e40
movl 0x2c(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x2c(%rsp)
jmp 0x67ab
addq $0x2e8, %rsp            # imm = 0x2E8
retq
nopw %cs:(%rax,%rax)