#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*/ exit(int);
int /*<<< orphan*/ exit_perror(int, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
int /*<<< orphan*/ stderr;
void die_if_readerr(int ret, size_t size) {
  if (ret == 0) {
    fprintf(stderr, "sread: eof reached, there is a bug or fs corrupted.");
    exit(1);
  } else if (ret == -1 || ret < size) {
    exit_perror(1, "sread");
  }
}


x86 assembly (clang, -O0):
<die_if_readerr>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x0,-0x4(%rbp)
jne    1168 <die_if_readerr+0x38>
mov    0x2e90(%rip),%rax
mov    (%rax),%edi
lea    0xea7(%rip),%rsi
call   1040 <fprintf@plt>
mov    $0x1,%edi
call   1050 <exit@plt>
cmpl   $0xffffffff,-0x4(%rbp)
je     1180 <die_if_readerr+0x50>
movslq -0x4(%rbp),%rax
cmp    -0x10(%rbp),%rax
jae    1191 <die_if_readerr+0x61>
mov    $0x1,%edi
lea    0xea8(%rip),%rsi
call   1030 <exit_perror@plt>
jmp    1196 <die_if_readerr+0x66>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<die_if_readerr>:
cmp    $0xffffffff,%edi
je     1141 <die_if_readerr+0x11>
test   %edi,%edi
je     1153 <die_if_readerr+0x23>
movslq %edi,%rax
cmp    %rsi,%rax
jae    1152 <die_if_readerr+0x22>
lea    0xeec(%rip),%rsi
mov    $0x1,%edi
jmp    1030 <exit_perror@plt>
ret
push   %rax
mov    0x2e85(%rip),%rax
mov    (%rax),%edi
lea    0xe9c(%rip),%rsi
call   1040 <fprintf@plt>
mov    $0x1,%edi
call   1050 <exit@plt>

LLVM IR (-O0):
@stderr = global i32 0
@.str = [52 x i8] c"sread: eof reached, there is a bug or fs corrupted.\00"
@.str.1 = [6 x i8] c"sread\00"
define void @die_if_readerr(i32 %0, i64 %1) {
%3 = alloca i32
%4 = alloca i64
store i32 %0, i32* %3
store i64 %1, i64* %4
%5 = load i32, i32* %3
%6 = icmp eq i32 %5, 0
br i1 %6, label %7, label %11
7: ; preds = %2
%8 = load i32, i32* @stderr
%9 = call i32 @fprintf(i32 %8, i8* getelementptr inbounds ([52 x i8], [52 x i8]* @.str, i64 0, i64 0))
%10 = call i32 @exit(i32 1)
unreachable
11: ; preds = %2
%12 = load i32, i32* %3
%13 = icmp eq i32 %12, -1
br i1 %13, label %19, label %14
14: ; preds = %11
%15 = load i32, i32* %3
%16 = sext i32 %15 to i64
%17 = load i64, i64* %4
%18 = icmp ult i64 %16, %17
br i1 %18, label %19, label %21
19: ; preds = %14, %11
%20 = call i32 @exit_perror(i32 1, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0))
br label %21
21: ; preds = %19, %14
br label %22
22: ; preds = %21
ret void
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [52 x i8] c"sread: eof reached, there is a bug or fs corrupted.\00"
@.str.1 = [6 x i8] c"sread\00"
define void @die_if_readerr(i32 %0, i64 %1) {
switch i32 %0, label %7 [
i32 0, label %3
i32 -1, label %10
]
3: ; preds = %2
%4 = load i32, i32* @stderr
%5 = tail call i32 @fprintf(i32 %4, i8* getelementptr inbounds ([52 x i8], [52 x i8]* @.str, i64 0, i64 0))
%6 = tail call i32 @exit(i32 1)
unreachable
7: ; preds = %2
%8 = sext i32 %0 to i64
%9 = icmp ult i64 %8, %1
br i1 %9, label %10, label %12
10: ; preds = %2, %7
%11 = tail call i32 @exit_perror(i32 1, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0))
br label %12
12: ; preds = %7, %10
ret void
}