// File: /workspace/github_c_makefile_star2_O0/chgzm[P]minic/generator.c
// Function: process_itr_stmt
static void process_itr_stmt(const ItrStmtNode* node) {
    switch (node->itr_type) {
    case ITR_WHILE: {
        char* label1 = get_label();
        char* label2 = get_label();
        stack_push(continue_label_stack, label1);
        stack_push(break_label_stack, label2);

        printf("%s:\n", label1);
        process_expr(node->expr_node_0);
        printf("  pop rax\n");
        printf("  cmp rax, 0\n");
        printf("  je %s\n", label2);
        process_stmt(node->stmt_node);
        printf("  jmp %s\n", label1);
        printf("%s:\n", label2);

        stack_pop(continue_label_stack);
        stack_pop(break_label_stack);
        break;
    }
    case ITR_FOR: {
        char* label3 = get_label();
        char* label4 = get_label();
        char* label5 = get_label();
        stack_push(continue_label_stack, label4);
        stack_push(break_label_stack, label5);

        if (node->declaration_nodes->size != 0) {
            for (int i = 0; i < node->declaration_nodes->size; ++i) {
                process_declaration(node->declaration_nodes->elements[i]);
            }
        }
        else if (node->expr_node_0 != NULL) {
            process_expr(node->expr_node_0);
        }
        printf("%s:\n", label3);
        if (node->expr_node_1 != NULL) {
            process_expr(node->expr_node_1);
        }

        printf("  pop rax\n");
        printf("  cmp rax, 0\n");
        printf("  je %s\n", label5);

        process_stmt(node->stmt_node);

        printf("%s:\n", label4);
        if (node->expr_node_2 != NULL) {
            process_expr(node->expr_node_2);
        }

        printf("  jmp %s\n", label3);
        printf("%s:\n", label5);

        stack_pop(continue_label_stack);
        stack_pop(break_label_stack);
        break;
    }
    default: {
        break;
    }
    }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x40, %rsp
movq %rdi, -0x8(%rbp)
movq -0x8(%rbp), %rax
movl (%rax), %eax
movl %eax, -0x38(%rbp)
testl %eax, %eax
je 0x66dc
jmp 0x66cb
movl -0x38(%rbp), %eax
subl $0x1, %eax
je 0x67a9
jmp 0x6915
callq 0x6500
movq %rax, -0x10(%rbp)
callq 0x6500
movq %rax, -0x18(%rbp)
movq 0xea33(%rip), %rdi      # 0x15128
movq -0x10(%rbp), %rsi
callq 0xe6e0
movq 0xea1b(%rip), %rdi      # 0x15120
movq -0x18(%rbp), %rsi
callq 0xe6e0
movq -0x10(%rbp), %rsi
leaq 0x8ed4(%rip), %rdi      # 0xf5ed
movb $0x0, %al
callq 0x1090
movq -0x8(%rbp), %rax
movq 0x10(%rax), %rdi
callq 0x4c20
leaq 0x8fb0(%rip), %rdi      # 0xf6e4
movb $0x0, %al
callq 0x1090
leaq 0x907d(%rip), %rdi      # 0xf7bf
movb $0x0, %al
callq 0x1090
movq -0x18(%rbp), %rsi
leaq 0x9079(%rip), %rdi      # 0xf7cd
movb $0x0, %al
callq 0x1090
movq -0x8(%rbp), %rax
movq 0x8(%rax), %rdi
callq 0x44b0
movq -0x10(%rbp), %rsi
leaq 0x9063(%rip), %rdi      # 0xf7d6
movb $0x0, %al
callq 0x1090
movq -0x18(%rbp), %rsi
leaq 0x8e68(%rip), %rdi      # 0xf5ed
movb $0x0, %al
callq 0x1090
movq 0xe995(%rip), %rdi      # 0x15128
callq 0xe7a0
movq 0xe981(%rip), %rdi      # 0x15120
callq 0xe7a0
jmp 0x6917
callq 0x6500
movq %rax, -0x20(%rbp)
callq 0x6500
movq %rax, -0x28(%rbp)
callq 0x6500
movq %rax, -0x30(%rbp)
movq 0xe95d(%rip), %rdi      # 0x15128
movq -0x28(%rbp), %rsi
callq 0xe6e0
movq 0xe945(%rip), %rdi      # 0x15120
movq -0x30(%rbp), %rsi
callq 0xe6e0
movq -0x8(%rbp), %rax
movq 0x28(%rax), %rax
cmpl $0x0, 0x8(%rax)
je 0x682e
movl $0x0, -0x34(%rbp)
movl -0x34(%rbp), %eax
movq -0x8(%rbp), %rcx
movq 0x28(%rcx), %rcx
cmpl 0x8(%rcx), %eax
jge 0x682c
movq -0x8(%rbp), %rax
movq 0x28(%rax), %rax
movq (%rax), %rax
movslq -0x34(%rbp), %rcx
movq (%rax,%rcx,8), %rdi
callq 0x4220
movl -0x34(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x34(%rbp)
jmp 0x67f9
jmp 0x6848
movq -0x8(%rbp), %rax
cmpq $0x0, 0x10(%rax)
je 0x6846
movq -0x8(%rbp), %rax
movq 0x10(%rax), %rdi
callq 0x4c20
jmp 0x6848
movq -0x20(%rbp), %rsi
leaq 0x8d9a(%rip), %rdi      # 0xf5ed
movb $0x0, %al
callq 0x1090
movq -0x8(%rbp), %rax
cmpq $0x0, 0x18(%rax)
je 0x6872
movq -0x8(%rbp), %rax
movq 0x18(%rax), %rdi
callq 0x4c20
leaq 0x8e6b(%rip), %rdi      # 0xf6e4
movb $0x0, %al
callq 0x1090
leaq 0x8f38(%rip), %rdi      # 0xf7bf
movb $0x0, %al
callq 0x1090
movq -0x30(%rbp), %rsi
leaq 0x8f34(%rip), %rdi      # 0xf7cd
movb $0x0, %al
callq 0x1090
movq -0x8(%rbp), %rax
movq 0x8(%rax), %rdi
callq 0x44b0
movq -0x28(%rbp), %rsi
leaq 0x8d35(%rip), %rdi      # 0xf5ed
movb $0x0, %al
callq 0x1090
movq -0x8(%rbp), %rax
cmpq $0x0, 0x20(%rax)
je 0x68d7
movq -0x8(%rbp), %rax
movq 0x20(%rax), %rdi
callq 0x4c20
movq -0x20(%rbp), %rsi
leaq 0x8ef4(%rip), %rdi      # 0xf7d6
movb $0x0, %al
callq 0x1090
movq -0x30(%rbp), %rsi
leaq 0x8cf9(%rip), %rdi      # 0xf5ed
movb $0x0, %al
callq 0x1090
movq 0xe826(%rip), %rdi      # 0x15128
callq 0xe7a0
movq 0xe812(%rip), %rdi      # 0x15120
callq 0xe7a0
jmp 0x6917
jmp 0x6917
addq $0x40, %rsp
popq %rbp
retq
nopl (%rax)