#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*/ erro(double, double, int, int /*<<< orphan*/);
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ scanf(char *, ...);
int /*<<< orphan*/ simpson(double, double, int);
int main() {
  int n, opcao;
  double a, b;
  printf("Entre com a: ");
  scanf("%lf", &a);
  printf("Entre com b: ");
  scanf("%lf", &b);
  do {
    printf("                       Metodo De Integracao de Simpson\n");
    printf("\n\n\n\t(1)..........................Calcular com n intervalos\n");
    printf(
        "\t(2)..........................Entrar Com Novos Valores de a e b\n");
    printf("\t(0)..........................Sair\n");
    printf("\nOpcao Desejada: ");
    scanf("%d", &opcao);
    switch (opcao) {
    case 1:
      do {
        printf("\nEntre com n: ");
        scanf("%d", &n);
        if (n % 2) {
          printf("N deve Ser Par!!!\n");
        }
      } while (n % 2);
      printf("Resultado %lf\n", simpson(a, b, n));
      printf("Erro Cometido: %lf\n", erro(a, b, n, simpson(a, b, n)));
      break;
    case 2:
      main();
      break;
    case 0:
      exit(0);
      break;
    }
  } while (opcao);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xe8a(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe8a(%rip),%rdi
lea    -0x18(%rbp),%rsi
mov    $0x0,%al
call   1070 <scanf@plt>
lea    0xe7c(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe6a(%rip),%rdi
lea    -0x20(%rbp),%rsi
mov    $0x0,%al
call   1070 <scanf@plt>
lea    0xe6a(%rip),%rdi
xor    %eax,%eax
mov    %al,-0x25(%rbp)
call   1030 <printf@plt>
mov    -0x25(%rbp),%al
lea    0xe8e(%rip),%rdi
call   1030 <printf@plt>
mov    -0x25(%rbp),%al
lea    0xebb(%rip),%rdi
call   1030 <printf@plt>
mov    -0x25(%rbp),%al
lea    0xeed(%rip),%rdi
call   1030 <printf@plt>
mov    -0x25(%rbp),%al
lea    0xf02(%rip),%rdi
call   1030 <printf@plt>
mov    -0x25(%rbp),%al
lea    0xf05(%rip),%rdi
lea    -0xc(%rbp),%rsi
call   1070 <scanf@plt>
mov    -0xc(%rbp),%eax
mov    %eax,-0x24(%rbp)
test   %eax,%eax
je     1325 <main+0x1c5>
jmp    1222 <main+0xc2>
mov    -0x24(%rbp),%eax
sub    $0x1,%eax
je     1244 <main+0xe4>
jmp    1233 <main+0xd3>
mov    -0x24(%rbp),%eax
sub    $0x2,%eax
je     131b <main+0x1bb>
jmp    132c <main+0x1cc>
jmp    1249 <main+0xe9>
lea    0xebe(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xead(%rip),%rdi
lea    -0x8(%rbp),%rsi
mov    $0x0,%al
call   1070 <scanf@plt>
mov    -0x8(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
cmp    $0x0,%edx
je     128b <main+0x12b>
lea    0xe99(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1290 <main+0x130>
mov    -0x8(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
cmp    $0x0,%edx
jne    1249 <main+0xe9>
movsd  -0x18(%rbp),%xmm0
movsd  -0x20(%rbp),%xmm1
mov    -0x8(%rbp),%edi
call   1050 <simpson@plt>
mov    %eax,%esi
lea    0xe71(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x40(%rbp)
movsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x38(%rbp)
mov    -0x8(%rbp),%eax
mov    %eax,-0x2c(%rbp)
movsd  -0x18(%rbp),%xmm0
movsd  -0x20(%rbp),%xmm1
mov    -0x8(%rbp),%edi
call   1050 <simpson@plt>
movsd  -0x40(%rbp),%xmm0
movsd  -0x38(%rbp),%xmm1
mov    -0x2c(%rbp),%edi
mov    %eax,%esi
call   1040 <erro@plt>
mov    %eax,%esi
lea    0xe30(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    132c <main+0x1cc>
call   1060 <main@plt>
jmp    132c <main+0x1cc>
xor    %edi,%edi
call   1080 <exit@plt>
jmp    1331 <main+0x1d1>
cmpl   $0x0,-0xc(%rbp)
jne    11af <main+0x4f>
xor    %eax,%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x28,%rsp
lea    0xe7b(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xe7b(%rip),%rbx
lea    0x10(%rsp),%rsi
mov    %rbx,%rdi
xor    %eax,%eax
call   1080 <scanf@plt>
lea    0xe69(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0x8(%rsp),%rsi
mov    %rbx,%rdi
xor    %eax,%eax
call   1080 <scanf@plt>
lea    0xea1(%rip),%r14
lea    0xed1(%rip),%r13
lea    0xf05(%rip),%rbx
lea    0xe57(%rip),%rbp
lea    0xe53(%rip),%r15
mov    %rsp,%r12
jmp    1201 <main+0x91>
nopw   0x0(%rax,%rax,1)
call   1070 <main@plt>
mov    0x4(%rsp),%eax
test   %eax,%eax
je     1324 <main+0x1b4>
mov    %r14,%rdi
call   1030 <puts@plt>
mov    %r13,%rdi
call   1030 <puts@plt>
mov    %rbx,%rdi
call   1030 <puts@plt>
lea    0xef9(%rip),%rdi
call   1030 <puts@plt>
lea    0xdf4(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %rbp,%rdi
lea    0x4(%rsp),%rsi
xor    %eax,%eax
call   1080 <scanf@plt>
mov    0x4(%rsp),%eax
cmp    $0x1,%eax
je     1260 <main+0xf0>
cmp    $0x2,%eax
je     11f0 <main+0x80>
test   %eax,%eax
jne    11f9 <main+0x89>
jmp    1335 <main+0x1c5>
nopl   0x0(%rax)
lea    0xed5(%rip),%rbx
jmp    1276 <main+0x106>
nopl   0x0(%rax)
test   $0x1,%dil
je     12b0 <main+0x140>
mov    %r15,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %rbp,%rdi
mov    %r12,%rsi
xor    %eax,%eax
call   1080 <scanf@plt>
mov    (%rsp),%edi
test   $0x1,%dil
je     1270 <main+0x100>
mov    %rbx,%rdi
call   1030 <puts@plt>
mov    (%rsp),%edi
jmp    1270 <main+0x100>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
movsd  0x10(%rsp),%xmm0
movsd  0x8(%rsp),%xmm1
call   1060 <simpson@plt>
lea    0xd7c(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1040 <printf@plt>
movsd  0x10(%rsp),%xmm0
movsd  %xmm0,0x20(%rsp)
movsd  0x8(%rsp),%xmm1
movsd  %xmm1,0x18(%rsp)
mov    (%rsp),%ebx
mov    %ebx,%edi
call   1060 <simpson@plt>
movsd  0x20(%rsp),%xmm0
movsd  0x18(%rsp),%xmm1
mov    %ebx,%edi
lea    0xdd1(%rip),%rbx
mov    %eax,%esi
call   1050 <erro@plt>
lea    0xd3d(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1040 <printf@plt>
jmp    11f5 <main+0x85>
xor    %eax,%eax
add    $0x28,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
xor    %edi,%edi
call   1090 <exit@plt>

LLVM IR (-O0):
@.str = [14 x i8] c"Entre com a: \00"
@.str.1 = [4 x i8] c"%lf\00"
@.str.2 = [14 x i8] c"Entre com b: \00"
@.str.3 = [56 x i8] c" Metodo De Integracao de Simpson\0A\00"
@.str.4 = [60 x i8] c"\0A\0A\0A\09(1)..........................Calcular com n intervalos\0A\00"
@.str.5 = [65 x i8] c"\09(2)..........................Entrar Com Novos Valores de a e b\0A\00"
@.str.6 = [36 x i8] c"\09(0)..........................Sair\0A\00"
@.str.7 = [18 x i8] c"\0AOpcao Desejada: \00"
@.str.8 = [3 x i8] c"%d\00"
@.str.9 = [15 x i8] c"\0AEntre com n: \00"
@.str.10 = [19 x i8] c"N deve Ser Par!!!\0A\00"
@.str.11 = [15 x i8] c"Resultado %lf\0A\00"
@.str.12 = [20 x i8] c"Erro Cometido: %lf\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca double
%5 = alloca double
store i32 0, i32* %1
%6 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0))
%7 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), double* %4)
%8 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.2, i64 0, i64 0))
%9 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), double* %5)
br label %10
10: ; preds = %52, %0
%11 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([56 x i8], [56 x i8]* @.str.3, i64 0, i64 0))
%12 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([60 x i8], [60 x i8]* @.str.4, i64 0, i64 0))
%13 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([65 x i8], [65 x i8]* @.str.5, i64 0, i64 0))
%14 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.6, i64 0, i64 0))
%15 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.7, i64 0, i64 0))
%16 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.8, i64 0, i64 0), i32* %3)
%17 = load i32, i32* %3
switch i32 %17, label %51 [
i32 1, label %18
i32 2, label %47
i32 0, label %49
]
18: ; preds = %10
br label %19
19: ; preds = %28, %18
%20 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.9, i64 0, i64 0))
%21 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.8, i64 0, i64 0), i32* %2)
%22 = load i32, i32* %2
%23 = srem i32 %22, 2
%24 = icmp ne i32 %23, 0
br i1 %24, label %25, label %27
25: ; preds = %19
%26 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.10, i64 0, i64 0))
br label %27
27: ; preds = %25, %19
br label %28
28: ; preds = %27
%29 = load i32, i32* %2
%30 = srem i32 %29, 2
%31 = icmp ne i32 %30, 0
br i1 %31, label %19, label %32
32: ; preds = %28
%33 = load double, double* %4
%34 = load double, double* %5
%35 = load i32, i32* %2
%36 = call i32 @simpson(double %33, double %34, i32 %35)
%37 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.11, i64 0, i64 0), i32 %36)
%38 = load double, double* %4
%39 = load double, double* %5
%40 = load i32, i32* %2
%41 = load double, double* %4
%42 = load double, double* %5
%43 = load i32, i32* %2
%44 = call i32 @simpson(double %41, double %42, i32 %43)
%45 = call i32 @erro(double %38, double %39, i32 %40, i32 %44)
%46 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.12, i64 0, i64 0), i32 %45)
br label %51
47: ; preds = %10
%48 = call i32 @main()
br label %51
49: ; preds = %10
%50 = call i32 @exit(i32 0)
unreachable
51: ; preds = %10, %47, %32
br label %52
52: ; preds = %51
%53 = load i32, i32* %3
%54 = icmp ne i32 %53, 0
br i1 %54, label %10, label %55
55: ; preds = %52
ret i32 0
}

LLVM IR (-O2):
@.str = [14 x i8] c"Entre com a: \00"
@.str.1 = [4 x i8] c"%lf\00"
@.str.2 = [14 x i8] c"Entre com b: \00"
@.str.7 = [18 x i8] c"\0AOpcao Desejada: \00"
@.str.8 = [3 x i8] c"%d\00"
@.str.9 = [15 x i8] c"\0AEntre com n: \00"
@.str.11 = [15 x i8] c"Resultado %lf\0A\00"
@.str.12 = [20 x i8] c"Erro Cometido: %lf\0A\00"
@str = [55 x i8] c" Metodo De Integracao de Simpson\00"
@str.13 = [59 x i8] c"\0A\0A\0A\09(1)..........................Calcular com n intervalos\00"
@str.14 = [64 x i8] c"\09(2)..........................Entrar Com Novos Valores de a e b\00"
@str.15 = [35 x i8] c"\09(0)..........................Sair\00"
@str.16 = [18 x i8] c"N deve Ser Par!!!\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca double
%4 = alloca double
%5 = bitcast i32* %1 to i8*
%6 = bitcast i32* %2 to i8*
%7 = bitcast double* %3 to i8*
%8 = bitcast double* %4 to i8*
%9 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0))
%10 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), double* %3)
%11 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @.str.2, i64 0, i64 0))
%12 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), double* %4)
br label %13
13: ; preds = %51, %0
%14 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([55 x i8], [55 x i8]* @str, i64 0, i64 0))
%15 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([59 x i8], [59 x i8]* @str.13, i64 0, i64 0))
%16 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([64 x i8], [64 x i8]* @str.14, i64 0, i64 0))
%17 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([35 x i8], [35 x i8]* @str.15, i64 0, i64 0))
%18 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @.str.7, i64 0, i64 0))
%19 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.8, i64 0, i64 0), i32* %2)
%20 = load i32, i32* %2
switch i32 %20, label %51 [
i32 1, label %21
i32 2, label %45
i32 0, label %47
]
21: ; preds = %13, %30
%22 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @.str.9, i64 0, i64 0))
%23 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.8, i64 0, i64 0), i32* %1)
%24 = load i32, i32* %1
%25 = and i32 %24, 1
%26 = icmp eq i32 %25, 0
br i1 %26, label %30, label %27
27: ; preds = %21
%28 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @str.16, i64 0, i64 0))
%29 = load i32, i32* %1
br label %30
30: ; preds = %21, %27
%31 = phi i32 [ %24, %21 ], [ %29, %27 ]
%32 = and i32 %31, 1
%33 = icmp eq i32 %32, 0
br i1 %33, label %34, label %21
34: ; preds = %30
%35 = load double, double* %3
%36 = load double, double* %4
%37 = call i32 @simpson(double %35, double %36, i32 %31)
%38 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @.str.11, i64 0, i64 0), i32 %37)
%39 = load double, double* %3
%40 = load double, double* %4
%41 = load i32, i32* %1
%42 = call i32 @simpson(double %39, double %40, i32 %41)
%43 = call i32 @erro(double %39, double %40, i32 %41, i32 %42)
%44 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @.str.12, i64 0, i64 0), i32 %43)
br label %49
45: ; preds = %13
%46 = call i32 @main()
br label %49
47: ; preds = %13
%48 = call i32 @exit(i32 0)
unreachable
49: ; preds = %45, %34
%50 = load i32, i32* %2
br label %51
51: ; preds = %49, %13
%52 = phi i32 [ %50, %49 ], [ %20, %13 ]
%53 = icmp eq i32 %52, 0
br i1 %53, label %54, label %13
54: ; preds = %51
ret i32 0
}