// File: JameyWoo[P]csmile/parse.cpp
// Function: factor(TreeNode*)
TreeNode* factor(TreeNode* k) {
    TreeNode* t = NULL;
    if (k != NULL) {
        if (ptoken.type == "LeftBracket" && k->nodekind != "ArrayElem") {  // TODO: 数组元素
            t = call(k);
        } else {
            t = k;
        }
    } else {
        if (ptoken.type == "LeftBracket") {
            match("LeftBracket");
            t = expression();
            match("RightBracket");
        } else if (ptoken.type == "Id") {
            k = var();
            if (ptoken.type == "LeftBracket" && k->nodekind != "ArrayElem") {
                t = call(k);
            } else {
                t = k;
            }
        } else if (ptoken.type == "Num") {
            t = new TreeNode("Const");
            if ((t != NULL) && (ptoken.type == "Num")) {
                t->val = stoi(ptoken.value);
            }
            match("Num");
        } else {
            ptoken = getToken();
        }
    }
    return t;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x210, %rsp            # imm = 0x210
movq %rdi, -0x8(%rbp)
movq $0x0, -0x10(%rbp)
cmpq $0x0, -0x8(%rbp)
je 0xb01d
leaq 0x235b3(%rip), %rdi     # 0x2e588
leaq 0x160d4(%rip), %rsi     # 0x210b0
callq 0x5e70
testb $0x1, %al
jne 0xafe7
jmp 0xb010
movq -0x8(%rbp), %rdi
addq $0x30, %rdi
leaq 0x161e9(%rip), %rsi     # 0x211df
callq 0xdad0
testb $0x1, %al
jne 0xb001
jmp 0xb010
movq -0x8(%rbp), %rdi
callq 0xac90
movq %rax, -0x10(%rbp)
jmp 0xb018
movq -0x8(%rbp), %rax
movq %rax, -0x10(%rbp)
jmp 0xb41d
leaq 0x23564(%rip), %rdi     # 0x2e588
leaq 0x16085(%rip), %rsi     # 0x210b0
callq 0x5e70
testb $0x1, %al
jne 0xb039
jmp 0xb182
leaq -0x79(%rbp), %rdi
movq %rdi, -0x1e8(%rbp)
callq 0x3480
movq -0x1e8(%rbp), %rdx
leaq 0x16059(%rip), %rsi     # 0x210b0
leaq -0x78(%rbp), %rdi
callq 0x4ef0
jmp 0xb062
leaq -0x58(%rbp), %rdi
leaq -0x78(%rbp), %rsi
callq 0x80b0
jmp 0xb071
leaq -0x58(%rbp), %rdi
callq 0x4ec0
leaq -0x78(%rbp), %rdi
callq 0x34e8
leaq -0x79(%rbp), %rdi
callq 0x32d0
callq 0x9b00
movq %rax, -0x10(%rbp)
leaq -0xf9(%rbp), %rdi
movq %rdi, -0x1f0(%rbp)
callq 0x3480
movq -0x1f0(%rbp), %rdx
leaq 0x16006(%rip), %rsi     # 0x210bc
leaq -0xf8(%rbp), %rdi
callq 0x4ef0
jmp 0xb0c4
leaq -0xd8(%rbp), %rdi
leaq -0xf8(%rbp), %rsi
callq 0x80b0
jmp 0xb0d9
leaq -0xd8(%rbp), %rdi
callq 0x4ec0
leaq -0xf8(%rbp), %rdi
callq 0x34e8
leaq -0xf9(%rbp), %rdi
callq 0x32d0
jmp 0xb41b
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x88(%rbp)
movl %eax, -0x8c(%rbp)
jmp 0xb131
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x88(%rbp)
movl %eax, -0x8c(%rbp)
leaq -0x78(%rbp), %rdi
callq 0x34e8
leaq -0x79(%rbp), %rdi
callq 0x32d0
jmp 0xb42a
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x88(%rbp)
movl %eax, -0x8c(%rbp)
jmp 0xb171
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x88(%rbp)
movl %eax, -0x8c(%rbp)
leaq -0xf8(%rbp), %rdi
callq 0x34e8
leaq -0xf9(%rbp), %rdi
callq 0x32d0
jmp 0xb42a
leaq 0x233ff(%rip), %rdi     # 0x2e588
leaq 0x1601c(%rip), %rsi     # 0x211ac
callq 0x5e70
testb $0x1, %al
jne 0xb19b
jmp 0xb1f3
callq 0xa890
movq %rax, -0x8(%rbp)
leaq 0x233dd(%rip), %rdi     # 0x2e588
leaq 0x15efe(%rip), %rsi     # 0x210b0
callq 0x5e70
testb $0x1, %al
jne 0xb1bd
jmp 0xb1e6
movq -0x8(%rbp), %rdi
addq $0x30, %rdi
leaq 0x16013(%rip), %rsi     # 0x211df
callq 0xdad0
testb $0x1, %al
jne 0xb1d7
jmp 0xb1e6
movq -0x8(%rbp), %rdi
callq 0xac90
movq %rax, -0x10(%rbp)
jmp 0xb1ee
movq -0x8(%rbp), %rax
movq %rax, -0x10(%rbp)
jmp 0xb419
leaq 0x2338e(%rip), %rdi     # 0x2e588
leaq 0x15e8c(%rip), %rsi     # 0x2108d
callq 0x5e70
testb $0x1, %al
jne 0xb20f
jmp 0xb3ec
movl $0xe0, %edi
callq 0x3280
movq %rax, -0x200(%rbp)
movb $0x1, -0x122(%rbp)
leaq -0x121(%rbp), %rdi
movq %rdi, -0x1f8(%rbp)
callq 0x3480
movq -0x1f8(%rbp), %rdx
leaq 0x15fa1(%rip), %rsi     # 0x211e9
leaq -0x120(%rbp), %rdi
callq 0x4ef0
jmp 0xb256
movq -0x200(%rbp), %rdi
leaq -0x120(%rbp), %rsi
callq 0xdb50
jmp 0xb26b
movq -0x200(%rbp), %rax
movb $0x0, -0x122(%rbp)
movq %rax, -0x10(%rbp)
leaq -0x120(%rbp), %rdi
callq 0x34e8
leaq -0x121(%rbp), %rdi
callq 0x32d0
cmpq $0x0, -0x10(%rbp)
je 0xb342
leaq 0x232e1(%rip), %rdi     # 0x2e588
leaq 0x15ddf(%rip), %rsi     # 0x2108d
callq 0x5e70
testb $0x1, %al
jne 0xb2bc
jmp 0xb342
leaq 0x232c5(%rip), %rdi     # 0x2e588
addq $0x20, %rdi
xorl %eax, %eax
movl %eax, %esi
movl $0xa, %edx
callq 0xdbf0
movl %eax, %ecx
movq -0x10(%rbp), %rax
movl %ecx, 0xb8(%rax)
jmp 0xb342
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x88(%rbp)
movl %eax, -0x8c(%rbp)
jmp 0xb315
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x88(%rbp)
movl %eax, -0x8c(%rbp)
leaq -0x120(%rbp), %rdi
callq 0x34e8
leaq -0x121(%rbp), %rdi
callq 0x32d0
testb $0x1, -0x122(%rbp)
jne 0xb32c
jmp 0xb33d
movq -0x200(%rbp), %rdi
movl $0xe0, %esi
callq 0x3290
jmp 0xb42a
leaq -0x191(%rbp), %rdi
movq %rdi, -0x208(%rbp)
callq 0x3480
movq -0x208(%rbp), %rdx
leaq 0x15d2a(%rip), %rsi     # 0x2108d
leaq -0x190(%rbp), %rdi
callq 0x4ef0
jmp 0xb371
leaq -0x170(%rbp), %rdi
leaq -0x190(%rbp), %rsi
callq 0x80b0
jmp 0xb386
leaq -0x170(%rbp), %rdi
callq 0x4ec0
leaq -0x190(%rbp), %rdi
callq 0x34e8
leaq -0x191(%rbp), %rdi
callq 0x32d0
jmp 0xb417
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x88(%rbp)
movl %eax, -0x8c(%rbp)
jmp 0xb3de
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x88(%rbp)
movl %eax, -0x8c(%rbp)
leaq -0x190(%rbp), %rdi
callq 0x34e8
leaq -0x191(%rbp), %rdi
callq 0x32d0
jmp 0xb42a
leaq -0x1e0(%rbp), %rdi
callq 0x5460
leaq 0x23189(%rip), %rdi     # 0x2e588
leaq -0x1e0(%rbp), %rsi
callq 0xdb00
leaq -0x1e0(%rbp), %rdi
callq 0x4ec0
jmp 0xb419
jmp 0xb41b
jmp 0xb41d
movq -0x10(%rbp), %rax
addq $0x210, %rsp            # imm = 0x210
popq %rbp
retq
movq -0x88(%rbp), %rdi
callq 0x3470
nopw %cs:(%rax,%rax)