#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 */
double f(double);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ scanf(char *, ...);
main() {
  int N, j;
  double h, x0, y;
  printf("Escolha o passo de integração: ");
  scanf("%lf", &h);
  printf("\nEscolha o número de pontos de integração: ");
  scanf("%d", &N);
  printf("\nInforme o valor inicial x0: ");
  scanf("%lf", &x0);
  printf("\nInforme o valor inicial y(x0):");
  scanf("%lf", &y);
  printf("   X        Y   \n");
  for (j = 0; j < N; j++) {
    x0 = x0 + h;
    y = y + h * f(y);
    printf("%lf   %lf   \n", x0, y);
  }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeba(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xece(%rip),%rdi
lea    -0x18(%rbp),%rsi
mov    $0x0,%al
call   1050 <scanf@plt>
lea    0xec0(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xee1(%rip),%rdi
lea    -0x8(%rbp),%rsi
mov    $0x0,%al
call   1050 <scanf@plt>
lea    0xed2(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xe8e(%rip),%rdi
lea    -0x20(%rbp),%rsi
mov    $0x0,%al
call   1050 <scanf@plt>
lea    0xed0(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xe6e(%rip),%rdi
lea    -0x28(%rbp),%rsi
mov    $0x0,%al
call   1050 <scanf@plt>
lea    0xed0(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x0,-0xc(%rbp)
mov    -0xc(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    124d <main+0x11d>
movsd  -0x20(%rbp),%xmm0
addsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  -0x28(%rbp),%xmm0
movsd  %xmm0,-0x38(%rbp)
movsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x30(%rbp)
movsd  -0x28(%rbp),%xmm0
call   1030 <f@plt>
movsd  -0x38(%rbp),%xmm1
movaps %xmm0,%xmm2
movsd  -0x30(%rbp),%xmm0
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  -0x20(%rbp),%xmm0
movsd  -0x28(%rbp),%xmm1
lea    0xe70(%rip),%rdi
mov    $0x2,%al
call   1040 <printf@plt>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    11d4 <main+0xa4>
mov    -0x4(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %rbx
sub    $0x38,%rsp
lea    0xeb3(%rip),%rdi
xor    %ebp,%ebp
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xec5(%rip),%rbx
lea    0x30(%rsp),%rsi
mov    %rbx,%rdi
xor    %eax,%eax
call   1060 <scanf@plt>
lea    0xeb3(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xed4(%rip),%rdi
lea    0xc(%rsp),%rsi
xor    %eax,%eax
call   1060 <scanf@plt>
lea    0xec4(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0x10(%rsp),%rsi
mov    %rbx,%rdi
xor    %eax,%eax
call   1060 <scanf@plt>
lea    0xec5(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0x18(%rsp),%rsi
mov    %rbx,%rdi
xor    %eax,%eax
call   1060 <scanf@plt>
lea    0xed6(%rip),%rdi
call   1030 <puts@plt>
cmpl   $0x0,0xc(%rsp)
jle    124c <main+0x10c>
lea    0xeb5(%rip),%rbx
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
movsd  0x30(%rsp),%xmm1
movsd  %xmm1,0x28(%rsp)
movsd  0x10(%rsp),%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,0x10(%rsp)
movsd  0x18(%rsp),%xmm0
movsd  %xmm0,0x20(%rsp)
call   1040 <f@plt>
movsd  0x28(%rsp),%xmm1
mulsd  %xmm0,%xmm1
addsd  0x20(%rsp),%xmm1
movsd  %xmm1,0x18(%rsp)
movsd  0x10(%rsp),%xmm0
mov    %rbx,%rdi
mov    $0x2,%al
call   1050 <printf@plt>
add    $0x1,%ebp
cmp    0xc(%rsp),%ebp
jl     11f0 <main+0xb0>
xor    %eax,%eax
add    $0x38,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@.str = [34 x i8] c"Escolha o passo de integra\C3\A7\C3\A3o: \00"
@.str.1 = [4 x i8] c"%lf\00"
@.str.2 = [47 x i8] c"\0AEscolha o n\C3\BAmero de pontos de integra\C3\A7\C3\A3o: \00"
@.str.3 = [3 x i8] c"%d\00"
@.str.4 = [30 x i8] c"\0AInforme o valor inicial x0: \00"
@.str.5 = [32 x i8] c"\0AInforme o valor inicial y(x0):\00"
@.str.6 = [18 x i8] c" X Y \0A\00"
@.str.7 = [14 x i8] c"%lf %lf \0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca double
%5 = alloca double
%6 = alloca double
store i32 0, i32* %1
%7 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str, i64 0, i64 0))
%8 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), double* %4)
%9 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([47 x i8], [47 x i8]* @.str.2, i64 0, i64 0))
%10 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i32* %2)
%11 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.4, 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* %5)
%13 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.5, i64 0, i64 0))
%14 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), double* %6)
%15 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.6, i64 0, i64 0))
store i32 0, i32* %3
br label %16
16: ; preds = %32, %0
%17 = load i32, i32* %3
%18 = load i32, i32* %2
%19 = icmp slt i32 %17, %18
br i1 %19, label %20, label %35
20: ; preds = %16
%21 = load double, double* %5
%22 = load double, double* %4
%23 = fadd double %21, %22
store double %23, double* %5
%24 = load double, double* %6
%25 = load double, double* %4
%26 = load double, double* %6
%27 = call double @f(double %26)
%28 = call double @llvm.fmuladd.f64(double %25, double %27, double %24)
store double %28, double* %6
%29 = load double, double* %5
%30 = load double, double* %6
%31 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.7, i64 0, i64 0), double %29, double %30)
br label %32
32: ; preds = %20
%33 = load i32, i32* %3
%34 = add nsw i32 %33, 1
store i32 %34, i32* %3
br label %16
35: ; preds = %16
%36 = load i32, i32* %1
ret i32 %36
}

LLVM IR (-O2):
@.str = [34 x i8] c"Escolha o passo de integra\C3\A7\C3\A3o: \00"
@.str.1 = [4 x i8] c"%lf\00"
@.str.2 = [47 x i8] c"\0AEscolha o n\C3\BAmero de pontos de integra\C3\A7\C3\A3o: \00"
@.str.3 = [3 x i8] c"%d\00"
@.str.4 = [30 x i8] c"\0AInforme o valor inicial x0: \00"
@.str.5 = [32 x i8] c"\0AInforme o valor inicial y(x0):\00"
@.str.7 = [14 x i8] c"%lf %lf \0A\00"
@str = [17 x i8] c" X Y \00"
define i32 @main() {
%1 = alloca i32
%2 = alloca double
%3 = alloca double
%4 = alloca double
%5 = bitcast i32* %1 to i8*
%6 = bitcast double* %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 ([34 x i8], [34 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* %2)
%11 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([47 x i8], [47 x i8]* @.str.2, i64 0, i64 0))
%12 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i32* %1)
%13 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([30 x i8], [30 x i8]* @.str.4, i64 0, i64 0))
%14 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), double* %3)
%15 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([32 x i8], [32 x i8]* @.str.5, i64 0, i64 0))
%16 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), double* %4)
%17 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @str, i64 0, i64 0))
%18 = load i32, i32* %1
%19 = icmp sgt i32 %18, 0
br i1 %19, label %20, label %33
20: ; preds = %0, %20
%21 = phi i32 [ %30, %20 ], [ 0, %0 ]
%22 = load double, double* %3
%23 = load double, double* %2
%24 = fadd double %22, %23
store double %24, double* %3
%25 = load double, double* %4
%26 = call double @f(double %25)
%27 = call double @llvm.fmuladd.f64(double %23, double %26, double %25)
store double %27, double* %4
%28 = load double, double* %3
%29 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @.str.7, i64 0, i64 0), double %28, double %27)
%30 = add nuw nsw i32 %21, 1
%31 = load i32, i32* %1
%32 = icmp slt i32 %30, %31
br i1 %32, label %20, label %33
33: ; preds = %20, %0
ret i32 0
}