#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;
  do {
    printf("\nQual operação deseja?");
    printf("\n1 - raiz quadrada");
    printf("\n2 - potencia de 2");
    printf("\nOpção:");
    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("\n O quadrado de %d = %.2f", num1, res);
      break;
    }
    printf("\nDeseja continuar(1-s/2-n)?");
    scanf("%d", &continuar);
  } while (continuar == 1);
  printf("\nBye bye\n");
  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,-0x21(%rbp)
call   1030 <printf@plt>
mov    -0x21(%rbp),%al
lea    0xeaf(%rip),%rdi
call   1030 <printf@plt>
mov    -0x21(%rbp),%al
lea    0xeb3(%rip),%rdi
call   1030 <printf@plt>
mov    -0x21(%rbp),%al
lea    0xeb7(%rip),%rdi
call   1030 <printf@plt>
lea    0xeb5(%rip),%rdi
mov    %rdi,-0x20(%rbp)
lea    -0x8(%rbp),%rsi
call   1040 <scanf@plt>
mov    -0x21(%rbp),%al
lea    0xea1(%rip),%rdi
call   1030 <printf@plt>
mov    -0x20(%rbp),%rdi
lea    -0x10(%rbp),%rsi
call   1040 <scanf@plt>
mov    -0x8(%rbp),%eax
mov    %eax,-0x18(%rbp)
sub    $0x1,%eax
je     11e2 <main+0xa2>
jmp    11d1 <main+0x91>
mov    -0x18(%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    0xe5b(%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    0xe47(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
lea    0xe53(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xdfa(%rip),%rdi
lea    -0xc(%rbp),%rsi
call   1040 <scanf@plt>
cmpl   $0x1,-0xc(%rbp)
je     114f <main+0xf>
lea    0xe47(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
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    0xee4(%rip),%rbx
lea    0x14(%rsp),%rbp
lea    0xedb(%rip),%r14
lea    0xc(%rsp),%r15
lea    0xf17(%rip),%r12
lea    0x10(%rsp),%r13
jmp    11d4 <main+0x84>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    0xc(%rsp),%edi
mov    $0x2,%esi
call   1060 <pow@plt>
mov    0xc(%rsp),%esi
cvtss2sd %xmm0,%xmm0
lea    0xecd(%rip),%rdi
mov    $0x1,%al
call   1040 <printf@plt>
mov    %r12,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %rbx,%rdi
mov    %r13,%rsi
call   1050 <scanf@plt>
cmpl   $0x1,0x10(%rsp)
jne    125f <main+0x10f>
lea    0xe25(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xe30(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xe35(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xe3a(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %rbx,%rdi
mov    %rbp,%rsi
call   1050 <scanf@plt>
mov    %r14,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %rbx,%rdi
mov    %r15,%rsi
call   1050 <scanf@plt>
mov    0x14(%rsp),%eax
cmp    $0x2,%eax
je     1190 <main+0x40>
cmp    $0x1,%eax
jne    11b4 <main+0x64>
mov    0xc(%rsp),%edi
call   1070 <sqrt@plt>
mov    0xc(%rsp),%esi
cvtss2sd %xmm0,%xmm0
lea    0xe03(%rip),%rdi
jmp    11ad <main+0x5d>
lea    0xe4a(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
@.str = [25 x i8] c"\0AQual opera\C3\A7\C3\A3o deseja?\00"
@.str.1 = [19 x i8] c"\0A1 - raiz quadrada\00"
@.str.2 = [19 x i8] c"\0A2 - potencia de 2\00"
@.str.3 = [10 x i8] c"\0AOp\C3\A7\C3\A3o:\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 = [26 x i8] c"\0A O quadrado de %d = %.2f\00"
@.str.8 = [28 x i8] c"\0ADeseja continuar(1-s/2-n)?\00"
@str = [9 x i8] c"\0ABye bye\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 ([25 x i8], [25 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 ([10 x i8], [10 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 ([26 x i8], [26 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
%34 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @str, i64 0, i64 0))
ret i32 0
}