// File: /workspace/github_c_makefile_star2_O0/mtnygard[P]complisp/lisp.c
// Function: Compile_expr
int Compile_expr(Buffer *buf, ASTNode *node, word stack_index, Env *varenv,
                 Env *labels) {
  if (AST_is_integer(node)) {
    word value = AST_get_integer(node);
    Emit_mov_reg_imm32(buf, kRax, Object_encode_integer(value));
    return 0;
  }
  if (AST_is_char(node)) {
    char value = AST_get_char(node);
    Emit_mov_reg_imm32(buf, kRax, Object_encode_char(value));
    return 0;
  }
  if (AST_is_bool(node)) {
    bool value = AST_get_bool(node);
    Emit_mov_reg_imm32(buf, kRax, Object_encode_bool(value));
    return 0;
  }
  if (AST_is_nil(node)) {
    Emit_mov_reg_imm32(buf, kRax, Object_nil());
    return 0;
  }
  if (AST_is_pair(node)) {
    return Compile_call(buf, AST_pair_car(node), AST_pair_cdr(node),
                        stack_index, varenv, labels);
  }
  if (AST_is_symbol(node)) {
    const char *symbol = AST_symbol_cstr(node);
    word value;
    if (Env_find(varenv, symbol, &value)) {
      Emit_load_reg_indirect(buf, kRax, Ind(kRsp, value));
      return 0;
    }
    return -1;
  }
  assert(0 && "unexpected node type");
}

// 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 0x15e0
testb $0x1, %al
jne 0x2a1e
jmp 0x2a55
movq -0x18(%rbp), %rdi
callq 0x1600
movq %rax, -0x38(%rbp)
movq -0x10(%rbp), %rax
movq %rax, -0x60(%rbp)
movq -0x38(%rbp), %rdi
callq 0x1290
movq -0x60(%rbp), %rdi
movl %eax, %edx
xorl %esi, %esi
callq 0x1ff0
movl $0x0, -0x4(%rbp)
jmp 0x2c07
movq -0x18(%rbp), %rdi
callq 0x1640
testb $0x1, %al
jne 0x2a64
jmp 0x2a9a
movq -0x18(%rbp), %rdi
callq 0x1660
movb %al, -0x39(%rbp)
movq -0x10(%rbp), %rax
movq %rax, -0x68(%rbp)
movsbl -0x39(%rbp), %edi
callq 0x1360
movq -0x68(%rbp), %rdi
movl %eax, %edx
xorl %esi, %esi
callq 0x1ff0
movl $0x0, -0x4(%rbp)
jmp 0x2c07
movq -0x18(%rbp), %rdi
callq 0x16b0
testb $0x1, %al
jne 0x2aa9
jmp 0x2ae5
movq -0x18(%rbp), %rdi
callq 0x16d0
andb $0x1, %al
movb %al, -0x3a(%rbp)
movq -0x10(%rbp), %rax
movq %rax, -0x70(%rbp)
movb -0x3a(%rbp), %al
andb $0x1, %al
movzbl %al, %edi
callq 0x13c0
movq -0x70(%rbp), %rdi
movl %eax, %edx
xorl %esi, %esi
callq 0x1ff0
movl $0x0, -0x4(%rbp)
jmp 0x2c07
movq -0x18(%rbp), %rdi
callq 0x1700
testb $0x1, %al
jne 0x2af4
jmp 0x2b1a
movq -0x10(%rbp), %rax
movq %rax, -0x78(%rbp)
callq 0x1420
movq -0x78(%rbp), %rdi
movl %eax, %edx
xorl %esi, %esi
callq 0x1ff0
movl $0x0, -0x4(%rbp)
jmp 0x2c07
movq -0x18(%rbp), %rdi
callq 0x1870
testb $0x1, %al
jne 0x2b29
jmp 0x2b71
movq -0x10(%rbp), %rax
movq %rax, -0x88(%rbp)
movq -0x18(%rbp), %rdi
callq 0x1890
movq %rax, -0x80(%rbp)
movq -0x18(%rbp), %rdi
callq 0x18b0
movq -0x88(%rbp), %rdi
movq -0x80(%rbp), %rsi
movq %rax, %rdx
movq -0x20(%rbp), %rcx
movq -0x28(%rbp), %r8
movq -0x30(%rbp), %r9
callq 0x2c20
movl %eax, -0x4(%rbp)
jmp 0x2c07
movq -0x18(%rbp), %rdi
callq 0x1a90
testb $0x1, %al
jne 0x2b80
jmp 0x2be8
movq -0x18(%rbp), %rdi
callq 0x1ab0
movq %rax, -0x48(%rbp)
movq -0x28(%rbp), %rdi
movq -0x48(%rbp), %rsi
leaq -0x50(%rbp), %rdx
callq 0x1550
testb $0x1, %al
jne 0x2ba4
jmp 0x2bdf
movq -0x10(%rbp), %rax
movq %rax, -0x90(%rbp)
movq -0x50(%rbp), %rax
movl $0x4, %edi
movsbl %al, %esi
callq 0x1f60
movq -0x90(%rbp), %rdi
movq %rax, -0x58(%rbp)
movq -0x58(%rbp), %rdx
xorl %esi, %esi
callq 0x26a0
movl $0x0, -0x4(%rbp)
jmp 0x2c07
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x2c07
leaq 0x11c90(%rip), %rdi     # 0x1487f
leaq 0x11aad(%rip), %rsi     # 0x146a3
movl $0x2aa, %edx            # imm = 0x2AA
leaq 0x11c99(%rip), %rcx     # 0x1489b
callq 0x1090
movl -0x4(%rbp), %eax
addq $0x90, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)