#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 */
scalar_t__ calloc(int, int);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ scanf(char *, double *);
void Euller(double h, int n) {
  double *y, *x;
  int i;
  y = (double *)calloc(n + 1, sizeof(double));
  x = (double *)calloc(n, sizeof(double));
  printf("\nValores Iniciais:\n");
  printf("Entre com x0: ");
  scanf("%lf", &x[0]);
  printf("Entre com y(x0): ");
  scanf("%lf", &y[0]);
  printf("\nIteracoes\n");
  for (i = 1; i < n; i++) {
    x[i] += x[i - 1] + h;
  }
  for (i = 1; i <= n; i++) {
    y[i] = y[i - 1] + h * (4 - 2 * x[i - 1]);
    printf("y%d = %lf\n", i, y[i]);
  }
}


x86 assembly (clang, -O0):
<Euller>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movsd  %xmm0,-0x8(%rbp)
mov    %edi,-0xc(%rbp)
mov    -0xc(%rbp),%edi
add    $0x1,%edi
mov    $0x8,%esi
call   1040 <calloc@plt>
mov    %rax,-0x18(%rbp)
mov    -0xc(%rbp),%edi
mov    $0x8,%esi
call   1040 <calloc@plt>
mov    %rax,-0x20(%rbp)
lea    0xe9c(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xea2(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x20(%rbp),%rsi
lea    0xe9f(%rip),%rdi
call   1050 <scanf@plt>
lea    0xe97(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x18(%rbp),%rsi
lea    0xe81(%rip),%rdi
call   1050 <scanf@plt>
lea    0xe8b(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x1,-0x24(%rbp)
mov    -0x24(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    1207 <Euller+0xd7>
mov    -0x20(%rbp),%rax
mov    -0x24(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
movsd  (%rax,%rcx,8),%xmm0
addsd  -0x8(%rbp),%xmm0
mov    -0x20(%rbp),%rax
movslq -0x24(%rbp),%rcx
addsd  (%rax,%rcx,8),%xmm0
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    11c4 <Euller+0x94>
movl   $0x1,-0x24(%rbp)
mov    -0x24(%rbp),%eax
cmp    -0xc(%rbp),%eax
jg     1294 <Euller+0x164>
mov    -0x18(%rbp),%rax
mov    -0x24(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
movsd  (%rax,%rcx,8),%xmm1
movsd  -0x8(%rbp),%xmm0
mov    -0x20(%rbp),%rax
mov    -0x24(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
movsd  (%rax,%rcx,8),%xmm3
addsd  %xmm3,%xmm3
movsd  0xdb1(%rip),%xmm2
subsd  %xmm3,%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
mov    -0x18(%rbp),%rax
movslq -0x24(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x24(%rbp),%esi
mov    -0x18(%rbp),%rax
movslq -0x24(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
lea    0xdce(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    120e <Euller+0xde>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<Euller>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x10,%rsp
mov    %edi,%r12d
movsd  %xmm0,0x8(%rsp)
lea    0x1(%r12),%r15d
mov    %r15d,%edi
mov    $0x8,%esi
call   1050 <calloc@plt>
mov    %rax,%r14
mov    %r12d,%edi
mov    $0x8,%esi
call   1050 <calloc@plt>
mov    %rax,%rbx
lea    0xeb7(%rip),%rdi
call   1030 <puts@plt>
lea    0xe7b(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xe7c(%rip),%rbp
mov    %rbp,%rdi
mov    %rbx,%rsi
call   1060 <scanf@plt>
lea    0xe6e(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %rbp,%rdi
mov    %r14,%rsi
call   1060 <scanf@plt>
lea    0xe85(%rip),%rdi
call   1030 <puts@plt>
movsd  0x8(%rsp),%xmm2
cmp    $0x2,%r12d
jl     1277 <Euller+0x137>
mov    %r12d,%esi
movsd  (%rbx),%xmm0
lea    -0x1(%rsi),%rdx
add    $0xfffffffffffffffe,%rsi
mov    %edx,%eax
and    $0x3,%eax
mov    $0x1,%ecx
cmp    $0x3,%rsi
jb     124d <Euller+0x10d>
and    $0xfffffffffffffffc,%rdx
xor    %ecx,%ecx
addsd  %xmm2,%xmm0
addsd  0x8(%rbx,%rcx,8),%xmm0
movsd  %xmm0,0x8(%rbx,%rcx,8)
addsd  %xmm2,%xmm0
addsd  0x10(%rbx,%rcx,8),%xmm0
movsd  %xmm0,0x10(%rbx,%rcx,8)
addsd  %xmm2,%xmm0
addsd  0x18(%rbx,%rcx,8),%xmm0
movsd  %xmm0,0x18(%rbx,%rcx,8)
addsd  %xmm2,%xmm0
addsd  0x20(%rbx,%rcx,8),%xmm0
movsd  %xmm0,0x20(%rbx,%rcx,8)
add    $0x4,%rcx
cmp    %rcx,%rdx
jne    1200 <Euller+0xc0>
add    $0x1,%rcx
test   %rax,%rax
je     1277 <Euller+0x137>
lea    (%rbx,%rcx,8),%rcx
xor    %edx,%edx
nopl   0x0(%rax,%rax,1)
addsd  %xmm2,%xmm0
addsd  (%rcx,%rdx,8),%xmm0
movsd  %xmm0,(%rcx,%rdx,8)
add    $0x1,%rdx
cmp    %rdx,%rax
jne    1260 <Euller+0x120>
test   %r12d,%r12d
jle    12d2 <Euller+0x192>
mov    %r15d,%r12d
mov    $0x1,%ebp
lea    0xda2(%rip),%r15
nopl   0x0(%rax,%rax,1)
movsd  -0x8(%rbx,%rbp,8),%xmm1
addsd  %xmm1,%xmm1
movsd  0xd5e(%rip),%xmm0
subsd  %xmm1,%xmm0
mulsd  %xmm2,%xmm0
addsd  -0x8(%r14,%rbp,8),%xmm0
movsd  %xmm0,(%r14,%rbp,8)
mov    %r15,%rdi
mov    %ebp,%esi
mov    $0x1,%al
call   1040 <printf@plt>
movsd  0x8(%rsp),%xmm2
add    $0x1,%rbp
cmp    %rbp,%r12
jne    1290 <Euller+0x150>
add    $0x10,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [20 x i8] c"\0AValores Iniciais:\0A\00"
@.str.1 = [15 x i8] c"Entre com x0: \00"
@.str.2 = [4 x i8] c"%lf\00"
@.str.3 = [18 x i8] c"Entre com y(x0): \00"
@.str.4 = [12 x i8] c"\0AIteracoes\0A\00"
@.str.5 = [11 x i8] c"y%d = %lf\0A\00"
define void @Euller(double %0, i32 %1) {
%3 = alloca double
%4 = alloca i32
%5 = alloca double*
%6 = alloca double*
%7 = alloca i32
store double %0, double* %3
store i32 %1, i32* %4
%8 = load i32, i32* %4
%9 = add nsw i32 %8, 1
%10 = call i64 @calloc(i32 %9, i32 8)
%11 = inttoptr i64 %10 to double*
store double* %11, double** %5
%12 = load i32, i32* %4
%13 = call i64 @calloc(i32 %12, i32 8)
%14 = inttoptr i64 %13 to double*
store double* %14, double** %6
%15 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0))
%16 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.1, i64 0, i64 0))
%17 = load double*, double** %6
%18 = getelementptr inbounds double, double* %17, i64 0
%19 = call i32 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), double* %18)
%20 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.3, i64 0, i64 0))
%21 = load double*, double** %5
%22 = getelementptr inbounds double, double* %21, i64 0
%23 = call i32 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), double* %22)
%24 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.4, i64 0, i64 0))
store i32 1, i32* %7
br label %25
25: ; preds = %44, %2
%26 = load i32, i32* %7
%27 = load i32, i32* %4
%28 = icmp slt i32 %26, %27
br i1 %28, label %29, label %47
29: ; preds = %25
%30 = load double*, double** %6
%31 = load i32, i32* %7
%32 = sub nsw i32 %31, 1
%33 = sext i32 %32 to i64
%34 = getelementptr inbounds double, double* %30, i64 %33
%35 = load double, double* %34
%36 = load double, double* %3
%37 = fadd double %35, %36
%38 = load double*, double** %6
%39 = load i32, i32* %7
%40 = sext i32 %39 to i64
%41 = getelementptr inbounds double, double* %38, i64 %40
%42 = load double, double* %41
%43 = fadd double %42, %37
store double %43, double* %41
br label %44
44: ; preds = %29
%45 = load i32, i32* %7
%46 = add nsw i32 %45, 1
store i32 %46, i32* %7
br label %25
47: ; preds = %25
store i32 1, i32* %7
br label %48
48: ; preds = %79, %47
%49 = load i32, i32* %7
%50 = load i32, i32* %4
%51 = icmp sle i32 %49, %50
br i1 %51, label %52, label %82
52: ; preds = %48
%53 = load double*, double** %5
%54 = load i32, i32* %7
%55 = sub nsw i32 %54, 1
%56 = sext i32 %55 to i64
%57 = getelementptr inbounds double, double* %53, i64 %56
%58 = load double, double* %57
%59 = load double, double* %3
%60 = load double*, double** %6
%61 = load i32, i32* %7
%62 = sub nsw i32 %61, 1
%63 = sext i32 %62 to i64
%64 = getelementptr inbounds double, double* %60, i64 %63
%65 = load double, double* %64
%66 = call double @llvm.fmuladd.f64(double -2.000000e+00, double %65, double 4.000000e+00)
%67 = call double @llvm.fmuladd.f64(double %59, double %66, double %58)
%68 = load double*, double** %5
%69 = load i32, i32* %7
%70 = sext i32 %69 to i64
%71 = getelementptr inbounds double, double* %68, i64 %70
store double %67, double* %71
%72 = load i32, i32* %7
%73 = load double*, double** %5
%74 = load i32, i32* %7
%75 = sext i32 %74 to i64
%76 = getelementptr inbounds double, double* %73, i64 %75
%77 = load double, double* %76
%78 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.5, i64 0, i64 0), i32 %72, double %77)
br label %79
79: ; preds = %52
%80 = load i32, i32* %7
%81 = add nsw i32 %80, 1
store i32 %81, i32* %7
br label %48
82: ; preds = %48
ret void
}

LLVM IR (-O2):
@.str.1 = [15 x i8] c"Entre com x0: \00"
@.str.2 = [4 x i8] c"%lf\00"
@.str.3 = [18 x i8] c"Entre com y(x0): \00"
@.str.5 = [11 x i8] c"y%d = %lf\0A\00"
@str = [19 x i8] c"\0AValores Iniciais:\00"
@str.6 = [11 x i8] c"\0AIteracoes\00"
define void @Euller(double %0, i32 %1) {
%3 = add i32 %1, 1
%4 = tail call i64 @calloc(i32 %3, i32 8)
%5 = inttoptr i64 %4 to double*
%6 = tail call i64 @calloc(i32 %1, i32 8)
%7 = inttoptr i64 %6 to double*
%8 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @str, i64 0, i64 0))
%9 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @.str.1, i64 0, i64 0))
%10 = tail call i32 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), double* %7)
%11 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @.str.3, i64 0, i64 0))
%12 = tail call i32 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), double* %5)
%13 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @str.6, i64 0, i64 0))
%14 = icmp sgt i32 %1, 1
br i1 %14, label %15, label %39
15: ; preds = %2
%16 = zext i32 %1 to i64
%17 = load double, double* %7
%18 = add nsw i64 %16, -1
%19 = add nsw i64 %16, -2
%20 = and i64 %18, 3
%21 = icmp ult i64 %19, 3
br i1 %21, label %24, label %22
22: ; preds = %15
%23 = and i64 %18, -4
br label %43
24: ; preds = %43, %15
%25 = phi double [ %17, %15 ], [ %65, %43 ]
%26 = phi i64 [ 1, %15 ], [ %66, %43 ]
%27 = icmp eq i64 %20, 0
br i1 %27, label %39, label %28
28: ; preds = %24, %28
%29 = phi double [ %35, %28 ], [ %25, %24 ]
%30 = phi i64 [ %36, %28 ], [ %26, %24 ]
%31 = phi i64 [ %37, %28 ], [ 0, %24 ]
%32 = fadd double %29, %0
%33 = getelementptr inbounds double, double* %7, i64 %30
%34 = load double, double* %33
%35 = fadd double %34, %32
store double %35, double* %33
%36 = add nuw nsw i64 %30, 1
%37 = add i64 %31, 1
%38 = icmp eq i64 %37, %20
br i1 %38, label %39, label %28
39: ; preds = %24, %28, %2
%40 = icmp slt i32 %1, 1
br i1 %40, label %83, label %41
41: ; preds = %39
%42 = zext i32 %3 to i64
br label %69
43: ; preds = %43, %22
%44 = phi double [ %17, %22 ], [ %65, %43 ]
%45 = phi i64 [ 1, %22 ], [ %66, %43 ]
%46 = phi i64 [ 0, %22 ], [ %67, %43 ]
%47 = fadd double %44, %0
%48 = getelementptr inbounds double, double* %7, i64 %45
%49 = load double, double* %48
%50 = fadd double %49, %47
store double %50, double* %48
%51 = add nuw nsw i64 %45, 1
%52 = fadd double %50, %0
%53 = getelementptr inbounds double, double* %7, i64 %51
%54 = load double, double* %53
%55 = fadd double %54, %52
store double %55, double* %53
%56 = add nuw nsw i64 %45, 2
%57 = fadd double %55, %0
%58 = getelementptr inbounds double, double* %7, i64 %56
%59 = load double, double* %58
%60 = fadd double %59, %57
store double %60, double* %58
%61 = add nuw nsw i64 %45, 3
%62 = fadd double %60, %0
%63 = getelementptr inbounds double, double* %7, i64 %61
%64 = load double, double* %63
%65 = fadd double %64, %62
store double %65, double* %63
%66 = add nuw nsw i64 %45, 4
%67 = add i64 %46, 4
%68 = icmp eq i64 %67, %23
br i1 %68, label %24, label %43
69: ; preds = %41, %69
%70 = phi i64 [ 1, %41 ], [ %81, %69 ]
%71 = add nsw i64 %70, -1
%72 = getelementptr inbounds double, double* %5, i64 %71
%73 = load double, double* %72
%74 = getelementptr inbounds double, double* %7, i64 %71
%75 = load double, double* %74
%76 = tail call double @llvm.fmuladd.f64(double %75, double -2.000000e+00, double 4.000000e+00)
%77 = tail call double @llvm.fmuladd.f64(double %0, double %76, double %73)
%78 = getelementptr inbounds double, double* %5, i64 %70
store double %77, double* %78
%79 = trunc i64 %70 to i32
%80 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @.str.5, i64 0, i64 0), i32 %79, double %77)
%81 = add nuw nsw i64 %70, 1
%82 = icmp eq i64 %81, %42
br i1 %82, label %83, label %69
83: ; preds = %69, %39
ret void
}