// File: /workspace/github_cpp_makefile_star2_O3/kelwinfc[P]ci4721-Fernandez-Gyomrey/src/AST/constant_folding.cpp
// Function: AST_un_op::constant_folding()
AST_expression* AST_un_op::constant_folding(){
    
    if ( typeid(*expr) == typeid(AST_boolean) && oper_type == NOT){
        tokenBoolean* tk = 
                new tokenBoolean(expr->line,expr->column,(char*)"true");
        AST_boolean* sol = new AST_boolean(tk);
        
        sol->value = !((AST_boolean*)expr)->value;
        return sol;
        
    } else if ( typeid(*expr) == typeid(AST_int) && oper_type == NEG){
        tokenInt* tk = 
                new tokenInt(expr->line,expr->column,(char*)"0");
        AST_int* sol = new AST_int(tk);
        
        sol->value = -((AST_int*)expr)->value;
        return sol;
    } else if ( typeid(*expr) == typeid(AST_float) && oper_type == NEG){
        tokenFloat* tk = 
                new tokenFloat(expr->line,expr->column,(char*)"0.0");
        AST_float* sol = new AST_float(tk);
        
        sol->value = -((AST_float*)expr)->value;
        return sol;
    }
    return this;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %rbx
pushq %rax
movq 0x50(%rdi), %r15
testq %r15, %r15
je 0xe7d7
movq %rdi, %rbx
movq (%r15), %rax
movq -0x8(%rax), %rax
movq 0x8(%rax), %r14
leaq 0x1ec3f(%rip), %rax     # 0x2d26e
cmpq %rax, %r14
je 0xe63f
cmpb $0x2a, (%r14)
jne 0xe643
movl 0x48(%rbx), %ebp
jmp 0xe6b5
movb $0x1, %al
jmp 0xe657
leaq 0x1ec24(%rip), %rsi     # 0x2d26e
movq %r14, %rdi
callq 0x6410
testl %eax, %eax
sete %al
movl 0x48(%rbx), %ebp
cmpl $0x1, %ebp
sete %cl
andb %al, %cl
cmpb $0x1, %cl
jne 0xe6b5
movl $0xc, %edi
callq 0x62f0
movq %rax, %r14
movl 0x8(%r15), %esi
movl 0xc(%r15), %edx
leaq 0x1e981(%rip), %rcx     # 0x2d004
movq %rax, %rdi
callq 0x6c40
movl $0x50, %edi
callq 0x62f0
movq %rax, %r15
movq %rax, %rdi
movq %r14, %rsi
callq 0x14984
movq 0x50(%rbx), %rax
movb 0x48(%rax), %al
xorb $0x1, %al
movb %al, 0x48(%r15)
jmp 0xe7c6
leaq 0x1eb8d(%rip), %rax     # 0x2d249
cmpq %rax, %r14
je 0xe6cf
cmpb $0x2a, (%r14)
jne 0xe6d3
testl %ebp, %ebp
sete %bpl
jmp 0xe742
movb $0x1, %al
jmp 0xe6e7
leaq 0x1eb6f(%rip), %rsi     # 0x2d249
movq %r14, %rdi
callq 0x6410
testl %eax, %eax
sete %al
testl %ebp, %ebp
sete %bpl
andb %bpl, %al
cmpb $0x1, %al
jne 0xe742
movl $0xc, %edi
callq 0x62f0
movq %rax, %r14
movl 0x8(%r15), %esi
movl 0xc(%r15), %edx
leaq 0x1f84b(%rip), %rcx     # 0x2df5b
movq %rax, %rdi
callq 0x6cea
movl $0x50, %edi
callq 0x62f0
movq %rax, %r15
movq %rax, %rdi
movq %r14, %rsi
callq 0x148d8
movq 0x50(%rbx), %rax
xorl %ecx, %ecx
subl 0x48(%rax), %ecx
movl %ecx, 0x48(%r15)
jmp 0xe7c6
leaq 0x1eb1a(%rip), %rax     # 0x2d263
cmpq %rax, %r14
je 0xe76f
cmpb $0x2a, (%r14)
je 0xe7c9
leaq 0x1eb08(%rip), %rsi     # 0x2d263
movq %r14, %rdi
callq 0x6410
testl %eax, %eax
sete %al
testb %bpl, %al
jne 0xe774
jmp 0xe7c9
testb %bpl, %bpl
je 0xe7c9
movl $0xc, %edi
callq 0x62f0
movq %rax, %r14
movl 0x8(%r15), %esi
movl 0xc(%r15), %edx
leaq 0x1f7c9(%rip), %rcx     # 0x2df59
movq %rax, %rdi
callq 0x6c24
movl $0x50, %edi
callq 0x62f0
movq %rax, %r15
movq %rax, %rdi
movq %r14, %rsi
callq 0x1492c
movq 0x50(%rbx), %rax
movss 0x48(%rax), %xmm0
xorps 0x1ec70(%rip), %xmm0    # 0x2d430
movss %xmm0, 0x48(%r15)
movq %r15, %rbx
movq %rbx, %rax
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
callq 0x6350
jmp 0xe7e0
jmp 0xe7e0
movq %rax, %rbx
movl $0xc, %esi
movq %r14, %rdi
callq 0x6300
movq %rbx, %rdi
callq 0x6560