#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");
  for (x = 0; x <= xf; x++) {
    x = x + h;
    y = y + h * f(y);
    printf("%.4f   %.4f   \n", x, y);
  }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xebe(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xed3(%rip),%rdi
lea    -0x10(%rbp),%rsi
mov    $0x0,%al
call   1050 <scanf@plt>
lea    0xec4(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xee5(%rip),%rdi
lea    -0x8(%rbp),%rsi
mov    $0x0,%al
call   1050 <scanf@plt>
lea    0xed6(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xe93(%rip),%rdi
lea    -0x14(%rbp),%rsi
mov    $0x0,%al
call   1050 <scanf@plt>
lea    0xed9(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xe73(%rip),%rdi
lea    -0x18(%rbp),%rsi
mov    $0x0,%al
call   1050 <scanf@plt>
lea    0xee0(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xe53(%rip),%rdi
lea    -0x1c(%rbp),%rsi
mov    $0x0,%al
call   1050 <scanf@plt>
lea    0xee4(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
xorps  %xmm0,%xmm0
movss  %xmm0,-0x14(%rbp)
movss  -0x14(%rbp),%xmm1
movss  -0x1c(%rbp),%xmm0
ucomiss %xmm1,%xmm0
jb     1286 <main+0x156>
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)
movss  -0x14(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
movss  -0x18(%rbp),%xmm1
cvtss2sd %xmm1,%xmm1
lea    0xe74(%rip),%rdi
mov    $0x2,%al
call   1040 <printf@plt>
movss  0xd89(%rip),%xmm0
addss  -0x14(%rbp),%xmm0
movss  %xmm0,-0x14(%rbp)
jmp    11f5 <main+0xc5>
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x20,%rsp
lea    0xece(%rip),%rdi
call   1030 <puts@plt>
lea    0xeac(%rip),%rbx
lea    0x18(%rsp),%rsi
mov    %rbx,%rdi
xor    %eax,%eax
call   1060 <scanf@plt>
lea    0xece(%rip),%rdi
call   1030 <puts@plt>
lea    0xe8d(%rip),%rdi
lea    0x1c(%rsp),%rsi
xor    %eax,%eax
call   1060 <scanf@plt>
lea    0xedd(%rip),%rdi
call   1030 <puts@plt>
lea    0x4(%rsp),%rsi
mov    %rbx,%rdi
xor    %eax,%eax
call   1060 <scanf@plt>
lea    0xee4(%rip),%rdi
call   1030 <puts@plt>
lea    0xc(%rsp),%rsi
mov    %rbx,%rdi
xor    %eax,%eax
call   1060 <scanf@plt>
lea    0xeef(%rip),%rdi
call   1030 <puts@plt>
lea    0x8(%rsp),%rsi
mov    %rbx,%rdi
xor    %eax,%eax
call   1060 <scanf@plt>
lea    0xef7(%rip),%rdi
call   1030 <puts@plt>
movss  0x8(%rsp),%xmm1
xorps  %xmm0,%xmm0
ucomiss %xmm0,%xmm1
jb     1279 <main+0x139>
lea    0xe0e(%rip),%rbx
nopl   0x0(%rax)
movss  0x18(%rsp),%xmm1
movss  %xmm1,0x14(%rsp)
addss  %xmm1,%xmm0
movss  %xmm0,0x4(%rsp)
movss  0xc(%rsp),%xmm0
movss  %xmm0,0x10(%rsp)
call   1040 <f@plt>
mulss  0x14(%rsp),%xmm0
addss  0x10(%rsp),%xmm0
movss  %xmm0,0xc(%rsp)
movss  0x4(%rsp),%xmm1
xorps  %xmm2,%xmm2
cvtss2sd %xmm1,%xmm2
xorps  %xmm1,%xmm1
cvtss2sd %xmm0,%xmm1
mov    %rbx,%rdi
movaps %xmm2,%xmm0
mov    $0x2,%al
call   1050 <printf@plt>
movss  0x4(%rsp),%xmm0
addss  0xd98(%rip),%xmm0
movss  %xmm0,0x4(%rsp)
movss  0x8(%rsp),%xmm1
ucomiss %xmm0,%xmm1
jae    1200 <main+0xc0>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbx
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 = [16 x i8] c"%.4f %.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 float 0.000000e+00, float* %5
br label %19
19: ; preds = %37, %0
%20 = load float, float* %5
%21 = load float, float* %7
%22 = fcmp ole float %20, %21
br i1 %22, label %23, label %40
23: ; preds = %19
%24 = load float, float* %5
%25 = load float, float* %4
%26 = fadd float %24, %25
store float %26, float* %5
%27 = load float, float* %6
%28 = load float, float* %4
%29 = load float, float* %6
%30 = call float @f(float %29)
%31 = call float @llvm.fmuladd.f32(float %28, float %30, float %27)
store float %31, float* %6
%32 = load float, float* %5
%33 = fpext float %32 to double
%34 = load float, float* %6
%35 = fpext float %34 to double
%36 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.8, i64 0, i64 0), double %33, double %35)
br label %37
37: ; preds = %23
%38 = load float, float* %5
%39 = fadd float %38, 1.000000e+00
store float %39, float* %5
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 = [16 x i8] c"%.4f %.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* %5
%23 = fcmp ult float %22, 0.000000e+00
br i1 %23, label %39, label %24
24: ; preds = %0, %24
%25 = phi float [ %36, %24 ], [ 0.000000e+00, %0 ]
%26 = load float, float* %2
%27 = fadd float %25, %26
store float %27, float* %3
%28 = load float, float* %4
%29 = call float @f(float %28)
%30 = call float @llvm.fmuladd.f32(float %26, float %29, float %28)
store float %30, float* %4
%31 = load float, float* %3
%32 = fpext float %31 to double
%33 = fpext float %30 to double
%34 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @.str.8, i64 0, i64 0), double %32, double %33)
%35 = load float, float* %3
%36 = fadd float %35, 1.000000e+00
store float %36, float* %3
%37 = load float, float* %5
%38 = fcmp ugt float %36, %37
br i1 %38, label %39, label %24
39: ; preds = %24, %0
ret i32 0
}