#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 /*<<< orphan*/ *fopen(char *, char *);
scalar_t__ fread(unsigned char *, int, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ printf(char *, int);
int main() {
  unsigned char bytes[4];
  int sum = 0;
  int count = 0;
  FILE *fp = fopen("1988730searlymelt.int.304.448.c", "rb");
  while (fread(bytes, 4, 1, fp) != 0) {
    int piece =
        bytes[0] | (bytes[1] << 8) | (bytes[2] << 16) | (bytes[3] << 24);
    sum += piece;
    printf("The piece is %d\n", piece);
    count = count + 1;
  }
  printf("The sum is %d\n", sum);
  printf("the total count is %d\n", count);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0xc(%rbp)
movl   $0x0,-0x10(%rbp)
lea    0xeac(%rip),%rdi
lea    0xec5(%rip),%rsi
call   1050 <fopen@plt>
mov    %rax,-0x18(%rbp)
lea    -0x8(%rbp),%rdi
mov    -0x18(%rbp),%rcx
mov    $0x4,%esi
mov    $0x1,%edx
call   1030 <fread@plt>
cmp    $0x0,%rax
je     11cd <main+0x9d>
movzbl -0x8(%rbp),%eax
movzbl -0x7(%rbp),%ecx
shl    $0x8,%ecx
or     %ecx,%eax
movzbl -0x6(%rbp),%ecx
shl    $0x10,%ecx
or     %ecx,%eax
movzbl -0x5(%rbp),%ecx
shl    $0x18,%ecx
or     %ecx,%eax
mov    %eax,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
add    -0xc(%rbp),%eax
mov    %eax,-0xc(%rbp)
mov    -0x1c(%rbp),%esi
lea    0xe69(%rip),%rdi
call   1040 <printf@plt>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    1164 <main+0x34>
mov    -0xc(%rbp),%esi
lea    0xe5d(%rip),%rdi
call   1040 <printf@plt>
mov    -0x10(%rbp),%esi
lea    0xe5d(%rip),%rdi
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x10,%rsp
lea    0xebd(%rip),%rdi
lea    0xed6(%rip),%rsi
call   1050 <fopen@plt>
mov    %rax,%r14
lea    0xc(%rsp),%rdi
mov    $0x4,%esi
mov    $0x1,%edx
mov    %rax,%rcx
call   1030 <fread@plt>
test   %rax,%rax
je     11ad <main+0x7d>
xor    %ebx,%ebx
lea    0xeac(%rip),%r15
lea    0xc(%rsp),%r12
xor    %ebp,%ebp
xchg   %ax,%ax
mov    0xc(%rsp),%esi
add    %esi,%ebx
mov    %r15,%rdi
call   1040 <printf@plt>
add    $0x1,%ebp
mov    %r12,%rdi
mov    $0x4,%esi
mov    $0x1,%edx
mov    %r14,%rcx
call   1030 <fread@plt>
test   %rax,%rax
jne    1180 <main+0x50>
jmp    11b1 <main+0x81>
xor    %ebp,%ebp
xor    %ebx,%ebx
lea    0xe7c(%rip),%rdi
mov    %ebx,%esi
call   1040 <printf@plt>
lea    0xe7d(%rip),%rdi
mov    %ebp,%esi
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [32 x i8] c"1988730searlymelt.int.304.448.c\00"
@.str.1 = [3 x i8] c"rb\00"
@.str.2 = [17 x i8] c"The piece is %d\0A\00"
@.str.3 = [15 x i8] c"The sum is %d\0A\00"
@.str.4 = [23 x i8] c"the total count is %d\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [4 x i8]
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32*
%6 = alloca i32
store i32 0, i32* %1
store i32 0, i32* %3
store i32 0, i32* %4
%7 = call i32* @fopen(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
store i32* %7, i32** %5
br label %8
8: ; preds = %13, %0
%9 = getelementptr inbounds [4 x i8], [4 x i8]* %2, i64 0, i64 0
%10 = load i32*, i32** %5
%11 = call i64 @fread(i8* %9, i32 4, i32 1, i32* %10)
%12 = icmp ne i64 %11, 0
br i1 %12, label %13, label %39
13: ; preds = %8
%14 = getelementptr inbounds [4 x i8], [4 x i8]* %2, i64 0, i64 0
%15 = load i8, i8* %14
%16 = zext i8 %15 to i32
%17 = getelementptr inbounds [4 x i8], [4 x i8]* %2, i64 0, i64 1
%18 = load i8, i8* %17
%19 = zext i8 %18 to i32
%20 = shl i32 %19, 8
%21 = or i32 %16, %20
%22 = getelementptr inbounds [4 x i8], [4 x i8]* %2, i64 0, i64 2
%23 = load i8, i8* %22
%24 = zext i8 %23 to i32
%25 = shl i32 %24, 16
%26 = or i32 %21, %25
%27 = getelementptr inbounds [4 x i8], [4 x i8]* %2, i64 0, i64 3
%28 = load i8, i8* %27
%29 = zext i8 %28 to i32
%30 = shl i32 %29, 24
%31 = or i32 %26, %30
store i32 %31, i32* %6
%32 = load i32, i32* %6
%33 = load i32, i32* %3
%34 = add nsw i32 %33, %32
store i32 %34, i32* %3
%35 = load i32, i32* %6
%36 = call i32 @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.2, i64 0, i64 0), i32 %35)
%37 = load i32, i32* %4
%38 = add nsw i32 %37, 1
store i32 %38, i32* %4
br label %8
39: ; preds = %8
%40 = load i32, i32* %3
%41 = call i32 @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.3, i64 0, i64 0), i32 %40)
%42 = load i32, i32* %4
%43 = call i32 @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.4, i64 0, i64 0), i32 %42)
ret i32 0
}

LLVM IR (-O2):
@.str = [32 x i8] c"1988730searlymelt.int.304.448.c\00"
@.str.1 = [3 x i8] c"rb\00"
@.str.2 = [17 x i8] c"The piece is %d\0A\00"
@.str.3 = [15 x i8] c"The sum is %d\0A\00"
@.str.4 = [23 x i8] c"the total count is %d\0A\00"
define i32 @main() {
%1 = alloca [4 x i8]
%2 = getelementptr inbounds [4 x i8], [4 x i8]* %1, i64 0, i64 0
%3 = tail call i32* @fopen(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%4 = call i64 @fread(i8* %2, i32 4, i32 1, i32* %3)
%5 = icmp eq i64 %4, 0
br i1 %5, label %32, label %6
6: ; preds = %0
%7 = getelementptr inbounds [4 x i8], [4 x i8]* %1, i64 0, i64 1
%8 = getelementptr inbounds [4 x i8], [4 x i8]* %1, i64 0, i64 2
%9 = getelementptr inbounds [4 x i8], [4 x i8]* %1, i64 0, i64 3
br label %10
10: ; preds = %6, %10
%11 = phi i32 [ 0, %6 ], [ %27, %10 ]
%12 = phi i32 [ 0, %6 ], [ %29, %10 ]
%13 = load i8, i8* %2
%14 = zext i8 %13 to i32
%15 = load i8, i8* %7
%16 = zext i8 %15 to i32
%17 = shl nuw nsw i32 %16, 8
%18 = or i32 %17, %14
%19 = load i8, i8* %8
%20 = zext i8 %19 to i32
%21 = shl nuw nsw i32 %20, 16
%22 = or i32 %18, %21
%23 = load i8, i8* %9
%24 = zext i8 %23 to i32
%25 = shl nuw i32 %24, 24
%26 = or i32 %22, %25
%27 = add nsw i32 %26, %11
%28 = tail call i32 @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.2, i64 0, i64 0), i32 %26)
%29 = add nuw nsw i32 %12, 1
%30 = call i64 @fread(i8* %2, i32 4, i32 1, i32* %3)
%31 = icmp eq i64 %30, 0
br i1 %31, label %32, label %10
32: ; preds = %10, %0
%33 = phi i32 [ 0, %0 ], [ %29, %10 ]
%34 = phi i32 [ 0, %0 ], [ %27, %10 ]
%35 = tail call i32 @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.3, i64 0, i64 0), i32 %34)
%36 = tail call i32 @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.4, i64 0, i64 0), i32 %33)
ret i32 0
}