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


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeba(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xecf(%rip),%rdi
lea    -0x10(%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    0xe8f(%rip),%rdi
lea    -0x14(%rbp),%rsi
mov    $0x0,%al
call   1050 <scanf@plt>
lea    0xed5(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xe6f(%rip),%rdi
lea    -0x18(%rbp),%rsi
mov    $0x0,%al
call   1050 <scanf@plt>
lea    0xedc(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xe4f(%rip),%rdi
lea    -0x1c(%rbp),%rsi
mov    $0x0,%al
call   1050 <scanf@plt>
lea    0xee0(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x0,-0xc(%rbp)
movss  -0x14(%rbp),%xmm1
movss  -0x1c(%rbp),%xmm0
ucomiss %xmm1,%xmm0
jbe    127f <main+0x14f>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
movss  -0x14(%rbp),%xmm0
addss  -0x10(%rbp),%xmm0
movss  %xmm0,-0x14(%rbp)
movss  -0x18(%rbp),%xmm0
movss  %xmm0,-0x24(%rbp)
movss  -0x10(%rbp),%xmm0
movss  %xmm0,-0x20(%rbp)
movss  -0x18(%rbp),%xmm0
call   1030 <f@plt>
movss  -0x24(%rbp),%xmm1
movaps %xmm0,%xmm2
movss  -0x20(%rbp),%xmm0
mulss  %xmm2,%xmm0
addss  %xmm1,%xmm0
movss  %xmm0,-0x18(%rbp)
mov    -0xc(%rbp),%esi
movss  -0x14(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
movss  -0x18(%rbp),%xmm1
cvtss2sd %xmm1,%xmm1
lea    0xe65(%rip),%rdi
mov    $0x2,%al
call   1040 <printf@plt>
jmp    11f4 <main+0xc4>
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
sub    $0x28,%rsp
lea    0xecd(%rip),%rdi
call   1030 <puts@plt>
lea    0xea6(%rip),%rbx
lea    0x20(%rsp),%rsi
mov    %rbx,%rdi
xor    %eax,%eax
call   1060 <scanf@plt>
lea    0xecd(%rip),%rdi
call   1030 <puts@plt>
lea    0xe87(%rip),%rdi
lea    0x24(%rsp),%rsi
xor    %eax,%eax
call   1060 <scanf@plt>
lea    0xedc(%rip),%rdi
call   1030 <puts@plt>
lea    0xc(%rsp),%rsi
mov    %rbx,%rdi
xor    %eax,%eax
call   1060 <scanf@plt>
lea    0xee3(%rip),%rdi
call   1030 <puts@plt>
lea    0x14(%rsp),%rsi
mov    %rbx,%rdi
xor    %eax,%eax
call   1060 <scanf@plt>
lea    0xeee(%rip),%rdi
call   1030 <puts@plt>
lea    0x10(%rsp),%rsi
mov    %rbx,%rdi
xor    %eax,%eax
call   1060 <scanf@plt>
lea    0xef6(%rip),%rdi
call   1030 <puts@plt>
movss  0xc(%rsp),%xmm0
movss  0x10(%rsp),%xmm1
ucomiss %xmm0,%xmm1
jbe    1280 <main+0x140>
mov    $0x1,%ebx
lea    0xe00(%rip),%r14
cs nopw 0x0(%rax,%rax,1)
movss  0x20(%rsp),%xmm1
movss  %xmm1,0x1c(%rsp)
addss  %xmm1,%xmm0
movss  %xmm0,0xc(%rsp)
movss  0x14(%rsp),%xmm0
movss  %xmm0,0x18(%rsp)
call   1040 <f@plt>
mulss  0x1c(%rsp),%xmm0
addss  0x18(%rsp),%xmm0
movss  %xmm0,0x14(%rsp)
movss  0xc(%rsp),%xmm1
xorps  %xmm2,%xmm2
cvtss2sd %xmm1,%xmm2
xorps  %xmm1,%xmm1
cvtss2sd %xmm0,%xmm1
mov    %r14,%rdi
mov    %ebx,%esi
movaps %xmm2,%xmm0
mov    $0x2,%al
call   1050 <printf@plt>
movss  0xc(%rsp),%xmm0
movss  0x10(%rsp),%xmm1
add    $0x1,%ebx
ucomiss %xmm0,%xmm1
ja     1210 <main+0xd0>
xor    %eax,%eax
add    $0x28,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [35 x i8] c"Escolha o passo de integra\C3\A7\C3\A3o: \0A\00"
@.str.1 = [3 x i8] c"%f\00"
@.str.2 = [47 x i8] c"Escolha o n\C3\BAmero de pontos de integra\C3\A7\C3\A3o: \0A\00"
@.str.3 = [3 x i8] c"%d\00"
@.str.4 = [35 x i8] c"Informe o valor inicial de x: x0 \0A\00"
@.str.5 = [39 x i8] c"Informe o valor inicial de y: y(x0): \0A\00"
@.str.6 = [36 x i8] c"Informe o valor final de x: x(xf):\0A\00"
@.str.7 = [18 x i8] c" X Y \0A\00"
@.str.8 = [21 x i8] c"%d %.10f %.4f \0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca float
%5 = alloca float
%6 = alloca float
%7 = alloca float
store i32 0, i32* %1
%8 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str, i64 0, i64 0))
%9 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), float* %4)
%10 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([47 x i8], [47 x i8]* @.str.2, i64 0, i64 0))
%11 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i32* %2)
%12 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.4, i64 0, i64 0))
%13 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), float* %5)
%14 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.5, i64 0, i64 0))
%15 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), float* %6)
%16 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.6, i64 0, i64 0))
%17 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), float* %7)
%18 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.7, i64 0, i64 0))
store i32 0, i32* %3
br label %19
19: ; preds = %23, %0
%20 = load float, float* %5
%21 = load float, float* %7
%22 = fcmp olt float %20, %21
br i1 %22, label %23, label %40
23: ; preds = %19
%24 = load i32, i32* %3
%25 = add nsw i32 %24, 1
store i32 %25, i32* %3
%26 = load float, float* %5
%27 = load float, float* %4
%28 = fadd float %26, %27
store float %28, float* %5
%29 = load float, float* %6
%30 = load float, float* %4
%31 = load float, float* %6
%32 = call float @f(float %31)
%33 = call float @llvm.fmuladd.f32(float %30, float %32, float %29)
store float %33, float* %6
%34 = load i32, i32* %3
%35 = load float, float* %5
%36 = fpext float %35 to double
%37 = load float, float* %6
%38 = fpext float %37 to double
%39 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.8, i64 0, i64 0), i32 %34, double %36, double %38)
br label %19
40: ; preds = %19
%41 = load i32, i32* %1
ret i32 %41
}

LLVM IR (-O2):
@.str.1 = [3 x i8] c"%f\00"
@.str.3 = [3 x i8] c"%d\00"
@.str.8 = [21 x i8] c"%d %.10f %.4f \0A\00"
@str = [34 x i8] c"Escolha o passo de integra\C3\A7\C3\A3o: \00"
@str.9 = [46 x i8] c"Escolha o n\C3\BAmero de pontos de integra\C3\A7\C3\A3o: \00"
@str.10 = [34 x i8] c"Informe o valor inicial de x: x0 \00"
@str.11 = [38 x i8] c"Informe o valor inicial de y: y(x0): \00"
@str.12 = [35 x i8] c"Informe o valor final de x: x(xf):\00"
@str.13 = [17 x i8] c" X Y \00"
define i32 @main() {
%1 = alloca i32
%2 = alloca float
%3 = alloca float
%4 = alloca float
%5 = alloca float
%6 = bitcast i32* %1 to i8*
%7 = bitcast float* %2 to i8*
%8 = bitcast float* %3 to i8*
%9 = bitcast float* %4 to i8*
%10 = bitcast float* %5 to i8*
%11 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([34 x i8], [34 x i8]* @str, i64 0, i64 0))
%12 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), float* %2)
%13 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([46 x i8], [46 x i8]* @str.9, i64 0, i64 0))
%14 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i32* %1)
%15 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([34 x i8], [34 x i8]* @str.10, i64 0, i64 0))
%16 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), float* %3)
%17 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([38 x i8], [38 x i8]* @str.11, i64 0, i64 0))
%18 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), float* %4)
%19 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([35 x i8], [35 x i8]* @str.12, i64 0, i64 0))
%20 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), float* %5)
%21 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @str.13, i64 0, i64 0))
%22 = load float, float* %3
%23 = load float, float* %5
%24 = fcmp olt float %22, %23
br i1 %24, label %25, label %41
25: ; preds = %0, %25
%26 = phi float [ %38, %25 ], [ %22, %0 ]
%27 = phi i32 [ %28, %25 ], [ 0, %0 ]
%28 = add nuw nsw i32 %27, 1
%29 = load float, float* %2
%30 = fadd float %26, %29
store float %30, float* %3
%31 = load float, float* %4
%32 = call float @f(float %31)
%33 = call float @llvm.fmuladd.f32(float %29, float %32, float %31)
store float %33, float* %4
%34 = load float, float* %3
%35 = fpext float %34 to double
%36 = fpext float %33 to double
%37 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @.str.8, i64 0, i64 0), i32 %28, double %35, double %36)
%38 = load float, float* %3
%39 = load float, float* %5
%40 = fcmp olt float %38, %39
br i1 %40, label %25, label %41
41: ; preds = %25, %0
ret i32 0
}