// File: /workspace/github_c_makefile_star2_O2/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 0x45bc
movq %rsi, %r14
movq %rdi, %rbx
pushq $0x16
popq %rsi
callq 0x35a8
testb %al, %al
je 0x4213
movq %rbx, %rdi
movq %r14, %rsi
callq 0x41dd
pushq $0x2
jmp 0x422f
pushq $0x15
popq %rsi
movq %rbx, %rdi
callq 0x35a8
testb %al, %al
je 0x4246
movq %rbx, %rdi
movq %r14, %rsi
callq 0x41dd
pushq $0x1
popq %rdi
movq %rax, %rsi
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x475a
pushq $0x14
popq %rsi
movq %rbx, %rdi
callq 0x35a8
testb %al, %al
je 0x4264
movq %rbx, %rdi
movq %r14, %rsi
callq 0x41dd
xorl %edi, %edi
jmp 0x4230
pushq $0x17
popq %rsi
movq %rbx, %rdi
callq 0x35a8
testb %al, %al
je 0x429d
movq %rbx, %rdi
movq %r14, %rsi
callq 0x41dd
movq %rax, %rbx
movq %rax, %rdi
callq 0x3e13
testb %al, %al
je 0x45e5
pushq $0x1
popq %rdi
callq 0x3cd8
xorl %edi, %edi
jmp 0x42d6
pushq $0x18
popq %rsi
movq %rbx, %rdi
callq 0x35a8
testb %al, %al
je 0x42fa
movq %rbx, %rdi
movq %r14, %rsi
callq 0x41dd
movq %rax, %rbx
movq %rax, %rdi
callq 0x3e13
testb %al, %al
je 0x4601
pushq $0x1
popq %rbp
movl %ebp, %edi
callq 0x3cd8
movl %ebp, %edi
movq %rbx, %rsi
movq %rax, %rdx
callq 0x3ea2
movq %rbx, %rdi
movq %rax, %rsi
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x3e2b
cmpl $0x0, 0x18(%rbx)
je 0x461d
movq %rbx, %rdi
callq 0x2d68
movq %rax, %r15
movl (%rax), %eax
cmpl $0x1, %eax
je 0x437a
cmpl $0x3, %eax
je 0x4393
cmpl $0xe, %eax
jne 0x4674
movq %rbx, %rdi
callq 0x2d0a
movq %rbx, %rdi
movq %r14, %rsi
callq 0x3b59
movq %rax, %r14
pushq $0xf
popq %rsi
movq %rbx, %rdi
callq 0x3666
pushq $0x10
popq %r12
movq %r12, %rdi
callq 0x10e0
movq %rax, %r15
andl $0x0, (%rax)
movq %r12, %rdi
callq 0x10e0
movq %rax, 0x8(%r15)
movl $0x3, (%rax)
movq %r14, 0x8(%rax)
movl 0x4(%r14), %eax
movl %eax, 0x4(%r15)
jmp 0x4550
movq %rbx, %rdi
callq 0x2d0a
movl 0x8(%r15), %edi
callq 0x3cd8
movq %rax, %r15
jmp 0x4550
movq %rbx, %rdi
callq 0x2d0a
movq 0x8(%r15), %rsi
movq %r14, %rdi
callq 0x2b94
testq %rax, %rax
je 0x43ec
movq 0x8(%r15), %r12
testq %r12, %r12
je 0x46fd
movl (%rax), %ebp
pushq $0x10
popq %r14
movq %r14, %rdi
callq 0x10e0
movq %rax, %r15
andl $0x0, (%rax)
movq %r14, %rdi
callq 0x10e0
movq %rax, 0x8(%r15)
movl $0x2, (%rax)
movq %r12, 0x8(%rax)
movl %ebp, 0x4(%r15)
jmp 0x4550
movq 0x4cc5(%rip), %rax      # 0x90b8
movq (%rax), %rdi
movq 0x8(%r15), %rsi
callq 0x2ed9
testq %rax, %rax
je 0x471c
movq %rax, %r12
pushq $0x10
popq %rbp
movq %rbp, %rdi
callq 0x10e0
movq %rax, %r15
andl $0x0, (%rax)
movq %rbp, %rdi
callq 0x10e0
movq %rax, %r13
movq %rax, 0x8(%r15)
movl $0x4, (%rax)
movq %rbp, %rdi
callq 0x10e0
movq %rax, 0x8(%r13)
movq (%r12), %rcx
movq %rcx, (%rax)
andq $0x0, 0x8(%rax)
movl 0x8(%r12), %eax
movl %eax, 0x4(%r15)
pushq $0xe
popq %rsi
movq %rbx, %rdi
callq 0x3666
movq 0x18(%r12), %rax
testq %rax, %rax
je 0x4505
cmpl $0x0, 0x18(%rax)
je 0x4505
callq 0x2c34
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 0x2dfe
testb %al, %al
je 0x4533
movq %rbx, %rdi
movq %r14, %rsi
callq 0x3b59
movq %rax, %rbp
movq 0x20(%r12), %rax
movq (%rax), %rdi
movq (%rsp), %rsi
callq 0x2ed9
movl 0x4(%rbp), %ecx
cmpl (%rax), %ecx
jne 0x4655
movq 0x8(%r15), %r13
movq 0x8(%r13), %rax
movq 0x8(%rax), %rdi
movq %rbp, %rsi
callq 0x2c7e
movq %rbx, %rdi
pushq $0xf
popq %rsi
callq 0x35a8
testb %al, %al
jne 0x4537
movq %rbx, %rdi
pushq $0x13
popq %rsi
callq 0x3666
movq 0x18(%r12), %rdi
jmp 0x4492
pushq $0xf
popq %rsi
movq %rbx, %rdi
callq 0x35a8
testb %al, %al
jne 0x4550
leaq 0xc19(%rip), %rdi       # 0x5134
leaq 0x135a(%rip), %rsi      # 0x587c
leaq 0x1616(%rip), %rcx      # 0x5b3f
movl $0xd7, %edx
jmp 0x45d6
movq 0x8(%r15), %r13
movq 0x18(%r12), %rax
movl 0x18(%rax), %eax
movq 0x8(%r13), %rcx
movq 0x8(%rcx), %rcx
cmpl 0x18(%rcx), %eax
jne 0x473b
cmpl $0x0, 0x18(%rbx)
je 0x4639
pushq $0x17
popq %rsi
movq %rbx, %rdi
callq 0x35a8
testb %al, %al
je 0x457d
movq %r15, %rdi
callq 0x3e13
testb %al, %al
je 0x46a0
pushq $0x3
jmp 0x459e
pushq $0x18
popq %rsi
movq %rbx, %rdi
callq 0x35a8
testb %al, %al
je 0x45aa
movq %r15, %rdi
callq 0x3e13
testb %al, %al
je 0x46de
pushq $0x4
popq %rdi
movq %r15, %rsi
callq 0x475a
movq %rax, %r15
movq %r15, %rax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0xb71(%rip), %rdi       # 0x5134
leaq 0x12b2(%rip), %rsi      # 0x587c
leaq 0x1407(%rip), %rcx      # 0x59d8
movl $0x145, %edx            # imm = 0x145
xorl %eax, %eax
callq 0x1080
pushq $-0x1
popq %rdi
callq 0x1110
leaq 0xb48(%rip), %rdi       # 0x5134
leaq 0x1289(%rip), %rsi      # 0x587c
leaq 0x13ec(%rip), %rcx      # 0x59e6
movl $0x15b, %edx            # imm = 0x15B
jmp 0x45d6
leaq 0xb2c(%rip), %rdi       # 0x5134
leaq 0x126d(%rip), %rsi      # 0x587c
leaq 0x1406(%rip), %rcx      # 0x5a1c
movl $0x166, %edx            # imm = 0x166
jmp 0x45d6
leaq 0xb10(%rip), %rdi       # 0x5134
leaq 0x1251(%rip), %rsi      # 0x587c
leaq 0x13a6(%rip), %rcx      # 0x59d8
movl $0x128, %edx            # imm = 0x128
jmp 0x45d6
leaq 0xaf4(%rip), %rdi       # 0x5134
leaq 0x1235(%rip), %rsi      # 0x587c
leaq 0x1404(%rip), %rcx      # 0x5a52
movl $0x12d, %edx            # imm = 0x12D
jmp 0x45d6
leaq 0xad8(%rip), %rdi       # 0x5134
leaq 0x1219(%rip), %rsi      # 0x587c
leaq 0x152c(%rip), %rcx      # 0x5b96
movl $0xe4, %edx
jmp 0x45d6
cmpl $0x2, %eax
jne 0x46bf
movq %rbx, %rdi
callq 0x2d0a
leaq 0xaac(%rip), %rdi       # 0x5134
leaq 0x11ed(%rip), %rsi      # 0x587c
leaq 0x1480(%rip), %rcx      # 0x5b16
movl $0x8c, %edx
jmp 0x45d6
leaq 0xa8d(%rip), %rdi       # 0x5134
leaq 0x11ce(%rip), %rsi      # 0x587c
leaq 0x13d1(%rip), %rcx      # 0x5a86
movl $0x133, %edx            # imm = 0x133
jmp 0x45d6
leaq 0xa6e(%rip), %rdi       # 0x5134
leaq 0x11af(%rip), %rsi      # 0x587c
leaq 0x1422(%rip), %rcx      # 0x5af6
movl $0x123, %edx            # imm = 0x123
jmp 0x45d6
leaq 0xa4f(%rip), %rdi       # 0x5134
leaq 0x1190(%rip), %rsi      # 0x587c
leaq 0x13c1(%rip), %rcx      # 0x5ab4
movl $0x13b, %edx            # imm = 0x13B
jmp 0x45d6
leaq 0xa30(%rip), %rdi       # 0x5134
leaq 0x1171(%rip), %rsi      # 0x587c
leaq 0x140f(%rip), %rcx      # 0x5b21
movl $0x98, %edx
jmp 0x45d6
leaq 0xa11(%rip), %rdi       # 0x5134
leaq 0x1152(%rip), %rsi      # 0x587c
leaq 0x13b1(%rip), %rcx      # 0x5ae2
movl $0x119, %edx            # imm = 0x119
jmp 0x45d6
leaq 0x9f2(%rip), %rdi       # 0x5134
leaq 0x1133(%rip), %rsi      # 0x587c
leaq 0x147e(%rip), %rcx      # 0x5bce
movl $0xee, %edx
jmp 0x45d6