// File: /workspace/github_c_makefile_star2_O3/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
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
movq %r8, %r12
movq %rcx, %r9
movq %rdi, %rbx
cmpq $0x2f, %rsi
je 0x3e6c
movq %rsi, %r13
movl %r13d, %eax
andl $0x7, %eax
cmpl $0x1, %eax
jne 0x3f04
andq $-0x8, %r13
movq (%r13), %rax
movl %eax, %ecx
andl $0x7, %ecx
cmpl $0x1, %ecx
jne 0x3ee5
andq $-0x8, %rax
movq (%rax), %r14
movl %r14d, %ecx
andl $0x7, %ecx
cmpl $0x5, %ecx
jne 0x3f23
movq %r9, -0x30(%rbp)
movq %rdx, -0x38(%rbp)
movq 0x8(%rax), %rax
movl %eax, %ecx
andl $0x7, %ecx
cmpl $0x1, %ecx
jne 0x3ee5
andq $-0x8, %rax
movq (%rax), %rsi
movq 0x10(%rbx), %r15
movq %rbx, %rdi
callq 0x3c95
movl %eax, %ecx
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
testl %ecx, %ecx
jne 0x3ed6
andq $-0x8, %r14
addq $0x8, %r14
leaq -0x50(%rbp), %rcx
movq %r14, (%rcx)
movq %r15, 0x8(%rcx)
movq -0x30(%rbp), %rax
movq %rax, 0x10(%rcx)
movq 0x8(%r13), %rsi
movq %rbx, %rdi
movq -0x38(%rbp), %rdx
movq %r12, %r8
callq 0x3d96
movl %eax, %ecx
xorl %eax, %eax
negl %ecx
sbbl %eax, %eax
jmp 0x3ed6
movl 0x10(%rbx), %eax
movslq %r12d, %r8
subl %r8d, %eax
addl $-0x4, %eax
xorl %ecx, %ecx
movl %eax, %esi
shrl %cl, %esi
movq (%rbx), %rdi
movb %sil, (%rdi,%r8)
addq $0x8, %rcx
incq %r8
cmpq $0x20, %rcx
jne 0x3e7a
movq %rbx, %rdi
movq %rdx, %rsi
movq $-0x8, %rdx
xorl %ecx, %ecx
movq %r9, %r8
callq 0x2ad7
movl %eax, %ecx
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
testl %ecx, %ecx
jne 0x3ed6
movl $0x1, %esi
movq %rbx, %rdi
callq 0x1df5
movq (%rbx), %rax
movq 0x10(%rbx), %rcx
leaq 0x1(%rcx), %rdx
movq %rdx, 0x10(%rbx)
movb $-0x3d, (%rax,%rcx)
xorl %eax, %eax
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0xb72a(%rip), %rdi      # 0xf616
leaq 0xb688(%rip), %rsi      # 0xf57b
leaq 0xb72e(%rip), %rcx      # 0xf628
movl $0xf0, %edx
callq 0x1090
leaq 0xb994(%rip), %rdi      # 0xf89f
leaq 0xb669(%rip), %rsi      # 0xf57b
leaq 0xbacd(%rip), %rcx      # 0xf9e6
movl $0x3c7, %edx            # imm = 0x3C7
callq 0x1090
leaq 0xb9d6(%rip), %rdi      # 0xf900
leaq 0xb64a(%rip), %rsi      # 0xf57b
leaq 0xbaae(%rip), %rcx      # 0xf9e6
movl $0x3cb, %edx            # imm = 0x3CB
callq 0x1090