// File: /workspace/github_c_makefile_star2_O0/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
movq %rsp, %rbp
subq $0x140, %rsp            # imm = 0x140
movq %rdi, -0x10(%rbp)
movl $0x0, -0x124(%rbp)
leaq -0x110(%rbp), %rdi
movq -0x10(%rbp), %rdx
movl $0x100, %esi            # imm = 0x100
callq 0x20a0
cmpq $0x0, %rax
je 0x2c82
leaq -0x110(%rbp), %rax
movq %rax, -0x118(%rbp)
movq -0x118(%rbp), %rax
movsbl (%rax), %ecx
xorl %eax, %eax
cmpl $0x3a, %ecx
movb %al, -0x125(%rbp)
je 0x2903
movq -0x118(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x0, %eax
setne %al
movb %al, -0x125(%rbp)
movb -0x125(%rbp), %al
testb $0x1, %al
jne 0x290f
jmp 0x2923
movq -0x118(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x118(%rbp)
jmp 0x28d6
movq -0x118(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x3a, %eax
jne 0x2944
movq -0x118(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x118(%rbp)
jmp 0x2946
movq -0x118(%rbp), %rax
movsbl (%rax), %ecx
xorl %eax, %eax
cmpl $0x20, %ecx
movb %al, -0x126(%rbp)
jne 0x2973
movq -0x118(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x0, %eax
setne %al
movb %al, -0x126(%rbp)
movb -0x126(%rbp), %al
testb $0x1, %al
jne 0x297f
jmp 0x2993
movq -0x118(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x118(%rbp)
jmp 0x2946
movq -0x118(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x0, %eax
jne 0x29ae
movl $0x1, -0x4(%rbp)
jmp 0x2c95
movl $0x0, -0x11c(%rbp)
movslq -0x11c(%rbp), %rcx
leaq 0x626a(%rip), %rax      # 0x8c30
shlq $0x4, %rcx
addq %rcx, %rax
cmpq $0x0, (%rax)
je 0x2a16
movslq -0x11c(%rbp), %rcx
leaq 0x624f(%rip), %rax      # 0x8c30
shlq $0x4, %rcx
addq %rcx, %rax
movq (%rax), %rdi
movq -0x118(%rbp), %rsi
movl $0x3, %edx
callq 0x2040
cmpl $0x0, %eax
jne 0x2a03
jmp 0x2a16
jmp 0x2a05
movl -0x11c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x11c(%rbp)
jmp 0x29b8
movslq -0x11c(%rbp), %rcx
leaq 0x620c(%rip), %rax      # 0x8c30
shlq $0x4, %rcx
addq %rcx, %rax
cmpq $0x0, (%rax)
jne 0x2a5c
movq 0x65b8(%rip), %rax      # 0x8ff0
movq (%rax), %rdi
leaq -0x110(%rbp), %rdx
leaq 0x370c(%rip), %rsi      # 0x6155
movb $0x0, %al
callq 0x20d0
movl $0x1, -0x4(%rbp)
jmp 0x2c95
movslq -0x11c(%rbp), %rax
shlq $0x4, %rax
leaq 0x61c2(%rip), %rcx      # 0x8c30
movl 0x8(%rax,%rcx), %esi
movslq -0x124(%rbp), %rax
leaq (%rax,%rax,2), %rdx
leaq 0x685c(%rip), %rax      # 0x92e0
movl %esi, (%rax,%rdx,4)
movslq -0x11c(%rbp), %rax
shlq $0x4, %rax
movl 0xc(%rax,%rcx), %eax
movl %eax, -0x12c(%rbp)
subl $0x1, %eax
je 0x2ac4
jmp 0x2aa3
movl -0x12c(%rbp), %eax
subl $0x2, %eax
je 0x2afb
jmp 0x2ab0
movl -0x12c(%rbp), %eax
subl $0x3, %eax
je 0x2b4f
jmp 0x2c6c
movq -0x118(%rbp), %rdi
addq $0x4, %rdi
movslq -0x124(%rbp), %rax
leaq 0x6803(%rip), %rdx      # 0x92e0
imulq $0xc, %rax, %rax
addq %rax, %rdx
addq $0x4, %rdx
leaq 0x3679(%rip), %rsi      # 0x6168
movb $0x0, %al
callq 0x2100
jmp 0x2c6c
movq -0x118(%rbp), %rdi
addq $0x4, %rdi
movslq -0x124(%rbp), %rax
leaq 0x67cc(%rip), %rdx      # 0x92e0
imulq $0xc, %rax, %rax
addq %rax, %rdx
addq $0x4, %rdx
movslq -0x124(%rbp), %rax
leaq 0x67b3(%rip), %rcx      # 0x92e0
imulq $0xc, %rax, %rax
addq %rax, %rcx
addq $0x4, %rcx
addq $0x4, %rcx
leaq 0x3622(%rip), %rsi      # 0x6165
movb $0x0, %al
callq 0x2100
jmp 0x2c6c
movl $0x0, -0x120(%rbp)
movslq -0x120(%rbp), %rcx
leaq 0x6169(%rip), %rax      # 0x8cd0
shlq $0x4, %rcx
addq %rcx, %rax
cmpq $0x0, (%rax)
je 0x2bf9
movslq -0x120(%rbp), %rcx
leaq 0x614a(%rip), %rax      # 0x8cd0
shlq $0x4, %rcx
addq %rcx, %rax
movq (%rax), %rax
movq %rax, -0x140(%rbp)
movq -0x118(%rbp), %rax
addq $0x4, %rax
movq %rax, -0x138(%rbp)
movslq -0x120(%rbp), %rcx
leaq 0x6119(%rip), %rax      # 0x8cd0
shlq $0x4, %rcx
addq %rcx, %rax
movq (%rax), %rdi
callq 0x2070
movq -0x140(%rbp), %rdi
movq -0x138(%rbp), %rsi
movq %rax, %rdx
callq 0x2040
cmpl $0x0, %eax
jne 0x2be3
jmp 0x2bf9
jmp 0x2be5
movl -0x120(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x120(%rbp)
jmp 0x2b59
movslq -0x120(%rbp), %rcx
leaq 0x60c9(%rip), %rax      # 0x8cd0
shlq $0x4, %rcx
addq %rcx, %rax
cmpq $0x0, (%rax)
jne 0x2c3c
movq 0x63d5(%rip), %rax      # 0x8ff0
movq (%rax), %rdi
leaq -0x110(%rbp), %rdx
leaq 0x353f(%rip), %rsi      # 0x616b
movb $0x0, %al
callq 0x20d0
movl $0x1, -0x4(%rbp)
jmp 0x2c95
movslq -0x120(%rbp), %rcx
leaq 0x6086(%rip), %rax      # 0x8cd0
shlq $0x4, %rcx
addq %rcx, %rax
movl 0x8(%rax), %ecx
movslq -0x124(%rbp), %rdx
leaq 0x667e(%rip), %rax      # 0x92e0
imulq $0xc, %rdx, %rdx
addq %rdx, %rax
movl %ecx, 0x4(%rax)
jmp 0x2c6e
movl -0x124(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x124(%rbp)
jmp 0x28a9
movl -0x124(%rbp), %eax
movl %eax, 0x6432(%rip)      # 0x90c0
movl $0x0, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x140, %rsp            # imm = 0x140
popq %rbp
retq
nopw %cs:(%rax,%rax)