// File: /workspace/github_c_makefile_star2_O0/tyabu12[P]pl0compiler/codegen.c
// Function: execute
void execute(const int *secretValue) {    /* 目的コード（命令語）の実行           */
#if 0
  static Mem m;
  initMemory(&m, secretValue);
  while (!m.exitCode) stepForward(&m);
#else
    int stack[MAXMEM];          /* 実行時スタック                       */
    int display[MAXLEVEL];      /* 現在見える各ブロックの先頭番地のディスプレイ */
    int pc, top, lev, temp;
    Inst i;                     /* 実行する命令語                       */
    /* printf("start execution\n"); */
    top = 0;  pc = 0;           /* top:次にスタックに入れる場所、pc:命令語のカウンタ */
    stack[0] = 0;  stack[1] = 0; /* stack[top]はcalleeで壊すディスプレイの退避場所 */
                                /* stack[top+1]はcallerへの戻り番地     */
    if (secretValue) stack[2] = *secretValue; /* シークレットモード (第3セルに値を格納) */
    display[0] = 0;             /* 主ブロックの先頭番地は 0             */
    do {
        i = code[pc++];         /* これから実行する命令語               */
        switch (i.opCode) {
        case lit: stack[top++] = i.u.value;
            break;
        case lod: stack[top++] = stack[display[i.u.addr.level] + i.u.addr.addr];
            break;
        case sto: stack[display[i.u.addr.level] + i.u.addr.addr] = stack[--top];
            break;
        case cal: lev = i.u.addr.level +1; /* i.u.addr.levelはcalleeの名前のレベル */
                                /* calleeのブロックのレベルlevはそれに＋１したもの */
            stack[top] = display[lev]; /* display[lev]の退避            */
            stack[top+1] = pc; display[lev] = top;
                                /* 現在のtopがcalleeのブロックの先頭番地 */
            pc = i.u.addr.addr;
            break;
        case ret: temp = stack[--top]; /* スタックのトップにあるものが返す値 */
            top = display[i.u.addr.level]; /* topを呼ばれたときの値に戻す */
            display[i.u.addr.level] = stack[top]; /* 壊したディスプレイの回復 */
            pc = stack[top+1];
            top -= i.u.addr.addr; /* 実引数の分だけトップを戻す         */
            stack[top++] = temp; /* 返す値をスタックのトップへ          */
            break;
        case ict: top += i.u.value;
            if (top >= MAXMEM-MAXREG)
                errorF("stack overflow");
            break;
        case jmp: pc = i.u.value; break;
        case jpc: if (stack[--top] == 0) pc = i.u.value;
            break;
        case opr:
            switch (i.u.optr) {
            case neg: stack[top-1] = -stack[top-1]; continue;
            case add: --top;  stack[top-1] += stack[top]; continue;
            case sub: --top; stack[top-1] -= stack[top]; continue;
            case mul: --top;  stack[top-1] *= stack[top];  continue;
            case div: --top;  stack[top-1] /= stack[top]; continue;
            case odd: stack[top-1] = stack[top-1] & 1; continue;
            case eq: --top;  stack[top-1] = (stack[top-1] == stack[top]); continue;
            case ls: --top;  stack[top-1] = (stack[top-1] < stack[top]); continue;
            case gr: --top;  stack[top-1] = (stack[top-1] > stack[top]); continue;
            case neq: --top;  stack[top-1] = (stack[top-1] != stack[top]); continue;
            case lseq: --top;  stack[top-1] = (stack[top-1] <= stack[top]); continue;
            case greq: --top;  stack[top-1] = (stack[top-1] >= stack[top]); continue;
            case rd: scanf("%d", &stack[top++]); continue;
            case wrt: printf("%d", stack[--top]); continue;
            case wrl: printf("\n"); continue;
            }
        }
    } while (pc != 0);
#endif
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x1fb0, %rsp           # imm = 0x1FB0
movq %rdi, -0x8(%rbp)
movl $0x0, -0x1f78(%rbp)
movl $0x0, -0x1f74(%rbp)
movl $0x0, -0x1f50(%rbp)
movl $0x0, -0x1f4c(%rbp)
cmpq $0x0, -0x8(%rbp)
je 0x388a
movq -0x8(%rbp), %rax
movl (%rax), %eax
movl %eax, -0x1f48(%rbp)
movl $0x0, -0x1f70(%rbp)
movslq -0x1f74(%rbp), %rax
movl %eax, %ecx
incl %ecx
movl %ecx, -0x1f74(%rbp)
leaq (%rax,%rax,2), %rcx
leaq 0x5a30(%rip), %rax      # 0x92e0
movl 0x8(%rax,%rcx,4), %edx
movl %edx, -0x1f88(%rbp)
movq (%rax,%rcx,4), %rax
movq %rax, -0x1f90(%rbp)
movl -0x1f90(%rbp), %eax
movq %rax, -0x1f98(%rbp)
subq $0x8, %rax
ja 0x3ec4
movq -0x1f98(%rbp), %rax
leaq 0x27da(%rip), %rcx      # 0x60c4
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movl -0x1f8c(%rbp), %ecx
movl -0x1f78(%rbp), %eax
movl %eax, %edx
addl $0x1, %edx
movl %edx, -0x1f78(%rbp)
cltq
movl %ecx, -0x1f50(%rbp,%rax,4)
jmp 0x3ec4
movslq -0x1f8c(%rbp), %rax
movl -0x1f70(%rbp,%rax,4), %eax
addl -0x1f88(%rbp), %eax
cltq
movl -0x1f50(%rbp,%rax,4), %ecx
movl -0x1f78(%rbp), %eax
movl %eax, %edx
addl $0x1, %edx
movl %edx, -0x1f78(%rbp)
cltq
movl %ecx, -0x1f50(%rbp,%rax,4)
jmp 0x3ec4
movl -0x1f78(%rbp), %eax
addl $-0x1, %eax
movl %eax, -0x1f78(%rbp)
cltq
movl -0x1f50(%rbp,%rax,4), %ecx
movslq -0x1f8c(%rbp), %rax
movl -0x1f70(%rbp,%rax,4), %eax
addl -0x1f88(%rbp), %eax
cltq
movl %ecx, -0x1f50(%rbp,%rax,4)
jmp 0x3ec4
movl -0x1f8c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x1f7c(%rbp)
movslq -0x1f7c(%rbp), %rax
movl -0x1f70(%rbp,%rax,4), %ecx
movslq -0x1f78(%rbp), %rax
movl %ecx, -0x1f50(%rbp,%rax,4)
movl -0x1f74(%rbp), %ecx
movl -0x1f78(%rbp), %eax
addl $0x1, %eax
cltq
movl %ecx, -0x1f50(%rbp,%rax,4)
movl -0x1f78(%rbp), %ecx
movslq -0x1f7c(%rbp), %rax
movl %ecx, -0x1f70(%rbp,%rax,4)
movl -0x1f88(%rbp), %eax
movl %eax, -0x1f74(%rbp)
jmp 0x3ec4
movl -0x1f78(%rbp), %eax
addl $-0x1, %eax
movl %eax, -0x1f78(%rbp)
cltq
movl -0x1f50(%rbp,%rax,4), %eax
movl %eax, -0x1f80(%rbp)
movslq -0x1f8c(%rbp), %rax
movl -0x1f70(%rbp,%rax,4), %eax
movl %eax, -0x1f78(%rbp)
movslq -0x1f78(%rbp), %rax
movl -0x1f50(%rbp,%rax,4), %ecx
movslq -0x1f8c(%rbp), %rax
movl %ecx, -0x1f70(%rbp,%rax,4)
movl -0x1f78(%rbp), %eax
addl $0x1, %eax
cltq
movl -0x1f50(%rbp,%rax,4), %eax
movl %eax, -0x1f74(%rbp)
movl -0x1f88(%rbp), %ecx
movl -0x1f78(%rbp), %eax
subl %ecx, %eax
movl %eax, -0x1f78(%rbp)
movl -0x1f80(%rbp), %ecx
movl -0x1f78(%rbp), %eax
movl %eax, %edx
addl $0x1, %edx
movl %edx, -0x1f78(%rbp)
cltq
movl %ecx, -0x1f50(%rbp,%rax,4)
jmp 0x3ec4
movl -0x1f8c(%rbp), %eax
addl -0x1f78(%rbp), %eax
movl %eax, -0x1f78(%rbp)
cmpl $0x7bc, -0x1f78(%rbp)   # imm = 0x7BC
jl 0x3abf
leaq 0x2786(%rip), %rdi      # 0x6240
callq 0x48b0
jmp 0x3ec4
movl -0x1f8c(%rbp), %eax
movl %eax, -0x1f74(%rbp)
jmp 0x3ec4
movl -0x1f78(%rbp), %eax
addl $-0x1, %eax
movl %eax, -0x1f78(%rbp)
cltq
cmpl $0x0, -0x1f50(%rbp,%rax,4)
jne 0x3afc
movl -0x1f8c(%rbp), %eax
movl %eax, -0x1f74(%rbp)
jmp 0x3ec4
movl -0x1f8c(%rbp), %eax
movq %rax, -0x1fa0(%rbp)
subq $0xe, %rax
ja 0x3ec2
movq -0x1fa0(%rbp), %rax
leaq 0x25c2(%rip), %rcx      # 0x60e8
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movl -0x1f78(%rbp), %eax
subl $0x1, %eax
cltq
xorl %ecx, %ecx
subl -0x1f50(%rbp,%rax,4), %ecx
movl -0x1f78(%rbp), %eax
subl $0x1, %eax
cltq
movl %ecx, -0x1f50(%rbp,%rax,4)
jmp 0x3ec6
movl -0x1f78(%rbp), %eax
addl $-0x1, %eax
movl %eax, -0x1f78(%rbp)
movslq -0x1f78(%rbp), %rax
movl -0x1f50(%rbp,%rax,4), %ecx
movl -0x1f78(%rbp), %eax
subl $0x1, %eax
cltq
addl -0x1f50(%rbp,%rax,4), %ecx
movl %ecx, -0x1f50(%rbp,%rax,4)
jmp 0x3ec6
movl -0x1f78(%rbp), %eax
addl $-0x1, %eax
movl %eax, -0x1f78(%rbp)
movslq -0x1f78(%rbp), %rax
movl -0x1f50(%rbp,%rax,4), %edx
movl -0x1f78(%rbp), %eax
subl $0x1, %eax
cltq
movl -0x1f50(%rbp,%rax,4), %ecx
subl %edx, %ecx
movl %ecx, -0x1f50(%rbp,%rax,4)
jmp 0x3ec6
movl -0x1f78(%rbp), %eax
addl $-0x1, %eax
movl %eax, -0x1f78(%rbp)
movslq -0x1f78(%rbp), %rax
movl -0x1f50(%rbp,%rax,4), %ecx
movl -0x1f78(%rbp), %eax
subl $0x1, %eax
cltq
imull -0x1f50(%rbp,%rax,4), %ecx
movl %ecx, -0x1f50(%rbp,%rax,4)
jmp 0x3ec6
movl -0x1f78(%rbp), %eax
addl $-0x1, %eax
movl %eax, -0x1f78(%rbp)
movslq -0x1f78(%rbp), %rax
movl -0x1f50(%rbp,%rax,4), %ecx
movl -0x1f78(%rbp), %eax
subl $0x1, %eax
cltq
movq %rax, -0x1fa8(%rbp)
movl -0x1f50(%rbp,%rax,4), %eax
cltd
idivl %ecx
movl %eax, %ecx
movq -0x1fa8(%rbp), %rax
movl %ecx, -0x1f50(%rbp,%rax,4)
jmp 0x3ec6
movl -0x1f78(%rbp), %eax
subl $0x1, %eax
cltq
movl -0x1f50(%rbp,%rax,4), %ecx
andl $0x1, %ecx
movl -0x1f78(%rbp), %eax
subl $0x1, %eax
cltq
movl %ecx, -0x1f50(%rbp,%rax,4)
jmp 0x3ec6
movl -0x1f78(%rbp), %eax
addl $-0x1, %eax
movl %eax, -0x1f78(%rbp)
movl -0x1f78(%rbp), %eax
subl $0x1, %eax
cltq
movl -0x1f50(%rbp,%rax,4), %eax
movslq -0x1f78(%rbp), %rcx
cmpl -0x1f50(%rbp,%rcx,4), %eax
sete %al
andb $0x1, %al
movzbl %al, %ecx
movl -0x1f78(%rbp), %eax
subl $0x1, %eax
cltq
movl %ecx, -0x1f50(%rbp,%rax,4)
jmp 0x3ec6
movl -0x1f78(%rbp), %eax
addl $-0x1, %eax
movl %eax, -0x1f78(%rbp)
movl -0x1f78(%rbp), %eax
subl $0x1, %eax
cltq
movl -0x1f50(%rbp,%rax,4), %eax
movslq -0x1f78(%rbp), %rcx
cmpl -0x1f50(%rbp,%rcx,4), %eax
setl %al
andb $0x1, %al
movzbl %al, %ecx
movl -0x1f78(%rbp), %eax
subl $0x1, %eax
cltq
movl %ecx, -0x1f50(%rbp,%rax,4)
jmp 0x3ec6
movl -0x1f78(%rbp), %eax
addl $-0x1, %eax
movl %eax, -0x1f78(%rbp)
movl -0x1f78(%rbp), %eax
subl $0x1, %eax
cltq
movl -0x1f50(%rbp,%rax,4), %eax
movslq -0x1f78(%rbp), %rcx
cmpl -0x1f50(%rbp,%rcx,4), %eax
setg %al
andb $0x1, %al
movzbl %al, %ecx
movl -0x1f78(%rbp), %eax
subl $0x1, %eax
cltq
movl %ecx, -0x1f50(%rbp,%rax,4)
jmp 0x3ec6
movl -0x1f78(%rbp), %eax
addl $-0x1, %eax
movl %eax, -0x1f78(%rbp)
movl -0x1f78(%rbp), %eax
subl $0x1, %eax
cltq
movl -0x1f50(%rbp,%rax,4), %eax
movslq -0x1f78(%rbp), %rcx
cmpl -0x1f50(%rbp,%rcx,4), %eax
setne %al
andb $0x1, %al
movzbl %al, %ecx
movl -0x1f78(%rbp), %eax
subl $0x1, %eax
cltq
movl %ecx, -0x1f50(%rbp,%rax,4)
jmp 0x3ec6
movl -0x1f78(%rbp), %eax
addl $-0x1, %eax
movl %eax, -0x1f78(%rbp)
movl -0x1f78(%rbp), %eax
subl $0x1, %eax
cltq
movl -0x1f50(%rbp,%rax,4), %eax
movslq -0x1f78(%rbp), %rcx
cmpl -0x1f50(%rbp,%rcx,4), %eax
setle %al
andb $0x1, %al
movzbl %al, %ecx
movl -0x1f78(%rbp), %eax
subl $0x1, %eax
cltq
movl %ecx, -0x1f50(%rbp,%rax,4)
jmp 0x3ec6
movl -0x1f78(%rbp), %eax
addl $-0x1, %eax
movl %eax, -0x1f78(%rbp)
movl -0x1f78(%rbp), %eax
subl $0x1, %eax
cltq
movl -0x1f50(%rbp,%rax,4), %eax
movslq -0x1f78(%rbp), %rcx
cmpl -0x1f50(%rbp,%rcx,4), %eax
setge %al
andb $0x1, %al
movzbl %al, %ecx
movl -0x1f78(%rbp), %eax
subl $0x1, %eax
cltq
movl %ecx, -0x1f50(%rbp,%rax,4)
jmp 0x3ec6
movl -0x1f78(%rbp), %eax
movl %eax, %ecx
addl $0x1, %ecx
movl %ecx, -0x1f78(%rbp)
cltq
leaq -0x1f50(%rbp), %rsi
shlq $0x2, %rax
addq %rax, %rsi
leaq 0x22e7(%rip), %rdi      # 0x6168
movb $0x0, %al
callq 0x2130
jmp 0x3ec6
movl -0x1f78(%rbp), %eax
addl $-0x1, %eax
movl %eax, -0x1f78(%rbp)
cltq
movl -0x1f50(%rbp,%rax,4), %esi
leaq 0x22bf(%rip), %rdi      # 0x6168
movb $0x0, %al
callq 0x2080
jmp 0x3ec6
leaq 0x270b(%rip), %rdi      # 0x65c4
movb $0x0, %al
callq 0x2080
jmp 0x3ec6
jmp 0x3ec4
jmp 0x3ec6
cmpl $0x0, -0x1f74(%rbp)
jne 0x3894
addq $0x1fb0, %rsp           # imm = 0x1FB0
popq %rbp
retq
nopl (%rax)