// File: /workspace/github_c_makefile_star2_O0/mtnygard[P]complisp/lisp.c
// Function: compile_symbol_in_env_returns_first_value
TEST compile_symbol_in_env_returns_first_value(Buffer *buf) {
  ASTNode *node = AST_new_symbol("hello");
  Env env0 = Env_bind("hello", 55, /*prev=*/NULL);
  Env env1 = Env_bind("hello", 66, &env0);
  int compile_result = Compile_expr(buf, node, -kWordSize, &env1, NULL);
  ASSERT_EQ(compile_result, 0);
  // clang-format off
  byte expected[] = {
    // mov rax, [rbp+66]
    0x48, 0x8b, 0x44, 0x24, 66};
  // clang-format on
  EXPECT_EQUALS_BYTES(buf, expected);
  AST_heap_free(node);
  PASS();
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x80, %rsp
movq %rdi, -0x10(%rbp)
leaq 0x8163(%rip), %rdi      # 0x15d19
callq 0x19d0
movq %rax, -0x18(%rbp)
leaq -0x30(%rbp), %rdi
leaq 0x814f(%rip), %rsi      # 0x15d19
movl $0x37, %edx
xorl %eax, %eax
movl %eax, %ecx
callq 0x1520
leaq -0x48(%rbp), %rdi
leaq 0x8136(%rip), %rsi      # 0x15d19
movl $0x42, %edx
leaq -0x30(%rbp), %rcx
callq 0x1520
movq -0x10(%rbp), %rdi
movq -0x18(%rbp), %rsi
movq $-0x8, %rdx
leaq -0x48(%rbp), %rcx
xorl %eax, %eax
movl %eax, %r8d
callq 0x29f0
movl %eax, -0x4c(%rbp)
movl 0xd52d(%rip), %eax      # 0x1b144
addl $0x1, %eax
movl %eax, 0xd524(%rip)      # 0x1b144
cmpl $0x0, -0x4c(%rbp)
je 0xdc6e
jmp 0xdc28
leaq 0x6a74(%rip), %rax      # 0x146a3
movq %rax, 0xd51a(%rip)      # 0x1b150
movl $0x819, 0xd508(%rip)    # imm = 0x819
leaq 0x843e(%rip), %rax      # 0x16085
movq %rax, 0xd50a(%rip)      # 0x1b158
movzbl 0xd4ab(%rip), %eax      # 0x1b100
andl $0x4, %eax
cmpl $0x0, %eax
je 0xdc62
callq 0x1040
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0xdd8f
jmp 0xdc70
movl 0x6829(%rip), %eax      # 0x1449f
movl %eax, -0x51(%rbp)
movb 0x6824(%rip), %al       # 0x144a3
movb %al, -0x4d(%rbp)
leaq -0x51(%rbp), %rax
movq %rax, -0x70(%rbp)
movq -0x10(%rbp), %rax
movq (%rax), %rax
movq %rax, -0x68(%rbp)
movq $0x5, -0x60(%rbp)
leaq 0xd444(%rip), %rax      # 0x1b0e8
movq %rax, -0x78(%rbp)
movl 0xd496(%rip), %eax      # 0x1b144
addl $0x1, %eax
movl %eax, 0xd48d(%rip)      # 0x1b144
movq -0x70(%rbp), %rdi
movq -0x68(%rbp), %rsi
movq -0x78(%rbp), %rdx
leaq -0x70(%rbp), %rcx
callq 0x11f00
cmpl $0x0, %eax
jne 0xdd70
cmpq $0x0, -0x78(%rbp)
je 0xdce6
movq -0x78(%rbp), %rax
cmpq $0x0, (%rax)
jne 0xdd2b
jmp 0xdce8
leaq 0x69b4(%rip), %rax      # 0x146a3
movq %rax, 0xd45a(%rip)      # 0x1b150
movl $0x81f, 0xd448(%rip)    # imm = 0x81F
leaq 0x7dd6(%rip), %rax      # 0x15add
movq %rax, 0xd44a(%rip)      # 0x1b158
movzbl 0xd3eb(%rip), %eax      # 0x1b100
andl $0x4, %eax
cmpl $0x0, %eax
je 0xdd22
callq 0x1040
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0xdd8f
jmp 0xdd2d
leaq 0x696f(%rip), %rax      # 0x146a3
movq %rax, 0xd415(%rip)      # 0x1b150
movl $0x81f, 0xd403(%rip)    # imm = 0x81F
leaq 0x85fb(%rip), %rax      # 0x16347
movq %rax, 0xd405(%rip)      # 0x1b158
movzbl 0xd3a6(%rip), %eax      # 0x1b100
andl $0x4, %eax
cmpl $0x0, %eax
je 0xdd67
callq 0x1040
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0xdd8f
jmp 0xdd72
jmp 0xdd74
movq -0x18(%rbp), %rdi
callq 0x1800
movq $0x0, 0xd3d0(%rip) # 0x1b158
movl $0x0, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x80, %rsp
popq %rbp
retq
nopl (%rax,%rax)