// File: /workspace/github_c_makefile_star2_O1/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 $0x1f58, %rsp           # imm = 0x1F58
movq %rdx, %rbx
movq %rsi, %r14
movq %rdi, %r15
movl (%r14), %eax
cmpl $0x2, %eax
jne 0x13b99
movq 0x10(%r14), %rsi
movq %r15, %rdi
movq %rbx, %rdx
callq 0x13b47
movq %rax, %r12
cmpl $0x0, (%rax)
jne 0x13bfb
cmpl $0x0, 0x8(%r12)
jne 0x13bfb
movq %r12, %rdi
callq 0x6030
movq 0x18(%r14), %r14
jmp 0x13b64
cmpl $0x3, %eax
je 0x13bc7
cmpl $0x1, %eax
je 0x13bc7
testl %eax, %eax
jne 0x13ca6
movq 0x8(%r14), %rsi
movq %r15, %rdi
movq %rbx, %rdx
callq 0x137c3
movq %rax, %r13
cmpl $0x0, (%rax)
je 0x13c10
movq %r13, %r12
jmp 0x13bfb
movq 0x8(%r14), %rsi
movq %r15, %rdi
movq %rbx, %rdx
callq 0x137c3
movq %rax, %r12
cmpl $0x0, (%rax)
jne 0x13bfb
cmpl $0x1, (%r14)
jne 0x13bf2
movl 0x4(%r12), %eax
movslq 0x20(%r14), %rcx
movl %eax, (%rbx,%rcx,4)
jmp 0x13bfb
movl $0x1, 0x8(%r12)
movq %r12, %rax
addq $0x1f58, %rsp           # imm = 0x1F58
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
cmpl $0x0, 0x4(%r13)
jle 0x13bc2
movq %rbx, -0x38(%rbp)
movq 0x10(%r14), %rsi
movq %r15, %rdi
movq -0x38(%rbp), %rdx
callq 0x13b47
movq %rax, %r12
cmpl $0x0, (%rax)
jne 0x13c3b
cmpl $0x1, 0x8(%r12)
jne 0x13c5b
movl $0x0, -0x2c(%rbp)
movq %r13, %rbx
movq %r13, %rdi
callq 0x6030
movq %rbx, %r13
movq %r12, %rbx
cmpb $0x0, -0x2c(%rbp)
jne 0x13c1b
jmp 0x13bfb
movq %r13, %rdi
callq 0x6030
movq 0x8(%r14), %rsi
movq %r15, %rdi
movq -0x38(%rbp), %rdx
callq 0x137c3
cmpl $0x0, (%rax)
je 0x13c8a
movl $0x0, -0x2c(%rbp)
movq %r12, %r13
movq %rax, %r12
movq %rax, %rbx
jmp 0x13c45
cmpl $0x0, 0x4(%rax)
setg %cl
jg 0x13c98
movq %rax, %r13
jmp 0x13c9e
movq %r12, %r13
movq %rbx, %r12
movq %rax, %rbx
movl %ecx, -0x2c(%rbp)
jmp 0x13c45
leaq 0x7357(%rip), %rdi      # 0x1b004
leaq 0x8790(%rip), %rsi      # 0x1c444
leaq 0x879b(%rip), %rcx      # 0x1c456
movl $0x91, %edx
xorl %eax, %eax
callq 0x6100
leaq 0x735e(%rip), %rdi      # 0x1b02c
leaq 0x7636(%rip), %rsi      # 0x1b30b
xorl %eax, %eax
callq 0x6100
leaq -0x1f80(%rbp), %rbx
movq %rbx, %rdi
movl $0x3e8, %esi            # imm = 0x3E8
callq 0x60e0
movl %eax, %r14d
movq %rbx, %rdi
movl %eax, %esi
callq 0x60b0
movq %rax, %rbx
leaq 0x750f(%rip), %rdi      # 0x1b216
callq 0x6070
testl %r14d, %r14d
jle 0x13d34
movl %r14d, %r15d
leaq 0x7311(%rip), %r14      # 0x1b02c
xorl %r12d, %r12d
movq (%rbx,%r12,8), %rsi
movq %r14, %rdi
xorl %eax, %eax
callq 0x6100
incq %r12
cmpq %r12, %r15
jne 0x13d1e
movl $0x1, %edi
callq 0x61a0
nop