// File: /workspace/github_cpp_makefile_star2_O3/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 0xb4ed
cmpl $0x14, %eax
jne 0xb902
movq (%r14), %rax
movq %r14, %rdi
callq *(%rax)
leal -0x11(%rax), %ecx
cmpl $0x2, %ecx
jb 0xb506
cmpl $0x14, %eax
jne 0xb921
leal -0x6(%r12), %eax
cmpl $0xa, %eax
ja 0xb940
leaq 0x39d15(%rip), %rcx     # 0x45230
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
leaq 0x5456d(%rip), %rsi     # 0x5fa98
leaq 0x5458e(%rip), %rdx     # 0x5fac0
movq %r15, %rdi
xorl %ecx, %ecx
callq 0x9340
testq %rax, %rax
je 0xb8fd
movq %rax, %r15
leaq 0x54549(%rip), %rsi     # 0x5fa98
leaq 0x5456a(%rip), %rdx     # 0x5fac0
movq %r14, %rdi
xorl %ecx, %ecx
callq 0x9340
testq %rax, %rax
je 0xb8fd
movl 0x8(%rax), %ebp
addl 0x8(%r15), %ebp
jmp 0xb7ec
leaq 0x5451c(%rip), %rsi     # 0x5fa98
leaq 0x54525(%rip), %rdx     # 0x5faa8
movq %r15, %rdi
xorl %ecx, %ecx
callq 0x9340
testq %rax, %rax
je 0xb8fd
movb $0x1, %bpl
cmpb $0x0, 0x8(%rax)
jne 0xb693
leaq 0x544ee(%rip), %rsi     # 0x5fa98
leaq 0x544f7(%rip), %rdx     # 0x5faa8
movq %r14, %rdi
xorl %ecx, %ecx
callq 0x9340
testq %rax, %rax
je 0xb8fd
movb 0x8(%rax), %bpl
jmp 0xb693
leaq 0x544c4(%rip), %rsi     # 0x5fa98
leaq 0x544cd(%rip), %rdx     # 0x5faa8
movq %r15, %rdi
xorl %ecx, %ecx
callq 0x9340
testq %rax, %rax
je 0xb8fd
cmpb $0x1, 0x8(%rax)
jne 0xb8af
leaq 0x54499(%rip), %rsi     # 0x5fa98
leaq 0x544a2(%rip), %rdx     # 0x5faa8
movq %r14, %rdi
xorl %ecx, %ecx
callq 0x9340
testq %rax, %rax
je 0xb8fd
movb 0x8(%rax), %bpl
jmp 0xb8b1
movq %r15, %rdi
movq %r14, %rsi
callq 0xe328
movl %eax, %ebp
jmp 0xb693
leaq 0x54460(%rip), %rsi     # 0x5fa98
leaq 0x54481(%rip), %rdx     # 0x5fac0
movq %r15, %rdi
xorl %ecx, %ecx
callq 0x9340
testq %rax, %rax
je 0xb8fd
movq %rax, %r15
leaq 0x5443c(%rip), %rsi     # 0x5fa98
leaq 0x5445d(%rip), %rdx     # 0x5fac0
movq %r14, %rdi
xorl %ecx, %ecx
callq 0x9340
testq %rax, %rax
je 0xb8fd
movl 0x8(%r15), %ebp
subl 0x8(%rax), %ebp
jmp 0xb7ec
movq %r15, %rdi
movq %r14, %rsi
callq 0xe328
movl %eax, %ebp
xorb $0x1, %bpl
movl $0x20, %edi
callq 0x92d0
movabsq $0x100000001, %rcx      # imm = 0x100000001
movq %rcx, 0x8(%rax)
leaq 0x54356(%rip), %rcx     # 0x5fa08
movq %rcx, (%rax)
leaq 0x10(%rax), %rcx
leaq 0x543c0(%rip), %rdx     # 0x5fa80
movq %rdx, 0x10(%rax)
movb %bpl, 0x18(%rax)
jmp 0xb8e6
leaq 0x543c4(%rip), %rsi     # 0x5fa98
leaq 0x543e5(%rip), %rdx     # 0x5fac0
movq %r15, %rdi
xorl %ecx, %ecx
callq 0x9340
testq %rax, %rax
je 0xb8fd
movq %rax, %r15
leaq 0x543a0(%rip), %rsi     # 0x5fa98
leaq 0x543c1(%rip), %rdx     # 0x5fac0
movq %r14, %rdi
xorl %ecx, %ecx
callq 0x9340
testq %rax, %rax
je 0xb8fd
movl 0x8(%rax), %ebp
imull 0x8(%r15), %ebp
jmp 0xb7ec
leaq 0x54372(%rip), %rsi     # 0x5fa98
leaq 0x54393(%rip), %rdx     # 0x5fac0
movq %r15, %rdi
xorl %ecx, %ecx
callq 0x9340
testq %rax, %rax
je 0xb8fd
movq %rax, %r15
leaq 0x5434e(%rip), %rsi     # 0x5fa98
leaq 0x5436f(%rip), %rdx     # 0x5fac0
movq %r14, %rdi
xorl %ecx, %ecx
callq 0x9340
testq %rax, %rax
je 0xb8fd
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 0x5427a(%rip), %rcx     # 0x5fa08
movq %rcx, (%rax)
setge 0x18(%rax)
jmp 0xb89b
leaq 0x542f7(%rip), %rsi     # 0x5fa98
leaq 0x54318(%rip), %rdx     # 0x5fac0
movq %r15, %rdi
xorl %ecx, %ecx
callq 0x9340
testq %rax, %rax
je 0xb8fd
movq %rax, %r15
leaq 0x542d3(%rip), %rsi     # 0x5fa98
leaq 0x542f4(%rip), %rdx     # 0x5fac0
movq %r14, %rdi
xorl %ecx, %ecx
callq 0x9340
testq %rax, %rax
je 0xb8fd
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 0x542dd(%rip), %rcx     # 0x5fae8
movq %rcx, (%rax)
leaq 0x10(%rax), %rcx
leaq 0x5431f(%rip), %rdx     # 0x5fb38
movq %rdx, 0x10(%rax)
movl %ebp, 0x18(%rax)
jmp 0xb8e6
leaq 0x5426c(%rip), %rsi     # 0x5fa98
leaq 0x5428d(%rip), %rdx     # 0x5fac0
movq %r15, %rdi
xorl %ecx, %ecx
callq 0x9340
testq %rax, %rax
je 0xb8fd
movq %rax, %r15
leaq 0x54248(%rip), %rsi     # 0x5fa98
leaq 0x54269(%rip), %rdx     # 0x5fac0
movq %r14, %rdi
xorl %ecx, %ecx
callq 0x9340
testq %rax, %rax
je 0xb8fd
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 0x54174(%rip), %rcx     # 0x5fa08
movq %rcx, (%rax)
setle 0x18(%rax)
leaq 0x541de(%rip), %rcx     # 0x5fa80
movq %rcx, 0x10(%rax)
movq %rax, %rcx
addq $0x10, %rcx
jmp 0xb8e6
xorl %ebp, %ebp
movl $0x20, %edi
callq 0x92d0
movabsq $0x100000001, %rcx      # imm = 0x100000001
movq %rcx, 0x8(%rax)
leaq 0x54138(%rip), %rcx     # 0x5fa08
movq %rcx, (%rax)
leaq 0x10(%rax), %rcx
leaq 0x541a2(%rip), %rdx     # 0x5fa80
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 0x399a7(%rip), %rdi     # 0x452b0
leaq 0x399ae(%rip), %rsi     # 0x452be
leaq 0x399b9(%rip), %rcx     # 0x452d0
movl $0xe, %edx
callq 0x91a0
leaq 0x39a04(%rip), %rdi     # 0x4532c
leaq 0x3998f(%rip), %rsi     # 0x452be
leaq 0x3999a(%rip), %rcx     # 0x452d0
movl $0xf, %edx
callq 0x91a0
movl $0x10, %edi
callq 0x9150
movq %rax, %rbx
movq %rsp, %rdi
movl %r12d, %esi
callq 0xe18c
leaq 0x399db(%rip), %rsi     # 0x4533a
leaq 0x20(%rsp), %rdi
movq %rsp, %rdx
callq 0xc8b3
movb $0x1, %bpl
leaq 0x20(%rsp), %rsi
movq %rbx, %rdi
callq 0x93f0
xorl %ebp, %ebp
movq 0x5664b(%rip), %rsi     # 0x61fd0
movq 0x5661c(%rip), %rdx     # 0x61fa8
movq %rbx, %rdi
callq 0x94b0
movq %rax, %r14
leaq 0x30(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0xb9b2
movq 0x30(%rsp), %rsi
incq %rsi
callq 0x92e0
leaq 0x10(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0xb9cd
movq 0x10(%rsp), %rsi
incq %rsi
callq 0x92e0
testb %bpl, %bpl
jne 0xb9f7
jmp 0xb9ff
movq %rax, %r14
leaq 0x10(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0xb9f7
movq 0x10(%rsp), %rsi
incq %rsi
callq 0x92e0
jmp 0xb9f7
movq %rax, %r14
movq %rbx, %rdi
callq 0x9200
movq %r14, %rdi
callq 0x94e0