#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 */
struct huffman {
  int dummy;
};
struct bitstream {
  int dummy;
};

/* Variables and functions */
int bits_get_signed_vlc(struct bitstream *, struct huffman const *);
int bits_get_signed_vlc_array(struct bitstream *bits, int *array, int size,
                              const struct huffman *h) {
  for (int i = 0; i < size; i++)
    if ((array[i] = bits_get_signed_vlc(bits, h)) == -16384)
      return -2;
  return 0;
}


x86 assembly (clang, -O0):
<bits_get_signed_vlc_array>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %edx,-0x1c(%rbp)
mov    %rcx,-0x28(%rbp)
movl   $0x0,-0x2c(%rbp)
mov    -0x2c(%rbp),%eax
cmp    -0x1c(%rbp),%eax
jge    117c <bits_get_signed_vlc_array+0x6c>
mov    -0x10(%rbp),%rdi
mov    -0x28(%rbp),%rsi
call   1030 <bits_get_signed_vlc@plt>
mov    -0x18(%rbp),%rcx
movslq -0x2c(%rbp),%rdx
mov    %eax,(%rcx,%rdx,4)
cmp    $0xffffc000,%eax
jne    1169 <bits_get_signed_vlc_array+0x59>
movl   $0xfffffffe,-0x4(%rbp)
jmp    1183 <bits_get_signed_vlc_array+0x73>
jmp    116e <bits_get_signed_vlc_array+0x5e>
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
jmp    112e <bits_get_signed_vlc_array+0x1e>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<bits_get_signed_vlc_array>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
test   %edx,%edx
jle    114f <bits_get_signed_vlc_array+0x3f>
mov    %rcx,%r14
mov    %rsi,%r15
mov    %rdi,%r12
mov    %edx,%r13d
xor    %ebx,%ebx
nopl   0x0(%rax,%rax,1)
mov    %r12,%rdi
mov    %r14,%rsi
call   1030 <bits_get_signed_vlc@plt>
mov    %eax,(%r15,%rbx,4)
cmp    $0xffffc000,%eax
je     1153 <bits_get_signed_vlc_array+0x43>
add    $0x1,%rbx
cmp    %rbx,%r13
jne    1130 <bits_get_signed_vlc_array+0x20>
xor    %eax,%eax
jmp    1158 <bits_get_signed_vlc_array+0x48>
mov    $0xfffffffe,%eax
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
%struct.bitstream = type { i32 }
%struct.huffman = type { i32 }
define i32 @bits_get_signed_vlc_array(%struct.bitstream* %0, i32* %1, i32 %2, %struct.huffman* %3) {
%5 = alloca i32
%6 = alloca %struct.bitstream*
%7 = alloca i32*
%8 = alloca i32
%9 = alloca %struct.huffman*
%10 = alloca i32
store %struct.bitstream* %0, %struct.bitstream** %6
store i32* %1, i32** %7
store i32 %2, i32* %8
store %struct.huffman* %3, %struct.huffman** %9
store i32 0, i32* %10
br label %11
11: ; preds = %26, %4
%12 = load i32, i32* %10
%13 = load i32, i32* %8
%14 = icmp slt i32 %12, %13
br i1 %14, label %15, label %29
15: ; preds = %11
%16 = load %struct.bitstream*, %struct.bitstream** %6
%17 = load %struct.huffman*, %struct.huffman** %9
%18 = call i32 @bits_get_signed_vlc(%struct.bitstream* %16, %struct.huffman* %17)
%19 = load i32*, i32** %7
%20 = load i32, i32* %10
%21 = sext i32 %20 to i64
%22 = getelementptr inbounds i32, i32* %19, i64 %21
store i32 %18, i32* %22
%23 = icmp eq i32 %18, -16384
br i1 %23, label %24, label %25
24: ; preds = %15
store i32 -2, i32* %5
br label %30
25: ; preds = %15
br label %26
26: ; preds = %25
%27 = load i32, i32* %10
%28 = add nsw i32 %27, 1
store i32 %28, i32* %10
br label %11
29: ; preds = %11
store i32 0, i32* %5
br label %30
30: ; preds = %29, %24
%31 = load i32, i32* %5
ret i32 %31
}

LLVM IR (-O2):
%struct.bitstream = type { i32 }
%struct.huffman = type { i32 }
define i32 @bits_get_signed_vlc_array(%struct.bitstream* %0, i32* nocapture writeonly %1, i32 %2, %struct.huffman* %3) {
%5 = icmp sgt i32 %2, 0
br i1 %5, label %6, label %16
6: ; preds = %4
%7 = zext i32 %2 to i64
br label %10
8: ; preds = %10
%9 = icmp eq i64 %15, %7
br i1 %9, label %16, label %10
10: ; preds = %6, %8
%11 = phi i64 [ 0, %6 ], [ %15, %8 ]
%12 = tail call i32 @bits_get_signed_vlc(%struct.bitstream* %0, %struct.huffman* %3)
%13 = getelementptr inbounds i32, i32* %1, i64 %11
store i32 %12, i32* %13
%14 = icmp eq i32 %12, -16384
%15 = add nuw nsw i64 %11, 1
br i1 %14, label %16, label %8
16: ; preds = %8, %10, %4
%17 = phi i32 [ 0, %4 ], [ -2, %10 ], [ 0, %8 ]
ret i32 %17
}