#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(char *, int, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ printf(char *, char *);
int main() {
  FILE *fp = fopen("sum.obj", "r");
  char ch[7] = "";
  do {
    if (fread((char *)ch, 3, 2, fp) <= 0)
      break;
    printf("%s|", ch);
  } while (1);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeaa(%rip),%rdi
lea    0xeab(%rip),%rsi
call   1060 <fopen@plt>
mov    %rax,-0x10(%rbp)
lea    -0x17(%rbp),%rdi
xor    %esi,%esi
mov    $0x7,%edx
call   1050 <memset@plt>
lea    -0x17(%rbp),%rdi
mov    -0x10(%rbp),%rcx
mov    $0x3,%esi
mov    $0x2,%edx
call   1030 <fread@plt>
cmp    $0x0,%rax
jg     119c <main+0x5c>
jmp    11bb <main+0x7b>
lea    -0x17(%rbp),%rsi
lea    0xe63(%rip),%rdi
call   1040 <printf@plt>
mov    $0x1,%al
test   $0x1,%al
jne    1176 <main+0x36>
jmp    11bb <main+0x7b>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
sub    $0x10,%rsp
lea    0xec0(%rip),%rdi
lea    0xec1(%rip),%rsi
call   1050 <fopen@plt>
mov    %rax,%r15
movl   $0x0,0xb(%rsp)
movl   $0x0,0x8(%rsp)
lea    0x8(%rsp),%rdi
mov    $0x3,%esi
mov    $0x2,%edx
mov    %rax,%rcx
call   1030 <fread@plt>
test   %rax,%rax
jle    11b5 <main+0x85>
lea    0xe88(%rip),%r14
lea    0x8(%rsp),%rbx
nopw   0x0(%rax,%rax,1)
mov    %r14,%rdi
mov    %rbx,%rsi
call   1040 <printf@plt>
mov    %rbx,%rdi
mov    $0x3,%esi
mov    $0x2,%edx
mov    %r15,%rcx
call   1030 <fread@plt>
test   %rax,%rax
jg     1190 <main+0x60>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [8 x i8] c"sum.obj\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [4 x i8] c"%s|\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32*
%3 = alloca [7 x i8]
store i32 0, i32* %1
%4 = call i32* @fopen(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %4, i32** %2
%5 = bitcast [7 x i8]* %3 to i8*
br label %6
6: ; preds = %15, %0
%7 = getelementptr inbounds [7 x i8], [7 x i8]* %3, i64 0, i64 0
%8 = load i32*, i32** %2
%9 = call i64 @fread(i8* %7, i32 3, i32 2, i32* %8)
%10 = icmp sle i64 %9, 0
br i1 %10, label %11, label %12
11: ; preds = %6
br label %16
12: ; preds = %6
%13 = getelementptr inbounds [7 x i8], [7 x i8]* %3, i64 0, i64 0
%14 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i8* %13)
br label %15
15: ; preds = %12
br i1 true, label %6, label %16
16: ; preds = %15, %11
ret i32 0
}

LLVM IR (-O2):
@.str = [8 x i8] c"sum.obj\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [4 x i8] c"%s|\00"
define i32 @main() {
%1 = alloca [7 x i8]
%2 = tail call i32* @fopen(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%3 = getelementptr inbounds [7 x i8], [7 x i8]* %1, i64 0, i64 0
%4 = call i64 @fread(i8* %3, i32 3, i32 2, i32* %2)
%5 = icmp slt i64 %4, 1
br i1 %5, label %10, label %6
6: ; preds = %0, %6
%7 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i8* %3)
%8 = call i64 @fread(i8* %3, i32 3, i32 2, i32* %2)
%9 = icmp slt i64 %8, 1
br i1 %9, label %10, label %6
10: ; preds = %6, %0
ret i32 0
}