#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 getvlrelem(int, long, long *, unsigned char *);
int read_blk2len(unsigned char *);
int read_blk2len_compression(unsigned char *);
int getvlrsize(int fp, long pos, int compression) {
  unsigned char datablk[1024];
  long actual_len;
  if (!pos)
    return 0;
  if ((getvlrelem(fp, pos, &pos, datablk)) == -1)
    return 0;
  if (compression) {
    int size;
    size = read_blk2len_compression(datablk);
    return (((size) > (read_blk2len(datablk))) ? (size)
                                               : (read_blk2len(datablk)));
  } else
    return read_blk2len(datablk);
}


x86 assembly (clang, -O0):
<getvlrsize>:
push   %rbp
mov    %rsp,%rbp
sub    $0x440,%rsp
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    115c <getvlrsize+0x2c>
movl   $0x0,-0x4(%rbp)
jmp    120c <getvlrsize+0xdc>
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%rsi
lea    -0x420(%rbp),%rcx
lea    -0x10(%rbp),%rdx
call   1050 <getvlrelem@plt>
cmp    $0xffffffff,%eax
jne    1188 <getvlrsize+0x58>
movl   $0x0,-0x4(%rbp)
jmp    120c <getvlrsize+0xdc>
cmpl   $0x0,-0x14(%rbp)
je     11fd <getvlrsize+0xcd>
lea    -0x420(%rbp),%rdi
call   1030 <read_blk2len_compression@plt>
mov    %eax,-0x42c(%rbp)
mov    -0x42c(%rbp),%eax
mov    %eax,-0x430(%rbp)
lea    -0x420(%rbp),%rdi
call   1040 <read_blk2len@plt>
mov    %eax,%ecx
mov    -0x430(%rbp),%eax
cmp    %ecx,%eax
jle    11dd <getvlrsize+0xad>
mov    -0x42c(%rbp),%eax
mov    %eax,-0x434(%rbp)
jmp    11ef <getvlrsize+0xbf>
lea    -0x420(%rbp),%rdi
call   1040 <read_blk2len@plt>
mov    %eax,-0x434(%rbp)
mov    -0x434(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    120c <getvlrsize+0xdc>
lea    -0x420(%rbp),%rdi
call   1040 <read_blk2len@plt>
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x440,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<getvlrsize>:
push   %rbp
push   %rbx
sub    $0x418,%rsp
mov    %rsi,0x8(%rsp)
xor    %ebx,%ebx
test   %rsi,%rsi
je     1186 <getvlrsize+0x56>
mov    %edx,%ebp
lea    0x8(%rsp),%rdx
lea    0x10(%rsp),%rcx
call   1050 <getvlrelem@plt>
cmp    $0xffffffff,%eax
je     1186 <getvlrsize+0x56>
test   %ebp,%ebp
je     117a <getvlrsize+0x4a>
lea    0x10(%rsp),%rbp
mov    %rbp,%rdi
call   1030 <read_blk2len_compression@plt>
mov    %eax,%ebx
mov    %rbp,%rdi
call   1040 <read_blk2len@plt>
cmp    %eax,%ebx
jg     1186 <getvlrsize+0x56>
lea    0x10(%rsp),%rdi
call   1040 <read_blk2len@plt>
mov    %eax,%ebx
mov    %ebx,%eax
add    $0x418,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
define i32 @getvlrsize(i32 %0, i64 %1, i32 %2) {
%4 = alloca i32
%5 = alloca i32
%6 = alloca i64
%7 = alloca i32
%8 = alloca [1024 x i8]
%9 = alloca i64
%10 = alloca i32
store i32 %0, i32* %5
store i64 %1, i64* %6
store i32 %2, i32* %7
%11 = load i64, i64* %6
%12 = icmp ne i64 %11, 0
br i1 %12, label %14, label %13
13: ; preds = %3
store i32 0, i32* %4
br label %41
14: ; preds = %3
%15 = load i32, i32* %5
%16 = load i64, i64* %6
%17 = getelementptr inbounds [1024 x i8], [1024 x i8]* %8, i64 0, i64 0
%18 = call i32 @getvlrelem(i32 %15, i64 %16, i64* %6, i8* %17)
%19 = icmp eq i32 %18, -1
br i1 %19, label %20, label %21
20: ; preds = %14
store i32 0, i32* %4
br label %41
21: ; preds = %14
%22 = load i32, i32* %7
%23 = icmp ne i32 %22, 0
br i1 %23, label %24, label %38
24: ; preds = %21
%25 = getelementptr inbounds [1024 x i8], [1024 x i8]* %8, i64 0, i64 0
%26 = call i32 @read_blk2len_compression(i8* %25)
store i32 %26, i32* %10
%27 = load i32, i32* %10
%28 = getelementptr inbounds [1024 x i8], [1024 x i8]* %8, i64 0, i64 0
%29 = call i32 @read_blk2len(i8* %28)
%30 = icmp sgt i32 %27, %29
br i1 %30, label %31, label %33
31: ; preds = %24
%32 = load i32, i32* %10
br label %36
33: ; preds = %24
%34 = getelementptr inbounds [1024 x i8], [1024 x i8]* %8, i64 0, i64 0
%35 = call i32 @read_blk2len(i8* %34)
br label %36
36: ; preds = %33, %31
%37 = phi i32 [ %32, %31 ], [ %35, %33 ]
store i32 %37, i32* %4
br label %41
38: ; preds = %21
%39 = getelementptr inbounds [1024 x i8], [1024 x i8]* %8, i64 0, i64 0
%40 = call i32 @read_blk2len(i8* %39)
store i32 %40, i32* %4
br label %41
41: ; preds = %38, %36, %20, %13
%42 = load i32, i32* %4
ret i32 %42
}

LLVM IR (-O2):
define i32 @getvlrsize(i32 %0, i64 %1, i32 %2) {
%4 = alloca i64
%5 = alloca [1024 x i8]
store i64 %1, i64* %4
%6 = getelementptr inbounds [1024 x i8], [1024 x i8]* %5, i64 0, i64 0
%7 = icmp eq i64 %1, 0
br i1 %7, label %19, label %8
8: ; preds = %3
%9 = call i32 @getvlrelem(i32 %0, i64 %1, i64* %4, i8* %6)
%10 = icmp eq i32 %9, -1
br i1 %10, label %19, label %11
11: ; preds = %8
%12 = icmp eq i32 %2, 0
br i1 %12, label %17, label %13
13: ; preds = %11
%14 = call i32 @read_blk2len_compression(i8* %6)
%15 = call i32 @read_blk2len(i8* %6)
%16 = icmp sgt i32 %14, %15
br i1 %16, label %19, label %17
17: ; preds = %11, %13
%18 = call i32 @read_blk2len(i8* %6)
br label %19
19: ; preds = %17, %13, %8, %3
%20 = phi i32 [ 0, %3 ], [ 0, %8 ], [ %14, %13 ], [ %18, %17 ]
ret i32 %20
}