// File: /workspace/github_c_makefile_star2_O1/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 0x4b02
movq %rsi, %r14
movq %rdi, %rbx
movl $0x16, %esi
callq 0x39ab
testb %al, %al
je 0x466d
movq %rbx, %rdi
movq %r14, %rsi
callq 0x4632
movl $0x2, %edi
jmp 0x46ae
movq %rbx, %rdi
movl $0x15, %esi
callq 0x39ab
testb %al, %al
je 0x4690
movq %rbx, %rdi
movq %r14, %rsi
callq 0x4632
movl $0x1, %edi
jmp 0x46ae
movq %rbx, %rdi
movl $0x14, %esi
callq 0x39ab
testb %al, %al
je 0x46c4
movq %rbx, %rdi
movq %r14, %rsi
callq 0x4632
xorl %edi, %edi
movq %rax, %rsi
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x4ca5
movq %rbx, %rdi
movl $0x17, %esi
callq 0x39ab
testb %al, %al
je 0x4733
movq %rbx, %rdi
movq %r14, %rsi
callq 0x4632
testq %rax, %rax
je 0x4b2d
movq %rax, %rbx
cmpl $0x0, (%rax)
jne 0x4b2d
movq 0x8(%rbx), %rax
cmpl $0x2, (%rax)
jne 0x4b2d
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 0x47a7
movq %rbx, %rdi
movl $0x18, %esi
callq 0x39ab
testb %al, %al
je 0x47cb
movq %rbx, %rdi
movq %r14, %rsi
callq 0x4632
testq %rax, %rax
je 0x4b49
movq %rax, %rbx
cmpl $0x0, (%rax)
jne 0x4b49
movq 0x8(%rbx), %rax
cmpl $0x2, (%rax)
jne 0x4b49
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 0x431a
movq %rbx, %rdi
movq %rax, %rsi
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x42a0
cmpl $0x0, 0x18(%rbx)
je 0x4b65
movq %rbx, %rdi
callq 0x305e
movq %rax, %r15
movl (%rax), %eax
cmpl $0x2, %eax
jle 0x4854
cmpl $0x3, %eax
je 0x489d
cmpl $0xe, %eax
jne 0x4c29
movq %rbx, %rdi
callq 0x2ffb
movq %rbx, %rdi
movq %r14, %rsi
callq 0x401c
movq %rax, %r14
movq %rbx, %rdi
movl $0xf, %esi
callq 0x3a74
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 0x4a7f
cmpl $0x1, %eax
jne 0x4bbf
movq %rbx, %rdi
callq 0x2ffb
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 0x4a7f
movq %rbx, %rdi
callq 0x2ffb
movq 0x8(%r15), %rsi
movq %r14, %rdi
callq 0x2e52
testq %rax, %rax
je 0x48f9
movq 0x8(%r15), %r14
testq %r14, %r14
je 0x4c48
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 0x4a7f
movq 0x57b8(%rip), %rax      # 0xa0b8
movq (%rax), %rdi
movq 0x8(%r15), %rsi
callq 0x31df
testq %rax, %rax
je 0x4c67
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 0x3a74
movq 0x18(%r12), %rax
testq %rax, %rax
je 0x4a6a
cmpl $0x0, 0x18(%rax)
je 0x4a6a
callq 0x2efc
movq 0x8(%r15), %rcx
movq 0x8(%rcx), %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 0x30f8
testb %al, %al
je 0x4a32
movq %rsp, %r13
movq %rbx, %rdi
movq %r14, %rsi
callq 0x401c
movq %rax, %rbp
movq 0x20(%r12), %rax
movq (%rax), %rdi
movq (%rsp), %rsi
callq 0x31df
movl 0x4(%rbp), %ecx
cmpl (%rax), %ecx
jne 0x4c0a
movq 0x8(%r15), %rax
movq 0x8(%rax), %rax
movq 0x8(%rax), %rdi
movq %rbp, %rsi
callq 0x2f67
movq %rbx, %rdi
movl $0xf, %esi
callq 0x39ab
testb %al, %al
jne 0x4a32
movq %rbx, %rdi
movl $0x13, %esi
callq 0x3a74
movq 0x18(%r12), %rdi
addq $0x10, %rdi
movq %r13, %rsi
callq 0x30f8
testb %al, %al
jne 0x49c1
movq 0x18(%r12), %rax
movl 0x18(%rax), %eax
movq 0x8(%r15), %rcx
movq 0x8(%rcx), %rcx
movq 0x8(%rcx), %rcx
cmpl 0x18(%rcx), %eax
je 0x4a7f
leaq 0x16e2(%rip), %rdi      # 0x6134
leaq 0x1e43(%rip), %rsi      # 0x689c
leaq 0x218e(%rip), %rcx      # 0x6bee
movl $0xee, %edx
jmp 0x4b1c
movq %rbx, %rdi
movl $0xf, %esi
callq 0x39ab
testb %al, %al
je 0x4c86
cmpl $0x0, 0x18(%rbx)
je 0x4b81
movq %rbx, %rdi
movl $0x17, %esi
callq 0x39ab
testb %al, %al
je 0x4ab8
cmpl $0x0, (%r15)
jne 0x4ba0
movq 0x8(%r15), %rax
cmpl $0x2, (%rax)
jne 0x4ba0
movl $0x3, %edi
jmp 0x4ae5
movq %rbx, %rdi
movl $0x18, %esi
callq 0x39ab
testb %al, %al
je 0x4af0
cmpl $0x0, (%r15)
jne 0x4beb
movq 0x8(%r15), %rax
cmpl $0x2, (%rax)
jne 0x4beb
movl $0x4, %edi
movq %r15, %rsi
callq 0x4ca5
movq %rax, %r15
movq %r15, %rax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x162b(%rip), %rdi      # 0x6134
leaq 0x1d8c(%rip), %rsi      # 0x689c
leaq 0x1ee1(%rip), %rcx      # 0x69f8
movl $0x145, %edx            # imm = 0x145
xorl %eax, %eax
callq 0x1080
movl $0xffffffff, %edi       # imm = 0xFFFFFFFF
callq 0x1110
leaq 0x1600(%rip), %rdi      # 0x6134
leaq 0x1d61(%rip), %rsi      # 0x689c
leaq 0x1ec4(%rip), %rcx      # 0x6a06
movl $0x15b, %edx            # imm = 0x15B
jmp 0x4b1c
leaq 0x15e4(%rip), %rdi      # 0x6134
leaq 0x1d45(%rip), %rsi      # 0x689c
leaq 0x1ede(%rip), %rcx      # 0x6a3c
movl $0x166, %edx            # imm = 0x166
jmp 0x4b1c
leaq 0x15c8(%rip), %rdi      # 0x6134
leaq 0x1d29(%rip), %rsi      # 0x689c
leaq 0x1e7e(%rip), %rcx      # 0x69f8
movl $0x128, %edx            # imm = 0x128
jmp 0x4b1c
leaq 0x15ac(%rip), %rdi      # 0x6134
leaq 0x1d0d(%rip), %rsi      # 0x689c
leaq 0x1edc(%rip), %rcx      # 0x6a72
movl $0x12d, %edx            # imm = 0x12D
jmp 0x4b1c
leaq 0x158d(%rip), %rdi      # 0x6134
leaq 0x1cee(%rip), %rsi      # 0x689c
leaq 0x1ef1(%rip), %rcx      # 0x6aa6
movl $0x133, %edx            # imm = 0x133
jmp 0x4b1c
cmpl $0x2, %eax
jne 0x4c29
movq %rbx, %rdi
callq 0x2ffb
leaq 0x1561(%rip), %rdi      # 0x6134
leaq 0x1cc2(%rip), %rsi      # 0x689c
leaq 0x1f55(%rip), %rcx      # 0x6b36
movl $0x8c, %edx
jmp 0x4b1c
leaq 0x1542(%rip), %rdi      # 0x6134
leaq 0x1ca3(%rip), %rsi      # 0x689c
leaq 0x1ed4(%rip), %rcx      # 0x6ad4
movl $0x13b, %edx            # imm = 0x13B
jmp 0x4b1c
leaq 0x1523(%rip), %rdi      # 0x6134
leaq 0x1c84(%rip), %rsi      # 0x689c
leaq 0x1f97(%rip), %rcx      # 0x6bb6
movl $0xe4, %edx
jmp 0x4b1c
leaq 0x1504(%rip), %rdi      # 0x6134
leaq 0x1c65(%rip), %rsi      # 0x689c
leaq 0x1ed8(%rip), %rcx      # 0x6b16
movl $0x123, %edx            # imm = 0x123
jmp 0x4b1c
leaq 0x14e5(%rip), %rdi      # 0x6134
leaq 0x1c46(%rip), %rsi      # 0x689c
leaq 0x1ee4(%rip), %rcx      # 0x6b41
movl $0x98, %edx
jmp 0x4b1c
leaq 0x14c6(%rip), %rdi      # 0x6134
leaq 0x1c27(%rip), %rsi      # 0x689c
leaq 0x1e86(%rip), %rcx      # 0x6b02
movl $0x119, %edx            # imm = 0x119
jmp 0x4b1c
leaq 0x14a7(%rip), %rdi      # 0x6134
leaq 0x1c08(%rip), %rsi      # 0x689c
leaq 0x1ec4(%rip), %rcx      # 0x6b5f
movl $0xd7, %edx
jmp 0x4b1c