#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 *, double *);
main() {
  int j;
  double h, x0, y, xf;
  printf("Escolha o passo de integração: ");
  scanf("%lf", &h);
  printf("\nInforme o valor inicial x0: ");
  scanf("%lf", &x0);
  printf("\nInforme o valor inicial y(x0):");
  scanf("%lf", &y);
  printf("\nInforme o valor final de x: x(xf):\n");
  scanf("%lf", &xf);
  printf("   X        Y   \n");
  j = 0;
  while (x0 < xf) {
    j++;
    x0 = x0 + h;
    y = y + h * f(y);
    printf("%d  %lf   %lf   \n", j, 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    -0x10(%rbp),%rsi
call   1050 <scanf@plt>
lea    0xec2(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xeb0(%rip),%rdi
lea    -0x18(%rbp),%rsi
call   1050 <scanf@plt>
lea    0xec2(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xe92(%rip),%rdi
lea    -0x20(%rbp),%rsi
call   1050 <scanf@plt>
lea    0xec4(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xe74(%rip),%rdi
lea    -0x28(%rbp),%rsi
call   1050 <scanf@plt>
lea    0xecb(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x0,-0x8(%rbp)
movsd  -0x18(%rbp),%xmm1
movsd  -0x28(%rbp),%xmm0
ucomisd %xmm1,%xmm0
jbe    1250 <main+0x120>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
movsd  -0x18(%rbp),%xmm0
addsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x18(%rbp)
movsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x38(%rbp)
movsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x30(%rbp)
movsd  -0x20(%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,-0x20(%rbp)
mov    -0x8(%rbp),%esi
movsd  -0x18(%rbp),%xmm0
movsd  -0x20(%rbp),%xmm1
lea    0xe57(%rip),%rdi
mov    $0x2,%al
call   1040 <printf@plt>
jmp    11cc <main+0x9c>
mov    -0x4(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
sub    $0x38,%rsp
lea    0xeb2(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xec6(%rip),%rbx
lea    0x30(%rsp),%rsi
mov    %rbx,%rdi
call   1060 <scanf@plt>
lea    0xeb6(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0x8(%rsp),%rsi
mov    %rbx,%rdi
call   1060 <scanf@plt>
lea    0xeb9(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0x18(%rsp),%rsi
mov    %rbx,%rdi
call   1060 <scanf@plt>
lea    0xed0(%rip),%rdi
call   1030 <puts@plt>
lea    0x10(%rsp),%rsi
mov    %rbx,%rdi
call   1060 <scanf@plt>
lea    0xedb(%rip),%rdi
call   1030 <puts@plt>
movsd  0x8(%rsp),%xmm0
movsd  0x10(%rsp),%xmm1
ucomisd %xmm0,%xmm1
jbe    1254 <main+0x114>
mov    $0x1,%ebx
lea    0xe82(%rip),%r14
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
movsd  0x30(%rsp),%xmm1
movsd  %xmm1,0x28(%rsp)
addsd  %xmm1,%xmm0
movsd  %xmm0,0x8(%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  0x8(%rsp),%xmm0
mov    %r14,%rdi
mov    %ebx,%esi
mov    $0x2,%al
call   1050 <printf@plt>
movsd  0x8(%rsp),%xmm0
movsd  0x10(%rsp),%xmm1
add    $0x1,%ebx
ucomisd %xmm0,%xmm1
ja     11f0 <main+0xb0>
xor    %eax,%eax
add    $0x38,%rsp
pop    %rbx
pop    %r14
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 = [30 x i8] c"\0AInforme o valor inicial x0: \00"
@.str.3 = [32 x i8] c"\0AInforme o valor inicial y(x0):\00"
@.str.4 = [37 x i8] c"\0AInforme o valor final de x: x(xf):\0A\00"
@.str.5 = [18 x i8] c" X Y \0A\00"
@.str.6 = [18 x i8] c"%d %lf %lf \0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca double
%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 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), double* %3)
%9 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.2, i64 0, i64 0))
%10 = call i32 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), double* %4)
%11 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.3, i64 0, i64 0))
%12 = call i32 @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 ([37 x i8], [37 x i8]* @.str.4, i64 0, i64 0))
%14 = call i32 @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.5, i64 0, i64 0))
store i32 0, i32* %2
br label %16
16: ; preds = %20, %0
%17 = load double, double* %4
%18 = load double, double* %6
%19 = fcmp olt double %17, %18
br i1 %19, label %20, label %35
20: ; preds = %16
%21 = load i32, i32* %2
%22 = add nsw i32 %21, 1
store i32 %22, i32* %2
%23 = load double, double* %4
%24 = load double, double* %3
%25 = fadd double %23, %24
store double %25, double* %4
%26 = load double, double* %5
%27 = load double, double* %3
%28 = load double, double* %5
%29 = call double @f(double %28)
%30 = call double @llvm.fmuladd.f64(double %27, double %29, double %26)
store double %30, double* %5
%31 = load i32, i32* %2
%32 = load double, double* %4
%33 = load double, double* %5
%34 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.6, i64 0, i64 0), i32 %31, double %32, double %33)
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 = [30 x i8] c"\0AInforme o valor inicial x0: \00"
@.str.3 = [32 x i8] c"\0AInforme o valor inicial y(x0):\00"
@.str.6 = [18 x i8] c"%d %lf %lf \0A\00"
@str = [36 x i8] c"\0AInforme o valor final de x: x(xf):\00"
@str.7 = [17 x i8] c" X Y \00"
define i32 @main() {
%1 = alloca double
%2 = alloca double
%3 = alloca double
%4 = alloca double
%5 = bitcast double* %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 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), double* %1)
%11 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([30 x i8], [30 x i8]* @.str.2, i64 0, i64 0))
%12 = call i32 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), double* %2)
%13 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([32 x i8], [32 x i8]* @.str.3, i64 0, i64 0))
%14 = call i32 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), double* %3)
%15 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([36 x i8], [36 x i8]* @str, i64 0, i64 0))
%16 = call i32 @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.7, i64 0, i64 0))
%18 = load double, double* %2
%19 = load double, double* %4
%20 = fcmp olt double %18, %19
br i1 %20, label %21, label %35
21: ; preds = %0, %21
%22 = phi double [ %32, %21 ], [ %18, %0 ]
%23 = phi i32 [ %24, %21 ], [ 0, %0 ]
%24 = add nuw nsw i32 %23, 1
%25 = load double, double* %1
%26 = fadd double %22, %25
store double %26, double* %2
%27 = load double, double* %3
%28 = call double @f(double %27)
%29 = call double @llvm.fmuladd.f64(double %25, double %28, double %27)
store double %29, double* %3
%30 = load double, double* %2
%31 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @.str.6, i64 0, i64 0), i32 %24, double %30, double %29)
%32 = load double, double* %2
%33 = load double, double* %4
%34 = fcmp olt double %32, %33
br i1 %34, label %21, label %35
35: ; preds = %21, %0
ret i32 0
}