#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*/ cami(int const, int const, int const, int const,
                        int /*<<< orphan*/);
void cam16i_sa(const int c, const int n, const int a, const int f,
               unsigned short **d, const int r) {
  unsigned short i;
  for (i = 0; i < r; i++)
    cami(c, n, a + i, f, (*d)++);
}


x86 assembly (clang, -O0):
<cam16i_sa>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %edx,-0xc(%rbp)
mov    %ecx,-0x10(%rbp)
mov    %r8,-0x18(%rbp)
mov    %r9d,-0x1c(%rbp)
movw   $0x0,-0x1e(%rbp)
movzwl -0x1e(%rbp),%eax
cmp    -0x1c(%rbp),%eax
jge    117b <cam16i_sa+0x6b>
mov    -0x4(%rbp),%edi
mov    -0x8(%rbp),%esi
mov    -0xc(%rbp),%edx
movzwl -0x1e(%rbp),%eax
add    %eax,%edx
mov    -0x10(%rbp),%ecx
mov    -0x18(%rbp),%r8
mov    (%r8),%rax
mov    %rax,%r9
add    $0x2,%r9
mov    %r9,(%r8)
mov    %eax,%r8d
call   1030 <cami@plt>
mov    -0x1e(%rbp),%ax
add    $0x1,%ax
mov    %ax,-0x1e(%rbp)
jmp    1132 <cam16i_sa+0x22>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<cam16i_sa>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
test   %r9d,%r9d
jle    116c <cam16i_sa+0x5c>
mov    %r9d,%r12d
mov    %r8,%rbx
mov    %ecx,%r15d
mov    %esi,%ebp
mov    %edi,%r13d
xor    %r14d,%r14d
mov    %rdx,(%rsp)
cs nopw 0x0(%rax,%rax,1)
nop
mov    (%rsp),%rax
lea    (%r14,%rax,1),%edx
mov    (%rbx),%r8
lea    0x2(%r8),%rax
mov    %rax,(%rbx)
mov    %r13d,%edi
mov    %ebp,%esi
mov    %r15d,%ecx
call   1030 <cami@plt>
add    $0x1,%r14d
movzwl %r14w,%r14d
cmp    %r12d,%r14d
jl     1140 <cam16i_sa+0x30>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
define void @cam16i_sa(i32 %0, i32 %1, i32 %2, i32 %3, i16** nocapture %4, i32 %5) {
%7 = icmp sgt i32 %5, 0
br i1 %7, label %8, label %19
8: ; preds = %6, %8
%9 = phi i32 [ %17, %8 ], [ 0, %6 ]
%10 = add nsw i32 %9, %2
%11 = load i16*, i16** %4
%12 = getelementptr inbounds i16, i16* %11, i64 1
store i16* %12, i16** %4
%13 = ptrtoint i16* %11 to i64
%14 = trunc i64 %13 to i32
%15 = tail call i32 @cami(i32 %0, i32 %1, i32 %10, i32 %3, i32 %14)
%16 = add nuw nsw i32 %9, 1
%17 = and i32 %16, 65535
%18 = icmp slt i32 %17, %5
br i1 %18, label %8, label %19
19: ; preds = %8, %6
ret void
}