#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 *, ...);
double raiz(double);
int /*<<< orphan*/ scanf(char *, double *);
double seno(double, double);
double sin(double);
double sqrt(double);
int /*<<< orphan*/ system(char *);
int main() {
  printf("Calculadora do seno de um angulo em graus (favor ler comentarios da "
         "funcao no codigo)\n\n");
  double x, y, z, n;
  printf("Insira o angulo em graus que deseja calcular o seno: ");
  scanf("%lf", &x);
  printf("\nInsira o numero de interacoes que deseja para calcular o seno: ");
  scanf("%d", &n);
  y = seno(x * 3.14159265358979323846 / 180, n);
  z = sin(x * 3.14159265358979323846 / 180);
  printf("\nFuncao do aluno: %lf\n", y);
  printf("Funcao do <math.h>: %lf\n", z);
  printf("Calculadora de raiz quadrada (retorna -1 se inserido um numero menor "
         "que 0)\n");
  printf("\nInsira o numero que deseja calcular a raiz quadrada: ");
  scanf("%lf", &x);
  y = raiz(x);
  z = sqrt(x);
  printf("\nFuncao do aluno: %lf \n", y);
  printf("Funcao do <math.h>: %lf \n", z);
  system("pause");
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xe8a(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xed4(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xefc(%rip),%rdi
lea    -0x10(%rbp),%rsi
call   1080 <scanf@plt>
lea    0xef0(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xf23(%rip),%rdi
lea    -0x28(%rbp),%rsi
call   1080 <scanf@plt>
movsd  0xe37(%rip),%xmm0
mulsd  -0x10(%rbp),%xmm0
movsd  0xe22(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  -0x28(%rbp),%xmm1
call   1050 <seno@plt>
movsd  %xmm0,-0x18(%rbp)
movsd  0xe0f(%rip),%xmm0
mulsd  -0x10(%rbp),%xmm0
movsd  0xdfa(%rip),%xmm1
divsd  %xmm1,%xmm0
call   1070 <sin@plt>
movsd  %xmm0,-0x20(%rbp)
movsd  -0x18(%rbp),%xmm0
lea    0xec6(%rip),%rdi
mov    $0x1,%al
call   1040 <printf@plt>
movsd  -0x20(%rbp),%xmm0
lea    0xeca(%rip),%rdi
mov    $0x1,%al
call   1040 <printf@plt>
lea    0xed5(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xf14(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xe41(%rip),%rdi
lea    -0x10(%rbp),%rsi
call   1080 <scanf@plt>
movsd  -0x10(%rbp),%xmm0
call   1060 <raiz@plt>
movsd  %xmm0,-0x18(%rbp)
movsd  -0x10(%rbp),%xmm0
call   1090 <sqrt@plt>
movsd  %xmm0,-0x20(%rbp)
movsd  -0x18(%rbp),%xmm0
lea    0xf0a(%rip),%rdi
mov    $0x1,%al
call   1040 <printf@plt>
movsd  -0x20(%rbp),%xmm0
lea    0xf0f(%rip),%rdi
mov    $0x1,%al
call   1040 <printf@plt>
lea    0xf1b(%rip),%rdi
call   1030 <system@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
sub    $0x28,%rsp
lea    0xf9f(%rip),%rdi
call   1030 <puts@plt>
lea    0xe76(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xe9e(%rip),%rbx
lea    0x10(%rsp),%r14
mov    %rbx,%rdi
mov    %r14,%rsi
call   1090 <scanf@plt>
lea    0xe8b(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xebe(%rip),%rdi
lea    0x20(%rsp),%rsi
call   1090 <scanf@plt>
movsd  0x10(%rsp),%xmm0
mulsd  0xe1b(%rip),%xmm0
divsd  0xe1b(%rip),%xmm0
movsd  0x20(%rsp),%xmm1
call   1060 <seno@plt>
movsd  %xmm0,0x8(%rsp)
movsd  0xdfa(%rip),%xmm0
mulsd  0x10(%rsp),%xmm0
divsd  0xdf4(%rip),%xmm0
call   1080 <sin@plt>
movsd  %xmm0,0x18(%rsp)
lea    0xe68(%rip),%rdi
movsd  0x8(%rsp),%xmm0
mov    $0x1,%al
call   1050 <printf@plt>
lea    0xe6b(%rip),%rdi
movsd  0x18(%rsp),%xmm0
mov    $0x1,%al
call   1050 <printf@plt>
lea    0xf36(%rip),%rdi
call   1030 <puts@plt>
lea    0xe64(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
call   1090 <scanf@plt>
movsd  0x10(%rsp),%xmm0
call   1070 <raiz@plt>
movaps %xmm0,%xmm2
movsd  0x10(%rsp),%xmm0
xorpd  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jb     1290 <main+0x110>
sqrtsd %xmm0,%xmm0
jmp    12a1 <main+0x121>
movsd  %xmm2,0x18(%rsp)
call   10a0 <sqrt@plt>
movsd  0x18(%rsp),%xmm2
movsd  %xmm0,0x8(%rsp)
lea    0xe47(%rip),%rdi
movaps %xmm2,%xmm0
mov    $0x1,%al
call   1050 <printf@plt>
lea    0xe4e(%rip),%rdi
movsd  0x8(%rsp),%xmm0
mov    $0x1,%al
call   1050 <printf@plt>
lea    0xe54(%rip),%rdi
call   1040 <system@plt>
xor    %eax,%eax
add    $0x28,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [88 x i8] c"Calculadora do seno de um angulo em graus (favor ler comentarios da funcao no codigo)\0A\0A\00"
@.str.1 = [54 x i8] c"Insira o angulo em graus que deseja calcular o seno: \00"
@.str.2 = [4 x i8] c"%lf\00"
@.str.3 = [65 x i8] c"\0AInsira o numero de interacoes que deseja para calcular o seno: \00"
@.str.4 = [3 x i8] c"%d\00"
@.str.5 = [23 x i8] c"\0AFuncao do aluno: %lf\0A\00"
@.str.6 = [25 x i8] c"Funcao do <math.h>: %lf\0A\00"
@.str.7 = [77 x i8] c"Calculadora de raiz quadrada (retorna -1 se inserido um numero menor que 0)\0A\00"
@.str.8 = [55 x i8] c"\0AInsira o numero que deseja calcular a raiz quadrada: \00"
@.str.9 = [24 x i8] c"\0AFuncao do aluno: %lf \0A\00"
@.str.10 = [26 x i8] c"Funcao do <math.h>: %lf \0A\00"
@.str.11 = [6 x i8] c"pause\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca double
%3 = alloca double
%4 = alloca double
%5 = alloca double
store i32 0, i32* %1
%6 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([88 x i8], [88 x i8]* @.str, i64 0, i64 0))
%7 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([54 x i8], [54 x i8]* @.str.1, i64 0, i64 0))
%8 = call i32 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), double* %2)
%9 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([65 x i8], [65 x i8]* @.str.3, i64 0, i64 0))
%10 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), double* %5)
%11 = load double, double* %2
%12 = fmul double %11, 0x400921FB54442D18
%13 = fdiv double %12, 1.800000e+02
%14 = load double, double* %5
%15 = call double @seno(double %13, double %14)
store double %15, double* %3
%16 = load double, double* %2
%17 = fmul double %16, 0x400921FB54442D18
%18 = fdiv double %17, 1.800000e+02
%19 = call double @sin(double %18)
store double %19, double* %4
%20 = load double, double* %3
%21 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.5, i64 0, i64 0), double %20)
%22 = load double, double* %4
%23 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.6, i64 0, i64 0), double %22)
%24 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([77 x i8], [77 x i8]* @.str.7, i64 0, i64 0))
%25 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([55 x i8], [55 x i8]* @.str.8, i64 0, i64 0))
%26 = call i32 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), double* %2)
%27 = load double, double* %2
%28 = call double @raiz(double %27)
store double %28, double* %3
%29 = load double, double* %2
%30 = call double @sqrt(double %29)
store double %30, double* %4
%31 = load double, double* %3
%32 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.9, i64 0, i64 0), double %31)
%33 = load double, double* %4
%34 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.10, i64 0, i64 0), double %33)
%35 = call i32 @system(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.11, i64 0, i64 0))
ret i32 0
}

LLVM IR (-O2):
@.str.1 = [54 x i8] c"Insira o angulo em graus que deseja calcular o seno: \00"
@.str.2 = [4 x i8] c"%lf\00"
@.str.3 = [65 x i8] c"\0AInsira o numero de interacoes que deseja para calcular o seno: \00"
@.str.4 = [3 x i8] c"%d\00"
@.str.5 = [23 x i8] c"\0AFuncao do aluno: %lf\0A\00"
@.str.6 = [25 x i8] c"Funcao do <math.h>: %lf\0A\00"
@.str.8 = [55 x i8] c"\0AInsira o numero que deseja calcular a raiz quadrada: \00"
@.str.9 = [24 x i8] c"\0AFuncao do aluno: %lf \0A\00"
@.str.10 = [26 x i8] c"Funcao do <math.h>: %lf \0A\00"
@.str.11 = [6 x i8] c"pause\00"
@str = [87 x i8] c"Calculadora do seno de um angulo em graus (favor ler comentarios da funcao no codigo)\0A\00"
@str.12 = [76 x i8] c"Calculadora de raiz quadrada (retorna -1 se inserido um numero menor que 0)\00"
define i32 @main() {
%1 = alloca double
%2 = alloca double
%3 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([87 x i8], [87 x i8]* @str, i64 0, i64 0))
%4 = bitcast double* %1 to i8*
%5 = bitcast double* %2 to i8*
%6 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([54 x i8], [54 x i8]* @.str.1, i64 0, i64 0))
%7 = call i32 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), double* %1)
%8 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([65 x i8], [65 x i8]* @.str.3, i64 0, i64 0))
%9 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), double* %2)
%10 = load double, double* %1
%11 = fmul double %10, 0x400921FB54442D18
%12 = fdiv double %11, 1.800000e+02
%13 = load double, double* %2
%14 = call double @seno(double %12, double %13)
%15 = load double, double* %1
%16 = fmul double %15, 0x400921FB54442D18
%17 = fdiv double %16, 1.800000e+02
%18 = call double @sin(double %17)
%19 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @.str.5, i64 0, i64 0), double %14)
%20 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @.str.6, i64 0, i64 0), double %18)
%21 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([76 x i8], [76 x i8]* @str.12, i64 0, i64 0))
%22 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([55 x i8], [55 x i8]* @.str.8, i64 0, i64 0))
%23 = call i32 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), double* %1)
%24 = load double, double* %1
%25 = call double @raiz(double %24)
%26 = load double, double* %1
%27 = call double @sqrt(double %26)
%28 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @.str.9, i64 0, i64 0), double %25)
%29 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @.str.10, i64 0, i64 0), double %27)
%30 = call i32 @system(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.11, i64 0, i64 0))
ret i32 0
}