// File: /workspace/github_cpp_makefile_star2_O1/pfnet-research[P]pml/src/evaluator.cpp
// Function: calc_int_binop(ast::expr_t const&, ast::expr_t const&, ast::expr_kind_t)
ptr<ast::expr_t> calc_int_binop(
        ast::expr_t const& lhs,
        ast::expr_t const& rhs,
        ast::expr_kind_t kind) {
    using namespace ast;
    assert(is_value(lhs));
    assert(is_value(rhs));
    switch (kind) {
    case expr_kind_t::Eq:
        return make<bool_expr_t>(lhs == rhs);
    case expr_kind_t::Neq:
        return make<bool_expr_t>(lhs != rhs);
    case expr_kind_t::Leq:
        return make<bool_expr_t>(cast<int_expr_t>(lhs).n <= cast<int_expr_t>(rhs).n);
    case expr_kind_t::Geq:
        return make<bool_expr_t>(cast<int_expr_t>(lhs).n >= cast<int_expr_t>(rhs).n);
    case expr_kind_t::Add:
        return make<int_expr_t>(cast<int_expr_t>(lhs).n + cast<int_expr_t>(rhs).n);
    case expr_kind_t::Sub:
        return make<int_expr_t>(cast<int_expr_t>(lhs).n - cast<int_expr_t>(rhs).n);
    case expr_kind_t::Mul:
        return make<int_expr_t>(cast<int_expr_t>(lhs).n * cast<int_expr_t>(rhs).n);
    case expr_kind_t::Div:
        return make<int_expr_t>(cast<int_expr_t>(lhs).n / cast<int_expr_t>(rhs).n);
    case expr_kind_t::And:
        return make<bool_expr_t>(cast<bool_expr_t>(lhs).b && cast<bool_expr_t>(rhs).b);
    case expr_kind_t::Or:
        return make<bool_expr_t>(cast<bool_expr_t>(lhs).b || cast<bool_expr_t>(rhs).b);
    default:
        throw std::logic_error{"invalid binop : " + to_string(kind)};
    }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0x40, %rsp
movl %ecx, %r12d
movq %rdx, %r14
movq %rsi, %r15
movq %rdi, %rbx
movq (%rsi), %rax
movq %rsi, %rdi
callq *(%rax)
leal -0x11(%rax), %ecx
cmpl $0x2, %ecx
jb 0xb5c1
cmpl $0x14, %eax
jne 0xb9d6
movq (%r14), %rax
movq %r14, %rdi
callq *(%rax)
leal -0x11(%rax), %ecx
cmpl $0x2, %ecx
jb 0xb5da
cmpl $0x14, %eax
jne 0xb9f5
leal -0x6(%r12), %eax
cmpl $0xa, %eax
ja 0xba14
leaq 0x39c41(%rip), %rcx     # 0x45230
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
leaq 0x55471(%rip), %rsi     # 0x60a70
leaq 0x55492(%rip), %rdx     # 0x60a98
movq %r15, %rdi
xorl %ecx, %ecx
callq 0x9340
testq %rax, %rax
je 0xb9d1
movq %rax, %r15
leaq 0x5544d(%rip), %rsi     # 0x60a70
leaq 0x5546e(%rip), %rdx     # 0x60a98
movq %r14, %rdi
xorl %ecx, %ecx
callq 0x9340
testq %rax, %rax
je 0xb9d1
movl 0x8(%rax), %ebp
addl 0x8(%r15), %ebp
jmp 0xb8c0
leaq 0x55420(%rip), %rsi     # 0x60a70
leaq 0x55429(%rip), %rdx     # 0x60a80
movq %r15, %rdi
xorl %ecx, %ecx
callq 0x9340
testq %rax, %rax
je 0xb9d1
movb $0x1, %bpl
cmpb $0x0, 0x8(%rax)
jne 0xb767
leaq 0x553f2(%rip), %rsi     # 0x60a70
leaq 0x553fb(%rip), %rdx     # 0x60a80
movq %r14, %rdi
xorl %ecx, %ecx
callq 0x9340
testq %rax, %rax
je 0xb9d1
movb 0x8(%rax), %bpl
jmp 0xb767
leaq 0x553c8(%rip), %rsi     # 0x60a70
leaq 0x553d1(%rip), %rdx     # 0x60a80
movq %r15, %rdi
xorl %ecx, %ecx
callq 0x9340
testq %rax, %rax
je 0xb9d1
cmpb $0x1, 0x8(%rax)
jne 0xb983
leaq 0x5539d(%rip), %rsi     # 0x60a70
leaq 0x553a6(%rip), %rdx     # 0x60a80
movq %r14, %rdi
xorl %ecx, %ecx
callq 0x9340
testq %rax, %rax
je 0xb9d1
movb 0x8(%rax), %bpl
jmp 0xb985
movq %r15, %rdi
movq %r14, %rsi
callq 0xe4ac
movl %eax, %ebp
jmp 0xb767
leaq 0x55364(%rip), %rsi     # 0x60a70
leaq 0x55385(%rip), %rdx     # 0x60a98
movq %r15, %rdi
xorl %ecx, %ecx
callq 0x9340
testq %rax, %rax
je 0xb9d1
movq %rax, %r15
leaq 0x55340(%rip), %rsi     # 0x60a70
leaq 0x55361(%rip), %rdx     # 0x60a98
movq %r14, %rdi
xorl %ecx, %ecx
callq 0x9340
testq %rax, %rax
je 0xb9d1
movl 0x8(%r15), %ebp
subl 0x8(%rax), %ebp
jmp 0xb8c0
movq %r15, %rdi
movq %r14, %rsi
callq 0xe4ac
movl %eax, %ebp
xorb $0x1, %bpl
movl $0x20, %edi
callq 0x92d0
movabsq $0x100000001, %rcx      # imm = 0x100000001
movq %rcx, 0x8(%rax)
leaq 0x55222(%rip), %rcx     # 0x609a8
movq %rcx, (%rax)
leaq 0x10(%rax), %rcx
leaq 0x552c4(%rip), %rdx     # 0x60a58
movq %rdx, 0x10(%rax)
movb %bpl, 0x18(%rax)
jmp 0xb9ba
leaq 0x552c8(%rip), %rsi     # 0x60a70
leaq 0x552e9(%rip), %rdx     # 0x60a98
movq %r15, %rdi
xorl %ecx, %ecx
callq 0x9340
testq %rax, %rax
je 0xb9d1
movq %rax, %r15
leaq 0x552a4(%rip), %rsi     # 0x60a70
leaq 0x552c5(%rip), %rdx     # 0x60a98
movq %r14, %rdi
xorl %ecx, %ecx
callq 0x9340
testq %rax, %rax
je 0xb9d1
movl 0x8(%rax), %ebp
imull 0x8(%r15), %ebp
jmp 0xb8c0
leaq 0x55276(%rip), %rsi     # 0x60a70
leaq 0x55297(%rip), %rdx     # 0x60a98
movq %r15, %rdi
xorl %ecx, %ecx
callq 0x9340
testq %rax, %rax
je 0xb9d1
movq %rax, %r15
leaq 0x55252(%rip), %rsi     # 0x60a70
leaq 0x55273(%rip), %rdx     # 0x60a98
movq %r14, %rdi
xorl %ecx, %ecx
callq 0x9340
testq %rax, %rax
je 0xb9d1
movl 0x8(%r15), %ebp
movl 0x8(%rax), %r14d
movl $0x20, %edi
callq 0x92d0
cmpl %r14d, %ebp
movabsq $0x100000001, %rcx      # imm = 0x100000001
movq %rcx, 0x8(%rax)
leaq 0x55146(%rip), %rcx     # 0x609a8
movq %rcx, (%rax)
setge 0x18(%rax)
jmp 0xb96f
leaq 0x551fb(%rip), %rsi     # 0x60a70
leaq 0x5521c(%rip), %rdx     # 0x60a98
movq %r15, %rdi
xorl %ecx, %ecx
callq 0x9340
testq %rax, %rax
je 0xb9d1
movq %rax, %r15
leaq 0x551d7(%rip), %rsi     # 0x60a70
leaq 0x551f8(%rip), %rdx     # 0x60a98
movq %r14, %rdi
xorl %ecx, %ecx
callq 0x9340
testq %rax, %rax
je 0xb9d1
movq %rax, %rcx
movl 0x8(%r15), %eax
cltd
idivl 0x8(%rcx)
movl %eax, %ebp
movl $0x20, %edi
callq 0x92d0
movabsq $0x100000001, %rcx      # imm = 0x100000001
movq %rcx, 0x8(%rax)
leaq 0x551e1(%rip), %rcx     # 0x60ac0
movq %rcx, (%rax)
leaq 0x10(%rax), %rcx
leaq 0x55223(%rip), %rdx     # 0x60b10
movq %rdx, 0x10(%rax)
movl %ebp, 0x18(%rax)
jmp 0xb9ba
leaq 0x55170(%rip), %rsi     # 0x60a70
leaq 0x55191(%rip), %rdx     # 0x60a98
movq %r15, %rdi
xorl %ecx, %ecx
callq 0x9340
testq %rax, %rax
je 0xb9d1
movq %rax, %r15
leaq 0x5514c(%rip), %rsi     # 0x60a70
leaq 0x5516d(%rip), %rdx     # 0x60a98
movq %r14, %rdi
xorl %ecx, %ecx
callq 0x9340
testq %rax, %rax
je 0xb9d1
movl 0x8(%r15), %ebp
movl 0x8(%rax), %r14d
movl $0x20, %edi
callq 0x92d0
cmpl %r14d, %ebp
movabsq $0x100000001, %rcx      # imm = 0x100000001
movq %rcx, 0x8(%rax)
leaq 0x55040(%rip), %rcx     # 0x609a8
movq %rcx, (%rax)
setle 0x18(%rax)
leaq 0x550e2(%rip), %rcx     # 0x60a58
movq %rcx, 0x10(%rax)
movq %rax, %rcx
addq $0x10, %rcx
jmp 0xb9ba
xorl %ebp, %ebp
movl $0x20, %edi
callq 0x92d0
movabsq $0x100000001, %rcx      # imm = 0x100000001
movq %rcx, 0x8(%rax)
leaq 0x55004(%rip), %rcx     # 0x609a8
movq %rcx, (%rax)
leaq 0x10(%rax), %rcx
leaq 0x550a6(%rip), %rdx     # 0x60a58
movq %rdx, 0x10(%rax)
movb %bpl, 0x18(%rax)
movq %rcx, (%rbx)
movq %rax, 0x8(%rbx)
movq %rbx, %rax
addq $0x40, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
callq 0x9530
leaq 0x398d3(%rip), %rdi     # 0x452b0
leaq 0x398da(%rip), %rsi     # 0x452be
leaq 0x398e5(%rip), %rcx     # 0x452d0
movl $0xe, %edx
callq 0x91a0
leaq 0x39930(%rip), %rdi     # 0x4532c
leaq 0x398bb(%rip), %rsi     # 0x452be
leaq 0x398c6(%rip), %rcx     # 0x452d0
movl $0xf, %edx
callq 0x91a0
movl $0x10, %edi
callq 0x9150
movq %rax, %rbx
movq %rsp, %rdi
movl %r12d, %esi
callq 0xe310
leaq 0x39907(%rip), %rsi     # 0x4533a
leaq 0x20(%rsp), %rdi
movq %rsp, %rdx
callq 0xc97c
movb $0x1, %bpl
leaq 0x20(%rsp), %rsi
movq %rbx, %rdi
callq 0x93f0
xorl %ebp, %ebp
movq 0x57577(%rip), %rsi     # 0x62fd0
movq 0x57548(%rip), %rdx     # 0x62fa8
movq %rbx, %rdi
callq 0x94b0
movq %rax, %r14
leaq 0x30(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0xba8e
movq 0x30(%rsp), %rsi
incq %rsi
callq 0x92e0
jmp 0xba8e
movq %rax, %r14
movb $0x1, %bpl
leaq 0x10(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0xbab1
movq 0x10(%rsp), %rsi
incq %rsi
callq 0x92e0
jmp 0xbab1
movq %rax, %r14
movb $0x1, %bpl
testb %bpl, %bpl
je 0xbabe
movq %rbx, %rdi
callq 0x9200
movq %r14, %rdi
callq 0x94e0