// File: /workspace/github_c_makefile_star2_O0/mtnygard[P]complisp/lisp.c
// Function: compile_binary_minus_nested
TEST compile_binary_minus_nested(Buffer *buf) {
  ASTNode *node = new_binary_call(
      "-", new_binary_call("-", AST_new_integer(5), AST_new_integer(1)),
      new_binary_call("-", AST_new_integer(4), AST_new_integer(3)));
  int compile_result = Compile_entry(buf, node);
  ASSERT_EQ(compile_result, 0);
  // clang-format off
  byte expected[] = {
      // mov    rax,0xc
      0x48, 0xc7, 0xc0, 0x0c, 0x00, 0x00, 0x00,
      // mov    QWORD PTR [rsp-0x8],rax
      0x48, 0x89, 0x44, 0x24, 0xf8,
      // mov    rax,0x10
      0x48, 0xc7, 0xc0, 0x10, 0x00, 0x00, 0x00,
      // add    rax,QWORD PTR [rsp-0x8]
      0x48, 0x2b, 0x44, 0x24, 0xf8,
      //  mov    QWORD PTR [rsp-0x8],rax
      0x48, 0x89, 0x44, 0x24, 0xf8,
      // mov    rax,0x4
      0x48, 0xc7, 0xc0, 0x04, 0x00, 0x00, 0x00,
      // mov    QWORD PTR [rsp-0x10],rax
      0x48, 0x89, 0x44, 0x24, 0xf0,
      // mov    rax,0x14
      0x48, 0xc7, 0xc0, 0x14, 0x00, 0x00, 0x00,
      // add    rax,QWORD PTR [rsp-0x10]
      0x48, 0x2b, 0x44, 0x24, 0xf0,
      // add    rax,QWORD PTR [rsp-0x8]
      0x48, 0x2b, 0x44, 0x24, 0xf8};
  // clang-format on
  EXPECT_ENTRY_CONTAINS_CODE(buf, expected);
  Buffer_make_executable(buf);
  uword result = Testing_execute_expr(buf);
  ASSERT_EQ(result, Object_encode_integer(3));
  AST_heap_free(node);
  PASS();
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x90, %rsp
movq %rdi, -0x10(%rbp)
movl $0x5, %edi
callq 0x15c0
movq %rax, -0x88(%rbp)
movl $0x1, %edi
callq 0x15c0
movq -0x88(%rbp), %rsi
movq %rax, %rdx
leaq 0x9f1a(%rip), %rdi      # 0x169a5
callq 0x5020
movq %rax, -0x78(%rbp)
movl $0x4, %edi
callq 0x15c0
movq %rax, -0x80(%rbp)
movl $0x3, %edi
callq 0x15c0
movq -0x80(%rbp), %rsi
movq %rax, %rdx
leaq 0x9eeb(%rip), %rdi      # 0x169a5
callq 0x5020
movq -0x78(%rbp), %rsi
movq %rax, %rdx
leaq 0x9ed8(%rip), %rdi      # 0x169a5
callq 0x5020
movq %rax, -0x18(%rbp)
movq -0x10(%rbp), %rdi
movq -0x18(%rbp), %rsi
callq 0x4690
movl %eax, -0x1c(%rbp)
movl 0xe658(%rip), %eax      # 0x1b144
addl $0x1, %eax
movl %eax, 0xe64f(%rip)      # 0x1b144
cmpl $0x0, -0x1c(%rbp)
je 0xcb43
jmp 0xcafd
leaq 0x7b9f(%rip), %rax      # 0x146a3
movq %rax, 0xe645(%rip)      # 0x1b150
movl $0x795, 0xe633(%rip)    # imm = 0x795
leaq 0x9569(%rip), %rax      # 0x16085
movq %rax, 0xe635(%rip)      # 0x1b158
movzbl 0xe5d6(%rip), %eax      # 0x1b100
andl $0x4, %eax
cmpl $0x0, %eax
je 0xcb37
callq 0x1040
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0xcc2d
jmp 0xcb45
leaq -0x60(%rbp), %rdi
leaq 0x7910(%rip), %rsi      # 0x14460
movl $0x3a, %edx
callq 0x1110
movq -0x10(%rbp), %rdi
leaq -0x60(%rbp), %rsi
movl $0x3a, %edx
callq 0x12d40
movl %eax, -0x64(%rbp)
cmpl $0x0, -0x64(%rbp)
je 0xcb80
movl -0x64(%rbp), %eax
movl %eax, -0x4(%rbp)
jmp 0xcc2d
jmp 0xcb82
movq -0x10(%rbp), %rdi
callq 0x1c50
movq -0x10(%rbp), %rdi
callq 0x4f20
movq %rax, -0x70(%rbp)
movl 0xe5a6(%rip), %eax      # 0x1b144
addl $0x1, %eax
movl %eax, 0xe59d(%rip)      # 0x1b144
movq -0x70(%rbp), %rax
movq %rax, -0x90(%rbp)
movl $0x3, %edi
callq 0x1290
movq %rax, %rcx
movq -0x90(%rbp), %rax
cmpq %rcx, %rax
je 0xcc10
jmp 0xcbcd
leaq 0x7acf(%rip), %rax      # 0x146a3
movq %rax, 0xe575(%rip)      # 0x1b150
movl $0x7b0, 0xe563(%rip)    # imm = 0x7B0
leaq 0x96b9(%rip), %rax      # 0x162a5
movq %rax, 0xe565(%rip)      # 0x1b158
movzbl 0xe506(%rip), %eax      # 0x1b100
andl $0x4, %eax
cmpl $0x0, %eax
je 0xcc07
callq 0x1040
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0xcc2d
jmp 0xcc12
movq -0x18(%rbp), %rdi
callq 0x1800
movq $0x0, 0xe532(%rip) # 0x1b158
movl $0x0, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x90, %rsp
popq %rbp
retq
nopl (%rax)