// File: /workspace/github_c_makefile_star2_O0/mtnygard[P]complisp/lisp.c
// Function: compile_labelcall_with_one_param_and_locals
TEST compile_labelcall_with_one_param_and_locals(Buffer *buf) {
  ASTNode *node = Reader_read(
      "(labels ((id (code (x) x))) (let ((a 1)) (labelcall id 5)))");
  int compile_result = Compile_entry(buf, node);
  ASSERT_EQ(compile_result, 0);
  // clang-format off
  byte expected[] = {
      // mov rsi, rdi
      0x48, 0x89, 0xfe,
      // jmp 0x06
      0xe9, 0x06, 0x00, 0x00, 0x00,
      // mov rax, [rsp-8]
      0x48, 0x8b, 0x44, 0x24, 0xf8,
      // ret
      0xc3,
      // mov rax, compile(1)
      0x48, 0xc7, 0xc0, 0x04, 0x00, 0x00, 0x00,
      // mov [rsp-8], rax
      0x48, 0x89, 0x44, 0x24, 0xf8,
      // mov rax, compile(5)
      0x48, 0xc7, 0xc0, 0x14, 0x00, 0x00, 0x00,
      // mov [rsp-24], rax
      0x48, 0x89, 0x44, 0x24, 0xe8,
      // sub rsp, 8
      0x48, 0x81, 0xec, 0x08, 0x00, 0x00, 0x00,
      // call `id`
      0xe8, 0xd6, 0xff, 0xff, 0xff,
      // add rsp, 8
      0x48, 0x81, 0xc4, 0x08, 0x00, 0x00, 0x00,
      // ret
      0xc3,
  };
  // clang-format on
  EXPECT_EQUALS_BYTES(buf, expected);
  Buffer_make_executable(buf);
  uword result = Testing_execute_entry(buf, /*heap=*/NULL);
  ASSERT_EQ_FMT(Object_encode_integer(5), result, "0x%lx");
  AST_heap_free(node);
  PASS();
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x90, %rsp
movq %rdi, -0x10(%rbp)
leaq 0x558d(%rip), %rdi      # 0x168a3
callq 0x4e40
movq %rax, -0x18(%rbp)
movq -0x10(%rbp), %rdi
movq -0x18(%rbp), %rsi
callq 0x4690
movl %eax, -0x1c(%rbp)
movl 0x9e0f(%rip), %eax      # 0x1b144
addl $0x1, %eax
movl %eax, 0x9e06(%rip)      # 0x1b144
cmpl $0x0, -0x1c(%rbp)
je 0x1138c
jmp 0x11346
leaq 0x3356(%rip), %rax      # 0x146a3
movq %rax, 0x9dfc(%rip)      # 0x1b150
movl $0xa0a, 0x9dea(%rip)    # imm = 0xA0A
leaq 0x4d20(%rip), %rax      # 0x16085
movq %rax, 0x9dec(%rip)      # 0x1b158
movzbl 0x9d8d(%rip), %eax      # 0x1b100
andl $0x4, %eax
cmpl $0x0, %eax
je 0x11380
callq 0x1040
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x115d8
jmp 0x1138e
leaq -0x60(%rbp), %rdi
leaq 0x32a7(%rip), %rsi      # 0x14640
movl $0x3a, %edx
callq 0x1110
leaq -0x60(%rbp), %rax
movq %rax, -0x78(%rbp)
movq -0x10(%rbp), %rax
movq (%rax), %rax
movq %rax, -0x70(%rbp)
movq $0x3a, -0x68(%rbp)
leaq 0x9d23(%rip), %rax      # 0x1b0e8
movq %rax, -0x80(%rbp)
movl 0x9d75(%rip), %eax      # 0x1b144
addl $0x1, %eax
movl %eax, 0x9d6c(%rip)      # 0x1b144
movq -0x78(%rbp), %rdi
movq -0x70(%rbp), %rsi
movq -0x80(%rbp), %rdx
leaq -0x78(%rbp), %rcx
callq 0x11f00
cmpl $0x0, %eax
jne 0x11497
cmpq $0x0, -0x80(%rbp)
je 0x11407
movq -0x80(%rbp), %rax
cmpq $0x0, (%rax)
jne 0x1144f
jmp 0x11409
leaq 0x3293(%rip), %rax      # 0x146a3
movq %rax, 0x9d39(%rip)      # 0x1b150
movl $0xa27, 0x9d27(%rip)    # imm = 0xA27
leaq 0x46b5(%rip), %rax      # 0x15add
movq %rax, 0x9d29(%rip)      # 0x1b158
movzbl 0x9cca(%rip), %eax      # 0x1b100
andl $0x4, %eax
cmpl $0x0, %eax
je 0x11443
callq 0x1040
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x115d8
jmp 0x11451
leaq 0x324b(%rip), %rax      # 0x146a3
movq %rax, 0x9cf1(%rip)      # 0x1b150
movl $0xa27, 0x9cdf(%rip)    # imm = 0xA27
leaq 0x4ed7(%rip), %rax      # 0x16347
movq %rax, 0x9ce1(%rip)      # 0x1b158
movzbl 0x9c82(%rip), %eax      # 0x1b100
andl $0x4, %eax
cmpl $0x0, %eax
je 0x1148b
callq 0x1040
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x115d8
jmp 0x11499
jmp 0x1149b
movq -0x10(%rbp), %rdi
callq 0x1c50
movq -0x10(%rbp), %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0x4e70
movq %rax, -0x88(%rbp)
movl 0x9c86(%rip), %eax      # 0x1b144
addl $0x1, %eax
movl %eax, 0x9c7d(%rip)      # 0x1b144
movl $0x5, %edi
callq 0x1290
cmpq -0x88(%rbp), %rax
je 0x115bb
movq 0x9aeb(%rip), %rax      # 0x1afd0
movq (%rax), %rdi
leaq 0x423f(%rip), %rsi      # 0x1572e
movb $0x0, %al
callq 0x1100
movq 0x9ad3(%rip), %rax      # 0x1afd0
movq (%rax), %rax
movq %rax, -0x90(%rbp)
movl $0x5, %edi
callq 0x1290
movq -0x90(%rbp), %rdi
movq %rax, %rdx
leaq 0x4da6(%rip), %rsi      # 0x162c8
movb $0x0, %al
callq 0x1100
movq 0x9aa0(%rip), %rax      # 0x1afd0
movq (%rax), %rdi
leaq 0x4200(%rip), %rsi      # 0x1573a
movb $0x0, %al
callq 0x1100
movq 0x9a88(%rip), %rax      # 0x1afd0
movq (%rax), %rdi
movq -0x88(%rbp), %rdx
leaq 0x4d6f(%rip), %rsi      # 0x162c8
movb $0x0, %al
callq 0x1100
movq 0x9a69(%rip), %rax      # 0x1afd0
movq (%rax), %rdi
leaq 0x544b(%rip), %rsi      # 0x169bc
movb $0x0, %al
callq 0x1100
leaq 0x3124(%rip), %rax      # 0x146a3
movq %rax, 0x9bca(%rip)      # 0x1b150
movl $0xa2a, 0x9bb8(%rip)    # imm = 0xA2A
leaq 0x527c(%rip), %rax      # 0x16813
movq %rax, 0x9bba(%rip)      # 0x1b158
movzbl 0x9b5b(%rip), %eax      # 0x1b100
andl $0x4, %eax
cmpl $0x0, %eax
je 0x115b2
callq 0x1040
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x115d8
jmp 0x115bd
movq -0x18(%rbp), %rdi
callq 0x1800
movq $0x0, 0x9b87(%rip) # 0x1b158
movl $0x0, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x90, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)