// File: /workspace/github_cpp_makefile_star2_O1/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 0xe780
movq %rdi, %rbx
movq (%r15), %rax
movq -0x8(%rax), %rax
movq 0x8(%rax), %r14
leaq 0x1dc85(%rip), %rax     # 0x2c26e
cmpq %rax, %r14
je 0xe5f8
cmpb $0x2a, (%r14)
jne 0xe5fc
xorl %eax, %eax
jmp 0xe610
movb $0x1, %al
jmp 0xe610
leaq 0x1dc6b(%rip), %rsi     # 0x2c26e
movq %r14, %rdi
callq 0x6400
testl %eax, %eax
sete %al
movl 0x48(%rbx), %ebp
cmpl $0x1, %ebp
sete %cl
andb %al, %cl
cmpb $0x1, %cl
jne 0xe66e
movl $0xc, %edi
callq 0x62e0
movq %rax, %r14
movl 0x8(%r15), %esi
movl 0xc(%r15), %edx
leaq 0x1d9c8(%rip), %rcx     # 0x2c004
movq %rax, %rdi
callq 0x6c30
movl $0x50, %edi
callq 0x62e0
movq %rax, %r15
movq %rax, %rdi
movq %r14, %rsi
callq 0x14934
movq 0x50(%rbx), %rax
movb 0x48(%rax), %al
xorb $0x1, %al
movb %al, 0x48(%r15)
jmp 0xe76f
leaq 0x1dbd4(%rip), %rax     # 0x2c249
cmpq %rax, %r14
je 0xe684
cmpb $0x2a, (%r14)
jne 0xe688
xorl %ecx, %ecx
jmp 0xe69c
movb $0x1, %cl
jmp 0xe69c
leaq 0x1dbba(%rip), %rsi     # 0x2c249
movq %r14, %rdi
callq 0x6400
testl %eax, %eax
sete %cl
testl %ebp, %ebp
sete %al
andb %al, %cl
cmpb $0x1, %cl
jne 0xe6f3
movl $0xc, %edi
callq 0x62e0
movq %rax, %r14
movl 0x8(%r15), %esi
movl 0xc(%r15), %edx
leaq 0x1e897(%rip), %rcx     # 0x2cf5b
movq %rax, %rdi
callq 0x6cda
movl $0x50, %edi
callq 0x62e0
movq %rax, %r15
movq %rax, %rdi
movq %r14, %rsi
callq 0x14888
movq 0x50(%rbx), %rax
xorl %ecx, %ecx
subl 0x48(%rax), %ecx
movl %ecx, 0x48(%r15)
jmp 0xe76f
leaq 0x1db69(%rip), %rcx     # 0x2c263
cmpq %rcx, %r14
je 0xe719
cmpb $0x2a, (%r14)
je 0xe772
leaq 0x1db57(%rip), %rsi     # 0x2c263
movq %r14, %rdi
callq 0x6400
orl %ebp, %eax
sete %al
testb %al, %al
je 0xe772
movl $0xc, %edi
callq 0x62e0
movq %rax, %r14
movl 0x8(%r15), %esi
movl 0xc(%r15), %edx
leaq 0x1e820(%rip), %rcx     # 0x2cf59
movq %rax, %rdi
callq 0x6c14
movl $0x50, %edi
callq 0x62e0
movq %rax, %r15
movq %rax, %rdi
movq %r14, %rsi
callq 0x148dc
movq 0x50(%rbx), %rax
movss 0x48(%rax), %xmm0
xorps 0x1dcc7(%rip), %xmm0    # 0x2c430
movss %xmm0, 0x48(%r15)
movq %r15, %rbx
movq %rbx, %rax
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
callq 0x6340
jmp 0xe789
jmp 0xe789
movq %rax, %rbx
movl $0xc, %esi
movq %r14, %rdi
callq 0x62f0
movq %rbx, %rdi
callq 0x6550
nop