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


x86 assembly (clang, -O0):
<limited_derivk>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    %ecx,-0x18(%rbp)
cmpl   $0x0,-0x18(%rbp)
setg   %al
and    $0x1,%al
movzbl %al,%edi
call   1040 <assert@plt>
movl   $0x0,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    11ab <limited_derivk+0x8b>
mov    -0x10(%rbp),%rax
mov    -0x1c(%rbp),%ecx
sub    -0x18(%rbp),%ecx
movslq %ecx,%rcx
movss  (%rax,%rcx,4),%xmm0
mov    -0x10(%rbp),%rax
movslq -0x1c(%rbp),%rcx
movss  (%rax,%rcx,4),%xmm1
mov    -0x10(%rbp),%rax
mov    -0x1c(%rbp),%ecx
add    -0x18(%rbp),%ecx
movslq %ecx,%rcx
movss  (%rax,%rcx,4),%xmm2
call   1030 <limdiff@plt>
mov    -0x8(%rbp),%rax
movslq -0x1c(%rbp),%rcx
movss  %xmm0,(%rax,%rcx,4)
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    114e <limited_derivk+0x2e>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<limited_derivk>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %ecx,%r15d
mov    %edx,%ebp
mov    %rsi,%r12
mov    %rdi,%r14
xor    %edi,%edi
test   %ecx,%ecx
setg   %dil
call   1040 <assert@plt>
test   %ebp,%ebp
jle    1187 <limited_derivk+0x67>
movslq %r15d,%rax
mov    %ebp,%r15d
lea    (%r12,%rax,4),%r13
shl    $0x2,%rax
mov    %r12,%rbp
sub    %rax,%rbp
xor    %ebx,%ebx
nopl   (%rax)
movss  0x0(%rbp,%rbx,4),%xmm0
movss  (%r12,%rbx,4),%xmm1
movss  0x0(%r13,%rbx,4),%xmm2
call   1030 <limdiff@plt>
movss  %xmm0,(%r14,%rbx,4)
add    $0x1,%rbx
cmp    %rbx,%r15
jne    1160 <limited_derivk+0x40>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

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