// File: /workspace/github_c_makefile_star2_O3/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 0x3f21
leaq 0x5664(%rip), %rcx      # 0x94f8
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movq (%rdi), %rdi
popq %rbx
jmp 0x407e
movq 0x28(%rdi), %rbx
movq %rbx, %rdi
callq 0x440d
testq %rax, %rax
jne 0x3ebf
movq %rbx, %rdi
callq 0x445b
movq (%rax), %rax
movl 0x4(%rax), %esi
jmp 0x406f
movq 0x8(%rdi), %rdi
callq 0x38e3
leaq 0x5a75(%rip), %rdi      # 0x994f
callq 0x1070
leaq 0x59b9(%rip), %rdi      # 0x989f
callq 0x1070
leaq 0x5957(%rip), %rdi      # 0x9849
jmp 0x3f4b
movl 0x24(%rdi), %eax
addl $-0xa, %eax
cmpl $0x7, %eax
ja 0x3f21
leaq 0x5622(%rip), %rcx      # 0x9528
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movq 0x10(%rdi), %rax
movq (%rax), %rdi
testq %rdi, %rdi
je 0x3f21
popq %rbx
jmp 0x38e3
popq %rbx
retq
movq 0x8(%rdi), %rdi
callq 0x38e3
leaq 0x5a1c(%rip), %rdi      # 0x994f
callq 0x1070
leaq 0x5960(%rip), %rdi      # 0x989f
callq 0x1070
leaq 0x590b(%rip), %rdi      # 0x9856
callq 0x1070
leaq 0x590c(%rip), %rdi      # 0x9863
jmp 0x403f
movq 0x18(%rdi), %rax
movl $0x8, %esi
cmpb $0x0, 0x8(%rax)
jne 0x406f
movq (%rax), %rax
movq (%rax), %rax
movl (%rax), %ecx
xorl %esi, %esi
addl $-0x2, %ecx
cmpl $0x5, %ecx
ja 0x406f
leaq 0x5584(%rip), %rdx      # 0x9510
movslq (%rdx,%rcx,4), %rcx
addq %rdx, %rcx
jmpq *%rcx
movl $0x8, %esi
jmp 0x406f
movq 0x10(%rdi), %rax
movq (%rax), %rdi
testq %rdi, %rdi
je 0x3fb0
callq 0x3e7f
leaq 0x5998(%rip), %rdi      # 0x994f
callq 0x1070
leaq 0x593b(%rip), %rdi      # 0x98fe
jmp 0x4033
movq 0x10(%rdi), %rax
movq (%rax), %rdi
testq %rdi, %rdi
je 0x3fd6
callq 0x3e7f
leaq 0x594e(%rip), %rdi      # 0x992b
callq 0x1070
leaq 0x5898(%rip), %rdi      # 0x9881
callq 0x1070
leaq 0x582b(%rip), %rdi      # 0x9820
jmp 0x4033
movq 0x10(%rdi), %rax
movq (%rax), %rdi
testq %rdi, %rdi
je 0x4008
callq 0x3e7f
leaq 0x5940(%rip), %rdi      # 0x994f
callq 0x1070
leaq 0x593e(%rip), %rdi      # 0x9959
callq 0x1070
leaq 0x5808(%rip), %rdi      # 0x982f
callq 0x1070
leaq 0x5806(%rip), %rdi      # 0x9839
callq 0x1070
leaq 0x58f6(%rip), %rdi      # 0x9935
popq %rbx
jmp 0x1070
movl $0x1, %esi
jmp 0x406f
movq 0x8(%rax), %rax
movq (%rax), %rsi
movq 0xa0ce(%rip), %rdi      # 0xe128
jmp 0x4067
movq 0xa0c5(%rip), %rdi      # 0xe128
movq 0x10(%rax), %rsi
callq 0x8a1e
movl 0x8(%rax), %esi
leaq 0x55e7(%rip), %rdi      # 0x965d
xorl %eax, %eax
popq %rbx
jmp 0x10a0