// File: /workspace/github_c_makefile_star2_O0/mtnygard[P]complisp/lisp.c
// Function: compile_car
TEST compile_car(Buffer *buf, uword *heap) {
  ASTNode *node = Reader_read("(car (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,
      // mov rax, [rax-1]
      0x48, 0x8b, 0x40, 0xff,
  };
  // clang-format on
  EXPECT_ENTRY_CONTAINS_CODE(buf, expected);
  Buffer_make_executable(buf);
  uword result = Testing_execute_entry(buf, heap);
  ASSERT_EQ_FMT(Object_encode_integer(1), result, "0x%lx");
  AST_heap_free(node);
  PASS();
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x80, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
leaq 0x6d39(%rip), %rdi      # 0x16763
callq 0x4e40
movq %rax, -0x20(%rbp)
movq -0x10(%rbp), %rdi
movq -0x20(%rbp), %rsi
callq 0x4690
movl %eax, -0x24(%rbp)
movl 0xb6fb(%rip), %eax      # 0x1b144
addl $0x1, %eax
movl %eax, 0xb6f2(%rip)      # 0x1b144
cmpl $0x0, -0x24(%rbp)
je 0xfaa0
jmp 0xfa5a
leaq 0x4c42(%rip), %rax      # 0x146a3
movq %rax, 0xb6e8(%rip)      # 0x1b150
movl $0x8ef, 0xb6d6(%rip)    # imm = 0x8EF
leaq 0x660c(%rip), %rax      # 0x16085
movq %rax, 0xb6d8(%rip)      # 0x1b158
movzbl 0xb679(%rip), %eax      # 0x1b100
andl $0x4, %eax
cmpl $0x0, %eax
je 0xfa94
callq 0x1040
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0xfc0d
jmp 0xfaa2
leaq -0x60(%rbp), %rdi
leaq 0x4a93(%rip), %rsi      # 0x14540
movl $0x30, %edx
callq 0x1110
movq -0x10(%rbp), %rdi
leaq -0x60(%rbp), %rsi
movl $0x30, %edx
callq 0x12d40
movl %eax, -0x64(%rbp)
cmpl $0x0, -0x64(%rbp)
je 0xfadd
movl -0x64(%rbp), %eax
movl %eax, -0x4(%rbp)
jmp 0xfc0d
jmp 0xfadf
movq -0x10(%rbp), %rdi
callq 0x1c50
movq -0x10(%rbp), %rdi
movq -0x18(%rbp), %rsi
callq 0x4e70
movq %rax, -0x70(%rbp)
movl 0xb645(%rip), %eax      # 0x1b144
addl $0x1, %eax
movl %eax, 0xb63c(%rip)      # 0x1b144
movl $0x1, %edi
callq 0x1290
cmpq -0x70(%rbp), %rax
je 0xfbf0
movq 0xb4ad(%rip), %rax      # 0x1afd0
movq (%rax), %rdi
leaq 0x5c01(%rip), %rsi      # 0x1572e
movb $0x0, %al
callq 0x1100
movq 0xb495(%rip), %rax      # 0x1afd0
movq (%rax), %rax
movq %rax, -0x78(%rbp)
movl $0x1, %edi
callq 0x1290
movq -0x78(%rbp), %rdi
movq %rax, %rdx
leaq 0x676e(%rip), %rsi      # 0x162c8
movb $0x0, %al
callq 0x1100
movq 0xb468(%rip), %rax      # 0x1afd0
movq (%rax), %rdi
leaq 0x5bc8(%rip), %rsi      # 0x1573a
movb $0x0, %al
callq 0x1100
movq 0xb450(%rip), %rax      # 0x1afd0
movq (%rax), %rdi
movq -0x70(%rbp), %rdx
leaq 0x673a(%rip), %rsi      # 0x162c8
movb $0x0, %al
callq 0x1100
movq 0xb434(%rip), %rax      # 0x1afd0
movq (%rax), %rdi
leaq 0x6e16(%rip), %rsi      # 0x169bc
movb $0x0, %al
callq 0x1100
leaq 0x4aef(%rip), %rax      # 0x146a3
movq %rax, 0xb595(%rip)      # 0x1b150
movl $0x90b, 0xb583(%rip)    # imm = 0x90B
leaq 0x6857(%rip), %rax      # 0x16423
movq %rax, 0xb585(%rip)      # 0x1b158
movzbl 0xb526(%rip), %eax      # 0x1b100
andl $0x4, %eax
cmpl $0x0, %eax
je 0xfbe7
callq 0x1040
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0xfc0d
jmp 0xfbf2
movq -0x20(%rbp), %rdi
callq 0x1800
movq $0x0, 0xb552(%rip) # 0x1b158
movl $0x0, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x80, %rsp
popq %rbp
retq
nopl (%rax)