// File: /workspace/github_c_makefile_star2_O3/johnvtan[P]ccccc/parse.c
// Function: parse_unary
static expr_t *parse_unary(list_t *tokens, env_t *env) {
    if (!tokens || !tokens->len) {
        UNREACHABLE("wtf you doin\n");
    }

    if (match(tokens, TOK_BANG)) {
        debug("Found unary bang\n");
        return new_unary_expr(UNARY_LOGICAL_NEG, parse_unary(tokens, env));
    }

    if (match(tokens, TOK_TILDE)) {
        debug("Found unary tilde\n");
        return new_unary_expr(UNARY_BITWISE_COMP, parse_unary(tokens, env));
    }

    if (match(tokens, TOK_MINUS)) {
        debug("Found unary neg\n");
        return new_unary_expr(UNARY_MATH_NEG, parse_unary(tokens, env));
    }

    if (match(tokens, TOK_INCREMENT)) {
        debug("Found preincrement\n");
        expr_t *lhs = parse_unary(tokens, env);
        if (!is_valid_lhs(lhs)) {
            UNREACHABLE("Compile error: invalid lhs for preincrement operator\n");
        }
        expr_t *rhs = new_bin_expr(BIN_ADD, lhs, new_primary_int(1));
        return new_assign(lhs, rhs);
    }

    if (match(tokens, TOK_DECREMENT)) {
        debug("Found predecrement\n");
        expr_t *lhs = parse_unary(tokens, env);
        if (!is_valid_lhs(lhs)) {
            debug("lhs type: %d\n", (int)lhs->type);
            UNREACHABLE("Compile error: invalid lhs for predecrement operator\n");
        }
        expr_t *rhs = new_bin_expr(BIN_SUB, lhs, new_primary_int(1));
        return new_assign(lhs, rhs);
    }

    // Thanks 9cc
    return parse_postfix(tokens, env);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
cmpl $0x0, 0x18(%rdi)
je 0x4a49
movq %rsi, %r14
movq %rdi, %rbx
movl $0x16, %esi
callq 0x391c
testb %al, %al
je 0x45cd
movq %rbx, %rdi
movq %r14, %rsi
callq 0x4592
movl $0x2, %edi
jmp 0x460e
movq %rbx, %rdi
movl $0x15, %esi
callq 0x391c
testb %al, %al
je 0x45f0
movq %rbx, %rdi
movq %r14, %rsi
callq 0x4592
movl $0x1, %edi
jmp 0x460e
movq %rbx, %rdi
movl $0x14, %esi
callq 0x391c
testb %al, %al
je 0x4624
movq %rbx, %rdi
movq %r14, %rsi
callq 0x4592
xorl %edi, %edi
movq %rax, %rsi
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x4bec
movq %rbx, %rdi
movl $0x17, %esi
callq 0x391c
testb %al, %al
je 0x4693
movq %rbx, %rdi
movq %r14, %rsi
callq 0x4592
testq %rax, %rax
je 0x4a74
movq %rax, %rbx
cmpl $0x0, (%rax)
jne 0x4a74
movq 0x8(%rbx), %rax
cmpl $0x2, (%rax)
jne 0x4a74
movl $0x10, %edi
callq 0x10e0
movq %rax, %r14
xorl %ebp, %ebp
movl %ebp, (%rax)
movl $0x10, %edi
callq 0x10e0
movq %rax, 0x8(%r14)
movl %ebp, (%rax)
movl $0x1, %ecx
movl %ecx, 0x8(%rax)
movl %ecx, 0x4(%r14)
xorl %edi, %edi
jmp 0x4707
movq %rbx, %rdi
movl $0x18, %esi
callq 0x391c
testb %al, %al
je 0x472b
movq %rbx, %rdi
movq %r14, %rsi
callq 0x4592
testq %rax, %rax
je 0x4a90
movq %rax, %rbx
cmpl $0x0, (%rax)
jne 0x4a90
movq 0x8(%rbx), %rax
cmpl $0x2, (%rax)
jne 0x4a90
movl $0x10, %edi
callq 0x10e0
movq %rax, %r14
xorl %ebp, %ebp
movl %ebp, (%rax)
movl $0x10, %edi
callq 0x10e0
movq %rax, 0x8(%r14)
movl %ebp, (%rax)
movl $0x1, %ecx
movl %ecx, 0x8(%rax)
movl %ecx, 0x4(%r14)
movl $0x1, %edi
movq %rbx, %rsi
movq %r14, %rdx
callq 0x4279
movq %rbx, %rdi
movq %rax, %rsi
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x41ff
cmpl $0x0, 0x18(%rbx)
je 0x4aac
movq %rbx, %rdi
callq 0x3002
movq %rax, %r15
movl (%rax), %eax
cmpl $0x2, %eax
jle 0x47b4
cmpl $0x3, %eax
je 0x47fd
cmpl $0xe, %eax
jne 0x4b70
movq %rbx, %rdi
callq 0x2f9f
movq %rbx, %rdi
movq %r14, %rsi
callq 0x3f79
movq %rax, %r14
movq %rbx, %rdi
movl $0xf, %esi
callq 0x39e5
movl $0x10, %edi
callq 0x10e0
movq %rax, %r15
movl $0x0, (%rax)
movl $0x10, %edi
callq 0x10e0
movq %rax, 0x8(%r15)
movl $0x3, (%rax)
movq %r14, 0x8(%rax)
movl 0x4(%r14), %eax
movl %eax, 0x4(%r15)
jmp 0x49c6
cmpl $0x1, %eax
jne 0x4b06
movq %rbx, %rdi
callq 0x2f9f
movl 0x8(%r15), %ebp
movl $0x10, %edi
callq 0x10e0
movq %rax, %r15
xorl %r14d, %r14d
movl %r14d, (%rax)
movl $0x10, %edi
callq 0x10e0
movq %rax, 0x8(%r15)
movl %r14d, (%rax)
movl %ebp, 0x8(%rax)
movl $0x1, 0x4(%r15)
jmp 0x49c6
movq %rbx, %rdi
callq 0x2f9f
movq 0x8(%r15), %rsi
movq %r14, %rdi
callq 0x2df6
testq %rax, %rax
je 0x4859
movq 0x8(%r15), %r14
testq %r14, %r14
je 0x4b8f
movl (%rax), %ebp
movl $0x10, %edi
callq 0x10e0
movq %rax, %r15
movl $0x0, (%rax)
movl $0x10, %edi
callq 0x10e0
movq %rax, 0x8(%r15)
movl $0x2, (%rax)
movq %r14, 0x8(%rax)
movl %ebp, 0x4(%r15)
jmp 0x49c6
movq 0x5858(%rip), %rax      # 0xa0b8
movq (%rax), %rdi
movq 0x8(%r15), %rsi
callq 0x3183
testq %rax, %rax
je 0x4bae
movq %rax, %r12
movl $0x10, %edi
callq 0x10e0
movq %rax, %r15
movl $0x0, (%rax)
movl $0x10, %edi
callq 0x10e0
movq %rax, %r13
movq %rax, 0x8(%r15)
movl $0x4, (%rax)
movl $0x10, %edi
callq 0x10e0
movq %rax, 0x8(%r13)
movq (%r12), %rcx
movq %rcx, (%rax)
movq $0x0, 0x8(%rax)
movl 0x8(%r12), %eax
movl %eax, 0x4(%r15)
movq %rbx, %rdi
movl $0xe, %esi
callq 0x39e5
movq 0x18(%r12), %rax
testq %rax, %rax
je 0x497d
cmpl $0x0, 0x18(%rax)
je 0x497d
callq 0x2ea0
movq 0x8(%r13), %rcx
movq %rax, 0x8(%rcx)
movq 0x18(%r12), %rdi
movq (%rdi), %rax
movq 0x8(%rax), %rax
movq %rax, 0x10(%rdi)
addq $0x10, %rdi
movq %rsp, %rsi
callq 0x309c
testb %al, %al
je 0x49ad
movq %rbx, %rdi
movq %r14, %rsi
callq 0x3f79
movq %rax, %rbp
movq 0x20(%r12), %rax
movq (%rax), %rdi
movq (%rsp), %rsi
callq 0x3183
movl 0x4(%rbp), %ecx
cmpl (%rax), %ecx
jne 0x4b51
movq 0x8(%r13), %rax
movq 0x8(%rax), %rdi
movq %rbp, %rsi
callq 0x2f0b
movq %rbx, %rdi
movl $0xf, %esi
callq 0x391c
testb %al, %al
jne 0x49ad
movq %rbx, %rdi
movl $0x13, %esi
callq 0x39e5
movq 0x18(%r12), %rdi
jmp 0x490a
movq %rbx, %rdi
movl $0xf, %esi
callq 0x391c
testb %al, %al
jne 0x49c6
leaq 0x179f(%rip), %rdi      # 0x6134
leaq 0x1eb0(%rip), %rsi      # 0x684c
leaq 0x216c(%rip), %rcx      # 0x6b0f
movl $0xd7, %edx
jmp 0x4a63
movq 0x18(%r12), %rax
movl 0x18(%rax), %eax
movq 0x8(%r13), %rcx
movq 0x8(%rcx), %rcx
cmpl 0x18(%rcx), %eax
jne 0x4bcd
cmpl $0x0, 0x18(%rbx)
je 0x4ac8
movq %rbx, %rdi
movl $0x17, %esi
callq 0x391c
testb %al, %al
je 0x49ff
cmpl $0x0, (%r15)
jne 0x4ae7
movq 0x8(%r15), %rax
cmpl $0x2, (%rax)
jne 0x4ae7
movl $0x3, %edi
jmp 0x4a2c
movq %rbx, %rdi
movl $0x18, %esi
callq 0x391c
testb %al, %al
je 0x4a37
cmpl $0x0, (%r15)
jne 0x4b32
movq 0x8(%r15), %rax
cmpl $0x2, (%rax)
jne 0x4b32
movl $0x4, %edi
movq %r15, %rsi
callq 0x4bec
movq %rax, %r15
movq %r15, %rax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x16e4(%rip), %rdi      # 0x6134
leaq 0x1df5(%rip), %rsi      # 0x684c
leaq 0x1f4a(%rip), %rcx      # 0x69a8
movl $0x145, %edx            # imm = 0x145
xorl %eax, %eax
callq 0x1080
movl $0xffffffff, %edi       # imm = 0xFFFFFFFF
callq 0x1110
leaq 0x16b9(%rip), %rdi      # 0x6134
leaq 0x1dca(%rip), %rsi      # 0x684c
leaq 0x1f2d(%rip), %rcx      # 0x69b6
movl $0x15b, %edx            # imm = 0x15B
jmp 0x4a63
leaq 0x169d(%rip), %rdi      # 0x6134
leaq 0x1dae(%rip), %rsi      # 0x684c
leaq 0x1f47(%rip), %rcx      # 0x69ec
movl $0x166, %edx            # imm = 0x166
jmp 0x4a63
leaq 0x1681(%rip), %rdi      # 0x6134
leaq 0x1d92(%rip), %rsi      # 0x684c
leaq 0x1ee7(%rip), %rcx      # 0x69a8
movl $0x128, %edx            # imm = 0x128
jmp 0x4a63
leaq 0x1665(%rip), %rdi      # 0x6134
leaq 0x1d76(%rip), %rsi      # 0x684c
leaq 0x1f45(%rip), %rcx      # 0x6a22
movl $0x12d, %edx            # imm = 0x12D
jmp 0x4a63
leaq 0x1646(%rip), %rdi      # 0x6134
leaq 0x1d57(%rip), %rsi      # 0x684c
leaq 0x1f5a(%rip), %rcx      # 0x6a56
movl $0x133, %edx            # imm = 0x133
jmp 0x4a63
cmpl $0x2, %eax
jne 0x4b70
movq %rbx, %rdi
callq 0x2f9f
leaq 0x161a(%rip), %rdi      # 0x6134
leaq 0x1d2b(%rip), %rsi      # 0x684c
leaq 0x1fbe(%rip), %rcx      # 0x6ae6
movl $0x8c, %edx
jmp 0x4a63
leaq 0x15fb(%rip), %rdi      # 0x6134
leaq 0x1d0c(%rip), %rsi      # 0x684c
leaq 0x1f3d(%rip), %rcx      # 0x6a84
movl $0x13b, %edx            # imm = 0x13B
jmp 0x4a63
leaq 0x15dc(%rip), %rdi      # 0x6134
leaq 0x1ced(%rip), %rsi      # 0x684c
leaq 0x2000(%rip), %rcx      # 0x6b66
movl $0xe4, %edx
jmp 0x4a63
leaq 0x15bd(%rip), %rdi      # 0x6134
leaq 0x1cce(%rip), %rsi      # 0x684c
leaq 0x1f41(%rip), %rcx      # 0x6ac6
movl $0x123, %edx            # imm = 0x123
jmp 0x4a63
leaq 0x159e(%rip), %rdi      # 0x6134
leaq 0x1caf(%rip), %rsi      # 0x684c
leaq 0x1f4d(%rip), %rcx      # 0x6af1
movl $0x98, %edx
jmp 0x4a63
leaq 0x157f(%rip), %rdi      # 0x6134
leaq 0x1c90(%rip), %rsi      # 0x684c
leaq 0x1eef(%rip), %rcx      # 0x6ab2
movl $0x119, %edx            # imm = 0x119
jmp 0x4a63
leaq 0x1560(%rip), %rdi      # 0x6134
leaq 0x1c71(%rip), %rsi      # 0x684c
leaq 0x1fbc(%rip), %rcx      # 0x6b9e
movl $0xee, %edx
jmp 0x4a63