// File: /workspace/github_c_makefile_star2_O1/chgzm[P]minic/generator.c
// Function: process_postfix_expr_left
static void process_postfix_expr_left(const PostfixExprNode* node) {
    switch (node->postfix_expr_type) {
    // primary-expression
    case PS_PRIMARY: {
        process_primary_expr_left(node->primary_expr_node);
        break;
    }
    // postfix-expression [ expression ]
    case PS_LSQUARE: {
        process_postfix_expr_left(node->postfix_expr_node);

        Type* type1 = stack_top(type_stack);
        stack_pop(type_stack);

        process_expr(node->expr_node);

        printf("  pop rdi\n");
        printf("  pop rax\n");
        if (type1->array_size) {
            if (type1->ptr_count > 0) {
                printf("  imul rdi, 8\n");
                printf("  mov rax, [rax]\n");
            } else {
                printf("  imul rdi, %d\n", type1->type_size);
            }
        } else {
            if (type1->ptr_count > 1) {
                printf("  imul rdi, 8\n");
                printf("  mov rax, [rax]\n");
            } else {
                printf("  imul rdi, %d\n", type1->type_size);
                printf("  mov rax, [rax]\n");
            }
        }

        printf("  add rax, rdi\n");
        printf("  push rax\n");

        stack_push(type_stack, type1);
        break;
    }
    // postfix-expression . identifier
    case PS_DOT: {
        process_postfix_expr_left(node->postfix_expr_node);

        Type* type2 = stack_top(type_stack);
        stack_pop(type_stack);

        const FieldInfo* field_info1 = strptrmap_get(type2->struct_info->field_info_map, node->identifier);

        printf("  pop rax\n");
        printf("  add rax, %d\n", field_info1->offset);
        printf("  push rax\n");

        break;        
    }
    // postfix-expression -> identifier
    case PS_ARROW: {
        process_postfix_expr_left(node->postfix_expr_node);

        Type* type3 = stack_top(type_stack);
        stack_pop(type_stack);

        const FieldInfo* field_info2 = strptrmap_get(type3->struct_info->field_info_map, node->identifier);
        stack_push(type_stack, field_info2->type);

        printf("  pop rax\n");
        printf("  mov rax, [rax]\n");
        printf("  add rax, %d\n", field_info2->offset);
        printf("  push rax\n");

        break;        
    }
    // postfix-expression ++
    case PS_INC: {
        process_postfix_expr_left(node->postfix_expr_node);
        printf("  pop rax\n");
        printf("  mov rdi, [rax]\n");
        printf("  push rdi\n");
        printf("  push 1\n");
        printf("  pop rdi\n");
        printf("  add [rax], rdi\n");
        break;                       
    }
    // postfix-expression --
    case PS_DEC: {
        process_postfix_expr_left(node->postfix_expr_node);
        printf("  pop rax\n");
        printf("  mov rdi, [rax]\n");
        printf("  push rdi\n");
        printf("  push 1\n");
        printf("  pop rdi\n");
        printf("  sub [rax], rdi\n");
        break;                       
    }
    default: {
        // @todo
        break;
    }
    }
}

// Assembly:
pushq %r14
pushq %rbx
pushq %rax
movl 0x28(%rdi), %eax
cmpq $0x6, %rax
ja 0x464b
movq %rdi, %r14
leaq 0x61cb(%rip), %rcx      # 0xa564
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movq (%r14), %rax
movq (%rax), %rdi
testq %rdi, %rdi
je 0x4591
addq $0x8, %rsp
popq %rbx
popq %r14
jmp 0x4653
movq 0x8(%r14), %rdi
callq 0x437e
movq 0xad3b(%rip), %rdi      # 0xf108
callq 0x8bf2
movq %rax, %rbx
movq 0xad2c(%rip), %rdi      # 0xf108
callq 0x8c06
movq 0x18(%rbx), %rax
movq (%rax), %rdi
movq 0x20(%r14), %rsi
callq 0x8def
movq %rax, %rbx
leaq 0x6554(%rip), %rdi      # 0xa94f
jmp 0x451a
movq 0x8(%r14), %rdi
callq 0x437e
leaq 0x653f(%rip), %rdi      # 0xa94f
callq 0x1070
leaq 0x6483(%rip), %rdi      # 0xa89f
callq 0x1070
leaq 0x6488(%rip), %rdi      # 0xa8b0
callq 0x1070
leaq 0x6487(%rip), %rdi      # 0xa8bb
callq 0x1070
leaq 0x64eb(%rip), %rdi      # 0xa92b
callq 0x1070
leaq 0x6442(%rip), %rdi      # 0xa88e
jmp 0x4585
movq 0x8(%r14), %rdi
callq 0x437e
movq 0xaca7(%rip), %rdi      # 0xf108
callq 0x8bf2
movq %rax, %rbx
movq 0xac98(%rip), %rdi      # 0xf108
callq 0x8c06
movq 0x10(%r14), %rdi
callq 0x3819
leaq 0x64a6(%rip), %rdi      # 0xa92b
callq 0x1070
leaq 0x64be(%rip), %rdi      # 0xa94f
callq 0x1070
cmpl $0x0, 0xc(%rbx)
movl 0x10(%rbx), %eax
je 0x45d8
testl %eax, %eax
jg 0x45dd
movl 0x4(%rbx), %esi
leaq 0x61cd(%rip), %rdi      # 0xa682
xorl %eax, %eax
callq 0x10a0
jmp 0x4608
movq 0x8(%r14), %rdi
callq 0x437e
movq 0xac37(%rip), %rdi      # 0xf108
callq 0x8bf2
movq %rax, %rbx
movq 0xac28(%rip), %rdi      # 0xf108
callq 0x8c06
movq 0x18(%rbx), %rax
movq (%rax), %rdi
movq 0x20(%r14), %rsi
callq 0x8def
movq %rax, %rbx
movq 0xac09(%rip), %rdi      # 0xf108
movq (%rax), %rsi
callq 0x8baf
leaq 0x6441(%rip), %rdi      # 0xa94f
callq 0x1070
leaq 0x63e4(%rip), %rdi      # 0xa8fe
callq 0x1070
movl 0x8(%rbx), %esi
leaq 0x6169(%rip), %rdi      # 0xa692
xorl %eax, %eax
callq 0x10a0
leaq 0x63fe(%rip), %rdi      # 0xa935
jmp 0x4585
movq 0x8(%r14), %rdi
callq 0x437e
leaq 0x6406(%rip), %rdi      # 0xa94f
callq 0x1070
leaq 0x634a(%rip), %rdi      # 0xa89f
callq 0x1070
leaq 0x634f(%rip), %rdi      # 0xa8b0
callq 0x1070
leaq 0x634e(%rip), %rdi      # 0xa8bb
callq 0x1070
leaq 0x63b2(%rip), %rdi      # 0xa92b
callq 0x1070
leaq 0x633f(%rip), %rdi      # 0xa8c4
addq $0x8, %rsp
popq %rbx
popq %r14
jmp 0x1070
movq 0x8(%rax), %rcx
testq %rcx, %rcx
je 0x4636
movq (%rcx), %rax
movq (%rax), %rax
movq (%rax), %rax
movq (%rax), %rax
movq (%rax), %rax
movq (%rax), %rax
movq (%rax), %rax
movq (%rax), %rax
movq 0x8(%rax), %rax
movq 0x8(%rax), %rax
movq (%rax), %rax
movq 0x8(%rax), %rax
movq 0x8(%rax), %rax
movq (%rax), %rdi
addq $0x8, %rsp
popq %rbx
popq %r14
jmp 0x379d
cmpl $0x2, %eax
jl 0x45eb
leaq 0x62f1(%rip), %rdi      # 0xa8d5
callq 0x1070
jmp 0x45fc
movl 0x4(%rbx), %esi
leaq 0x608d(%rip), %rdi      # 0xa682
xorl %eax, %eax
callq 0x10a0
leaq 0x62fb(%rip), %rdi      # 0xa8fe
callq 0x1070
leaq 0x62d4(%rip), %rdi      # 0xa8e3
callq 0x1070
leaq 0x631a(%rip), %rdi      # 0xa935
callq 0x1070
movq 0xaae1(%rip), %rdi      # 0xf108
movq %rbx, %rsi
addq $0x8, %rsp
popq %rbx
popq %r14
jmp 0x8baf
movq 0x18(%rax), %rdi
testq %rdi, %rdi
je 0x464b
addq $0x8, %rsp
popq %rbx
popq %r14
jmp 0x4823
addq $0x8, %rsp
popq %rbx
popq %r14
retq