// File: /workspace/github_c_makefile_star2_O2/alexj136[P]minijit/src/interpreter.c
// Function: interpret_Comm
InterpretResult *interpret_Comm(Prog *prog, Comm *comm, int *store) {
    if(Comm_isWhile(comm)) {

        InterpretResult *guard_res =
                interpret_Expr(prog, While_guard(comm), store);

        if((guard_res->type != iSuccess) || (guard_res->result < 1)) {
            return guard_res;
        }

        while(true) {

            InterpretResult *comm_res =
                    interpret_Comm(prog, While_body(comm), store);

            if((comm_res->type != iSuccess) ||(comm_res->returning == true)) {
                free(guard_res);
                return comm_res;
            }

            free(guard_res);
            guard_res = interpret_Expr(prog, While_guard(comm), store);

            if(guard_res->type != iSuccess) {
                free(comm_res);
                return guard_res;
            }
            else if(guard_res->result < 1) {
                free(guard_res);
                return comm_res;
            }

            free(comm_res);
        }
    }
    else if(Comm_isAssign(comm) || Comm_isReturn(comm)) {

        InterpretResult *res = interpret_Expr(prog, Assign_expr(comm), store);

        if(res->type != iSuccess) {
            return res;
        }

        if(Comm_isAssign(comm)) {
            store[Assign_name(comm)] = res->result;
        }
        else /* if(Comm_isReturn(comm)) */ {
            res->returning = true;
        }

        return res;
    }
    else if(Comm_isComp(comm)) {

        InterpretResult *res = interpret_Comm(prog, Comp_fst(comm), store);

        if((res->type != iSuccess) || res->returning) {
            return res;
        }

        free(res);

        return interpret_Comm(prog, Comp_snd(comm), store);
    }
    else {
        ERROR("Comm type not recognised.");
    }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x1f48, %rsp           # imm = 0x1F48
movq %rdx, %rbx
movq %rsi, %r14
movq %rdi, %r15
leaq 0x85fa(%rip), %r13      # 0x1b464
movl (%r14), %eax
cmpq $0x3, %rax
ja 0x12f8f
movslq (%r13,%rax,4), %rax
addq %r13, %rax
jmpq *%rax
movq 0x10(%r14), %rsi
movq %r15, %rdi
movq %rbx, %rdx
callq 0x12e46
movq %rax, %r12
cmpl $0x0, (%rax)
jne 0x12f6d
cmpl $0x0, 0x8(%r12)
jne 0x12f6d
movq %r12, %rdi
callq 0x6030
movq 0x18(%r14), %r14
jmp 0x12e6a
movq 0x8(%r14), %rsi
movq %r15, %rdi
movq %rbx, %rdx
callq 0x12b5c
movq %rax, %r12
cmpl $0x0, (%rax)
jne 0x12f6d
cmpl $0x1, (%r14)
jne 0x12f04
movl 0x4(%r12), %eax
movslq 0x20(%r14), %rcx
movl %eax, (%rbx,%rcx,4)
jmp 0x12f6d
movq 0x8(%r14), %rsi
movq %r15, %rdi
movq %rbx, %rdx
callq 0x12b5c
movq %rax, %r13
cmpl $0x0, (%rax)
je 0x12f0f
movq %r13, %r12
jmp 0x12f6d
movl $0x1, 0x8(%r12)
jmp 0x12f6d
cmpl $0x0, 0x4(%r13)
jle 0x12eff
movq 0x10(%r14), %rsi
movq %r15, %rdi
movq %rbx, %rdx
callq 0x12e46
movq %rax, %r12
cmpl $0x0, (%rax)
jne 0x12f65
cmpl $0x1, 0x8(%r12)
je 0x12f65
movq %r13, %rdi
callq 0x6030
movq 0x8(%r14), %rsi
movq %r15, %rdi
movq %rbx, %rdx
callq 0x12b5c
movq %rax, %r13
cmpl $0x0, (%rax)
jne 0x12f82
cmpl $0x0, 0x4(%r13)
jle 0x12f65
movq %r12, %rdi
callq 0x6030
jmp 0x12f16
movq %r13, %rdi
callq 0x6030
movq %r12, %rax
addq $0x1f48, %rsp           # imm = 0x1F48
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %r12, %rdi
callq 0x6030
jmp 0x12eff
leaq 0x706e(%rip), %rdi      # 0x1a004
leaq 0x84d7(%rip), %rsi      # 0x1b474
leaq 0x84e2(%rip), %rcx      # 0x1b486
xorl %r12d, %r12d
movl $0x91, %edx
xorl %eax, %eax
callq 0x6100
leaq 0x7072(%rip), %rbx      # 0x1a02c
leaq 0x735a(%rip), %rsi      # 0x1a31b
movq %rbx, %rdi
xorl %eax, %eax
callq 0x6100
leaq -0x1f70(%rbp), %r15
movq %r15, %rdi
movl $0x3e8, %esi            # imm = 0x3E8
callq 0x60e0
movl %eax, %r14d
movq %r15, %rdi
movl %eax, %esi
callq 0x60b0
movq %rax, %r15
leaq 0x7220(%rip), %rdi      # 0x1a216
callq 0x6070
testl %r14d, %r14d
cmovlel %r12d, %r14d
xorl %r12d, %r12d
cmpq %r12, %r14
je 0x1301d
movq (%r15,%r12,8), %rsi
movq %rbx, %rdi
xorl %eax, %eax
callq 0x6100
incq %r12
jmp 0x13005
pushq $0x1
popq %rdi
callq 0x61a0
nopl (%rax)