#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 errno;
int fread(char *, int, unsigned int, int /*<<< orphan*/ *);
unsigned int ReadFromFile_Real(FILE *handle, char *buf, unsigned int count,
                               int *carry) {
  int errno_old, ret_val;
  errno_old = errno;
  errno = 0;
  ret_val = fread(buf, 1, count, handle);
  if (errno) {
    *carry = 1;
    ret_val = errno;
  } else {
    *carry = 0;
  }
  errno = errno_old;
  return ret_val;
}


x86 assembly (clang, -O0):
<ReadFromFile_Real>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    %rcx,-0x20(%rbp)
mov    0x2eb2(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x24(%rbp)
mov    0x2ea6(%rip),%rax
movl   $0x0,(%rax)
mov    -0x10(%rbp),%rdi
mov    -0x14(%rbp),%edx
mov    -0x8(%rbp),%rcx
mov    $0x1,%esi
call   1030 <fread@plt>
mov    %eax,-0x28(%rbp)
mov    0x2e81(%rip),%rax
cmpl   $0x0,(%rax)
je     1183 <ReadFromFile_Real+0x73>
mov    -0x20(%rbp),%rax
movl   $0x1,(%rax)
mov    0x2e67(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x28(%rbp)
jmp    118d <ReadFromFile_Real+0x7d>
mov    -0x20(%rbp),%rax
movl   $0x0,(%rax)
mov    -0x24(%rbp),%ecx
mov    0x2e49(%rip),%rax
mov    %ecx,(%rax)
mov    -0x28(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ReadFromFile_Real>:
push   %rbp
push   %r14
push   %rbx
mov    %rcx,%r14
mov    %rdi,%rcx
mov    0x2ebf(%rip),%rbx
mov    (%rbx),%ebp
movl   $0x0,(%rbx)
mov    %rsi,%rdi
mov    $0x1,%esi
call   1030 <fread@plt>
cmpl   $0x0,(%rbx)
je     1146 <ReadFromFile_Real+0x36>
movl   $0x1,(%r14)
mov    (%rbx),%eax
jmp    114d <ReadFromFile_Real+0x3d>
movl   $0x0,(%r14)
mov    %ebp,(%rbx)
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@errno = global i32 0
define i32 @ReadFromFile_Real(i32* %0, i8* %1, i32 %2, i32* %3) {
%5 = alloca i32*
%6 = alloca i8*
%7 = alloca i32
%8 = alloca i32*
%9 = alloca i32
%10 = alloca i32
store i32* %0, i32** %5
store i8* %1, i8** %6
store i32 %2, i32* %7
store i32* %3, i32** %8
%11 = load i32, i32* @errno
store i32 %11, i32* %9
store i32 0, i32* @errno
%12 = load i8*, i8** %6
%13 = load i32, i32* %7
%14 = load i32*, i32** %5
%15 = call i32 @fread(i8* %12, i32 1, i32 %13, i32* %14)
store i32 %15, i32* %10
%16 = load i32, i32* @errno
%17 = icmp ne i32 %16, 0
br i1 %17, label %18, label %21
18: ; preds = %4
%19 = load i32*, i32** %8
store i32 1, i32* %19
%20 = load i32, i32* @errno
store i32 %20, i32* %10
br label %23
21: ; preds = %4
%22 = load i32*, i32** %8
store i32 0, i32* %22
br label %23
23: ; preds = %21, %18
%24 = load i32, i32* %9
store i32 %24, i32* @errno
%25 = load i32, i32* %10
ret i32 %25
}

LLVM IR (-O2):
@errno = global i32 0
define i32 @ReadFromFile_Real(i32* nocapture %0, i8* nocapture %1, i32 %2, i32* nocapture writeonly %3) {
%5 = load i32, i32* @errno
store i32 0, i32* @errno
%6 = tail call i32 @fread(i8* %1, i32 1, i32 %2, i32* %0)
%7 = load i32, i32* @errno
%8 = icmp eq i32 %7, 0
br i1 %8, label %11, label %9
9: ; preds = %4
store i32 1, i32* %3
%10 = load i32, i32* @errno
br label %12
11: ; preds = %4
store i32 0, i32* %3
br label %12
12: ; preds = %11, %9
%13 = phi i32 [ %10, %9 ], [ %6, %11 ]
store i32 %5, i32* @errno
ret i32 %13
}