#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 */
float pow(int, int);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ scanf(char *, int *);
float sqrt(int);
int main() {
  int opc, continuar;
  int num1;
  float res, m;
  do {
    printf("\n Escolha uma operaçao");
    printf("\n 1- raiz quadrada");
    printf("\n 2- potencia de 2");
    printf("\nOpçao");
    scanf("%d", &opc);
    printf("\nEntre com num1:");
    scanf("%d", &num1);
    switch (opc) {
    case 1:
      res = sqrt(num1);
      printf("\n Raiz quadrada de %d = %.2f", num1, res);
      break;
    case 2:
      res = pow(num1, 2);
      printf("\nO quadrado de %d = %.2f", num1, res);
      break;
    }
    printf("\nDeseja continuar(1-s/2-n)?");
    scanf("%d", &continuar);
  } while (continuar == 1);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeaa(%rip),%rdi
xor    %eax,%eax
mov    %al,-0x29(%rbp)
call   1030 <printf@plt>
mov    -0x29(%rbp),%al
lea    0xeae(%rip),%rdi
call   1030 <printf@plt>
mov    -0x29(%rbp),%al
lea    0xeb2(%rip),%rdi
call   1030 <printf@plt>
mov    -0x29(%rbp),%al
lea    0xeb6(%rip),%rdi
call   1030 <printf@plt>
lea    0xeb2(%rip),%rdi
mov    %rdi,-0x28(%rbp)
lea    -0x8(%rbp),%rsi
call   1040 <scanf@plt>
mov    -0x29(%rbp),%al
lea    0xe9e(%rip),%rdi
call   1030 <printf@plt>
mov    -0x28(%rbp),%rdi
lea    -0x10(%rbp),%rsi
call   1040 <scanf@plt>
mov    -0x8(%rbp),%eax
mov    %eax,-0x1c(%rbp)
sub    $0x1,%eax
je     11e2 <main+0xa2>
jmp    11d1 <main+0x91>
mov    -0x1c(%rbp),%eax
sub    $0x2,%eax
je     120e <main+0xce>
jmp    123a <main+0xfa>
mov    -0x10(%rbp),%edi
call   1060 <sqrt@plt>
movss  %xmm0,-0x14(%rbp)
mov    -0x10(%rbp),%esi
movss  -0x14(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xe58(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
jmp    123a <main+0xfa>
mov    -0x10(%rbp),%edi
mov    $0x2,%esi
call   1050 <pow@plt>
movss  %xmm0,-0x14(%rbp)
mov    -0x10(%rbp),%esi
movss  -0x14(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xe44(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
lea    0xe4f(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xdf7(%rip),%rdi
lea    -0xc(%rbp),%rsi
call   1040 <scanf@plt>
cmpl   $0x1,-0xc(%rbp)
je     114f <main+0xf>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
lea    0xef1(%rip),%rbx
lea    0x14(%rsp),%rbp
lea    0xee8(%rip),%r14
lea    0xc(%rsp),%r15
lea    0xf23(%rip),%r12
lea    0x10(%rsp),%r13
jmp    11c4 <main+0x84>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    0xc(%rsp),%edi
mov    $0x2,%esi
call   1050 <pow@plt>
mov    0xc(%rsp),%esi
cvtss2sd %xmm0,%xmm0
lea    0xeda(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
mov    %r12,%rdi
xor    %eax,%eax
call   1030 <printf@plt>
mov    %rbx,%rdi
mov    %r13,%rsi
call   1040 <scanf@plt>
cmpl   $0x1,0x10(%rsp)
jne    124f <main+0x10f>
lea    0xe35(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xe3f(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xe44(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xe49(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
mov    %rbx,%rdi
mov    %rbp,%rsi
call   1040 <scanf@plt>
mov    %r14,%rdi
xor    %eax,%eax
call   1030 <printf@plt>
mov    %rbx,%rdi
mov    %r15,%rsi
call   1040 <scanf@plt>
mov    0x14(%rsp),%eax
cmp    $0x2,%eax
je     1180 <main+0x40>
cmp    $0x1,%eax
jne    11a4 <main+0x64>
mov    0xc(%rsp),%edi
call   1060 <sqrt@plt>
mov    0xc(%rsp),%esi
cvtss2sd %xmm0,%xmm0
lea    0xe10(%rip),%rdi
jmp    119d <main+0x5d>
xor    %eax,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [24 x i8] c"\0A Escolha uma opera\C3\A7ao\00"
@.str.1 = [19 x i8] c"\0A 1- raiz quadrada\00"
@.str.2 = [19 x i8] c"\0A 2- potencia de 2\00"
@.str.3 = [8 x i8] c"\0AOp\C3\A7ao\00"
@.str.4 = [3 x i8] c"%d\00"
@.str.5 = [17 x i8] c"\0AEntre com num1:\00"
@.str.6 = [29 x i8] c"\0A Raiz quadrada de %d = %.2f\00"
@.str.7 = [25 x i8] c"\0AO quadrado de %d = %.2f\00"
@.str.8 = [28 x i8] c"\0ADeseja continuar(1-s/2-n)?\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca float
%6 = alloca float
store i32 0, i32* %1
br label %7
7: ; preds = %33, %0
%8 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0))
%9 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.1, i64 0, i64 0))
%10 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.2, i64 0, i64 0))
%11 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i64 0, i64 0))
%12 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i32* %2)
%13 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.5, i64 0, i64 0))
%14 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i32* %4)
%15 = load i32, i32* %2
switch i32 %15, label %30 [
i32 1, label %16
i32 2, label %23
]
16: ; preds = %7
%17 = load i32, i32* %4
%18 = call float @sqrt(i32 %17)
store float %18, float* %5
%19 = load i32, i32* %4
%20 = load float, float* %5
%21 = fpext float %20 to double
%22 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.6, i64 0, i64 0), i32 %19, double %21)
br label %30
23: ; preds = %7
%24 = load i32, i32* %4
%25 = call float @pow(i32 %24, i32 2)
store float %25, float* %5
%26 = load i32, i32* %4
%27 = load float, float* %5
%28 = fpext float %27 to double
%29 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.7, i64 0, i64 0), i32 %26, double %28)
br label %30
30: ; preds = %7, %23, %16
%31 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.8, i64 0, i64 0))
%32 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i32* %3)
br label %33
33: ; preds = %30
%34 = load i32, i32* %3
%35 = icmp eq i32 %34, 1
br i1 %35, label %7, label %36
36: ; preds = %33
ret i32 0
}

LLVM IR (-O2):
@.str = [24 x i8] c"\0A Escolha uma opera\C3\A7ao\00"
@.str.1 = [19 x i8] c"\0A 1- raiz quadrada\00"
@.str.2 = [19 x i8] c"\0A 2- potencia de 2\00"
@.str.3 = [8 x i8] c"\0AOp\C3\A7ao\00"
@.str.4 = [3 x i8] c"%d\00"
@.str.5 = [17 x i8] c"\0AEntre com num1:\00"
@.str.6 = [29 x i8] c"\0A Raiz quadrada de %d = %.2f\00"
@.str.7 = [25 x i8] c"\0AO quadrado de %d = %.2f\00"
@.str.8 = [28 x i8] c"\0ADeseja continuar(1-s/2-n)?\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = bitcast i32* %1 to i8*
%5 = bitcast i32* %2 to i8*
%6 = bitcast i32* %3 to i8*
br label %7
7: ; preds = %28, %0
%8 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0))
%9 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @.str.1, i64 0, i64 0))
%10 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @.str.2, i64 0, i64 0))
%11 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i64 0, i64 0))
%12 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i32* %1)
%13 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @.str.5, i64 0, i64 0))
%14 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i32* %3)
%15 = load i32, i32* %1
switch i32 %15, label %28 [
i32 1, label %16
i32 2, label %22
]
16: ; preds = %7
%17 = load i32, i32* %3
%18 = call float @sqrt(i32 %17)
%19 = load i32, i32* %3
%20 = fpext float %18 to double
%21 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([29 x i8], [29 x i8]* @.str.6, i64 0, i64 0), i32 %19, double %20)
br label %28
22: ; preds = %7
%23 = load i32, i32* %3
%24 = call float @pow(i32 %23, i32 2)
%25 = load i32, i32* %3
%26 = fpext float %24 to double
%27 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @.str.7, i64 0, i64 0), i32 %25, double %26)
br label %28
28: ; preds = %7, %22, %16
%29 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([28 x i8], [28 x i8]* @.str.8, i64 0, i64 0))
%30 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i32* %2)
%31 = load i32, i32* %2
%32 = icmp eq i32 %31, 1
br i1 %32, label %7, label %33
33: ; preds = %28
ret i32 0
}