#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 intio_read(FILE *f) {
  unsigned char b[4];
  int top;
  int i;
  for (i = 0; i < 4; i++) {
    if (fread(&b[i], 1, 1, f) != 1)
      return 0;
  }
  top = b[3] > 127 ? (int)b[3] - 256 : b[3];
  return (top << 24) + (b[2] << 16) + (b[1] << 8) + b[0];
}


x86 assembly (clang, -O0):
<intio_read>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
movl   $0x0,-0x1c(%rbp)
cmpl   $0x4,-0x1c(%rbp)
jge    1170 <intio_read+0x60>
movslq -0x1c(%rbp),%rax
lea    -0x14(%rbp),%rdi
add    %rax,%rdi
mov    -0x10(%rbp),%rcx
mov    $0x1,%edx
mov    %edx,%esi
call   1030 <fread@plt>
cmp    $0x1,%eax
je     115d <intio_read+0x4d>
movl   $0x0,-0x4(%rbp)
jmp    11bc <intio_read+0xac>
jmp    1162 <intio_read+0x52>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    1123 <intio_read+0x13>
movzbl -0x11(%rbp),%eax
cmp    $0x7f,%eax
jle    118e <intio_read+0x7e>
movzbl -0x11(%rbp),%eax
sub    $0x100,%eax
mov    %eax,-0x20(%rbp)
jmp    1195 <intio_read+0x85>
movzbl -0x11(%rbp),%eax
mov    %eax,-0x20(%rbp)
mov    -0x20(%rbp),%eax
mov    %eax,-0x18(%rbp)
mov    -0x18(%rbp),%eax
shl    $0x18,%eax
movzbl -0x12(%rbp),%ecx
shl    $0x10,%ecx
add    %ecx,%eax
movzbl -0x13(%rbp),%ecx
shl    $0x8,%ecx
add    %ecx,%eax
movzbl -0x14(%rbp),%ecx
add    %ecx,%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<intio_read>:
push   %rbp
push   %rbx
push   %rax
mov    %rdi,%rbx
lea    0x4(%rsp),%rdi
mov    $0x1,%esi
mov    $0x1,%edx
mov    %rbx,%rcx
call   1030 <fread@plt>
xor    %ebp,%ebp
cmp    $0x1,%eax
jne    118c <intio_read+0x7c>
lea    0x5(%rsp),%rdi
mov    $0x1,%esi
mov    $0x1,%edx
mov    %rbx,%rcx
call   1030 <fread@plt>
cmp    $0x1,%eax
jne    118c <intio_read+0x7c>
lea    0x6(%rsp),%rdi
mov    $0x1,%esi
mov    $0x1,%edx
mov    %rbx,%rcx
call   1030 <fread@plt>
cmp    $0x1,%eax
jne    118c <intio_read+0x7c>
lea    0x7(%rsp),%rdi
mov    $0x1,%esi
mov    $0x1,%edx
mov    %rbx,%rcx
call   1030 <fread@plt>
cmp    $0x1,%eax
jne    118c <intio_read+0x7c>
mov    0x4(%rsp),%ebp
mov    %ebp,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
define i32 @intio_read(i32* %0) {
%2 = alloca i32
%3 = alloca i32*
%4 = alloca [4 x i8]
%5 = alloca i32
%6 = alloca i32
store i32* %0, i32** %3
store i32 0, i32* %6
br label %7
7: ; preds = %19, %1
%8 = load i32, i32* %6
%9 = icmp slt i32 %8, 4
br i1 %9, label %10, label %22
10: ; preds = %7
%11 = load i32, i32* %6
%12 = sext i32 %11 to i64
%13 = getelementptr inbounds [4 x i8], [4 x i8]* %4, i64 0, i64 %12
%14 = load i32*, i32** %3
%15 = call i32 @fread(i8* %13, i32 1, i32 1, i32* %14)
%16 = icmp ne i32 %15, 1
br i1 %16, label %17, label %18
17: ; preds = %10
store i32 0, i32* %2
br label %54
18: ; preds = %10
br label %19
19: ; preds = %18
%20 = load i32, i32* %6
%21 = add nsw i32 %20, 1
store i32 %21, i32* %6
br label %7
22: ; preds = %7
%23 = getelementptr inbounds [4 x i8], [4 x i8]* %4, i64 0, i64 3
%24 = load i8, i8* %23
%25 = zext i8 %24 to i32
%26 = icmp sgt i32 %25, 127
br i1 %26, label %27, label %32
27: ; preds = %22
%28 = getelementptr inbounds [4 x i8], [4 x i8]* %4, i64 0, i64 3
%29 = load i8, i8* %28
%30 = zext i8 %29 to i32
%31 = sub nsw i32 %30, 256
br label %36
32: ; preds = %22
%33 = getelementptr inbounds [4 x i8], [4 x i8]* %4, i64 0, i64 3
%34 = load i8, i8* %33
%35 = zext i8 %34 to i32
br label %36
36: ; preds = %32, %27
%37 = phi i32 [ %31, %27 ], [ %35, %32 ]
store i32 %37, i32* %5
%38 = load i32, i32* %5
%39 = shl i32 %38, 24
%40 = getelementptr inbounds [4 x i8], [4 x i8]* %4, i64 0, i64 2
%41 = load i8, i8* %40
%42 = zext i8 %41 to i32
%43 = shl i32 %42, 16
%44 = add nsw i32 %39, %43
%45 = getelementptr inbounds [4 x i8], [4 x i8]* %4, i64 0, i64 1
%46 = load i8, i8* %45
%47 = zext i8 %46 to i32
%48 = shl i32 %47, 8
%49 = add nsw i32 %44, %48
%50 = getelementptr inbounds [4 x i8], [4 x i8]* %4, i64 0, i64 0
%51 = load i8, i8* %50
%52 = zext i8 %51 to i32
%53 = add nsw i32 %49, %52
store i32 %53, i32* %2
br label %54
54: ; preds = %36, %17
%55 = load i32, i32* %2
ret i32 %55
}

LLVM IR (-O2):
define i32 @intio_read(i32* nocapture %0) {
%2 = alloca [4 x i8]
%3 = getelementptr inbounds [4 x i8], [4 x i8]* %2, i64 0, i64 0
%4 = call i32 @fread(i8* %3, i32 1, i32 1, i32* %0)
%5 = icmp eq i32 %4, 1
br i1 %5, label %6, label %33
6: ; preds = %1
%7 = getelementptr inbounds [4 x i8], [4 x i8]* %2, i64 0, i64 1
%8 = call i32 @fread(i8* %7, i32 1, i32 1, i32* %0)
%9 = icmp eq i32 %8, 1
br i1 %9, label %10, label %33
10: ; preds = %6
%11 = getelementptr inbounds [4 x i8], [4 x i8]* %2, i64 0, i64 2
%12 = call i32 @fread(i8* %11, i32 1, i32 1, i32* %0)
%13 = icmp eq i32 %12, 1
br i1 %13, label %14, label %33
14: ; preds = %10
%15 = getelementptr inbounds [4 x i8], [4 x i8]* %2, i64 0, i64 3
%16 = call i32 @fread(i8* %15, i32 1, i32 1, i32* %0)
%17 = icmp eq i32 %16, 1
br i1 %17, label %18, label %33
18: ; preds = %14
%19 = load i8, i8* %15
%20 = zext i8 %19 to i32
%21 = shl nuw i32 %20, 24
%22 = load i8, i8* %11
%23 = zext i8 %22 to i32
%24 = shl nuw nsw i32 %23, 16
%25 = or i32 %24, %21
%26 = load i8, i8* %7
%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
br label %33
33: ; preds = %1, %6, %10, %14, %18
%34 = phi i32 [ %32, %18 ], [ 0, %14 ], [ 0, %10 ], [ 0, %6 ], [ 0, %1 ]
ret i32 %34
}