#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*/ feof(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
size_t fread(char *, int, size_t, int /*<<< orphan*/ *);
size_t get_file(char *file_path, char *buff, size_t buffsize) {
  FILE *file;
  size_t nread;
  if ((file = fopen(file_path, "r")) == NULL)
    return 0;
  nread = fread(buff, sizeof buff[0], buffsize, file);
  if (!feof(file))
    return 0;
  return nread;
}


x86 assembly (clang, -O0):
<get_file>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    -0x10(%rbp),%rdi
lea    0xeb1(%rip),%rsi
call   1050 <fopen@plt>
mov    %rax,-0x28(%rbp)
cmp    $0x0,%rax
jne    116f <get_file+0x3f>
movq   $0x0,-0x8(%rbp)
jmp    11b0 <get_file+0x80>
mov    -0x18(%rbp),%rdi
mov    -0x20(%rbp),%rdx
mov    -0x28(%rbp),%rcx
mov    $0x1,%esi
call   1030 <fread@plt>
mov    %rax,-0x30(%rbp)
mov    -0x28(%rbp),%rdi
call   1040 <feof@plt>
cmp    $0x0,%eax
jne    11a8 <get_file+0x78>
movq   $0x0,-0x8(%rbp)
jmp    11b0 <get_file+0x80>
mov    -0x30(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_file>:
push   %r15
push   %r14
push   %rbx
mov    %rdx,%r14
mov    %rsi,%r15
lea    0xebe(%rip),%rsi
call   1050 <fopen@plt>
test   %rax,%rax
je     1179 <get_file+0x49>
mov    %rax,%rbx
mov    %r15,%rdi
mov    $0x1,%esi
mov    %r14,%rdx
mov    %rax,%rcx
call   1030 <fread@plt>
mov    %rax,%r14
mov    %rbx,%rdi
call   1040 <feof@plt>
mov    %eax,%ecx
xor    %eax,%eax
test   %ecx,%ecx
cmovne %r14,%rax
jmp    117b <get_file+0x4b>
xor    %eax,%eax
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [2 x i8] c"r\00"
define i64 @get_file(i8* %0, i8* %1, i64 %2) {
%4 = alloca i64
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca i64
%8 = alloca i32*
%9 = alloca i64
store i8* %0, i8** %5
store i8* %1, i8** %6
store i64 %2, i64* %7
%10 = load i8*, i8** %5
%11 = call i32* @fopen(i8* %10, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i32* %11, i32** %8
%12 = icmp eq i32* %11, null
br i1 %12, label %13, label %14
13: ; preds = %3
store i64 0, i64* %4
br label %25
14: ; preds = %3
%15 = load i8*, i8** %6
%16 = load i64, i64* %7
%17 = load i32*, i32** %8
%18 = call i64 @fread(i8* %15, i32 1, i64 %16, i32* %17)
store i64 %18, i64* %9
%19 = load i32*, i32** %8
%20 = call i32 @feof(i32* %19)
%21 = icmp ne i32 %20, 0
br i1 %21, label %23, label %22
22: ; preds = %14
store i64 0, i64* %4
br label %25
23: ; preds = %14
%24 = load i64, i64* %9
store i64 %24, i64* %4
br label %25
25: ; preds = %23, %22, %13
%26 = load i64, i64* %4
ret i64 %26
}

LLVM IR (-O2):
@.str = [2 x i8] c"r\00"
define i64 @get_file(i8* nocapture %0, i8* nocapture %1, i64 %2) {
%4 = tail call i32* @fopen(i8* %0, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%5 = icmp eq i32* %4, null
br i1 %5, label %11, label %6
6: ; preds = %3
%7 = tail call i64 @fread(i8* %1, i32 1, i64 %2, i32* %4)
%8 = tail call i32 @feof(i32* %4)
%9 = icmp eq i32 %8, 0
%10 = select i1 %9, i64 0, i64 %7
br label %11
11: ; preds = %6, %3
%12 = phi i64 [ 0, %3 ], [ %10, %6 ]
ret i64 %12
}