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

/* Variables and functions */
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *, int);
int fread(int *, int, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ stderr;
int mxf_read_uint16(FILE *mxfFile, uint16_t *value) {
  uint8_t buffer[2];
  if (!(fread(buffer, 1, 2, mxfFile) == 2)) {
    fprintf(stderr, "'%s' failed in line %d\n",
            "fread(buffer, 1, 2, mxfFile) == 2", 193);
    return 0;
  };
  *value = (buffer[0] << 8) | (buffer[1]);
  return 1;
}


x86 assembly (clang, -O0):
<mxf_read_uint16>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
lea    -0x20(%rbp),%rdi
mov    -0x10(%rbp),%rcx
mov    $0x1,%esi
mov    $0x2,%edx
call   1030 <fread@plt>
cmp    $0x2,%eax
je     117d <mxf_read_uint16+0x5d>
mov    0x2e89(%rip),%rax
mov    (%rax),%edi
lea    0xea0(%rip),%rsi
lea    0xeb1(%rip),%rdx
mov    $0xc1,%ecx
call   1040 <fprintf@plt>
movl   $0x0,-0x4(%rbp)
jmp    1193 <mxf_read_uint16+0x73>
mov    -0x20(%rbp),%ecx
shl    $0x8,%ecx
or     -0x1c(%rbp),%ecx
mov    -0x18(%rbp),%rax
mov    %ecx,(%rax)
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<mxf_read_uint16>:
push   %r14
push   %rbx
push   %rax
mov    %rsi,%r14
mov    %rdi,%rcx
mov    %rsp,%rdi
mov    $0x1,%ebx
mov    $0x1,%esi
mov    $0x2,%edx
call   1030 <fread@plt>
cmp    $0x2,%eax
jne    1155 <mxf_read_uint16+0x35>
mov    (%rsp),%eax
shl    $0x8,%eax
or     0x4(%rsp),%eax
mov    %eax,(%r14)
jmp    1178 <mxf_read_uint16+0x58>
mov    0x2e84(%rip),%rax
mov    (%rax),%edi
lea    0xe9b(%rip),%rsi
lea    0xeac(%rip),%rdx
mov    $0xc1,%ecx
call   1040 <fprintf@plt>
xor    %ebx,%ebx
mov    %ebx,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@stderr = global i32 0
@.str = [24 x i8] c"'%s' failed in line %d\0A\00"
@.str.1 = [34 x i8] c"fread(buffer, 1, 2, mxfFile) == 2\00"
define i32 @mxf_read_uint16(i32* %0, i32* %1) {
%3 = alloca i32
%4 = alloca i32*
%5 = alloca i32*
%6 = alloca [2 x i32]
store i32* %0, i32** %4
store i32* %1, i32** %5
%7 = getelementptr inbounds [2 x i32], [2 x i32]* %6, i64 0, i64 0
%8 = load i32*, i32** %4
%9 = call i32 @fread(i32* %7, i32 1, i32 2, i32* %8)
%10 = icmp eq i32 %9, 2
br i1 %10, label %14, label %11
11: ; preds = %2
%12 = load i32, i32* @stderr
%13 = call i32 @fprintf(i32 %12, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.1, i64 0, i64 0), i32 193)
store i32 0, i32* %3
br label %22
14: ; preds = %2
%15 = getelementptr inbounds [2 x i32], [2 x i32]* %6, i64 0, i64 0
%16 = load i32, i32* %15
%17 = shl i32 %16, 8
%18 = getelementptr inbounds [2 x i32], [2 x i32]* %6, i64 0, i64 1
%19 = load i32, i32* %18
%20 = or i32 %17, %19
%21 = load i32*, i32** %5
store i32 %20, i32* %21
store i32 1, i32* %3
br label %22
22: ; preds = %14, %11
%23 = load i32, i32* %3
ret i32 %23
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [24 x i8] c"'%s' failed in line %d\0A\00"
@.str.1 = [34 x i8] c"fread(buffer, 1, 2, mxfFile) == 2\00"
define i32 @mxf_read_uint16(i32* nocapture %0, i32* nocapture writeonly %1) {
%3 = alloca [2 x i32]
%4 = bitcast [2 x i32]* %3 to i8*
%5 = getelementptr inbounds [2 x i32], [2 x i32]* %3, i64 0, i64 0
%6 = call i32 @fread(i32* %5, i32 1, i32 2, i32* %0)
%7 = icmp eq i32 %6, 2
br i1 %7, label %11, label %8
8: ; preds = %2
%9 = load i32, i32* @stderr
%10 = tail call i32 @fprintf(i32 %9, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.1, i64 0, i64 0), i32 193)
br label %17
11: ; preds = %2
%12 = load i32, i32* %5
%13 = shl i32 %12, 8
%14 = getelementptr inbounds [2 x i32], [2 x i32]* %3, i64 0, i64 1
%15 = load i32, i32* %14
%16 = or i32 %13, %15
store i32 %16, i32* %1
br label %17
17: ; preds = %11, %8
%18 = phi i32 [ 1, %11 ], [ 0, %8 ]
ret i32 %18
}