// File: /workspace/github_c_makefile_star2_O0/thiagok00[P]INF1715-Compilers/GeraCodigo.c
// Function: gera_codigo_expunaria
static int gera_codigo_expunaria(Exp *e) {
    int idtemp =-1;
    int idexp;

    idexp = gera_codigo_expressao(e->u.expunaria.exp);

    if(e->u.expunaria.opun == opnot){

      if(e->u.expunaria.exp->tipo->tipo_base == bInt){
        int lastid = idexp;
        idtemp = gen_id();
        //  %t(idtemp) = icmp ne i32 %t(lastid), 0
        fprintf(output,"\t%%t%d = icmp ne i32 %%t%d, 0\n",idtemp,lastid);
        lastid = idtemp;
        idtemp = gen_id();
        //  %t(idtemp) = xor i1 %t(lastid), true
        fprintf(output,"\t%%t%d = xor i1 %%t%d, true\n",idtemp,lastid);
        lastid = idtemp;
        idtemp = gen_id();
        //  %t(idtemp) = zext i1 %t(lastid) to i32
        fprintf(output,"\t%%t%d = zext i1 %%t%d to i32\n",idtemp,lastid);
        return idtemp;
      }
      else if(e->u.expunaria.exp->tipo->tipo_base == bFloat){
        int lastid = idexp;
        idtemp = gen_id();
        //%2 = fcmp une float %1, 0.000000e+00
        fprintf(output,"\t%%t%d = fcmp une float %%t%d, 0.000000e+00\n",idtemp,lastid);
        lastid = idtemp;
        idtemp = gen_id();
        //%3 = xor i1 %2, true
        fprintf(output,"\t%%t%d = xor i1 %%t%d, true\n",idtemp,lastid);
        lastid = idtemp;
        idtemp = gen_id();
        //%4 = zext i1 %3 to i32
        fprintf(output,"\t%%t%d = zext i1 %%t%d to i32\n",idtemp,lastid);
        lastid = idtemp;
        idtemp = gen_id();
        //%5 = sitofp i32 %4 to float
        fprintf(output,"\t%%t%d = sitofp i32 %%t%d to float\n",idtemp,lastid);
        return idtemp;
      }
    }
    else if (e->u.expunaria.opun == opmenos) {
      if (e->u.expunaria.exp->tipo->tipo_base == bInt){
        int lastid = idexp;
        idtemp = gen_id();
        //%2 = sub nsw i32 0, %1
        fprintf(output,("\t%%t%d = sub nsw i32 0, %%t%d\n"),idtemp,lastid);
        return idtemp;
      }
      else if(e->u.expunaria.exp->tipo->tipo_base == bFloat){
        int lastid = idexp;
        idtemp = gen_id();
        //%4 = fsub float -0.000000e+00, %3
        fprintf(output,"\t%%t%d = fsub float -0.000000e+00, %%t%d\n",idtemp,lastid);
        return idtemp;
      }
    }


    return idtemp;

}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x30, %rsp
movq %rdi, -0x10(%rbp)
movl $0xffffffff, -0x14(%rbp) # imm = 0xFFFFFFFF
movq -0x10(%rbp), %rax
movq 0x10(%rax), %rdi
callq 0x7b60
movl %eax, -0x18(%rbp)
movq -0x10(%rbp), %rax
cmpl $0x0, 0x18(%rax)
jne 0x82f9
movq -0x10(%rbp), %rax
movq 0x10(%rax), %rax
movq 0x8(%rax), %rax
cmpl $0x2, 0x4(%rax)
jne 0x822d
movl -0x18(%rbp), %eax
movl %eax, -0x1c(%rbp)
callq 0x77b0
movl %eax, -0x14(%rbp)
movq 0x5fcc(%rip), %rdi      # 0xe188
movl -0x14(%rbp), %edx
movl -0x1c(%rbp), %ecx
leaq 0x2b8a(%rip), %rsi      # 0xad53
movb $0x0, %al
callq 0x10e0
movl -0x14(%rbp), %eax
movl %eax, -0x1c(%rbp)
callq 0x77b0
movl %eax, -0x14(%rbp)
movq 0x5fa3(%rip), %rdi      # 0xe188
movl -0x14(%rbp), %edx
movl -0x1c(%rbp), %ecx
leaq 0x2b80(%rip), %rsi      # 0xad72
movb $0x0, %al
callq 0x10e0
movl -0x14(%rbp), %eax
movl %eax, -0x1c(%rbp)
callq 0x77b0
movl %eax, -0x14(%rbp)
movq 0x5f7a(%rip), %rdi      # 0xe188
movl -0x14(%rbp), %edx
movl -0x1c(%rbp), %ecx
leaq 0x2b74(%rip), %rsi      # 0xad8f
movb $0x0, %al
callq 0x10e0
movl -0x14(%rbp), %eax
movl %eax, -0x4(%rbp)
jmp 0x8399
movq -0x10(%rbp), %rax
movq 0x10(%rax), %rax
movq 0x8(%rax), %rax
cmpl $0x3, 0x4(%rax)
jne 0x82f2
movl -0x18(%rbp), %eax
movl %eax, -0x20(%rbp)
callq 0x77b0
movl %eax, -0x14(%rbp)
movq 0x5f30(%rip), %rdi      # 0xe188
movl -0x14(%rbp), %edx
movl -0x20(%rbp), %ecx
leaq 0x2b49(%rip), %rsi      # 0xadae
movb $0x0, %al
callq 0x10e0
movl -0x14(%rbp), %eax
movl %eax, -0x20(%rbp)
callq 0x77b0
movl %eax, -0x14(%rbp)
movq 0x5f07(%rip), %rdi      # 0xe188
movl -0x14(%rbp), %edx
movl -0x20(%rbp), %ecx
leaq 0x2ae4(%rip), %rsi      # 0xad72
movb $0x0, %al
callq 0x10e0
movl -0x14(%rbp), %eax
movl %eax, -0x20(%rbp)
callq 0x77b0
movl %eax, -0x14(%rbp)
movq 0x5ede(%rip), %rdi      # 0xe188
movl -0x14(%rbp), %edx
movl -0x20(%rbp), %ecx
leaq 0x2ad8(%rip), %rsi      # 0xad8f
movb $0x0, %al
callq 0x10e0
movl -0x14(%rbp), %eax
movl %eax, -0x20(%rbp)
callq 0x77b0
movl %eax, -0x14(%rbp)
movq 0x5eb5(%rip), %rdi      # 0xe188
movl -0x14(%rbp), %edx
movl -0x20(%rbp), %ecx
leaq 0x2afb(%rip), %rsi      # 0xaddb
movb $0x0, %al
callq 0x10e0
movl -0x14(%rbp), %eax
movl %eax, -0x4(%rbp)
jmp 0x8399
jmp 0x82f4
jmp 0x8393
movq -0x10(%rbp), %rax
cmpl $0x1, 0x18(%rax)
jne 0x8391
movq -0x10(%rbp), %rax
movq 0x10(%rax), %rax
movq 0x8(%rax), %rax
cmpl $0x2, 0x4(%rax)
jne 0x834a
movl -0x18(%rbp), %eax
movl %eax, -0x24(%rbp)
callq 0x77b0
movl %eax, -0x14(%rbp)
movq 0x5e5a(%rip), %rdi      # 0xe188
movl -0x14(%rbp), %edx
movl -0x24(%rbp), %ecx
leaq 0x2ac4(%rip), %rsi      # 0xadff
movb $0x0, %al
callq 0x10e0
movl -0x14(%rbp), %eax
movl %eax, -0x4(%rbp)
jmp 0x8399
movq -0x10(%rbp), %rax
movq 0x10(%rax), %rax
movq 0x8(%rax), %rax
cmpl $0x3, 0x4(%rax)
jne 0x838d
movl -0x18(%rbp), %eax
movl %eax, -0x28(%rbp)
callq 0x77b0
movl %eax, -0x14(%rbp)
movq 0x5e17(%rip), %rdi      # 0xe188
movl -0x14(%rbp), %edx
movl -0x28(%rbp), %ecx
leaq 0x2aa0(%rip), %rsi      # 0xae1e
movb $0x0, %al
callq 0x10e0
movl -0x14(%rbp), %eax
movl %eax, -0x4(%rbp)
jmp 0x8399
jmp 0x838f
jmp 0x8391
jmp 0x8393
movl -0x14(%rbp), %eax
movl %eax, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x30, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)