#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*/ Euller(double, int);
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ scanf(char *, ...);
int main() {
  double a, b, h;
  int n, opcao;
  do {
    printf("            Resolucao de Equacoes Diferenciais Pelo Metodo de "
           "Euller\n");
    printf("\n\n\n\t(1)..........................Entrar com a, b e n\n");
    printf("\t(2)..........................Entrar com h e n\n");
    printf(
        "\t(3)..........................Entrar Com Novos Valores de a e b\n");
    printf("\t(0)..........................Sair\n");
    printf("\nOpcao Desejada: ");
    scanf("%d", &opcao);
    switch (opcao) {
    case 1:
      printf("Entre com a: ");
      scanf("%lf", &a);
      printf("Entre com b: ");
      scanf("%lf", &b);
      printf("Entre com o numero de intervalos: ");
      scanf("%d", &n);
      h = (b - a) / n;
      Euller(h, n);
      break;
    case 2:
      printf("Entre com h: ");
      scanf("%lf", &h);
      printf("Entre com o numero de intervalos: ");
      scanf("%d", &n);
      Euller(h, n);
      break;
    case 3:
      main();
      break;
    case 0:
      exit(0);
      break;
    }
  } while (opcao);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeaa(%rip),%rdi
call   1030 <printf@plt>
lea    0xee4(%rip),%rdi
call   1030 <printf@plt>
lea    0xf0e(%rip),%rdi
call   1030 <printf@plt>
lea    0xf32(%rip),%rdi
call   1030 <printf@plt>
lea    0xf67(%rip),%rdi
call   1030 <printf@plt>
lea    0xf7f(%rip),%rdi
call   1030 <printf@plt>
lea    0xf85(%rip),%rdi
xor    %eax,%eax
lea    -0x28(%rbp),%rsi
call   1050 <scanf@plt>
mov    -0x28(%rbp),%eax
mov    %rax,-0x30(%rbp)
sub    $0x3,%rax
ja     12c1 <main+0x171>
mov    -0x30(%rbp),%rax
lea    0xe2b(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
lea    0xf51(%rip),%rdi
call   1030 <printf@plt>
lea    0xf53(%rip),%rdi
lea    -0x10(%rbp),%rsi
mov    $0x0,%al
call   1050 <scanf@plt>
lea    0xf45(%rip),%rdi
call   1030 <printf@plt>
lea    0xf35(%rip),%rdi
lea    -0x18(%rbp),%rsi
mov    $0x0,%al
call   1050 <scanf@plt>
lea    0xf35(%rip),%rdi
call   1030 <printf@plt>
lea    0xf06(%rip),%rdi
lea    -0x24(%rbp),%rsi
mov    $0x0,%al
call   1050 <scanf@plt>
movsd  -0x18(%rbp),%xmm0
subsd  -0x10(%rbp),%xmm0
cvtsi2sdl -0x24(%rbp),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  -0x20(%rbp),%xmm0
mov    -0x24(%rbp),%edi
call   1070 <Euller@plt>
jmp    12c1 <main+0x171>
lea    0xf10(%rip),%rdi
call   1030 <printf@plt>
lea    0xecf(%rip),%rdi
lea    -0x20(%rbp),%rsi
mov    $0x0,%al
call   1050 <scanf@plt>
lea    0xecf(%rip),%rdi
call   1030 <printf@plt>
lea    0xea0(%rip),%rdi
lea    -0x24(%rbp),%rsi
mov    $0x0,%al
call   1050 <scanf@plt>
movsd  -0x20(%rbp),%xmm0
mov    -0x24(%rbp),%edi
call   1070 <Euller@plt>
jmp    12c1 <main+0x171>
call   1040 <main@plt>
jmp    12c1 <main+0x171>
xor    %edi,%edi
call   1060 <exit@plt>
jmp    12c6 <main+0x176>
cmpl   $0x0,-0x28(%rbp)
jne    115f <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    $0x28,%rsp
lea    0xfaa(%rip),%rbx
lea    0xfe3(%rip),%rbp
lea    0xe8d(%rip),%r13
lea    0xe98(%rip),%r14
lea    0xc(%rsp),%r15
lea    0xe6a(%rip),%r12
jmp    11f5 <main+0x95>
nopl   0x0(%rax,%rax,1)
lea    0xec1(%rip),%rdi
call   1040 <printf@plt>
lea    0xe80(%rip),%rdi
lea    0x10(%rsp),%rsi
xor    %eax,%eax
call   1060 <scanf@plt>
lea    0xe7f(%rip),%rdi
call   1040 <printf@plt>
mov    %r14,%rdi
lea    0x8(%rsp),%rsi
xor    %eax,%eax
call   1060 <scanf@plt>
movsd  0x10(%rsp),%xmm0
mov    0x8(%rsp),%edi
call   1080 <Euller@plt>
mov    0xc(%rsp),%eax
test   %eax,%eax
je     12fa <main+0x19a>
lea    0xe7a(%rip),%rdi
call   1030 <puts@plt>
lea    0xeb3(%rip),%rdi
call   1030 <puts@plt>
lea    0xedc(%rip),%rdi
call   1030 <puts@plt>
mov    %rbx,%rdi
call   1030 <puts@plt>
mov    %rbp,%rdi
call   1030 <puts@plt>
mov    %r13,%rdi
call   1040 <printf@plt>
mov    %r14,%rdi
mov    %r15,%rsi
xor    %eax,%eax
call   1060 <scanf@plt>
mov    0xc(%rsp),%eax
cmp    $0x3,%rax
ja     11ed <main+0x8d>
movslq (%r12,%rax,4),%rax
add    %r12,%rax
jmp    *%rax
lea    0xdcd(%rip),%rdi
call   1040 <printf@plt>
mov    %r14,%r12
mov    %r15,%r14
mov    %r13,%r15
lea    0xdc6(%rip),%r13
mov    %r13,%rdi
lea    0x20(%rsp),%rsi
xor    %eax,%eax
call   1060 <scanf@plt>
lea    0xdb4(%rip),%rdi
call   1040 <printf@plt>
mov    %r13,%rdi
mov    %r15,%r13
mov    %r14,%r15
mov    %r12,%r14
lea    0xd65(%rip),%r12
lea    0x18(%rsp),%rsi
xor    %eax,%eax
call   1060 <scanf@plt>
lea    0xd97(%rip),%rdi
call   1040 <printf@plt>
mov    %r14,%rdi
lea    0x8(%rsp),%rsi
xor    %eax,%eax
call   1060 <scanf@plt>
movsd  0x18(%rsp),%xmm0
subsd  0x20(%rsp),%xmm0
mov    0x8(%rsp),%edi
xorps  %xmm1,%xmm1
cvtsi2sd %edi,%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,0x10(%rsp)
jmp    11e4 <main+0x84>
nopl   0x0(%rax,%rax,1)
call   1050 <main@plt>
jmp    11e9 <main+0x89>
xor    %eax,%eax
add    $0x28,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
xor    %edi,%edi
call   1070 <exit@plt>

LLVM IR (-O0):
@.str = [70 x i8] c" Resolucao de Equacoes Diferenciais Pelo Metodo de Euller\0A\00"
@.str.1 = [54 x i8] c"\0A\0A\0A\09(1)..........................Entrar com a, b e n\0A\00"
@.str.2 = [48 x i8] c"\09(2)..........................Entrar com h e n\0A\00"
@.str.3 = [65 x i8] c"\09(3)..........................Entrar Com Novos Valores de a e b\0A\00"
@.str.4 = [36 x i8] c"\09(0)..........................Sair\0A\00"
@.str.5 = [18 x i8] c"\0AOpcao Desejada: \00"
@.str.6 = [3 x i8] c"%d\00"
@.str.7 = [14 x i8] c"Entre com a: \00"
@.str.8 = [4 x i8] c"%lf\00"
@.str.9 = [14 x i8] c"Entre com b: \00"
@.str.10 = [35 x i8] c"Entre com o numero de intervalos: \00"
@.str.11 = [14 x i8] c"Entre com h: \00"
define i32 @main() {
%1 = alloca i32
%2 = alloca double
%3 = alloca double
%4 = alloca double
%5 = alloca i32
%6 = alloca i32
store i32 0, i32* %1
br label %7
7: ; preds = %45, %0
%8 = call i32 @printf(i8* getelementptr inbounds ([70 x i8], [70 x i8]* @.str, i64 0, i64 0))
%9 = call i32 @printf(i8* getelementptr inbounds ([54 x i8], [54 x i8]* @.str.1, i64 0, i64 0))
%10 = call i32 @printf(i8* getelementptr inbounds ([48 x i8], [48 x i8]* @.str.2, i64 0, i64 0))
%11 = call i32 @printf(i8* getelementptr inbounds ([65 x i8], [65 x i8]* @.str.3, i64 0, i64 0))
%12 = call i32 @printf(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.4, i64 0, i64 0))
%13 = call i32 @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.5, i64 0, i64 0))
%14 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.6, i64 0, i64 0), i32* %6)
%15 = load i32, i32* %6
switch i32 %15, label %44 [
i32 1, label %16
i32 2, label %32
i32 3, label %40
i32 0, label %42
]
16: ; preds = %7
%17 = call i32 @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.7, i64 0, i64 0))
%18 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.8, i64 0, i64 0), double* %2)
%19 = call i32 @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.9, i64 0, i64 0))
%20 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.8, i64 0, i64 0), double* %3)
%21 = call i32 @printf(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.10, i64 0, i64 0))
%22 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.6, i64 0, i64 0), i32* %5)
%23 = load double, double* %3
%24 = load double, double* %2
%25 = fsub double %23, %24
%26 = load i32, i32* %5
%27 = sitofp i32 %26 to double
%28 = fdiv double %25, %27
store double %28, double* %4
%29 = load double, double* %4
%30 = load i32, i32* %5
%31 = call i32 @Euller(double %29, i32 %30)
br label %44
32: ; preds = %7
%33 = call i32 @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.11, i64 0, i64 0))
%34 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.8, i64 0, i64 0), double* %4)
%35 = call i32 @printf(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.10, i64 0, i64 0))
%36 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.6, i64 0, i64 0), i32* %5)
%37 = load double, double* %4
%38 = load i32, i32* %5
%39 = call i32 @Euller(double %37, i32 %38)
br label %44
40: ; preds = %7
%41 = call i32 @main()
br label %44
42: ; preds = %7
%43 = call i32 @exit(i32 0)
unreachable
44: ; preds = %7, %40, %32, %16
br label %45
45: ; preds = %44
%46 = load i32, i32* %6
%47 = icmp ne i32 %46, 0
br i1 %47, label %7, label %48
48: ; preds = %45
ret i32 0
}

LLVM IR (-O2):
@.str.5 = [18 x i8] c"\0AOpcao Desejada: \00"
@.str.6 = [3 x i8] c"%d\00"
@.str.7 = [14 x i8] c"Entre com a: \00"
@.str.8 = [4 x i8] c"%lf\00"
@.str.9 = [14 x i8] c"Entre com b: \00"
@.str.10 = [35 x i8] c"Entre com o numero de intervalos: \00"
@.str.11 = [14 x i8] c"Entre com h: \00"
@str = [69 x i8] c" Resolucao de Equacoes Diferenciais Pelo Metodo de Euller\00"
@str.12 = [53 x i8] c"\0A\0A\0A\09(1)..........................Entrar com a, b e n\00"
@str.13 = [47 x i8] c"\09(2)..........................Entrar com h e n\00"
@str.14 = [64 x i8] c"\09(3)..........................Entrar Com Novos Valores de a e b\00"
@str.15 = [35 x i8] c"\09(0)..........................Sair\00"
define i32 @main() {
%1 = alloca double
%2 = alloca double
%3 = alloca double
%4 = alloca i32
%5 = alloca i32
%6 = bitcast double* %1 to i8*
%7 = bitcast double* %2 to i8*
%8 = bitcast double* %3 to i8*
%9 = bitcast i32* %4 to i8*
%10 = bitcast i32* %5 to i8*
br label %11
11: ; preds = %48, %0
%12 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([69 x i8], [69 x i8]* @str, i64 0, i64 0))
%13 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([53 x i8], [53 x i8]* @str.12, i64 0, i64 0))
%14 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([47 x i8], [47 x i8]* @str.13, i64 0, i64 0))
%15 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([64 x i8], [64 x i8]* @str.14, i64 0, i64 0))
%16 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([35 x i8], [35 x i8]* @str.15, i64 0, i64 0))
%17 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @.str.5, i64 0, i64 0))
%18 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.6, i64 0, i64 0), i32* %5)
%19 = load i32, i32* %5
switch i32 %19, label %48 [
i32 1, label %20
i32 2, label %34
i32 3, label %42
i32 0, label %44
]
20: ; preds = %11
%21 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @.str.7, i64 0, i64 0))
%22 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.8, i64 0, i64 0), double* %1)
%23 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @.str.9, i64 0, i64 0))
%24 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.8, i64 0, i64 0), double* %2)
%25 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([35 x i8], [35 x i8]* @.str.10, i64 0, i64 0))
%26 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.6, i64 0, i64 0), i32* %4)
%27 = load double, double* %2
%28 = load double, double* %1
%29 = fsub double %27, %28
%30 = load i32, i32* %4
%31 = sitofp i32 %30 to double
%32 = fdiv double %29, %31
store double %32, double* %3
%33 = call i32 @Euller(double %32, i32 %30)
br label %46
34: ; preds = %11
%35 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @.str.11, i64 0, i64 0))
%36 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.8, i64 0, i64 0), double* %3)
%37 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([35 x i8], [35 x i8]* @.str.10, i64 0, i64 0))
%38 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.6, i64 0, i64 0), i32* %4)
%39 = load double, double* %3
%40 = load i32, i32* %4
%41 = call i32 @Euller(double %39, i32 %40)
br label %46
42: ; preds = %11
%43 = call i32 @main()
br label %46
44: ; preds = %11
%45 = call i32 @exit(i32 0)
unreachable
46: ; preds = %42, %34, %20
%47 = load i32, i32* %5
br label %48
48: ; preds = %46, %11
%49 = phi i32 [ %47, %46 ], [ %19, %11 ]
%50 = icmp eq i32 %49, 0
br i1 %50, label %51, label %11
51: ; preds = %48
ret i32 0
}