// File: /workspace/github_c_makefile_star2_O0/mtnygard[P]complisp/lisp.c
// Function: compile_binary_plus_nested
TEST compile_binary_plus_nested(Buffer *buf) {
  ASTNode *node = new_binary_call(
      "+", new_binary_call("+", AST_new_integer(1), AST_new_integer(2)),
      new_binary_call("+", AST_new_integer(3), AST_new_integer(4)));
  int compile_result = Compile_entry(buf, node);
  ASSERT_EQ(compile_result, 0);
  // clang-format off
  byte expected[] = {
      // mov    rax,0x10
      0x48, 0xc7, 0xc0, 0x10, 0x00, 0x00, 0x00,
      // mov    QWORD PTR [rsp-0x8],rax
      0x48, 0x89, 0x44, 0x24, 0xf8,
      // mov    rax,0xc
      0x48, 0xc7, 0xc0, 0x0c, 0x00, 0x00, 0x00,
      // add    rax,QWORD PTR [rsp-0x8]
      0x48, 0x03, 0x44, 0x24, 0xf8,
      // mov    QWORD PTR [rsp-0x8],rax
      0x48, 0x89, 0x44, 0x24, 0xf8,
      // mov    rax,0x8
      0x48, 0xc7, 0xc0, 0x08, 0x00, 0x00, 0x00,
      // mov    QWORD PTR [rsp-0x10],rax
      0x48, 0x89, 0x44, 0x24, 0xf0,
      // mov    rax,0x4
      0x48, 0xc7, 0xc0, 0x04, 0x00, 0x00, 0x00,
      // add    rax,QWORD PTR [rsp-0x10]
      0x48, 0x03, 0x44, 0x24, 0xf0,
      // add    rax,QWORD PTR [rsp-0x8]
      0x48, 0x03, 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(10));
  AST_heap_free(node);
  PASS();
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x90, %rsp
movq %rdi, -0x10(%rbp)
movl $0x1, %edi
callq 0x15c0
movq %rax, -0x88(%rbp)
movl $0x2, %edi
callq 0x15c0
movq -0x88(%rbp), %rsi
movq %rax, %rdx
leaq 0x830f(%rip), %rdi      # 0x149fa
callq 0x5020
movq %rax, -0x78(%rbp)
movl $0x3, %edi
callq 0x15c0
movq %rax, -0x80(%rbp)
movl $0x4, %edi
callq 0x15c0
movq -0x80(%rbp), %rsi
movq %rax, %rdx
leaq 0x82e0(%rip), %rdi      # 0x149fa
callq 0x5020
movq -0x78(%rbp), %rsi
movq %rax, %rdx
leaq 0x82cd(%rip), %rdi      # 0x149fa
callq 0x5020
movq %rax, -0x18(%rbp)
movq -0x10(%rbp), %rdi
movq -0x18(%rbp), %rsi
callq 0x4690
movl %eax, -0x1c(%rbp)
movl 0xe9f8(%rip), %eax      # 0x1b144
addl $0x1, %eax
movl %eax, 0xe9ef(%rip)      # 0x1b144
cmpl $0x0, -0x1c(%rbp)
je 0xc7a3
jmp 0xc75d
leaq 0x7f3f(%rip), %rax      # 0x146a3
movq %rax, 0xe9e5(%rip)      # 0x1b150
movl $0x759, 0xe9d3(%rip)    # imm = 0x759
leaq 0x9909(%rip), %rax      # 0x16085
movq %rax, 0xe9d5(%rip)      # 0x1b158
movzbl 0xe976(%rip), %eax      # 0x1b100
andl $0x4, %eax
cmpl $0x0, %eax
je 0xc797
callq 0x1040
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0xc88d
jmp 0xc7a5
leaq -0x60(%rbp), %rdi
leaq 0x7c50(%rip), %rsi      # 0x14400
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 0xc7e0
movl -0x64(%rbp), %eax
movl %eax, -0x4(%rbp)
jmp 0xc88d
jmp 0xc7e2
movq -0x10(%rbp), %rdi
callq 0x1c50
movq -0x10(%rbp), %rdi
callq 0x4f20
movq %rax, -0x70(%rbp)
movl 0xe946(%rip), %eax      # 0x1b144
addl $0x1, %eax
movl %eax, 0xe93d(%rip)      # 0x1b144
movq -0x70(%rbp), %rax
movq %rax, -0x90(%rbp)
movl $0xa, %edi
callq 0x1290
movq %rax, %rcx
movq -0x90(%rbp), %rax
cmpq %rcx, %rax
je 0xc870
jmp 0xc82d
leaq 0x7e6f(%rip), %rax      # 0x146a3
movq %rax, 0xe915(%rip)      # 0x1b150
movl $0x774, 0xe903(%rip)    # imm = 0x774
leaq 0x9a11(%rip), %rax      # 0x1625d
movq %rax, 0xe905(%rip)      # 0x1b158
movzbl 0xe8a6(%rip), %eax      # 0x1b100
andl $0x4, %eax
cmpl $0x0, %eax
je 0xc867
callq 0x1040
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0xc88d
jmp 0xc872
movq -0x18(%rbp), %rdi
callq 0x1800
movq $0x0, 0xe8d2(%rip) # 0x1b158
movl $0x0, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x90, %rsp
popq %rbp
retq
nopl (%rax)