#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*/ cam16i_q(int const, int const, int const, int const,
                            int /*<<< orphan*/, int *, int *);
void cam16i_rq(const int c, const int n, const int a, const int f,
               unsigned short **d, const int r) {
  unsigned short i;
  int q, x;
  for (i = 0; i < r; i++) {
    cam16i_q(c, n, a, f, (*d)++, &x, &q);
    if (!q)
      break;
  }
}


x86 assembly (clang, -O0):
<cam16i_rq>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%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    1195 <cam16i_rq+0x85>
mov    -0x4(%rbp),%edi
mov    -0x8(%rbp),%esi
mov    -0xc(%rbp),%edx
mov    -0x10(%rbp),%ecx
mov    -0x18(%rbp),%r8
mov    (%r8),%rax
mov    %rax,%r9
add    $0x2,%r9
mov    %r9,(%r8)
mov    %eax,%r8d
lea    -0x28(%rbp),%r9
lea    -0x24(%rbp),%rax
mov    %rax,(%rsp)
call   1030 <cam16i_q@plt>
cmpl   $0x0,-0x24(%rbp)
jne    117f <cam16i_rq+0x6f>
jmp    1195 <cam16i_rq+0x85>
jmp    1184 <cam16i_rq+0x74>
mov    -0x1e(%rbp),%ax
add    $0x1,%ax
mov    %ax,-0x1e(%rbp)
jmp    1132 <cam16i_rq+0x22>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<cam16i_rq>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %ecx,0xc(%rsp)
test   %r9d,%r9d
jle    1180 <cam16i_rq+0x70>
mov    %r8,%rbx
mov    %edx,%r12d
mov    %esi,%r13d
mov    %edi,%ebp
mov    %r9d,%r15d
mov    $0x1,%r14w
nopw   0x0(%rax,%rax,1)
mov    (%rbx),%r8
lea    0x2(%r8),%rax
mov    %rax,(%rbx)
lea    0x10(%rsp),%rax
mov    %rax,(%rsp)
mov    %ebp,%edi
mov    %r13d,%esi
mov    %r12d,%edx
mov    0xc(%rsp),%ecx
lea    0x14(%rsp),%r9
call   1030 <cam16i_q@plt>
cmpl   $0x0,0x10(%rsp)
je     1180 <cam16i_rq+0x70>
movzwl %r14w,%eax
lea    0x1(%r14),%ecx
mov    %ecx,%r14d
cmp    %r15d,%eax
jl     1140 <cam16i_rq+0x30>
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define void @cam16i_rq(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
%14 = alloca i32
%15 = alloca i32
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 %16
16: ; preds = %35, %6
%17 = load i16, i16* %13
%18 = zext i16 %17 to i32
%19 = load i32, i32* %12
%20 = icmp slt i32 %18, %19
br i1 %20, label %21, label %38
21: ; preds = %16
%22 = load i32, i32* %7
%23 = load i32, i32* %8
%24 = load i32, i32* %9
%25 = load i32, i32* %10
%26 = load i16**, i16*** %11
%27 = load i16*, i16** %26
%28 = getelementptr inbounds i16, i16* %27, i32 1
store i16* %28, i16** %26
%29 = ptrtoint i16* %27 to i32
%30 = call i32 @cam16i_q(i32 %22, i32 %23, i32 %24, i32 %25, i32 %29, i32* %15, i32* %14)
%31 = load i32, i32* %14
%32 = icmp ne i32 %31, 0
br i1 %32, label %34, label %33
33: ; preds = %21
br label %38
34: ; preds = %21
br label %35
35: ; preds = %34
%36 = load i16, i16* %13
%37 = add i16 %36, 1
store i16 %37, i16* %13
br label %16
38: ; preds = %33, %16
ret void
}

LLVM IR (-O2):
define void @cam16i_rq(i32 %0, i32 %1, i32 %2, i32 %3, i16** nocapture %4, i32 %5) {
%7 = alloca i32
%8 = alloca i32
%9 = bitcast i32* %7 to i8*
%10 = bitcast i32* %8 to i8*
%11 = icmp sgt i32 %5, 0
br i1 %11, label %12, label %25
12: ; preds = %6, %12
%13 = phi i16 [ %21, %12 ], [ 0, %6 ]
%14 = load i16*, i16** %4
%15 = getelementptr inbounds i16, i16* %14, i64 1
store i16* %15, i16** %4
%16 = ptrtoint i16* %14 to i64
%17 = trunc i64 %16 to i32
%18 = call i32 @cam16i_q(i32 %0, i32 %1, i32 %2, i32 %3, i32 %17, i32* %8, i32* %7)
%19 = load i32, i32* %7
%20 = icmp ne i32 %19, 0
%21 = add i16 %13, 1
%22 = zext i16 %21 to i32
%23 = icmp slt i32 %22, %5
%24 = select i1 %20, i1 %23, i1 false
br i1 %24, label %12, label %25
25: ; preds = %12, %6
ret void
}