#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 limdiff(float const, float const, float const);
void limited_deriv1(float *restrict du, const float *restrict u, int ncell) {
  for (int i = 0; i < ncell; ++i)
    du[i] = limdiff(u[i - 1], u[i], u[i + 1]);
}


x86 assembly (clang, -O0):
<limited_deriv1>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
movl   $0x0,-0x18(%rbp)
mov    -0x18(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    1187 <limited_deriv1+0x77>
mov    -0x10(%rbp),%rax
mov    -0x18(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
movss  (%rax,%rcx,4),%xmm0
mov    -0x10(%rbp),%rax
movslq -0x18(%rbp),%rcx
movss  (%rax,%rcx,4),%xmm1
mov    -0x10(%rbp),%rax
mov    -0x18(%rbp),%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
movss  (%rax,%rcx,4),%xmm2
call   1030 <limdiff@plt>
mov    -0x8(%rbp),%rax
movslq -0x18(%rbp),%rcx
movss  %xmm0,(%rax,%rcx,4)
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    112a <limited_deriv1+0x1a>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<limited_deriv1>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x10,%rsp
test   %edx,%edx
jle    1176 <limited_deriv1+0x66>
mov    %rsi,%r15
mov    %rdi,%r14
mov    %edx,%r12d
movss  -0x4(%rsi),%xmm0
movss  (%rsi),%xmm1
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
nop
movss  %xmm1,0xc(%rsp)
lea    0x1(%rbx),%r13
movss  0x4(%r15,%rbx,4),%xmm2
movss  %xmm2,0x8(%rsp)
call   1030 <limdiff@plt>
movss  0x8(%rsp),%xmm1
movss  %xmm0,(%r14,%rbx,4)
movss  0xc(%rsp),%xmm0
mov    %r13,%rbx
cmp    %r13,%r12
jne    1140 <limited_deriv1+0x30>
add    $0x10,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define void @limited_deriv1(float* noalias %0, float* noalias %1, i32 %2) {
%4 = alloca float*
%5 = alloca float*
%6 = alloca i32
%7 = alloca i32
store float* %0, float** %4
store float* %1, float** %5
store i32 %2, i32* %6
store i32 0, i32* %7
br label %8
8: ; preds = %35, %3
%9 = load i32, i32* %7
%10 = load i32, i32* %6
%11 = icmp slt i32 %9, %10
br i1 %11, label %12, label %38
12: ; preds = %8
%13 = load float*, float** %5
%14 = load i32, i32* %7
%15 = sub nsw i32 %14, 1
%16 = sext i32 %15 to i64
%17 = getelementptr inbounds float, float* %13, i64 %16
%18 = load float, float* %17
%19 = load float*, float** %5
%20 = load i32, i32* %7
%21 = sext i32 %20 to i64
%22 = getelementptr inbounds float, float* %19, i64 %21
%23 = load float, float* %22
%24 = load float*, float** %5
%25 = load i32, i32* %7
%26 = add nsw i32 %25, 1
%27 = sext i32 %26 to i64
%28 = getelementptr inbounds float, float* %24, i64 %27
%29 = load float, float* %28
%30 = call float @limdiff(float %18, float %23, float %29)
%31 = load float*, float** %4
%32 = load i32, i32* %7
%33 = sext i32 %32 to i64
%34 = getelementptr inbounds float, float* %31, i64 %33
store float %30, float* %34
br label %35
35: ; preds = %12
%36 = load i32, i32* %7
%37 = add nsw i32 %36, 1
store i32 %37, i32* %7
br label %8
38: ; preds = %8
ret void
}

LLVM IR (-O2):
define void @limited_deriv1(float* noalias nocapture writeonly %0, float* noalias nocapture %1, i32 %2) {
%4 = icmp sgt i32 %2, 0
br i1 %4, label %5, label %10
5: ; preds = %3
%6 = zext i32 %2 to i64
%7 = getelementptr inbounds float, float* %1, i64 -1
%8 = load float, float* %7
%9 = load float, float* %1
br label %11
10: ; preds = %11, %3
ret void
11: ; preds = %5, %11
%12 = phi float [ %9, %5 ], [ %17, %11 ]
%13 = phi float [ %8, %5 ], [ %12, %11 ]
%14 = phi i64 [ 0, %5 ], [ %15, %11 ]
%15 = add nuw nsw i64 %14, 1
%16 = getelementptr inbounds float, float* %1, i64 %15
%17 = load float, float* %16
%18 = tail call float @limdiff(float %13, float %12, float %17)
%19 = getelementptr inbounds float, float* %0, i64 %14
store float %18, float* %19
%20 = icmp eq i64 %15, %6
br i1 %20, label %10, label %11
}