#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 */
typedef int uint8_t;
typedef scalar_t__ uint32_t;
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int /*<<< orphan*/ SEEK_CUR;
scalar_t__ fgetc(int /*<<< orphan*/ *);
int /*<<< orphan*/ fseek(int /*<<< orphan*/ *, int, int /*<<< orphan*/);
scalar_t__ read_compressed_int(int /*<<< orphan*/ *);
int skip_array(FILE *f) {
  uint8_t type;
  uint32_t num_entries;
  for (num_entries = read_compressed_int(f); num_entries > 0; num_entries--) {
    type = fgetc(f);
    if (type == 0 || type == 4)
      while (fgetc(f) != 0)
        ;
    else if (type == 1 || type == 2)
      fseek(f, 4, SEEK_CUR);
    else
      skip_array(f);
  }
  return 0;
}


x86 assembly (clang, -O0):
<skip_array>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
call   1050 <read_compressed_int@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jle    11fa <skip_array+0xba>
mov    -0x8(%rbp),%rdi
call   1030 <fgetc@plt>
mov    %eax,-0xc(%rbp)
cmpl   $0x0,-0xc(%rbp)
je     1184 <skip_array+0x44>
cmpl   $0x4,-0xc(%rbp)
jne    11a6 <skip_array+0x66>
jmp    1189 <skip_array+0x49>
mov    -0x8(%rbp),%rdi
call   1030 <fgetc@plt>
cmp    $0x0,%rax
je     11a1 <skip_array+0x61>
jmp    1189 <skip_array+0x49>
jmp    11e4 <skip_array+0xa4>
cmpl   $0x1,-0xc(%rbp)
je     11ba <skip_array+0x7a>
cmpl   $0x2,-0xc(%rbp)
jne    11d6 <skip_array+0x96>
mov    -0x8(%rbp),%rdi
mov    0x2e23(%rip),%rax
mov    (%rax),%edx
mov    $0x4,%esi
call   1060 <fseek@plt>
jmp    11df <skip_array+0x9f>
mov    -0x8(%rbp),%rdi
call   1040 <skip_array@plt>
jmp    11e4 <skip_array+0xa4>
jmp    11e9 <skip_array+0xa9>
mov    -0x18(%rbp),%rax
add    $0xffffffffffffffff,%rax
mov    %rax,-0x18(%rbp)
jmp    1159 <skip_array+0x19>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<skip_array>:
push   %r15
push   %r14
push   %rbx
mov    %rdi,%rbx
call   1050 <read_compressed_int@plt>
test   %rax,%rax
jle    11af <skip_array+0x6f>
mov    %rax,%r14
mov    0x2e8c(%rip),%r15
jmp    1175 <skip_array+0x35>
xchg   %ax,%ax
mov    %rbx,%rdi
call   1040 <skip_array@plt>
lea    -0x1(%r14),%rax
cmp    $0x1,%r14
mov    %rax,%r14
jle    11af <skip_array+0x6f>
mov    %rbx,%rdi
call   1030 <fgetc@plt>
test   $0xfffffffb,%eax
je     11a0 <skip_array+0x60>
add    $0xffffffff,%eax
cmp    $0x1,%eax
ja     1160 <skip_array+0x20>
mov    (%r15),%edx
mov    %rbx,%rdi
mov    $0x4,%esi
call   1060 <fseek@plt>
jmp    1168 <skip_array+0x28>
xchg   %ax,%ax
mov    %rbx,%rdi
call   1030 <fgetc@plt>
test   %rax,%rax
jne    11a0 <skip_array+0x60>
jmp    1168 <skip_array+0x28>
xor    %eax,%eax
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@SEEK_CUR = global i32 0
define i32 @skip_array(i32* %0) {
%2 = alloca i32*
%3 = alloca i32
%4 = alloca i64
store i32* %0, i32** %2
%5 = load i32*, i32** %2
%6 = call i64 @read_compressed_int(i32* %5)
store i64 %6, i64* %4
br label %7
7: ; preds = %41, %1
%8 = load i64, i64* %4
%9 = icmp sgt i64 %8, 0
br i1 %9, label %10, label %44
10: ; preds = %7
%11 = load i32*, i32** %2
%12 = call i64 @fgetc(i32* %11)
%13 = trunc i64 %12 to i32
store i32 %13, i32* %3
%14 = load i32, i32* %3
%15 = icmp eq i32 %14, 0
br i1 %15, label %19, label %16
16: ; preds = %10
%17 = load i32, i32* %3
%18 = icmp eq i32 %17, 4
br i1 %18, label %19, label %26
19: ; preds = %16, %10
br label %20
20: ; preds = %24, %19
%21 = load i32*, i32** %2
%22 = call i64 @fgetc(i32* %21)
%23 = icmp ne i64 %22, 0
br i1 %23, label %24, label %25
24: ; preds = %20
br label %20
25: ; preds = %20
br label %40
26: ; preds = %16
%27 = load i32, i32* %3
%28 = icmp eq i32 %27, 1
br i1 %28, label %32, label %29
29: ; preds = %26
%30 = load i32, i32* %3
%31 = icmp eq i32 %30, 2
br i1 %31, label %32, label %36
32: ; preds = %29, %26
%33 = load i32*, i32** %2
%34 = load i32, i32* @SEEK_CUR
%35 = call i32 @fseek(i32* %33, i32 4, i32 %34)
br label %39
36: ; preds = %29
%37 = load i32*, i32** %2
%38 = call i32 @skip_array(i32* %37)
br label %39
39: ; preds = %36, %32
br label %40
40: ; preds = %39, %25
br label %41
41: ; preds = %40
%42 = load i64, i64* %4
%43 = add nsw i64 %42, -1
store i64 %43, i64* %4
br label %7
44: ; preds = %7
ret i32 0
}

LLVM IR (-O2):
@SEEK_CUR = global i32 0
define i32 @skip_array(i32* %0) {
%2 = tail call i64 @read_compressed_int(i32* %0)
%3 = icmp sgt i64 %2, 0
br i1 %3, label %4, label %24
4: ; preds = %1, %21
%5 = phi i64 [ %22, %21 ], [ %2, %1 ]
%6 = tail call i64 @fgetc(i32* %0)
%7 = trunc i64 %6 to i32
%8 = and i32 %7, -5
%9 = icmp eq i32 %8, 0
br i1 %9, label %10, label %13
10: ; preds = %4, %10
%11 = tail call i64 @fgetc(i32* %0)
%12 = icmp eq i64 %11, 0
br i1 %12, label %21, label %10
13: ; preds = %4
%14 = add i32 %7, -1
%15 = icmp ult i32 %14, 2
br i1 %15, label %16, label %19
16: ; preds = %13
%17 = load i32, i32* @SEEK_CUR
%18 = tail call i32 @fseek(i32* %0, i32 4, i32 %17)
br label %21
19: ; preds = %13
%20 = tail call i32 @skip_array(i32* %0)
br label %21
21: ; preds = %10, %19, %16
%22 = add nsw i64 %5, -1
%23 = icmp sgt i64 %5, 1
br i1 %23, label %4, label %24
24: ; preds = %21, %1
ret i32 0
}