// File: /workspace/github_c_makefile_star2_O1/chgzm[P]minic/generator.c
// Function: process_unary_expr_right
static void process_unary_expr_right(const UnaryExprNode* node) {
    switch (node->type) {
    // postfix-expression
    case UN_NONE: {
        process_postfix_expr_right(node->postfix_expr_node);
        break;
    }
    // ++ unary-expression
    case UN_INC: {
        process_unary_expr_left(node->unary_expr_node);

        printf("  pop rax\n");
        printf("  mov rdi, [rax]\n");
        printf("  add rdi, 1\n");
        printf("  mov [rax], rdi\n");

        break;
    }
    // -- unary-expression
    case UN_DEC: {
        process_unary_expr_left(node->unary_expr_node);

        printf("  pop rax\n");
        printf("  mov rdi, [rax]\n");
        printf("  sub rdi, 1\n");
        printf("  mov [rax], rdi\n");

        break;
    }
    // unary-operator cast-expression
    case UN_OP: {
        switch (node->op_type) {
        case OP_AND: {
            process_cast_expr_left(node->cast_expr_node);
            break;
        }
        case OP_MUL: {
            process_cast_expr(node->cast_expr_node);
            printf("  pop rax\n");
            printf("  mov rax, [rax]\n");
            printf("  push rax\n");
            break;
        }
        case OP_ADD: {
            break;
        }
        case OP_SUB: {
            process_cast_expr(node->cast_expr_node);
            printf("  pop rdi\n");
            printf("  mov rax, 0\n");
            printf("  sub rax, rdi\n");
            printf("  push rax\n");
            break;
        }
        case OP_TILDE: {
            break;
        }
        case OP_EXCLA: {
            process_cast_expr(node->cast_expr_node);
            printf("  pop rax\n");
            printf("  cmp rax, 0\n");
            printf("  sete al\n");
            printf("  movzb rax, al\n");
            printf("  push rax\n");
            break;
        }
        default: {
            break;
        }
        }

        break;
    }
    case UN_SIZEOF_IDENT: {
        const LocalVar* lv = get_localvar(node->sizeof_name);
        if (lv != NULL) {
            printf("  push %d\n", lv->type->type_size);
        } 
        else {
            const GlobalVar* gv = get_globalvar(node->sizeof_name);
            printf("  push %d\n", gv->type->type_size);
        }
        break;
    }
    case UN_SIZEOF_TYPE: {
        const TypeNameNode* type_name_node = node->type_name_node;
        int size = 0;
        if (type_name_node->is_pointer) {
            size = 8;
        }
        else {
            const TypeSpecifierNode* type_specifier_node = type_name_node->specifier_qualifier_node->type_specifier_node; 
            switch (type_specifier_node->type_specifier) {
            case TYPE_CHAR:   { size = 1; break; }
            case TYPE_INT:    { size = 8; break; }
            case TYPE_DOUBLE: { size = 8; break; } 
            case TYPE_STRUCT: { 
                const StructSpecifierNode* struct_specifier_node = type_specifier_node->struct_specifier_node;
                const char* ident = struct_specifier_node->identifier;
                const StructInfo* struct_info1 = strptrmap_get(struct_map, ident);
                size = struct_info1->size;
                break;                                   
            }
            case TYPE_TYPEDEFNAME: {
                const StructInfo* struct_info2 = strptrmap_get(struct_map, type_specifier_node->struct_name);
                size = struct_info2->size;
                break;
            }
            default: {
                break;
            }
            }
        }

        printf("  push %d\n", size);

        break;
    }
    default: {
        break;
    }
    }
}

// Assembly:
pushq %rbx
movl 0x20(%rdi), %eax
cmpq $0x5, %rax
ja 0x3ddd
leaq 0x67a8(%rip), %rcx      # 0xa4f8
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movq (%rdi), %rdi
popq %rbx
jmp 0x3f3a
movq 0x28(%rdi), %rbx
movq %rbx, %rdi
callq 0x42cc
testq %rax, %rax
jne 0x3d7b
movq %rbx, %rdi
callq 0x4325
movq (%rax), %rax
movl 0x4(%rax), %esi
jmp 0x3f2b
movq 0x8(%rdi), %rdi
callq 0x379d
leaq 0x6bb9(%rip), %rdi      # 0xa94f
callq 0x1070
leaq 0x6afd(%rip), %rdi      # 0xa89f
callq 0x1070
leaq 0x6a9b(%rip), %rdi      # 0xa849
jmp 0x3e07
movl 0x24(%rdi), %eax
addl $-0xa, %eax
cmpl $0x7, %eax
ja 0x3ddd
leaq 0x6766(%rip), %rcx      # 0xa528
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movq 0x10(%rdi), %rax
movq (%rax), %rdi
testq %rdi, %rdi
je 0x3ddd
popq %rbx
jmp 0x379d
popq %rbx
retq
movq 0x8(%rdi), %rdi
callq 0x379d
leaq 0x6b60(%rip), %rdi      # 0xa94f
callq 0x1070
leaq 0x6aa4(%rip), %rdi      # 0xa89f
callq 0x1070
leaq 0x6a4f(%rip), %rdi      # 0xa856
callq 0x1070
leaq 0x6a50(%rip), %rdi      # 0xa863
jmp 0x3efb
movq 0x18(%rdi), %rax
movl $0x8, %esi
cmpb $0x0, 0x8(%rax)
jne 0x3f2b
movq (%rax), %rax
movq (%rax), %rax
movl (%rax), %ecx
xorl %esi, %esi
addl $-0x2, %ecx
cmpl $0x5, %ecx
ja 0x3f2b
leaq 0x66c8(%rip), %rdx      # 0xa510
movslq (%rdx,%rcx,4), %rcx
addq %rdx, %rcx
jmpq *%rcx
movl $0x8, %esi
jmp 0x3f2b
movq 0x10(%rdi), %rax
movq (%rax), %rdi
testq %rdi, %rdi
je 0x3e6c
callq 0x3d3b
leaq 0x6adc(%rip), %rdi      # 0xa94f
callq 0x1070
leaq 0x6a7f(%rip), %rdi      # 0xa8fe
jmp 0x3eef
movq 0x10(%rdi), %rax
movq (%rax), %rdi
testq %rdi, %rdi
je 0x3e92
callq 0x3d3b
leaq 0x6a92(%rip), %rdi      # 0xa92b
callq 0x1070
leaq 0x69dc(%rip), %rdi      # 0xa881
callq 0x1070
leaq 0x696f(%rip), %rdi      # 0xa820
jmp 0x3eef
movq 0x10(%rdi), %rax
movq (%rax), %rdi
testq %rdi, %rdi
je 0x3ec4
callq 0x3d3b
leaq 0x6a84(%rip), %rdi      # 0xa94f
callq 0x1070
leaq 0x6a82(%rip), %rdi      # 0xa959
callq 0x1070
leaq 0x694c(%rip), %rdi      # 0xa82f
callq 0x1070
leaq 0x694a(%rip), %rdi      # 0xa839
callq 0x1070
leaq 0x6a3a(%rip), %rdi      # 0xa935
popq %rbx
jmp 0x1070
movl $0x1, %esi
jmp 0x3f2b
movq 0x8(%rax), %rax
movq (%rax), %rsi
movq 0xb212(%rip), %rdi      # 0xf128
jmp 0x3f23
movq 0xb209(%rip), %rdi      # 0xf128
movq 0x10(%rax), %rsi
callq 0x8def
movl 0x8(%rax), %esi
leaq 0x672b(%rip), %rdi      # 0xa65d
xorl %eax, %eax
popq %rbx
jmp 0x10a0