#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 update_u(double *u_future, double *u_present, double *u_past, double n_x,
              double r) {
  int i;
  for (i = 1; i < n_x - 1; i++) {
    u_future[i] = (2.0 * (1.0 - pow(r, 2.0))) * u_present[i] - u_past[i] +
                  (pow(r, 2.0)) * (u_present[i + 1] + u_present[i - 1]);
  }
}


x86 assembly (clang, -O0):
<update_u>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
movsd  %xmm0,-0x20(%rbp)
movsd  %xmm1,-0x28(%rbp)
movl   $0x1,-0x2c(%rbp)
cvtsi2sdl -0x2c(%rbp),%xmm1
movsd  -0x20(%rbp),%xmm0
movsd  0xeb9(%rip),%xmm2
subsd  %xmm2,%xmm0
ucomisd %xmm1,%xmm0
jbe    121b <update_u+0x10b>
movsd  -0x28(%rbp),%xmm0
movsd  0xea6(%rip),%xmm1
call   1030 <pow@plt>
movsd  0xe91(%rip),%xmm1
subsd  %xmm0,%xmm1
movsd  0xe8d(%rip),%xmm0
mulsd  %xmm1,%xmm0
mov    -0x10(%rbp),%rax
movslq -0x2c(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm2
mov    -0x18(%rbp),%rax
movslq -0x2c(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm1
movq   %xmm1,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x38(%rbp)
movsd  -0x28(%rbp),%xmm0
movsd  0xe3e(%rip),%xmm1
call   1030 <pow@plt>
movsd  -0x38(%rbp),%xmm1
mov    -0x10(%rbp),%rax
mov    -0x2c(%rbp),%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
movsd  (%rax,%rcx,8),%xmm2
mov    -0x10(%rbp),%rax
mov    -0x2c(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
addsd  (%rax,%rcx,8),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
mov    -0x8(%rbp),%rax
movslq -0x2c(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
jmp    1135 <update_u+0x25>
add    $0x40,%rsp
pop    %rbp
ret

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

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

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