// File: /workspace/github_c_makefile_star2_O2/alexj136[P]minijit/src/icodegen.c
// Function: icodegen_Comm
ICodeOperationVector *icodegen_Comm(Prog *prog, Comm *comm, int *next_label,
        int *func_labels) {

    BEGIN_CODE_GENERATION;

    if(Comm_isWhile(comm)) {

        // Label names
        int guard_label = (*next_label)++;
        int end_label   = (*next_label)++;

        // Guard label & guard evaluation
        INSERT_OPERATION(LABEL      , guard_label   , 0                 );
        INSERT_EXPR_CODE(While_guard(comm));

        // Jump straight to the end if the guard was less than 1
        INSERT_OPERATION(JUMPCOND   , end_label     , ACCUMULATOR       );

        // If we didn't jump to the end, run the code for the body and jump back
        // to the guard evaluation
        INSERT_COMM_CODE(While_body(comm)                               );
        INSERT_OPERATION(JUMP       , guard_label   , 0                 );

        // End label
        INSERT_OPERATION(LABEL      , end_label     , 0                 );
    }
    else if(Comm_isAssign(comm)) {

        // Evaluate the expression
        INSERT_EXPR_CODE(Assign_expr(comm));

        // Calculate the address to store the value, store the calculated
        // address in temporary
        INSERT_OPERATION(LOADIMM    , -Assign_name(comm), TEMPORARY     );
        INSERT_OPERATION(ADD        , TEMPORARY         , FRAME_POINTER );

        // Store the expression result at the calculated address
        INSERT_OPERATION(STORE      , ACCUMULATOR       , TEMPORARY     );
    }
    else if(Comm_isComp(comm)) {

        // Just insert code for the first and second command
        INSERT_COMM_CODE(Comp_fst(comm));
        INSERT_COMM_CODE(Comp_snd(comm));
    }
    else if(Comm_isReturn(comm)) {

        // Evaluate the expression
        INSERT_EXPR_CODE(Return_expr(comm));

        // Return to caller
        INSERT_OPERATION(JUMPADDR   , RETURN_ADDRESS    , 0             );
    }
    else {
        ERROR("Comm type not recognised.");
    }

    RETURN_GENERATED_CODE;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x1f58, %rsp           # imm = 0x1F58
movq %rcx, %r14
movq %rdx, %r12
movq %rsi, %r15
movq %rdi, %r13
xorl %eax, %eax
callq 0x134fa
movq %rax, %rbx
movl (%r15), %eax
cmpq $0x3, %rax
ja 0x14727
leaq 0x71fd(%rip), %rcx      # 0x1b744
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movl (%r12), %esi
movq %rsi, -0x40(%rbp)
leal 0x1(%rsi), %eax
movl %eax, -0x2c(%rbp)
leal 0x2(%rsi), %eax
movl %eax, (%r12)
pushq $0xa
popq %rdi
xorl %edx, %edx
callq 0x13028
movq %rbx, %rdi
movq %rax, %rsi
callq 0x135dc
movq 0x8(%r15), %rsi
movq %r13, %rdi
movq %r12, %rdx
movq %r14, -0x38(%rbp)
movq %r14, %rcx
callq 0x147bf
movq %rax, %r14
movq %rbx, %rdi
movq %rax, %rsi
callq 0x136c9
movq %r14, %rdi
callq 0x13c48
pushq $0x7
popq %rdi
pushq $0x4
popq %rdx
movl -0x2c(%rbp), %esi
callq 0x13028
movq %rbx, %rdi
movq %rax, %rsi
callq 0x135dc
movq 0x10(%r15), %rsi
movq %r13, %rdi
movq %r12, %rdx
movq -0x38(%rbp), %rcx
callq 0x14509
movq %rax, %r14
movq %rbx, %rdi
movq %rax, %rsi
callq 0x136c9
movq %r14, %rdi
callq 0x13c48
pushq $0x6
popq %rdi
movq -0x40(%rbp), %rsi
xorl %edx, %edx
callq 0x13028
movq %rbx, %rdi
movq %rax, %rsi
callq 0x135dc
pushq $0xa
popq %rdi
movl -0x2c(%rbp), %esi
jmp 0x14694
movq 0x10(%r15), %rsi
movq %r13, %rdi
movq %r12, %rdx
movq %r14, -0x38(%rbp)
movq %r14, %rcx
callq 0x14509
movq %rax, %r14
movq %rbx, %rdi
movq %rax, %rsi
callq 0x136c9
movq %r14, %rdi
callq 0x13c48
movq 0x18(%r15), %rsi
movq %r13, %rdi
movq %r12, %rdx
movq -0x38(%rbp), %rcx
callq 0x14509
movq %rax, %r14
movq %rbx, %rdi
movq %rax, %rsi
callq 0x136c9
movq %r14, %rdi
callq 0x13c48
jmp 0x14712
movq 0x8(%r15), %rsi
movq %r13, %rdi
movq %r12, %rdx
movq %r14, %rcx
callq 0x147bf
movq %rax, %r14
movq %rbx, %rdi
movq %rax, %rsi
callq 0x136c9
movq %r14, %rdi
callq 0x13c48
pushq $0x9
popq %rdi
pushq $0x2
popq %rsi
xorl %edx, %edx
jmp 0x14702
movq 0x8(%r15), %rsi
movq %r13, %rdi
movq %r12, %rdx
movq %r14, %rcx
callq 0x147bf
movq %rax, %r14
movq %rbx, %rdi
movq %rax, %rsi
callq 0x136c9
movq %r14, %rdi
callq 0x13c48
xorl %esi, %esi
subl 0x20(%r15), %esi
pushq $0x5
popq %r14
movl %r14d, %edi
movl %r14d, %edx
callq 0x13028
movq %rbx, %rdi
movq %rax, %rsi
callq 0x135dc
pushq $0x3
popq %rdi
pushq $0x1
popq %rdx
movl %r14d, %esi
callq 0x13028
movq %rbx, %rdi
movq %rax, %rsi
callq 0x135dc
pushq $0x2
popq %rdi
pushq $0x4
popq %rsi
movl %r14d, %edx
callq 0x13028
movq %rbx, %rdi
movq %rax, %rsi
callq 0x135dc
movq %rbx, %rax
addq $0x1f58, %rsp           # imm = 0x1F58
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x58d6(%rip), %rdi      # 0x1a004
leaq 0x7033(%rip), %rsi      # 0x1b768
leaq 0x703b(%rip), %rcx      # 0x1b777
movl $0x8c, %edx
xorl %eax, %eax
callq 0x6100
leaq 0x58dd(%rip), %rbx      # 0x1a02c
leaq 0x5bc5(%rip), %rsi      # 0x1a31b
movq %rbx, %rdi
xorl %eax, %eax
callq 0x6100
leaq -0x1f80(%rbp), %r15
movq %r15, %rdi
movl $0x3e8, %esi            # imm = 0x3E8
callq 0x60e0
movl %eax, %r12d
movq %r15, %rdi
movl %eax, %esi
callq 0x60b0
movq %rax, %r15
leaq 0x5a8b(%rip), %rdi      # 0x1a216
callq 0x6070
testl %r12d, %r12d
movl $0x0, %eax
cmovlel %eax, %r12d
xorl %r14d, %r14d
cmpq %r14, %r12
je 0x147b7
movq (%r15,%r14,8), %rsi
movq %rbx, %rdi
xorl %eax, %eax
callq 0x6100
incq %r14
jmp 0x1479f
pushq $0x1
popq %rdi
callq 0x61a0