// File: /workspace/github_c_makefile_star2_O3/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 0x4776
movq %rdi, %r14
leaq 0x50a0(%rip), %rcx      # 0x9564
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movq (%r14), %rax
movq (%rax), %rdi
testq %rdi, %rdi
je 0x46bc
addq $0x8, %rsp
popq %rbx
popq %r14
jmp 0x477e
movq 0x8(%r14), %rdi
callq 0x44a9
movq 0x9c10(%rip), %rdi      # 0xe108
callq 0x8825
movq %rax, %rbx
movq 0x9c01(%rip), %rdi      # 0xe108
callq 0x8839
movq 0x18(%rbx), %rax
movq (%rax), %rdi
movq 0x20(%r14), %rsi
callq 0x8a1e
movq %rax, %rbx
leaq 0x5429(%rip), %rdi      # 0x994f
jmp 0x4645
movq 0x8(%r14), %rdi
callq 0x44a9
leaq 0x5414(%rip), %rdi      # 0x994f
callq 0x1070
leaq 0x5358(%rip), %rdi      # 0x989f
callq 0x1070
leaq 0x535d(%rip), %rdi      # 0x98b0
callq 0x1070
leaq 0x535c(%rip), %rdi      # 0x98bb
callq 0x1070
leaq 0x53c0(%rip), %rdi      # 0x992b
callq 0x1070
leaq 0x5317(%rip), %rdi      # 0x988e
jmp 0x46b0
movq 0x8(%r14), %rdi
callq 0x44a9
movq 0x9b7c(%rip), %rdi      # 0xe108
callq 0x8825
movq %rax, %rbx
movq 0x9b6d(%rip), %rdi      # 0xe108
callq 0x8839
movq 0x10(%r14), %rdi
callq 0x395f
leaq 0x537b(%rip), %rdi      # 0x992b
callq 0x1070
leaq 0x5393(%rip), %rdi      # 0x994f
callq 0x1070
cmpl $0x0, 0xc(%rbx)
movl 0x10(%rbx), %eax
je 0x4703
testl %eax, %eax
jg 0x4708
movl 0x4(%rbx), %esi
leaq 0x50a2(%rip), %rdi      # 0x9682
xorl %eax, %eax
callq 0x10a0
jmp 0x4733
movq 0x8(%r14), %rdi
callq 0x44a9
movq 0x9b0c(%rip), %rdi      # 0xe108
callq 0x8825
movq %rax, %rbx
movq 0x9afd(%rip), %rdi      # 0xe108
callq 0x8839
movq 0x18(%rbx), %rax
movq (%rax), %rdi
movq 0x20(%r14), %rsi
callq 0x8a1e
movq %rax, %rbx
movq 0x9ade(%rip), %rdi      # 0xe108
movq (%rax), %rsi
callq 0x87e1
leaq 0x5316(%rip), %rdi      # 0x994f
callq 0x1070
leaq 0x52b9(%rip), %rdi      # 0x98fe
callq 0x1070
movl 0x8(%rbx), %esi
leaq 0x503e(%rip), %rdi      # 0x9692
xorl %eax, %eax
callq 0x10a0
leaq 0x52d3(%rip), %rdi      # 0x9935
jmp 0x46b0
movq 0x8(%r14), %rdi
callq 0x44a9
leaq 0x52db(%rip), %rdi      # 0x994f
callq 0x1070
leaq 0x521f(%rip), %rdi      # 0x989f
callq 0x1070
leaq 0x5224(%rip), %rdi      # 0x98b0
callq 0x1070
leaq 0x5223(%rip), %rdi      # 0x98bb
callq 0x1070
leaq 0x5287(%rip), %rdi      # 0x992b
callq 0x1070
leaq 0x5214(%rip), %rdi      # 0x98c4
addq $0x8, %rsp
popq %rbx
popq %r14
jmp 0x1070
movq 0x8(%rax), %rcx
testq %rcx, %rcx
je 0x4761
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 0x38e3
cmpl $0x2, %eax
jl 0x4716
leaq 0x51c6(%rip), %rdi      # 0x98d5
callq 0x1070
jmp 0x4727
movl 0x4(%rbx), %esi
leaq 0x4f62(%rip), %rdi      # 0x9682
xorl %eax, %eax
callq 0x10a0
leaq 0x51d0(%rip), %rdi      # 0x98fe
callq 0x1070
leaq 0x51a9(%rip), %rdi      # 0x98e3
callq 0x1070
leaq 0x51ef(%rip), %rdi      # 0x9935
callq 0x1070
movq 0x99b6(%rip), %rdi      # 0xe108
movq %rbx, %rsi
addq $0x8, %rsp
popq %rbx
popq %r14
jmp 0x87e1
movq 0x18(%rax), %rdi
testq %rdi, %rdi
je 0x4776
addq $0x8, %rsp
popq %rbx
popq %r14
jmp 0x494e
addq $0x8, %rsp
popq %rbx
popq %r14
retq