// File: /workspace/github_c_makefile_star2_O3/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, %r12
movl (%r14), %eax
cmpl $0x2, %eax
jne 0x13b62
movq 0x10(%r14), %rsi
movq %r12, %rdi
movq %rbx, %rdx
callq 0x13b09
movq %rax, %r15
cmpl $0x0, (%rax)
jne 0x13c2b
cmpl $0x0, 0x8(%r15)
jne 0x13c2b
movq %r15, %rdi
callq 0x6030
movq 0x18(%r14), %r14
jmp 0x13b26
cmpl $0x3, %eax
je 0x13bec
cmpl $0x1, %eax
je 0x13bec
testl %eax, %eax
jne 0x13c4a
movq 0x8(%r14), %rsi
movq %r12, %rdi
movq %rbx, %rdx
callq 0x137c3
movq %rax, %r15
cmpl $0x0, (%rax)
jne 0x13c2b
cmpl $0x0, 0x4(%r15)
jle 0x13c2b
movq 0x10(%r14), %rsi
movq %r12, %rdi
movq %rbx, %rdx
callq 0x13b09
movq %rax, %r13
cmpl $0x0, (%rax)
jne 0x13c20
cmpl $0x1, 0x8(%r13)
je 0x13c20
movq %r15, %rdi
callq 0x6030
movq 0x8(%r14), %rsi
movq %r12, %rdi
movq %rbx, %rdx
callq 0x137c3
movq %rax, %r15
cmpl $0x0, (%rax)
jne 0x13c40
cmpl $0x0, 0x4(%r15)
jle 0x13c20
movq %r13, %rdi
callq 0x6030
jmp 0x13b9e
movq 0x8(%r14), %rsi
movq %r12, %rdi
movq %rbx, %rdx
callq 0x137c3
movq %rax, %r15
cmpl $0x0, (%rax)
jne 0x13c2b
cmpl $0x1, (%r14)
jne 0x13c16
movl 0x4(%r15), %eax
movslq 0x20(%r14), %rcx
movl %eax, (%rbx,%rcx,4)
jmp 0x13c2b
movl $0x1, 0x8(%r15)
jmp 0x13c2b
movq %r15, %rdi
callq 0x6030
movq %r13, %r15
movq %r15, %rax
addq $0x1f48, %rsp           # imm = 0x1F48
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %r13, %rdi
callq 0x6030
jmp 0x13c2b
leaq 0x73b3(%rip), %rdi      # 0x1b004
leaq 0x87dc(%rip), %rsi      # 0x1c434
leaq 0x87e7(%rip), %rcx      # 0x1c446
movl $0x91, %edx
xorl %eax, %eax
callq 0x6100
leaq 0x73ba(%rip), %rdi      # 0x1b02c
leaq 0x7692(%rip), %rsi      # 0x1b30b
xorl %eax, %eax
callq 0x6100
leaq -0x1f70(%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 0x756b(%rip), %rdi      # 0x1b216
callq 0x6070
testl %r14d, %r14d
jle 0x13cd8
movl %r14d, %r15d
leaq 0x736d(%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 0x13cc2
movl $0x1, %edi
callq 0x61a0
nop