#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*/ exit(int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, size_t, size_t);
size_t fread(void *, size_t, size_t, int /*<<< orphan*/ *);
int /*<<< orphan*/ stderr;
void efread(void *ptr, size_t size, size_t nmemb, FILE *stream) {
  size_t r;
  r = fread(ptr, size, nmemb, stream);
  if (r == 0) {
    fprintf(stderr, "ply2off: fails to read: %ld/%ld\n", size, nmemb);
    exit(2);
  }
}


x86 assembly (clang, -O0):
<efread>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x18(%rbp),%rdx
mov    -0x20(%rbp),%rcx
call   1030 <fread@plt>
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
jne    1193 <efread+0x63>
mov    0x2e6d(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rdx
mov    -0x18(%rbp),%rcx
lea    0xe7c(%rip),%rsi
call   1040 <fprintf@plt>
mov    $0x2,%edi
call   1050 <exit@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<efread>:
push   %r14
push   %rbx
push   %rax
mov    %rdx,%r14
mov    %rsi,%rbx
call   1030 <fread@plt>
test   %rax,%rax
je     114c <efread+0x1c>
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret
mov    0x2e8d(%rip),%rax
mov    (%rax),%edi
lea    0xea4(%rip),%rsi
mov    %rbx,%rdx
mov    %r14,%rcx
call   1040 <fprintf@plt>
mov    $0x2,%edi
call   1050 <exit@plt>

LLVM IR (-O0):
@stderr = global i32 0
@.str = [33 x i8] c"ply2off: fails to read: %ld/%ld\0A\00"
define void @efread(i8* %0, i64 %1, i64 %2, i32* %3) {
%5 = alloca i8*
%6 = alloca i64
%7 = alloca i64
%8 = alloca i32*
%9 = alloca i64
store i8* %0, i8** %5
store i64 %1, i64* %6
store i64 %2, i64* %7
store i32* %3, i32** %8
%10 = load i8*, i8** %5
%11 = load i64, i64* %6
%12 = load i64, i64* %7
%13 = load i32*, i32** %8
%14 = call i64 @fread(i8* %10, i64 %11, i64 %12, i32* %13)
store i64 %14, i64* %9
%15 = load i64, i64* %9
%16 = icmp eq i64 %15, 0
br i1 %16, label %17, label %23
17: ; preds = %4
%18 = load i32, i32* @stderr
%19 = load i64, i64* %6
%20 = load i64, i64* %7
%21 = call i32 @fprintf(i32 %18, i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str, i64 0, i64 0), i64 %19, i64 %20)
%22 = call i32 @exit(i32 2)
unreachable
23: ; preds = %4
ret void
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [33 x i8] c"ply2off: fails to read: %ld/%ld\0A\00"
define void @efread(i8* nocapture %0, i64 %1, i64 %2, i32* nocapture %3) {
%5 = tail call i64 @fread(i8* %0, i64 %1, i64 %2, i32* %3)
%6 = icmp eq i64 %5, 0
br i1 %6, label %7, label %11
7: ; preds = %4
%8 = load i32, i32* @stderr
%9 = tail call i32 @fprintf(i32 %8, i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str, i64 0, i64 0), i64 %1, i64 %2)
%10 = tail call i32 @exit(i32 2)
unreachable
11: ; preds = %4
ret void
}