// File: /workspace/github_c_makefile_star2_O0/mtnygard[P]complisp/lisp.c
// Function: compile_cons
TEST compile_cons(Buffer *buf, uword *heap) {
  ASTNode *node = Reader_read("(cons 1 2)");
  int compile_result = Compile_entry(buf, node);
  ASSERT_EQ(compile_result, 0);
  // clang-format off
  byte expected[] = {
      // mov rax, 0x2
      0x48, 0xc7, 0xc0, 0x04, 0x00, 0x00, 0x00,
      // mov [rbp-8], rax
      0x48, 0x89, 0x45, 0xf8,
      // mov rax, 0x4
      0x48, 0xc7, 0xc0, 0x08, 0x00, 0x00, 0x00,
      // mov [rsi+Cdr], rax
      0x48, 0x89, 0x46, 0x08,
      // mov rax, [rbp-8]
      0x48, 0x8b, 0x45, 0xf8,
      // mov [rsi+Car], rax
      0x48, 0x89, 0x46, 0x00,
      // mov rax, rsi
      0x48, 0x89, 0xf0,
      // or rax, kPairTag
      0x48, 0x83, 0xc8, 0x01,
      // add rsi, 2*kWordSize
      0x48, 0x81, 0xc6, 0x10, 0x00, 0x00, 0x00,
  };
  // clang-format on
  EXPECT_ENTRY_CONTAINS_CODE(buf, expected);
  Buffer_make_executable(buf);
  uword result = Testing_execute_entry(buf, heap);
  ASSERT(Object_is_pair(result));
  ASSERT_EQ_FMT(Object_encode_integer(1), Object_pair_car(result), "0x%lx");
  ASSERT_EQ_FMT(Object_encode_integer(2), Object_pair_cdr(result), "0x%lx");
  AST_heap_free(node);
  PASS();
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x90, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
leaq 0x78c9(%rip), %rdi      # 0x164b3
callq 0x4e40
movq %rax, -0x20(%rbp)
movq -0x10(%rbp), %rdi
movq -0x20(%rbp), %rsi
callq 0x4690
movl %eax, -0x24(%rbp)
movl 0xc53b(%rip), %eax      # 0x1b144
addl $0x1, %eax
movl %eax, 0xc532(%rip)      # 0x1b144
cmpl $0x0, -0x24(%rbp)
je 0xec60
jmp 0xec1a
leaq 0x5a82(%rip), %rax      # 0x146a3
movq %rax, 0xc528(%rip)      # 0x1b150
movl $0x8a8, 0xc516(%rip)    # imm = 0x8A8
leaq 0x744c(%rip), %rax      # 0x16085
movq %rax, 0xc518(%rip)      # 0x1b158
movzbl 0xc4b9(%rip), %eax      # 0x1b100
andl $0x4, %eax
cmpl $0x0, %eax
je 0xec54
callq 0x1040
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0xef85
jmp 0xec62
leaq -0x50(%rbp), %rdi
leaq 0x58a3(%rip), %rsi      # 0x14510
movl $0x2c, %edx
callq 0x1110
movq -0x10(%rbp), %rdi
leaq -0x50(%rbp), %rsi
movl $0x2c, %edx
callq 0x12d40
movl %eax, -0x54(%rbp)
cmpl $0x0, -0x54(%rbp)
je 0xec9d
movl -0x54(%rbp), %eax
movl %eax, -0x4(%rbp)
jmp 0xef85
jmp 0xec9f
movq -0x10(%rbp), %rdi
callq 0x1c50
movq -0x10(%rbp), %rdi
movq -0x18(%rbp), %rsi
callq 0x4e70
movq %rax, -0x60(%rbp)
movl 0xc485(%rip), %eax      # 0x1b144
addl $0x1, %eax
movl %eax, 0xc47c(%rip)      # 0x1b144
movq -0x60(%rbp), %rdi
callq 0x1460
testb $0x1, %al
jne 0xed1d
jmp 0xecd7
leaq 0x59c5(%rip), %rax      # 0x146a3
movq %rax, 0xc46b(%rip)      # 0x1b150
movl $0x8c2, 0xc459(%rip)    # imm = 0x8C2
leaq 0x77c8(%rip), %rax      # 0x164be
movq %rax, 0xc45b(%rip)      # 0x1b158
movzbl 0xc3fc(%rip), %eax      # 0x1b100
andl $0x4, %eax
cmpl $0x0, %eax
je 0xed11
callq 0x1040
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0xef85
jmp 0xed1f
jmp 0xed21
movl 0xc41d(%rip), %eax      # 0x1b144
addl $0x1, %eax
movl %eax, 0xc414(%rip)      # 0x1b144
movl $0x1, %edi
callq 0x1290
movq %rax, -0x68(%rbp)
movq -0x60(%rbp), %rdi
callq 0x1480
movq %rax, %rcx
movq -0x68(%rbp), %rax
cmpq %rcx, %rax
je 0xee3e
movq 0xc272(%rip), %rax      # 0x1afd0
movq (%rax), %rdi
leaq 0x69c6(%rip), %rsi      # 0x1572e
movb $0x0, %al
callq 0x1100
movq 0xc25a(%rip), %rax      # 0x1afd0
movq (%rax), %rax
movq %rax, -0x78(%rbp)
movl $0x1, %edi
callq 0x1290
movq -0x78(%rbp), %rdi
movq %rax, %rdx
leaq 0x7533(%rip), %rsi      # 0x162c8
movb $0x0, %al
callq 0x1100
movq 0xc22d(%rip), %rax      # 0x1afd0
movq (%rax), %rdi
leaq 0x698d(%rip), %rsi      # 0x1573a
movb $0x0, %al
callq 0x1100
movq 0xc215(%rip), %rax      # 0x1afd0
movq (%rax), %rax
movq %rax, -0x70(%rbp)
movq -0x60(%rbp), %rdi
callq 0x1480
movq -0x70(%rbp), %rdi
movq %rax, %rdx
leaq 0x74ef(%rip), %rsi      # 0x162c8
movb $0x0, %al
callq 0x1100
movq 0xc1e9(%rip), %rax      # 0x1afd0
movq (%rax), %rdi
leaq 0x7bcb(%rip), %rsi      # 0x169bc
movb $0x0, %al
callq 0x1100
leaq 0x58a4(%rip), %rax      # 0x146a3
movq %rax, 0xc34a(%rip)      # 0x1b150
movl $0x8c3, 0xc338(%rip)    # imm = 0x8C3
leaq 0x76be(%rip), %rax      # 0x164d5
movq %rax, 0xc33a(%rip)      # 0x1b158
movzbl 0xc2db(%rip), %eax      # 0x1b100
andl $0x4, %eax
cmpl $0x0, %eax
je 0xee32
callq 0x1040
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0xef85
jmp 0xee40
jmp 0xee42
movl 0xc2fc(%rip), %eax      # 0x1b144
addl $0x1, %eax
movl %eax, 0xc2f3(%rip)      # 0x1b144
movl $0x2, %edi
callq 0x1290
movq %rax, -0x80(%rbp)
movq -0x60(%rbp), %rdi
callq 0x14d0
movq %rax, %rcx
movq -0x80(%rbp), %rax
cmpq %rcx, %rax
je 0xef68
movq 0xc151(%rip), %rax      # 0x1afd0
movq (%rax), %rdi
leaq 0x68a5(%rip), %rsi      # 0x1572e
movb $0x0, %al
callq 0x1100
movq 0xc139(%rip), %rax      # 0x1afd0
movq (%rax), %rax
movq %rax, -0x90(%rbp)
movl $0x2, %edi
callq 0x1290
movq -0x90(%rbp), %rdi
movq %rax, %rdx
leaq 0x740c(%rip), %rsi      # 0x162c8
movb $0x0, %al
callq 0x1100
movq 0xc106(%rip), %rax      # 0x1afd0
movq (%rax), %rdi
leaq 0x6866(%rip), %rsi      # 0x1573a
movb $0x0, %al
callq 0x1100
movq 0xc0ee(%rip), %rax      # 0x1afd0
movq (%rax), %rax
movq %rax, -0x88(%rbp)
movq -0x60(%rbp), %rdi
callq 0x14d0
movq -0x88(%rbp), %rdi
movq %rax, %rdx
leaq 0x73c2(%rip), %rsi      # 0x162c8
movb $0x0, %al
callq 0x1100
movq 0xc0bc(%rip), %rax      # 0x1afd0
movq (%rax), %rdi
leaq 0x7a9e(%rip), %rsi      # 0x169bc
movb $0x0, %al
callq 0x1100
leaq 0x5777(%rip), %rax      # 0x146a3
movq %rax, 0xc21d(%rip)      # 0x1b150
movl $0x8c4, 0xc20b(%rip)    # imm = 0x8C4
leaq 0x75c5(%rip), %rax      # 0x16509
movq %rax, 0xc20d(%rip)      # 0x1b158
movzbl 0xc1ae(%rip), %eax      # 0x1b100
andl $0x4, %eax
cmpl $0x0, %eax
je 0xef5f
callq 0x1040
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0xef85
jmp 0xef6a
movq -0x20(%rbp), %rdi
callq 0x1800
movq $0x0, 0xc1da(%rip) # 0x1b158
movl $0x0, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x90, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)