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

/* Variables and functions */
int fread(unsigned char *, int, int, int /*<<< orphan*/ *);
int readLong(FILE *fp, unsigned int *result) {
  unsigned char b1, b2, b3, b4;
  if (fread(&b1, 1, 1, fp) != 1)
    return (-1);
  if (fread(&b2, 1, 1, fp) != 1)
    return (-1);
  if (fread(&b3, 1, 1, fp) != 1)
    return (-1);
  if (fread(&b4, 1, 1, fp) != 1)
    return (-1);
  *result = (((unsigned int)b4) << 24) + (((unsigned int)b3) << 16) +
            (((unsigned int)b2) << 8) + b1;
  return (0);
}


x86 assembly (clang, -O0):
<readLong>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    -0x10(%rbp),%rcx
lea    -0x19(%rbp),%rdi
mov    $0x1,%edx
mov    %edx,%esi
call   1030 <fread@plt>
cmp    $0x1,%eax
je     1149 <readLong+0x39>
movl   $0xffffffff,-0x4(%rbp)
jmp    11f0 <readLong+0xe0>
mov    -0x10(%rbp),%rcx
lea    -0x1a(%rbp),%rdi
mov    $0x1,%edx
mov    %edx,%esi
call   1030 <fread@plt>
cmp    $0x1,%eax
je     1172 <readLong+0x62>
movl   $0xffffffff,-0x4(%rbp)
jmp    11f0 <readLong+0xe0>
mov    -0x10(%rbp),%rcx
lea    -0x1b(%rbp),%rdi
mov    $0x1,%edx
mov    %edx,%esi
call   1030 <fread@plt>
cmp    $0x1,%eax
je     119b <readLong+0x8b>
movl   $0xffffffff,-0x4(%rbp)
jmp    11f0 <readLong+0xe0>
mov    -0x10(%rbp),%rcx
lea    -0x1c(%rbp),%rdi
mov    $0x1,%edx
mov    %edx,%esi
call   1030 <fread@plt>
cmp    $0x1,%eax
je     11c4 <readLong+0xb4>
movl   $0xffffffff,-0x4(%rbp)
jmp    11f0 <readLong+0xe0>
movzbl -0x1c(%rbp),%ecx
shl    $0x18,%ecx
movzbl -0x1b(%rbp),%eax
shl    $0x10,%eax
add    %eax,%ecx
movzbl -0x1a(%rbp),%eax
shl    $0x8,%eax
add    %eax,%ecx
movzbl -0x19(%rbp),%eax
add    %eax,%ecx
mov    -0x18(%rbp),%rax
mov    %ecx,(%rax)
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<readLong>:
push   %rbp
push   %r14
push   %rbx
sub    $0x10,%rsp
mov    %rsi,%r14
mov    %rdi,%rbx
lea    0xf(%rsp),%rdi
mov    $0x1,%esi
mov    $0x1,%edx
mov    %rbx,%rcx
call   1030 <fread@plt>
mov    $0xffffffff,%ebp
cmp    $0x1,%eax
jne    11bb <readLong+0xab>
lea    0xe(%rsp),%rdi
mov    $0x1,%esi
mov    $0x1,%edx
mov    %rbx,%rcx
call   1030 <fread@plt>
cmp    $0x1,%eax
jne    11bb <readLong+0xab>
lea    0xd(%rsp),%rdi
mov    $0x1,%esi
mov    $0x1,%edx
mov    %rbx,%rcx
call   1030 <fread@plt>
cmp    $0x1,%eax
jne    11bb <readLong+0xab>
lea    0xc(%rsp),%rdi
mov    $0x1,%esi
mov    $0x1,%edx
mov    %rbx,%rcx
call   1030 <fread@plt>
cmp    $0x1,%eax
jne    11bb <readLong+0xab>
movzbl 0xc(%rsp),%eax
shl    $0x18,%eax
movzbl 0xd(%rsp),%ecx
shl    $0x10,%ecx
or     %eax,%ecx
movzbl 0xe(%rsp),%eax
shl    $0x8,%eax
or     %ecx,%eax
movzbl 0xf(%rsp),%ecx
or     %eax,%ecx
mov    %ecx,(%r14)
xor    %ebp,%ebp
mov    %ebp,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

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

LLVM IR (-O2):
define i32 @readLong(i32* nocapture %0, i32* nocapture writeonly %1) {
%3 = alloca i8
%4 = alloca i8
%5 = alloca i8
%6 = alloca i8
%7 = call i32 @fread(i8* %3, i32 1, i32 1, i32* %0)
%8 = icmp eq i32 %7, 1
br i1 %8, label %9, label %33
9: ; preds = %2
%10 = call i32 @fread(i8* %4, i32 1, i32 1, i32* %0)
%11 = icmp eq i32 %10, 1
br i1 %11, label %12, label %33
12: ; preds = %9
%13 = call i32 @fread(i8* %5, i32 1, i32 1, i32* %0)
%14 = icmp eq i32 %13, 1
br i1 %14, label %15, label %33
15: ; preds = %12
%16 = call i32 @fread(i8* %6, i32 1, i32 1, i32* %0)
%17 = icmp eq i32 %16, 1
br i1 %17, label %18, label %33
18: ; preds = %15
%19 = load i8, i8* %6
%20 = zext i8 %19 to i32
%21 = shl nuw i32 %20, 24
%22 = load i8, i8* %5
%23 = zext i8 %22 to i32
%24 = shl nuw nsw i32 %23, 16
%25 = or i32 %24, %21
%26 = load i8, i8* %4
%27 = zext i8 %26 to i32
%28 = shl nuw nsw i32 %27, 8
%29 = or i32 %25, %28
%30 = load i8, i8* %3
%31 = zext i8 %30 to i32
%32 = or i32 %29, %31
store i32 %32, i32* %1
br label %33
33: ; preds = %15, %12, %9, %2, %18
%34 = phi i32 [ 0, %18 ], [ -1, %2 ], [ -1, %9 ], [ -1, %12 ], [ -1, %15 ]
ret i32 %34
}