#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 */
size_t fread(char *, int, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ printf(char *, char *);
void process_file(FILE *p_file) {
  char buffer[1025];
  size_t count;
  while ((count = fread(buffer, sizeof(char), 1025 - 1, p_file))) {
    buffer[count] = '\0';
    printf("%s", buffer);
  }
}


x86 assembly (clang, -O0):
<process_file>:
push   %rbp
mov    %rsp,%rbp
sub    $0x420,%rsp
mov    %rdi,-0x8(%rbp)
lea    -0x410(%rbp),%rdi
mov    -0x8(%rbp),%rcx
mov    $0x1,%esi
mov    $0x400,%edx
call   1030 <fread@plt>
mov    %rax,-0x418(%rbp)
cmp    $0x0,%rax
je     1181 <process_file+0x61>
mov    -0x418(%rbp),%rax
movb   $0x0,-0x410(%rbp,%rax,1)
lea    -0x410(%rbp),%rsi
lea    0xe89(%rip),%rdi
call   1040 <printf@plt>
jmp    112f <process_file+0xf>
add    $0x420,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<process_file>:
push   %r15
push   %r14
push   %rbx
sub    $0x410,%rsp
mov    %rdi,%r15
mov    %rsp,%rdi
mov    $0x1,%esi
mov    $0x400,%edx
mov    %r15,%rcx
call   1030 <fread@plt>
test   %rax,%rax
je     1189 <process_file+0x69>
lea    0xeb0(%rip),%r14
mov    %rsp,%rbx
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
movb   $0x0,(%rsp,%rax,1)
mov    %r14,%rdi
mov    %rbx,%rsi
call   1040 <printf@plt>
mov    %rbx,%rdi
mov    $0x1,%esi
mov    $0x400,%edx
mov    %r15,%rcx
call   1030 <fread@plt>
test   %rax,%rax
jne    1160 <process_file+0x40>
add    $0x410,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [3 x i8] c"%s\00"
define void @process_file(i32* %0) {
%2 = alloca i32*
%3 = alloca [1025 x i8]
%4 = alloca i64
store i32* %0, i32** %2
br label %5
5: ; preds = %10, %1
%6 = getelementptr inbounds [1025 x i8], [1025 x i8]* %3, i64 0, i64 0
%7 = load i32*, i32** %2
%8 = call i64 @fread(i8* %6, i32 1, i32 1024, i32* %7)
store i64 %8, i64* %4
%9 = icmp ne i64 %8, 0
br i1 %9, label %10, label %15
10: ; preds = %5
%11 = load i64, i64* %4
%12 = getelementptr inbounds [1025 x i8], [1025 x i8]* %3, i64 0, i64 %11
store i8 0, i8* %12
%13 = getelementptr inbounds [1025 x i8], [1025 x i8]* %3, i64 0, i64 0
%14 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %13)
br label %5
15: ; preds = %5
ret void
}

LLVM IR (-O2):
@.str = [3 x i8] c"%s\00"
define void @process_file(i32* nocapture %0) {
%2 = alloca [1025 x i8]
%3 = getelementptr inbounds [1025 x i8], [1025 x i8]* %2, i64 0, i64 0
%4 = call i64 @fread(i8* %3, i32 1, i32 1024, i32* %0)
%5 = icmp eq i64 %4, 0
br i1 %5, label %12, label %6
6: ; preds = %1, %6
%7 = phi i64 [ %10, %6 ], [ %4, %1 ]
%8 = getelementptr inbounds [1025 x i8], [1025 x i8]* %2, i64 0, i64 %7
store i8 0, i8* %8
%9 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %3)
%10 = call i64 @fread(i8* %3, i32 1, i32 1024, i32* %0)
%11 = icmp eq i64 %10, 0
br i1 %11, label %12, label %6
12: ; preds = %6, %1
ret void
}