#define NULL ((void *)0)
typedef unsigned long size_t; // Customize by platform.
typedef long intptr_t;
typedef unsigned long uintptr_t;
typedef long scalar_t__; // Either arithmetic or pointer type.
/* By default, we understand bool (as a convenience). */
typedef int bool;
#define false 0
#define true 1

/* Forward declarations */

/* Type definitions */

/* Variables and functions */
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ scanf(char *, int *);
double sqrt(int);
void main() {
  int num;
  printf("Digite um inteiro: ");
  scanf("%d", &num);
  if (num % 2 == 0)
    printf("\nRaiz quadrada aproximada de %d: %.2f.\n", num, sqrt(num));
  else
    printf("\nQuadrado de %d: %d.\n", num, num * num);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
lea    0xec1(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xec7(%rip),%rdi
lea    -0x4(%rbp),%rsi
call   1040 <scanf@plt>
mov    -0x4(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
cmp    $0x0,%edx
jne    118e <main+0x5e>
mov    -0x4(%rbp),%eax
mov    %eax,-0x8(%rbp)
mov    -0x4(%rbp),%edi
call   1050 <sqrt@plt>
mov    -0x8(%rbp),%esi
lea    0xe95(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
jmp    11a6 <main+0x76>
mov    -0x4(%rbp),%esi
mov    -0x4(%rbp),%edx
imul   -0x4(%rbp),%edx
lea    0xea0(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x10,%rsp
lea    0xec4(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xeca(%rip),%rdi
lea    0xc(%rsp),%rsi
call   1040 <scanf@plt>
mov    0xc(%rsp),%ebx
test   $0x1,%bl
jne    1176 <main+0x46>
mov    %ebx,%edi
call   1050 <sqrt@plt>
lea    0xeac(%rip),%rdi
mov    %ebx,%esi
mov    $0x1,%al
call   1030 <printf@plt>
jmp    118b <main+0x5b>
mov    %ebx,%edx
imul   %ebx,%edx
lea    0xebd(%rip),%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1030 <printf@plt>
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [20 x i8] c"Digite um inteiro: \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [40 x i8] c"\0ARaiz quadrada aproximada de %d: %.2f.\0A\00"
@.str.3 = [22 x i8] c"\0AQuadrado de %d: %d.\0A\00"
define void @main() {
%1 = alloca i32
%2 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0))
%3 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %1)
%4 = load i32, i32* %1
%5 = srem i32 %4, 2
%6 = icmp eq i32 %5, 0
br i1 %6, label %7, label %12
7: ; preds = %0
%8 = load i32, i32* %1
%9 = load i32, i32* %1
%10 = call double @sqrt(i32 %9)
%11 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.2, i64 0, i64 0), i32 %8, double %10)
br label %18
12: ; preds = %0
%13 = load i32, i32* %1
%14 = load i32, i32* %1
%15 = load i32, i32* %1
%16 = mul nsw i32 %14, %15
%17 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.3, i64 0, i64 0), i32 %13, i32 %16)
br label %18
18: ; preds = %12, %7
ret void
}

LLVM IR (-O2):
@.str = [20 x i8] c"Digite um inteiro: \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [40 x i8] c"\0ARaiz quadrada aproximada de %d: %.2f.\0A\00"
@.str.3 = [22 x i8] c"\0AQuadrado de %d: %d.\0A\00"
define void @main() {
%1 = alloca i32
%2 = bitcast i32* %1 to i8*
%3 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0))
%4 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %1)
%5 = load i32, i32* %1
%6 = and i32 %5, 1
%7 = icmp eq i32 %6, 0
br i1 %7, label %8, label %11
8: ; preds = %0
%9 = call double @sqrt(i32 %5)
%10 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([40 x i8], [40 x i8]* @.str.2, i64 0, i64 0), i32 %5, double %9)
br label %14
11: ; preds = %0
%12 = mul nsw i32 %5, %5
%13 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @.str.3, i64 0, i64 0), i32 %5, i32 %12)
br label %14
14: ; preds = %11, %8
ret void
}