#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 */

/* Variables and functions */
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
unsigned int read(unsigned int, char *, unsigned int);
int /*<<< orphan*/ stderr;
int request_read(unsigned int fd, char *buf, unsigned int quantity,
                 int is_fatal) {
  if (read(fd, buf, quantity) != quantity) {
    if (is_fatal)
      fprintf(stderr, "Error while reading map file: unexpected end of file\n");
    buf[0] = '\0';
    return -1;
  }
  return 1;
}


x86 assembly (clang, -O0):
<request_read>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    %ecx,-0x18(%rbp)
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%rsi
mov    -0x14(%rbp),%edx
call   1030 <read@plt>
cmp    -0x14(%rbp),%eax
je     117f <request_read+0x5f>
cmpl   $0x0,-0x18(%rbp)
je     116c <request_read+0x4c>
mov    0x2e82(%rip),%rax
mov    (%rax),%edi
lea    0xe99(%rip),%rsi
call   1040 <fprintf@plt>
mov    -0x10(%rbp),%rax
movb   $0x0,(%rax)
movl   $0xffffffff,-0x4(%rbp)
jmp    1186 <request_read+0x66>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<request_read>:
push   %rbp
push   %r14
push   %rbx
mov    %ecx,%r14d
mov    %edx,%ebp
mov    %rsi,%rbx
call   1030 <read@plt>
mov    %eax,%ecx
mov    $0x1,%eax
cmp    %ebp,%ecx
je     115e <request_read+0x3e>
test   %r14d,%r14d
je     1156 <request_read+0x36>
mov    0x2e98(%rip),%rax
mov    (%rax),%edi
lea    0xeaf(%rip),%rsi
call   1040 <fprintf@plt>
movb   $0x0,(%rbx)
mov    $0xffffffff,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@stderr = global i32 0
@.str = [54 x i8] c"Error while reading map file: unexpected end of file\0A\00"
define i32 @request_read(i32 %0, i8* %1, i32 %2, i32 %3) {
%5 = alloca i32
%6 = alloca i32
%7 = alloca i8*
%8 = alloca i32
%9 = alloca i32
store i32 %0, i32* %6
store i8* %1, i8** %7
store i32 %2, i32* %8
store i32 %3, i32* %9
%10 = load i32, i32* %6
%11 = load i8*, i8** %7
%12 = load i32, i32* %8
%13 = call i32 @read(i32 %10, i8* %11, i32 %12)
%14 = load i32, i32* %8
%15 = icmp ne i32 %13, %14
br i1 %15, label %16, label %25
16: ; preds = %4
%17 = load i32, i32* %9
%18 = icmp ne i32 %17, 0
br i1 %18, label %19, label %22
19: ; preds = %16
%20 = load i32, i32* @stderr
%21 = call i32 @fprintf(i32 %20, i8* getelementptr inbounds ([54 x i8], [54 x i8]* @.str, i64 0, i64 0))
br label %22
22: ; preds = %19, %16
%23 = load i8*, i8** %7
%24 = getelementptr inbounds i8, i8* %23, i64 0
store i8 0, i8* %24
store i32 -1, i32* %5
br label %26
25: ; preds = %4
store i32 1, i32* %5
br label %26
26: ; preds = %25, %22
%27 = load i32, i32* %5
ret i32 %27
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [54 x i8] c"Error while reading map file: unexpected end of file\0A\00"
define i32 @request_read(i32 %0, i8* nocapture %1, i32 %2, i32 %3) {
%5 = tail call i32 @read(i32 %0, i8* %1, i32 %2)
%6 = icmp eq i32 %5, %2
br i1 %6, label %13, label %7
7: ; preds = %4
%8 = icmp eq i32 %3, 0
br i1 %8, label %12, label %9
9: ; preds = %7
%10 = load i32, i32* @stderr
%11 = tail call i32 @fprintf(i32 %10, i8* getelementptr inbounds ([54 x i8], [54 x i8]* @.str, i64 0, i64 0))
br label %12
12: ; preds = %9, %7
store i8 0, i8* %1
br label %13
13: ; preds = %4, %12
%14 = phi i32 [ -1, %12 ], [ 1, %4 ]
ret i32 %14
}