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

/* Variables and functions */
int EOF;
int fgetc(int /*<<< orphan*/ *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *, int);
int /*<<< orphan*/ stderr;
int mxf_read_l(FILE *mxfFile, uint8_t *llen, uint64_t *len) {
  int i;
  int c;
  uint64_t length;
  uint8_t llength;
  if (!((c = fgetc(mxfFile)) != EOF)) {
    fprintf(stderr, "'%s' failed in line %d\n", "(c = fgetc(mxfFile)) != EOF",
            151);
    return 0;
  };
  length = 0;
  llength = 1;
  if (c < 0x80) {
    length = c;
  } else {
    int bytesToRead = c & 0x7f;
    if (!(bytesToRead <= 8)) {
      fprintf(stderr, "'%s' failed in line %d\n", "bytesToRead <= 8", 162);
      return 0;
    };
    for (i = 0; i < bytesToRead; i++) {
      if (!((c = fgetc(mxfFile)) != EOF)) {
        fprintf(stderr, "'%s' failed in line %d\n",
                "(c = fgetc(mxfFile)) != EOF", 165);
        return 0;
      };
      length = length << 8;
      length = length | c;
    }
    llength += bytesToRead;
  }
  *llen = llength;
  *len = length;
  return 1;
}


x86 assembly (clang, -O0):
<mxf_read_l>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <fgetc@plt>
mov    %eax,-0x28(%rbp)
mov    0x2ea1(%rip),%rcx
cmp    (%rcx),%eax
jne    117c <mxf_read_l+0x5c>
mov    0x2e82(%rip),%rax
mov    (%rax),%edi
lea    0xea1(%rip),%rsi
lea    0xeb2(%rip),%rdx
mov    $0x97,%ecx
call   1040 <fprintf@plt>
movl   $0x0,-0x4(%rbp)
jmp    127f <mxf_read_l+0x15f>
movl   $0x0,-0x2c(%rbp)
movl   $0x1,-0x30(%rbp)
cmpl   $0x80,-0x28(%rbp)
jge    11a2 <mxf_read_l+0x82>
mov    -0x28(%rbp),%eax
mov    %eax,-0x2c(%rbp)
jmp    1266 <mxf_read_l+0x146>
mov    -0x28(%rbp),%eax
and    $0x7f,%eax
mov    %eax,-0x34(%rbp)
cmpl   $0x8,-0x34(%rbp)
jle    11e2 <mxf_read_l+0xc2>
mov    0x2e1c(%rip),%rax
mov    (%rax),%edi
lea    0xe3b(%rip),%rsi
lea    0xe68(%rip),%rdx
mov    $0xa2,%ecx
call   1040 <fprintf@plt>
movl   $0x0,-0x4(%rbp)
jmp    127f <mxf_read_l+0x15f>
movl   $0x0,-0x24(%rbp)
mov    -0x24(%rbp),%eax
cmp    -0x34(%rbp),%eax
jge    125d <mxf_read_l+0x13d>
mov    -0x10(%rbp),%rdi
call   1030 <fgetc@plt>
mov    %eax,-0x28(%rbp)
mov    0x2de0(%rip),%rcx
cmp    (%rcx),%eax
jne    123d <mxf_read_l+0x11d>
mov    0x2dc1(%rip),%rax
mov    (%rax),%edi
lea    0xde0(%rip),%rsi
lea    0xdf1(%rip),%rdx
mov    $0xa5,%ecx
call   1040 <fprintf@plt>
movl   $0x0,-0x4(%rbp)
jmp    127f <mxf_read_l+0x15f>
mov    -0x2c(%rbp),%eax
shl    $0x8,%eax
mov    %eax,-0x2c(%rbp)
mov    -0x2c(%rbp),%eax
or     -0x28(%rbp),%eax
mov    %eax,-0x2c(%rbp)
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    11e9 <mxf_read_l+0xc9>
mov    -0x34(%rbp),%eax
add    -0x30(%rbp),%eax
mov    %eax,-0x30(%rbp)
mov    -0x30(%rbp),%ecx
mov    -0x18(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x2c(%rbp),%ecx
mov    -0x20(%rbp),%rax
mov    %ecx,(%rax)
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<mxf_read_l>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %rdx,%r14
mov    %rsi,%rbx
mov    %rdi,%rbp
call   1030 <fgetc@plt>
mov    0x2ea5(%rip),%r13
cmp    0x0(%r13),%eax
jne    1172 <mxf_read_l+0x52>
mov    0x2e88(%rip),%rax
mov    (%rax),%edi
lea    0xea7(%rip),%rsi
lea    0xeb8(%rip),%rdx
mov    $0x97,%ecx
call   1040 <fprintf@plt>
xor    %r12d,%r12d
jmp    1206 <mxf_read_l+0xe6>
mov    %eax,%r15d
mov    $0x1,%r12d
mov    $0x1,%eax
cmp    $0x80,%r15d
jl     1201 <mxf_read_l+0xe1>
and    $0x7f,%r15d
cmp    $0x8,%r15d
ja     11cb <mxf_read_l+0xab>
test   %r15d,%r15d
mov    %r14,0x10(%rsp)
mov    %rbx,0x8(%rsp)
je     11ec <mxf_read_l+0xcc>
xor    %ebx,%ebx
mov    %r15d,%r14d
nopw   0x0(%rax,%rax,1)
mov    %rbp,%rdi
call   1030 <fgetc@plt>
cmp    0x0(%r13),%eax
je     1218 <mxf_read_l+0xf8>
shl    $0x8,%ebx
or     %eax,%ebx
add    $0xffffffff,%r14d
jne    11b0 <mxf_read_l+0x90>
jmp    11ee <mxf_read_l+0xce>
mov    0x2e06(%rip),%rax
mov    (%rax),%edi
lea    0xe25(%rip),%rsi
lea    0xe52(%rip),%rdx
mov    $0xa2,%ecx
jmp    1165 <mxf_read_l+0x45>
xor    %ebx,%ebx
mov    %r15d,%eax
add    $0x1,%eax
mov    %ebx,%r15d
mov    0x10(%rsp),%r14
mov    0x8(%rsp),%rbx
mov    %eax,(%rbx)
mov    %r15d,(%r14)
mov    %r12d,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    0x2db9(%rip),%rax
mov    (%rax),%edi
lea    0xdd8(%rip),%rsi
lea    0xde9(%rip),%rdx
mov    $0xa5,%ecx
jmp    1165 <mxf_read_l+0x45>

LLVM IR (-O0):
@EOF = global i32 0
@stderr = global i32 0
@.str = [24 x i8] c"'%s' failed in line %d\0A\00"
@.str.1 = [28 x i8] c"(c = fgetc(mxfFile)) != EOF\00"
@.str.2 = [17 x i8] c"bytesToRead <= 8\00"
define i32 @mxf_read_l(i32* %0, i32* %1, i32* %2) {
%4 = alloca i32
%5 = alloca i32*
%6 = alloca i32*
%7 = alloca i32*
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32
store i32* %0, i32** %5
store i32* %1, i32** %6
store i32* %2, i32** %7
%13 = load i32*, i32** %5
%14 = call i32 @fgetc(i32* %13)
store i32 %14, i32* %9
%15 = load i32, i32* @EOF
%16 = icmp ne i32 %14, %15
br i1 %16, label %20, label %17
17: ; preds = %3
%18 = load i32, i32* @stderr
%19 = call i32 @fprintf(i32 %18, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.1, i64 0, i64 0), i32 151)
store i32 0, i32* %4
br label %64
20: ; preds = %3
store i32 0, i32* %10
store i32 1, i32* %11
%21 = load i32, i32* %9
%22 = icmp slt i32 %21, 128
br i1 %22, label %23, label %25
23: ; preds = %20
%24 = load i32, i32* %9
store i32 %24, i32* %10
br label %59
25: ; preds = %20
%26 = load i32, i32* %9
%27 = and i32 %26, 127
store i32 %27, i32* %12
%28 = load i32, i32* %12
%29 = icmp sle i32 %28, 8
br i1 %29, label %33, label %30
30: ; preds = %25
%31 = load i32, i32* @stderr
%32 = call i32 @fprintf(i32 %31, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.2, i64 0, i64 0), i32 162)
store i32 0, i32* %4
br label %64
33: ; preds = %25
store i32 0, i32* %8
br label %34
34: ; preds = %52, %33
%35 = load i32, i32* %8
%36 = load i32, i32* %12
%37 = icmp slt i32 %35, %36
br i1 %37, label %38, label %55
38: ; preds = %34
%39 = load i32*, i32** %5
%40 = call i32 @fgetc(i32* %39)
store i32 %40, i32* %9
%41 = load i32, i32* @EOF
%42 = icmp ne i32 %40, %41
br i1 %42, label %46, label %43
43: ; preds = %38
%44 = load i32, i32* @stderr
%45 = call i32 @fprintf(i32 %44, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.1, i64 0, i64 0), i32 165)
store i32 0, i32* %4
br label %64
46: ; preds = %38
%47 = load i32, i32* %10
%48 = shl i32 %47, 8
store i32 %48, i32* %10
%49 = load i32, i32* %10
%50 = load i32, i32* %9
%51 = or i32 %49, %50
store i32 %51, i32* %10
br label %52
52: ; preds = %46
%53 = load i32, i32* %8
%54 = add nsw i32 %53, 1
store i32 %54, i32* %8
br label %34
55: ; preds = %34
%56 = load i32, i32* %12
%57 = load i32, i32* %11
%58 = add nsw i32 %57, %56
store i32 %58, i32* %11
br label %59
59: ; preds = %55, %23
%60 = load i32, i32* %11
%61 = load i32*, i32** %6
store i32 %60, i32* %61
%62 = load i32, i32* %10
%63 = load i32*, i32** %7
store i32 %62, i32* %63
store i32 1, i32* %4
br label %64
64: ; preds = %59, %43, %30, %17
%65 = load i32, i32* %4
ret i32 %65
}

LLVM IR (-O2):
@EOF = global i32 0
@stderr = global i32 0
@.str = [24 x i8] c"'%s' failed in line %d\0A\00"
@.str.1 = [28 x i8] c"(c = fgetc(mxfFile)) != EOF\00"
@.str.2 = [17 x i8] c"bytesToRead <= 8\00"
define i32 @mxf_read_l(i32* nocapture %0, i32* nocapture writeonly %1, i32* nocapture writeonly %2) {
%4 = tail call i32 @fgetc(i32* %0)
%5 = load i32, i32* @EOF
%6 = icmp eq i32 %4, %5
br i1 %6, label %7, label %10
7: ; preds = %3
%8 = load i32, i32* @stderr
%9 = tail call i32 @fprintf(i32 %8, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.1, i64 0, i64 0), i32 151)
br label %40
10: ; preds = %3
%11 = icmp slt i32 %4, 128
br i1 %11, label %37, label %12
12: ; preds = %10
%13 = and i32 %4, 127
%14 = icmp ult i32 %13, 9
br i1 %14, label %15, label %17
15: ; preds = %12
%16 = icmp eq i32 %13, 0
br i1 %16, label %34, label %20
17: ; preds = %12
%18 = load i32, i32* @stderr
%19 = tail call i32 @fprintf(i32 %18, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.2, i64 0, i64 0), i32 162)
br label %40
20: ; preds = %15, %29
%21 = phi i32 [ %31, %29 ], [ 0, %15 ]
%22 = phi i32 [ %32, %29 ], [ 0, %15 ]
%23 = tail call i32 @fgetc(i32* %0)
%24 = load i32, i32* @EOF
%25 = icmp eq i32 %23, %24
br i1 %25, label %26, label %29
26: ; preds = %20
%27 = load i32, i32* @stderr
%28 = tail call i32 @fprintf(i32 %27, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.1, i64 0, i64 0), i32 165)
br label %40
29: ; preds = %20
%30 = shl i32 %21, 8
%31 = or i32 %23, %30
%32 = add nuw nsw i32 %22, 1
%33 = icmp eq i32 %32, %13
br i1 %33, label %34, label %20
34: ; preds = %29, %15
%35 = phi i32 [ 0, %15 ], [ %31, %29 ]
%36 = add nuw nsw i32 %13, 1
br label %37
37: ; preds = %34, %10
%38 = phi i32 [ %35, %34 ], [ %4, %10 ]
%39 = phi i32 [ %36, %34 ], [ 1, %10 ]
store i32 %39, i32* %1
store i32 %38, i32* %2
br label %40
40: ; preds = %17, %26, %37, %7
%41 = phi i32 [ 1, %37 ], [ 0, %7 ], [ 0, %26 ], [ 0, %17 ]
ret i32 %41
}