// File: /workspace/github_c_makefile_star2_O0/mtnygard[P]complisp/lisp.c
// Function: Compile_labels
int Compile_labels(Buffer *buf, ASTNode *bindings, ASTNode *body, Env *labels,
                   word body_pos) {
  if (AST_is_nil(bindings)) {
    Emit_backpatch_imm32(buf, body_pos);
    // Base case: no bindings; compile the body
    _(Compile_expr(buf, body, -kWordSize, NULL, labels));
    Buffer_write_arr(buf, kFunctionEpilogue, sizeof kFunctionEpilogue);
    return 0;
  }

  assert(AST_is_pair(bindings));
  // Get the next binding
  ASTNode *binding = AST_pair_car(bindings);
  ASTNode *name = AST_pair_car(binding);
  assert(AST_is_symbol(name));
  ASTNode *binding_code = AST_pair_car(AST_pair_cdr(binding));
  word function_location = Buffer_len(buf);
  // Compile the binding function
  _(Compile_code(buf, binding_code));
  // Bind the name to the location in the instruction strema
  Env entry = Env_bind(AST_symbol_cstr(name), function_location, labels);
  _(Compile_labels(buf, AST_pair_cdr(bindings), body, &entry, body_pos));
  return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x90, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq %rdx, -0x20(%rbp)
movq %rcx, -0x28(%rbp)
movq %r8, -0x30(%rbp)
movq -0x18(%rbp), %rdi
callq 0x1700
testb $0x1, %al
jne 0x44fe
jmp 0x4560
movq -0x10(%rbp), %rdi
movq -0x30(%rbp), %rax
movl %eax, %esi
callq 0x27f0
movq -0x10(%rbp), %rdi
movq -0x20(%rbp), %rsi
movq -0x28(%rbp), %r8
movq $-0x8, %rdx
xorl %eax, %eax
movl %eax, %ecx
callq 0x29f0
movl %eax, -0x34(%rbp)
cmpl $0x0, -0x34(%rbp)
je 0x453d
movl -0x34(%rbp), %eax
movl %eax, -0x4(%rbp)
jmp 0x4682
jmp 0x453f
movq -0x10(%rbp), %rdi
leaq 0xfc8e(%rip), %rsi      # 0x141d8
movl $0x1, %edx
callq 0x1f10
movl $0x0, -0x4(%rbp)
jmp 0x4682
movq -0x18(%rbp), %rdi
callq 0x1870
testb $0x1, %al
jne 0x456f
jmp 0x4571
jmp 0x4590
leaq 0x104a6(%rip), %rdi     # 0x14a1e
leaq 0x10124(%rip), %rsi     # 0x146a3
movl $0x3c7, %edx            # imm = 0x3C7
leaq 0x105da(%rip), %rcx     # 0x14b65
callq 0x1090
movq -0x18(%rbp), %rdi
callq 0x1890
movq %rax, -0x40(%rbp)
movq -0x40(%rbp), %rdi
callq 0x1890
movq %rax, -0x48(%rbp)
movq -0x48(%rbp), %rdi
callq 0x1a90
testb $0x1, %al
jne 0x45b9
jmp 0x45bb
jmp 0x45da
leaq 0x104bd(%rip), %rdi     # 0x14a7f
leaq 0x100da(%rip), %rsi     # 0x146a3
movl $0x3cb, %edx            # imm = 0x3CB
leaq 0x10590(%rip), %rcx     # 0x14b65
callq 0x1090
movq -0x40(%rbp), %rdi
callq 0x18b0
movq %rax, %rdi
callq 0x1890
movq %rax, -0x50(%rbp)
movq -0x10(%rbp), %rdi
callq 0x1c90
movq %rax, -0x58(%rbp)
movq -0x10(%rbp), %rdi
movq -0x50(%rbp), %rsi
callq 0x43c0
movl %eax, -0x5c(%rbp)
cmpl $0x0, -0x5c(%rbp)
je 0x461a
movl -0x5c(%rbp), %eax
movl %eax, -0x4(%rbp)
jmp 0x4682
jmp 0x461c
movq -0x48(%rbp), %rdi
callq 0x1ab0
movq %rax, %rsi
movq -0x58(%rbp), %rdx
movq -0x28(%rbp), %rcx
leaq -0x78(%rbp), %rdi
callq 0x1520
movq -0x10(%rbp), %rax
movq %rax, -0x88(%rbp)
movq -0x18(%rbp), %rdi
callq 0x18b0
movq -0x88(%rbp), %rdi
movq %rax, %rsi
movq -0x20(%rbp), %rdx
movq -0x30(%rbp), %r8
leaq -0x78(%rbp), %rcx
callq 0x44d0
movl %eax, -0x7c(%rbp)
cmpl $0x0, -0x7c(%rbp)
je 0x4679
movl -0x7c(%rbp), %eax
movl %eax, -0x4(%rbp)
jmp 0x4682
jmp 0x467b
movl $0x0, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x90, %rsp
popq %rbp
retq
nop