#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 num1, opcao;
  float result;
  do {
    printf(" \n1 - Raiz quadrada\n 2 - Potencia de 2\n");
    printf("Digite a opção desejada:\n");
    scanf("%d", &opcao);
    printf("Digite o primeiro número:\n");
    scanf("%d", &num1);
    switch (opcao) {
    case 1:
      result = sqrt(num1);
      printf("Raíz quadrada de %d = %.2f\n", num1, result);
      printf("Deseja continuar?\n");
      scanf("%d", &opcao);
      break;
    case 2:
      result = pow(num1, 2);
      printf("O quadrado de %d = %.2f\n", num1, result);
      printf("Deseja continuar?\n");
      scanf("%d", &opcao);
      break;
    }
  } while (opcao == 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,-0x21(%rbp)
call   1030 <printf@plt>
mov    -0x21(%rbp),%al
lea    0xebe(%rip),%rdi
call   1030 <printf@plt>
lea    0xece(%rip),%rdi
mov    %rdi,-0x20(%rbp)
lea    -0xc(%rbp),%rsi
call   1040 <scanf@plt>
mov    -0x21(%rbp),%al
lea    0xeba(%rip),%rdi
call   1030 <printf@plt>
mov    -0x20(%rbp),%rdi
lea    -0x8(%rbp),%rsi
call   1040 <scanf@plt>
mov    -0xc(%rbp),%eax
mov    %eax,-0x14(%rbp)
sub    $0x1,%eax
je     11c4 <main+0x84>
jmp    11b3 <main+0x73>
mov    -0x14(%rbp),%eax
sub    $0x2,%eax
je     120e <main+0xce>
jmp    1258 <main+0x118>
mov    -0x8(%rbp),%edi
call   1060 <sqrt@plt>
movss  %xmm0,-0x10(%rbp)
mov    -0x8(%rbp),%esi
movss  -0x10(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xe7f(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
lea    0xe8e(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe44(%rip),%rdi
lea    -0xc(%rbp),%rsi
call   1040 <scanf@plt>
jmp    1258 <main+0x118>
mov    -0x8(%rbp),%edi
mov    $0x2,%esi
call   1050 <pow@plt>
movss  %xmm0,-0x10(%rbp)
mov    -0x8(%rbp),%esi
movss  -0x10(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xe60(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
lea    0xe3f(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xdf5(%rip),%rdi
lea    -0xc(%rbp),%rsi
call   1040 <scanf@plt>
jmp    125d <main+0x11d>
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
push   %rax
lea    0xefe(%rip),%r15
lea    0xe97(%rip),%rbx
lea    0x4(%rsp),%r12
lea    0xf06(%rip),%r13
mov    %rsp,%rbp
lea    0xf17(%rip),%r14
jmp    11cc <main+0x7c>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    (%rsp),%edi
mov    $0x2,%esi
call   1060 <pow@plt>
mov    (%rsp),%esi
cvtss2sd %xmm0,%xmm0
lea    0xe75(%rip),%rdi
mov    $0x1,%al
call   1040 <printf@plt>
mov    %r14,%rdi
call   1030 <puts@plt>
mov    %rbx,%rdi
mov    %r12,%rsi
call   1050 <scanf@plt>
cmpl   $0x1,0x4(%rsp)
jne    1224 <main+0xd4>
lea    0xe66(%rip),%rdi
call   1030 <puts@plt>
mov    %r15,%rdi
call   1030 <puts@plt>
mov    %rbx,%rdi
mov    %r12,%rsi
call   1050 <scanf@plt>
mov    %r13,%rdi
call   1030 <puts@plt>
mov    %rbx,%rdi
mov    %rbp,%rsi
call   1050 <scanf@plt>
mov    0x4(%rsp),%eax
cmp    $0x2,%eax
je     1190 <main+0x40>
cmp    $0x1,%eax
jne    1224 <main+0xd4>
mov    (%rsp),%edi
call   1070 <sqrt@plt>
mov    (%rsp),%esi
cvtss2sd %xmm0,%xmm0
lea    0xde1(%rip),%rdi
jmp    11ab <main+0x5b>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [40 x i8] c" \0A1 - Raiz quadrada\0A 2 - Potencia de 2\0A\00"
@.str.1 = [28 x i8] c"Digite a op\C3\A7\C3\A3o desejada:\0A\00"
@.str.2 = [3 x i8] c"%d\00"
@.str.3 = [28 x i8] c"Digite o primeiro n\C3\BAmero:\0A\00"
@.str.4 = [29 x i8] c"Ra\C3\ADz quadrada de %d = %.2f\0A\00"
@.str.5 = [19 x i8] c"Deseja continuar?\0A\00"
@.str.6 = [25 x i8] c"O quadrado de %d = %.2f\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca float
store i32 0, i32* %1
br label %5
5: ; preds = %31, %0
%6 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str, i64 0, i64 0))
%7 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.1, i64 0, i64 0))
%8 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %3)
%9 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.3, i64 0, i64 0))
%10 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %2)
%11 = load i32, i32* %3
switch i32 %11, label %30 [
i32 1, label %12
i32 2, label %21
]
12: ; preds = %5
%13 = load i32, i32* %2
%14 = call float @sqrt(i32 %13)
store float %14, float* %4
%15 = load i32, i32* %2
%16 = load float, float* %4
%17 = fpext float %16 to double
%18 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.4, i64 0, i64 0), i32 %15, double %17)
%19 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.5, i64 0, i64 0))
%20 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %3)
br label %30
21: ; preds = %5
%22 = load i32, i32* %2
%23 = call float @pow(i32 %22, i32 2)
store float %23, float* %4
%24 = load i32, i32* %2
%25 = load float, float* %4
%26 = fpext float %25 to double
%27 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.6, i64 0, i64 0), i32 %24, double %26)
%28 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.5, i64 0, i64 0))
%29 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %3)
br label %30
30: ; preds = %5, %21, %12
br label %31
31: ; preds = %30
%32 = load i32, i32* %3
%33 = icmp eq i32 %32, 1
br i1 %33, label %5, label %34
34: ; preds = %31
ret i32 0
}

LLVM IR (-O2):
@.str.2 = [3 x i8] c"%d\00"
@.str.4 = [29 x i8] c"Ra\C3\ADz quadrada de %d = %.2f\0A\00"
@.str.6 = [25 x i8] c"O quadrado de %d = %.2f\0A\00"
@str = [39 x i8] c" \0A1 - Raiz quadrada\0A 2 - Potencia de 2\00"
@str.7 = [27 x i8] c"Digite a op\C3\A7\C3\A3o desejada:\00"
@str.8 = [27 x i8] c"Digite o primeiro n\C3\BAmero:\00"
@str.10 = [18 x i8] c"Deseja continuar?\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = bitcast i32* %1 to i8*
%4 = bitcast i32* %2 to i8*
br label %5
5: ; preds = %24, %0
%6 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([39 x i8], [39 x i8]* @str, i64 0, i64 0))
%7 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @str.7, i64 0, i64 0))
%8 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %2)
%9 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @str.8, i64 0, i64 0))
%10 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %1)
%11 = load i32, i32* %2
switch i32 %11, label %30 [
i32 1, label %12
i32 2, label %18
]
12: ; preds = %5
%13 = load i32, i32* %1
%14 = call float @sqrt(i32 %13)
%15 = load i32, i32* %1
%16 = fpext float %14 to double
%17 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([29 x i8], [29 x i8]* @.str.4, i64 0, i64 0), i32 %15, double %16)
br label %24
18: ; preds = %5
%19 = load i32, i32* %1
%20 = call float @pow(i32 %19, i32 2)
%21 = load i32, i32* %1
%22 = fpext float %20 to double
%23 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @.str.6, i64 0, i64 0), i32 %21, double %22)
br label %24
24: ; preds = %12, %18
%25 = phi i8* [ getelementptr inbounds ([18 x i8], [18 x i8]* @str.10, i64 0, i64 0), %12 ], [ getelementptr inbounds ([18 x i8], [18 x i8]* @str.10, i64 0, i64 0), %18 ]
%26 = call i32 @puts(i8* dereferenceable(1) %25)
%27 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %2)
%28 = load i32, i32* %2
%29 = icmp eq i32 %28, 1
br i1 %29, label %5, label %30
30: ; preds = %5, %24
ret i32 0
}