// File: /workspace/github_c_makefile_star2_O3/tyabu12[P]pl0compiler/codegen.c
// Function: readCode
int readCode(FILE *fp) {
struct {
  const char *name;
  OpCode opCode;
  int flag;
} static const opTbl[] = {
  { "lit", lit, 1 },
  { "opr", opr, 3 },
  { "lod", lod, 2 },
  { "sto", sto, 2 },
  { "cal", cal, 2 },
  { "ret", ret, 2 },
  { "ict", ict, 1 },
  { "jmp", jmp, 1 },
  { "jpc", jpc, 1 },
  { NULL, } /* 番兵 */
};
struct {
  const char *name;
  Operator optr;
} static const optrTbl[] = {
  { "neg",  neg  },
  { "add",  add  },
  { "sub",  sub  },
  { "mul",  mul  },
  { "div",  div  },
  { "odd",  odd  },
  { "eq",   eq   },
  { "lseq", lseq },
  { "ls",   ls   },
  { "greq", greq },
  { "gr",   gr   },
  { "neq",  neq  },
  { "rd",   rd   },
  { "wrt",  wrt  },
  { "wrl",  wrl  },
  { NULL, } /* 番兵 */
};
    char str[256];
    char *p;
    int op, optr, i;
    for (i = 0; fgets(str, 256, fp) != NULL; i++) {
        p = str;
        /* 行番号のスキップ */
        while (*p != ':' && *p != '\0') p++;
        if (*p == ':') p++;
        while (*p == ' ' && *p != '\0') p++;
        if (*p == '\0') return 1;
        /* 命令語をテーブルから検索 */
        for (op = 0; opTbl[op].name != NULL; op++) {
            if (strncmp(opTbl[op].name, p, 3) == 0)
                break;
        }
        if (opTbl[op].name == NULL) {
            fprintf(stderr, "Unknown op: %s\n", str);
            return 1;
        }
        code[i].opCode = opTbl[op].opCode;
        /* 命令語の形式毎に処理 */
        switch (opTbl[op].flag) {
        case 1:
            sscanf(p+4, "%d", &code[i].u.value);
            break;
        case 2:
            sscanf(p+4, "%d,%d",
                &code[i].u.addr.level, &code[i].u.addr.addr);
            break;
        case 3:
            for (optr = 0; optrTbl[optr].name != NULL; optr++) {
                if (strncmp(optrTbl[optr].name, p+4,
                  strlen(optrTbl[optr].name)) == 0)
                    break;
            }
            if (optrTbl[optr].name == NULL) {
                fprintf(stderr, "Unknown operator: %s\n", str);
                return 1;
            }
            code[i].u.optr = optrTbl[optr].optr;
            break;
        }
    }
    cIndex = i;
    return 0;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x118, %rsp            # imm = 0x118
movq %rdi, %r12
leaq 0x10(%rsp), %r15
movq %r15, %rdi
movl $0x100, %esi            # imm = 0x100
movq %r12, %rdx
callq 0x20e0
xorl %r14d, %r14d
movl $0x0, %r13d
testq %rax, %rax
je 0x28ad
leaq 0x14(%rsp), %rbp
leaq 0x2a33(%rip), %rdi      # 0x5131
leaq 0x532b(%rip), %rbx      # 0x7a30
xorl %r13d, %r13d
movzbl (%r15), %eax
testl %eax, %eax
je 0x271d
cmpl $0x3a, %eax
je 0x271d
incq %r15
incq %rbp
jmp 0x2708
xorl %ecx, %ecx
cmpb $0x3a, %al
sete %cl
addq %rcx, %r15
addq %rcx, %rbp
movzbl (%r15), %eax
cmpl $0x20, %eax
jne 0x273b
incq %r15
incq %rbp
jmp 0x272a
testl %eax, %eax
je 0x28d3
movq %r12, 0x8(%rsp)
movl $0x3, %edx
movq %r15, %rsi
callq 0x2040
movq %rbx, %r12
testl %eax, %eax
je 0x278b
xorl %ecx, %ecx
leaq 0x10(%rcx), %r12
cmpq $0x90, %r12
je 0x28b6
movq 0x10(%rcx,%rbx), %rdi
movl $0x3, %edx
movq %r15, %rsi
callq 0x2040
movq %r12, %rcx
testl %eax, %eax
jne 0x275e
addq %rbx, %r12
leaq (,%r13,2), %rax
addq %r13, %rax
leaq 0x5953(%rip), %rcx      # 0x80f0
leaq (%rcx,%rax,4), %r15
movl 0x8(%r12), %ecx
movl 0xc(%r12), %eax
movl %ecx, (%r15)
cmpl $0x1, %eax
je 0x2863
cmpl $0x2, %eax
movq 0x8(%rsp), %r12
je 0x2845
cmpl $0x3, %eax
jne 0x2880
movl $0x3, %edx
leaq 0x2a38(%rip), %rdi      # 0x5212
movq %rbp, %rsi
callq 0x2040
leaq 0x52e7(%rip), %r14      # 0x7ad0
testl %eax, %eax
je 0x2838
xorl %ecx, %ecx
leaq 0x10(%rcx), %r14
cmpq $0xf0, %r14
je 0x28ee
leaq 0x52c9(%rip), %rax      # 0x7ad0
movq 0x10(%rcx,%rax), %r12
movq %r12, %rdi
callq 0x2080
movq %r12, %rdi
movq %rbp, %rsi
movq %rax, %rdx
callq 0x2040
movq %r14, %rcx
testl %eax, %eax
jne 0x27ef
leaq 0x52a0(%rip), %rax      # 0x7ad0
addq %rax, %r14
movq 0x8(%rsp), %r12
movl 0x8(%r14), %eax
movl %eax, 0x4(%r15)
xorl %r14d, %r14d
jmp 0x2880
leaq 0x4(%r15), %rdx
addq $0x8, %r15
movq %rbp, %rdi
leaq 0x290e(%rip), %rsi      # 0x5165
movq %r15, %rcx
xorl %eax, %eax
callq 0x2130
jmp 0x2880
addq $0x4, %r15
movq %rbp, %rdi
leaq 0x28f7(%rip), %rsi      # 0x5168
movq %r15, %rdx
xorl %eax, %eax
callq 0x2130
movq 0x8(%rsp), %r12
incq %r13
leaq 0x10(%rsp), %r15
movq %r15, %rdi
movl $0x100, %esi            # imm = 0x100
movq %r12, %rdx
callq 0x20e0
testq %rax, %rax
leaq 0x14(%rsp), %rbp
leaq 0x288a(%rip), %rdi      # 0x5131
jne 0x2708
movl %r13d, 0x5824(%rip)     # 0x80d8
jmp 0x28d9
movq 0x5733(%rip), %rax      # 0x7ff0
movq (%rax), %rdi
leaq 0x288e(%rip), %rsi      # 0x5155
leaq 0x10(%rsp), %rdx
xorl %eax, %eax
callq 0x2110
movl $0x1, %r14d
movl %r14d, %eax
addq $0x118, %rsp            # imm = 0x118
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x56fb(%rip), %rax      # 0x7ff0
movq (%rax), %rdi
leaq 0x286c(%rip), %rsi      # 0x516b
jmp 0x28c7