// File: /workspace/github_c_makefile_star2_O0/alexj136[P]minijit/src/icode_interpreter.c
// Function: ICodeInterpreterState_step
void ICodeInterpreterState_step(ICodeInterpreterState *state) {

    int initial_prog_counter_value = (state->registers)[PROGRAM_COUNTER];

    ICodeOperation *current =
            ICodeOperationVector_get(state->code, initial_prog_counter_value);

    Opcode opc = current->opc;
    int arg1   = current->arg1;
    int arg2   = current->arg2;

    if(opc == MOVE) {

        // Do the move
        (state->registers)[arg2] = (state->registers)[arg1];

        // Increment the program counter
        (state->registers)[PROGRAM_COUNTER]++;
    }
    else if(opc == LOAD) {

        // Check stack bounds
        ICodeInterpreterState_check_stack_bounds((state->registers)[arg1]);

        // Do the load
        (state->registers)[arg2] = (state->stack)[(state->registers)[arg1]];

        // Increment the program counter
        (state->registers)[PROGRAM_COUNTER]++;
    }
    else if(opc == STORE) {

        // Check stack bounds
        ICodeInterpreterState_check_stack_bounds((state->registers)[arg2]);

        // Do the store
        (state->stack)[(state->registers)[arg2]] = (state->registers)[arg1];

        // Increment the program counter
        (state->registers)[PROGRAM_COUNTER]++;
    }
    else if(opc == ADD) {

        // Do the addition
        (state->registers)[arg1] =
                (state->registers)[arg1] + (state->registers)[arg2];

        // Increment the program counter
        (state->registers)[PROGRAM_COUNTER]++;
    }
    else if(opc == SUB) {

        // Do the subtraction
        (state->registers)[arg1] =
                (state->registers)[arg1] - (state->registers)[arg2];

        // Increment the program counter
        (state->registers)[PROGRAM_COUNTER]++;
    }
    else if(opc == LOADIMM) {

        // Do the load immediate
        (state->registers)[arg2] = arg1;

        // Increment the program counter
        (state->registers)[PROGRAM_COUNTER]++;
    }
    else if(opc == JUMP) {

        // Set the program counter at the target label
        (state->registers)[PROGRAM_COUNTER] =
                ICodeInterpreterState_lookup_label_address(state, arg1);
    }
    else if(opc == JUMPCOND) {

        // Based on the condition, optionally set the program counter at the
        // target label, or just advance to the next instruction.
        if((state->registers)[arg2] < 1) {
            (state->registers)[PROGRAM_COUNTER] =
                ICodeInterpreterState_lookup_label_address(state, arg1);
        }
        else {
            (state->registers)[PROGRAM_COUNTER]++;
        }
    }
    else if(opc == JUMPLINK) {

        // Store the address of the next instruction in the return address
        // register
        (state->registers)[RETURN_ADDRESS] =
                (state->registers)[PROGRAM_COUNTER] + 1;

        // Set the program counter at the target label
        (state->registers)[PROGRAM_COUNTER] =
                ICodeInterpreterState_lookup_label_address(state, arg1);
    }
    else if(opc == JUMPADDR) {

        // Set the program counter at the address in the register
        (state->registers)[PROGRAM_COUNTER] = (state->registers)[arg1];
    }
    else if(opc == LABEL) {

        // Labels have no effect other than being jump destinations. Just
        // increment the program counter.
        (state->registers)[PROGRAM_COUNTER]++;
    }
    else if(opc == HALT) {

        // Do nothing - we've halted
    }
    else {
        ERROR("Opcode not recognised");
    }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x1f90, %rsp           # imm = 0x1F90
movq %rdi, -0x8(%rbp)
movq -0x8(%rbp), %rax
movq 0x10(%rax), %rax
movl 0xc(%rax), %eax
movl %eax, -0xc(%rbp)
movq -0x8(%rbp), %rax
movq (%rax), %rdi
movl -0xc(%rbp), %esi
callq 0x1a900
movq %rax, -0x18(%rbp)
movq -0x18(%rbp), %rax
movl (%rax), %eax
movl %eax, -0x1c(%rbp)
movq -0x18(%rbp), %rax
movl 0x4(%rax), %eax
movl %eax, -0x20(%rbp)
movq -0x18(%rbp), %rax
movl 0x8(%rax), %eax
movl %eax, -0x24(%rbp)
cmpl $0x0, -0x1c(%rbp)
jne 0x1d377
movq -0x8(%rbp), %rax
movq 0x10(%rax), %rax
movslq -0x20(%rbp), %rcx
movl (%rax,%rcx,4), %edx
movq -0x8(%rbp), %rax
movq 0x10(%rax), %rax
movslq -0x24(%rbp), %rcx
movl %edx, (%rax,%rcx,4)
movq -0x8(%rbp), %rax
movq 0x10(%rax), %rax
movl 0xc(%rax), %ecx
addl $0x1, %ecx
movl %ecx, 0xc(%rax)
jmp 0x1d6c0
cmpl $0x1, -0x1c(%rbp)
jne 0x1d3d1
movq -0x8(%rbp), %rax
movq 0x10(%rax), %rax
movslq -0x20(%rbp), %rcx
movl (%rax,%rcx,4), %edi
callq 0x1d120
movq -0x8(%rbp), %rax
movq 0x8(%rax), %rax
movq -0x8(%rbp), %rcx
movq 0x10(%rcx), %rcx
movslq -0x20(%rbp), %rdx
movslq (%rcx,%rdx,4), %rcx
movl (%rax,%rcx,4), %edx
movq -0x8(%rbp), %rax
movq 0x10(%rax), %rax
movslq -0x24(%rbp), %rcx
movl %edx, (%rax,%rcx,4)
movq -0x8(%rbp), %rax
movq 0x10(%rax), %rax
movl 0xc(%rax), %ecx
addl $0x1, %ecx
movl %ecx, 0xc(%rax)
jmp 0x1d6be
cmpl $0x2, -0x1c(%rbp)
jne 0x1d42b
movq -0x8(%rbp), %rax
movq 0x10(%rax), %rax
movslq -0x24(%rbp), %rcx
movl (%rax,%rcx,4), %edi
callq 0x1d120
movq -0x8(%rbp), %rax
movq 0x10(%rax), %rax
movslq -0x20(%rbp), %rcx
movl (%rax,%rcx,4), %edx
movq -0x8(%rbp), %rax
movq 0x8(%rax), %rax
movq -0x8(%rbp), %rcx
movq 0x10(%rcx), %rcx
movslq -0x24(%rbp), %rsi
movslq (%rcx,%rsi,4), %rcx
movl %edx, (%rax,%rcx,4)
movq -0x8(%rbp), %rax
movq 0x10(%rax), %rax
movl 0xc(%rax), %ecx
addl $0x1, %ecx
movl %ecx, 0xc(%rax)
jmp 0x1d6bc
cmpl $0x3, -0x1c(%rbp)
jne 0x1d474
movq -0x8(%rbp), %rax
movq 0x10(%rax), %rax
movslq -0x20(%rbp), %rcx
movl (%rax,%rcx,4), %edx
movq -0x8(%rbp), %rax
movq 0x10(%rax), %rax
movslq -0x24(%rbp), %rcx
addl (%rax,%rcx,4), %edx
movq -0x8(%rbp), %rax
movq 0x10(%rax), %rax
movslq -0x20(%rbp), %rcx
movl %edx, (%rax,%rcx,4)
movq -0x8(%rbp), %rax
movq 0x10(%rax), %rax
movl 0xc(%rax), %ecx
addl $0x1, %ecx
movl %ecx, 0xc(%rax)
jmp 0x1d6ba
cmpl $0x4, -0x1c(%rbp)
jne 0x1d4bd
movq -0x8(%rbp), %rax
movq 0x10(%rax), %rax
movslq -0x20(%rbp), %rcx
movl (%rax,%rcx,4), %edx
movq -0x8(%rbp), %rax
movq 0x10(%rax), %rax
movslq -0x24(%rbp), %rcx
subl (%rax,%rcx,4), %edx
movq -0x8(%rbp), %rax
movq 0x10(%rax), %rax
movslq -0x20(%rbp), %rcx
movl %edx, (%rax,%rcx,4)
movq -0x8(%rbp), %rax
movq 0x10(%rax), %rax
movl 0xc(%rax), %ecx
addl $0x1, %ecx
movl %ecx, 0xc(%rax)
jmp 0x1d6b8
cmpl $0x5, -0x1c(%rbp)
jne 0x1d4eb
movl -0x20(%rbp), %edx
movq -0x8(%rbp), %rax
movq 0x10(%rax), %rax
movslq -0x24(%rbp), %rcx
movl %edx, (%rax,%rcx,4)
movq -0x8(%rbp), %rax
movq 0x10(%rax), %rax
movl 0xc(%rax), %ecx
addl $0x1, %ecx
movl %ecx, 0xc(%rax)
jmp 0x1d6b6
cmpl $0x6, -0x1c(%rbp)
jne 0x1d50f
movq -0x8(%rbp), %rdi
movl -0x20(%rbp), %esi
callq 0x1d0f0
movl %eax, %ecx
movq -0x8(%rbp), %rax
movq 0x10(%rax), %rax
movl %ecx, 0xc(%rax)
jmp 0x1d6b4
cmpl $0x7, -0x1c(%rbp)
jne 0x1d558
movq -0x8(%rbp), %rax
movq 0x10(%rax), %rax
movslq -0x24(%rbp), %rcx
cmpl $0x1, (%rax,%rcx,4)
jge 0x1d542
movq -0x8(%rbp), %rdi
movl -0x20(%rbp), %esi
callq 0x1d0f0
movl %eax, %ecx
movq -0x8(%rbp), %rax
movq 0x10(%rax), %rax
movl %ecx, 0xc(%rax)
jmp 0x1d553
movq -0x8(%rbp), %rax
movq 0x10(%rax), %rax
movl 0xc(%rax), %ecx
addl $0x1, %ecx
movl %ecx, 0xc(%rax)
jmp 0x1d6b2
cmpl $0x8, -0x1c(%rbp)
jne 0x1d595
movq -0x8(%rbp), %rax
movq 0x10(%rax), %rax
movl 0xc(%rax), %ecx
addl $0x1, %ecx
movq -0x8(%rbp), %rax
movq 0x10(%rax), %rax
movl %ecx, 0x8(%rax)
movq -0x8(%rbp), %rdi
movl -0x20(%rbp), %esi
callq 0x1d0f0
movl %eax, %ecx
movq -0x8(%rbp), %rax
movq 0x10(%rax), %rax
movl %ecx, 0xc(%rax)
jmp 0x1d6b0
cmpl $0x9, -0x1c(%rbp)
jne 0x1d5ba
movq -0x8(%rbp), %rax
movq 0x10(%rax), %rax
movslq -0x20(%rbp), %rcx
movl (%rax,%rcx,4), %ecx
movq -0x8(%rbp), %rax
movq 0x10(%rax), %rax
movl %ecx, 0xc(%rax)
jmp 0x1d6ae
cmpl $0xa, -0x1c(%rbp)
jne 0x1d5d6
movq -0x8(%rbp), %rax
movq 0x10(%rax), %rax
movl 0xc(%rax), %ecx
addl $0x1, %ecx
movl %ecx, 0xc(%rax)
jmp 0x1d6ac
cmpl $0xb, -0x1c(%rbp)
jne 0x1d5e1
jmp 0x1d6aa
jmp 0x1d5e3
leaq 0x6a1a(%rip), %rdi      # 0x24004
leaq 0x8125(%rip), %rsi      # 0x25716
movl $0x12a, %edx            # imm = 0x12A
leaq 0x823f(%rip), %rcx      # 0x2583c
movb $0x0, %al
callq 0x60f0
leaq 0x6a21(%rip), %rdi      # 0x2402c
leaq 0x8245(%rip), %rsi      # 0x25857
movb $0x0, %al
callq 0x60f0
leaq -0x1f70(%rbp), %rdi
movl $0x3e8, %esi            # imm = 0x3E8
callq 0x60d0
movl %eax, -0x1f74(%rbp)
leaq -0x1f70(%rbp), %rdi
movl -0x1f74(%rbp), %esi
callq 0x60a0
movq %rax, -0x1f80(%rbp)
leaq 0x69fb(%rip), %rdi      # 0x2404b
movb $0x0, %al
callq 0x60f0
movl $0x0, -0x1f84(%rbp)
movl -0x1f84(%rbp), %eax
cmpl -0x1f74(%rbp), %eax
jge 0x1d6a0
movq -0x1f80(%rbp), %rax
movslq -0x1f84(%rbp), %rcx
movq (%rax,%rcx,8), %rsi
leaq 0x69a4(%rip), %rdi      # 0x2402c
movb $0x0, %al
callq 0x60f0
movl -0x1f84(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x1f84(%rbp)
jmp 0x1d661
movl $0x1, %edi
callq 0x61a0
jmp 0x1d6ac
jmp 0x1d6ae
jmp 0x1d6b0
jmp 0x1d6b2
jmp 0x1d6b4
jmp 0x1d6b6
jmp 0x1d6b8
jmp 0x1d6ba
jmp 0x1d6bc
jmp 0x1d6be
jmp 0x1d6c0
addq $0x1f90, %rsp           # imm = 0x1F90
popq %rbp
retq
nopl (%rax)