// File: /workspace/github_c_makefile_star2_O3/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 0x141d6
movq %rax, %rbx
movl (%r15), %eax
cmpq $0x3, %rax
ja 0x154eb
leaq 0x7413(%rip), %rcx      # 0x1c704
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)
movl $0xa, %edi
xorl %edx, %edx
callq 0x13ce4
movq %rbx, %rdi
movq %rax, %rsi
callq 0x142c0
movq 0x8(%r15), %rsi
movq %r13, %rdi
movq %r12, %rdx
movq %r14, %rcx
callq 0x15583
movq %r14, -0x38(%rbp)
movq %rax, %r14
movq %rbx, %rdi
movq %rax, %rsi
callq 0x143b1
movq %r14, %rdi
callq 0x14992
movl $0x7, %edi
movl -0x2c(%rbp), %esi
movl $0x4, %edx
callq 0x13ce4
movq %rbx, %rdi
movq %rax, %rsi
callq 0x142c0
movq 0x10(%r15), %rsi
movq %r13, %rdi
movq %r12, %rdx
movq -0x38(%rbp), %rcx
callq 0x152b3
movq %rax, %r14
movq %rbx, %rdi
movq %rax, %rsi
callq 0x143b1
movq %r14, %rdi
callq 0x14992
movl $0x6, %edi
movq -0x40(%rbp), %rsi
xorl %edx, %edx
callq 0x13ce4
movq %rbx, %rdi
movq %rax, %rsi
callq 0x142c0
movl $0xa, %edi
movl -0x2c(%rbp), %esi
jmp 0x1544c
movq 0x10(%r15), %rsi
movq %r13, %rdi
movq %r12, %rdx
movq %r14, %rcx
callq 0x152b3
movq %r14, -0x38(%rbp)
movq %rax, %r14
movq %rbx, %rdi
movq %rax, %rsi
callq 0x143b1
movq %r14, %rdi
callq 0x14992
movq 0x18(%r15), %rsi
movq %r13, %rdi
movq %r12, %rdx
movq -0x38(%rbp), %rcx
callq 0x152b3
movq %rax, %r14
movq %rbx, %rdi
movq %rax, %rsi
callq 0x143b1
movq %r14, %rdi
callq 0x14992
jmp 0x154d6
movq 0x8(%r15), %rsi
movq %r13, %rdi
movq %r12, %rdx
movq %r14, %rcx
callq 0x15583
movq %rax, %r14
movq %rbx, %rdi
movq %rax, %rsi
callq 0x143b1
movq %r14, %rdi
callq 0x14992
movl $0x9, %edi
movl $0x2, %esi
xorl %edx, %edx
jmp 0x154c6
movq 0x8(%r15), %rsi
movq %r13, %rdi
movq %r12, %rdx
movq %r14, %rcx
callq 0x15583
movq %rax, %r14
movq %rbx, %rdi
movq %rax, %rsi
callq 0x143b1
movq %r14, %rdi
callq 0x14992
xorl %esi, %esi
subl 0x20(%r15), %esi
movl $0x5, %edi
movl $0x5, %edx
callq 0x13ce4
movq %rbx, %rdi
movq %rax, %rsi
callq 0x142c0
movl $0x3, %edi
movl $0x5, %esi
movl $0x1, %edx
callq 0x13ce4
movq %rbx, %rdi
movq %rax, %rsi
callq 0x142c0
movl $0x2, %edi
movl $0x4, %esi
movl $0x5, %edx
callq 0x13ce4
movq %rbx, %rdi
movq %rax, %rsi
callq 0x142c0
movq %rbx, %rax
addq $0x1f58, %rsp           # imm = 0x1F58
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x5b12(%rip), %rdi      # 0x1b004
leaq 0x722f(%rip), %rsi      # 0x1c728
leaq 0x7237(%rip), %rcx      # 0x1c737
movl $0x8c, %edx
xorl %eax, %eax
callq 0x6100
leaq 0x5b19(%rip), %rdi      # 0x1b02c
leaq 0x5df1(%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 0x5cca(%rip), %rdi      # 0x1b216
callq 0x6070
testl %r14d, %r14d
jle 0x15579
movl %r14d, %r15d
leaq 0x5acc(%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 0x15563
movl $0x1, %edi
callq 0x61a0