#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 pow(double, double);
void first_iteration(double *u_present, double *u_initial, double n_x,
                     double r) {
  int i;
  for (i = 1; i < n_x - 1; i++) {
    u_present[i] = u_initial[i] + pow(r, 2.0) / 2.0 *
                                      (u_initial[i + 1] - 2.0 * u_initial[i] +
                                       u_initial[i - 1]);
  }
}


x86 assembly (clang, -O0):
<first_iteration>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movsd  %xmm0,-0x18(%rbp)
movsd  %xmm1,-0x20(%rbp)
movl   $0x1,-0x24(%rbp)
cvtsi2sdl -0x24(%rbp),%xmm1
movsd  -0x18(%rbp),%xmm0
movsd  0xebd(%rip),%xmm2
subsd  %xmm2,%xmm0
ucomisd %xmm1,%xmm0
jbe    11e2 <first_iteration+0xd2>
mov    -0x10(%rbp),%rax
movslq -0x24(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
movsd  %xmm0,-0x30(%rbp)
movsd  -0x20(%rbp),%xmm0
movsd  0xe98(%rip),%xmm1
call   1030 <pow@plt>
movsd  -0x30(%rbp),%xmm1
movsd  0xe86(%rip),%xmm2
divsd  %xmm2,%xmm0
mov    -0x10(%rbp),%rax
mov    -0x24(%rbp),%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
movsd  (%rax,%rcx,8),%xmm2
mov    -0x10(%rbp),%rax
movslq -0x24(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm3
addsd  %xmm3,%xmm3
subsd  %xmm3,%xmm2
mov    -0x10(%rbp),%rax
mov    -0x24(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
addsd  (%rax,%rcx,8),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
mov    -0x8(%rbp),%rax
movslq -0x24(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    1131 <first_iteration+0x21>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<first_iteration>:
addsd  0xef8(%rip),%xmm0
ucomisd 0xef8(%rip),%xmm0
jbe    116c <first_iteration+0x6c>
mulsd  %xmm1,%xmm1
mulsd  0xef2(%rip),%xmm1
mov    $0x2,%eax
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
movsd  -0x8(%rsi,%rax,8),%xmm2
movsd  (%rsi,%rax,8),%xmm3
movapd %xmm2,%xmm4
addsd  %xmm2,%xmm4
subsd  %xmm4,%xmm3
addsd  -0x10(%rsi,%rax,8),%xmm3
mulsd  %xmm1,%xmm3
addsd  %xmm2,%xmm3
xorps  %xmm2,%xmm2
cvtsi2sd %eax,%xmm2
movsd  %xmm3,-0x8(%rdi,%rax,8)
add    $0x1,%rax
ucomisd %xmm2,%xmm0
ja     1130 <first_iteration+0x30>
ret

LLVM IR (-O0):
define void @first_iteration(double* %0, double* %1, double %2, double %3) {
%5 = alloca double*
%6 = alloca double*
%7 = alloca double
%8 = alloca double
%9 = alloca i32
store double* %0, double** %5
store double* %1, double** %6
store double %2, double* %7
store double %3, double* %8
store i32 1, i32* %9
br label %10
10: ; preds = %49, %4
%11 = load i32, i32* %9
%12 = sitofp i32 %11 to double
%13 = load double, double* %7
%14 = fsub double %13, 1.000000e+00
%15 = fcmp olt double %12, %14
br i1 %15, label %16, label %52
16: ; preds = %10
%17 = load double*, double** %6
%18 = load i32, i32* %9
%19 = sext i32 %18 to i64
%20 = getelementptr inbounds double, double* %17, i64 %19
%21 = load double, double* %20
%22 = load double, double* %8
%23 = call double @pow(double %22, double 2.000000e+00)
%24 = fdiv double %23, 2.000000e+00
%25 = load double*, double** %6
%26 = load i32, i32* %9
%27 = add nsw i32 %26, 1
%28 = sext i32 %27 to i64
%29 = getelementptr inbounds double, double* %25, i64 %28
%30 = load double, double* %29
%31 = load double*, double** %6
%32 = load i32, i32* %9
%33 = sext i32 %32 to i64
%34 = getelementptr inbounds double, double* %31, i64 %33
%35 = load double, double* %34
%36 = call double @llvm.fmuladd.f64(double -2.000000e+00, double %35, double %30)
%37 = load double*, double** %6
%38 = load i32, i32* %9
%39 = sub nsw i32 %38, 1
%40 = sext i32 %39 to i64
%41 = getelementptr inbounds double, double* %37, i64 %40
%42 = load double, double* %41
%43 = fadd double %36, %42
%44 = call double @llvm.fmuladd.f64(double %24, double %43, double %21)
%45 = load double*, double** %5
%46 = load i32, i32* %9
%47 = sext i32 %46 to i64
%48 = getelementptr inbounds double, double* %45, i64 %47
store double %44, double* %48
br label %49
49: ; preds = %16
%50 = load i32, i32* %9
%51 = add nsw i32 %50, 1
store i32 %51, i32* %9
br label %10
52: ; preds = %10
ret void
}

LLVM IR (-O2):
define void @first_iteration(double* nocapture writeonly %0, double* nocapture %1, double %2, double %3) {
%5 = fadd double %2, -1.000000e+00
%6 = fcmp ogt double %5, 1.000000e+00
br i1 %6, label %7, label %27
7: ; preds = %4
%8 = fmul double %3, %3
%9 = fmul double %8, 5.000000e-01
br label %10
10: ; preds = %7, %10
%11 = phi i64 [ 1, %7 ], [ %14, %10 ]
%12 = getelementptr inbounds double, double* %1, i64 %11
%13 = load double, double* %12
%14 = add nuw nsw i64 %11, 1
%15 = getelementptr inbounds double, double* %1, i64 %14
%16 = load double, double* %15
%17 = tail call double @llvm.fmuladd.f64(double %13, double -2.000000e+00, double %16)
%18 = add nsw i64 %11, -1
%19 = getelementptr inbounds double, double* %1, i64 %18
%20 = load double, double* %19
%21 = fadd double %17, %20
%22 = tail call double @llvm.fmuladd.f64(double %9, double %21, double %13)
%23 = getelementptr inbounds double, double* %0, i64 %11
store double %22, double* %23
%24 = trunc i64 %14 to i32
%25 = sitofp i32 %24 to double
%26 = fcmp ogt double %5, %25
br i1 %26, label %10, label %27
27: ; preds = %10, %4
ret void
}