#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*/ assert(int);
size_t strlen(char const *const);
size_t eof_test_read(void *buf, size_t size, size_t nmemb, void *stream) {
  assert(size == 1);
  assert(nmemb == 1);
  (void)size;
  static const char *const string = "_:s1 <http://example.org/p> _:o1 .\n"
                                    "_:s2 <http://example.org/p> _:o2 .\n";
  size_t *const count = (size_t *)stream;
  if (*count < 35) {
    *(char *)buf = string[*count];
    ++*count;
    return nmemb;
  }
  if (*count == 35) {
    assert(string[*count] == '_');
    ++*count;
    return 0;
  }
  if (*count >= strlen(string)) {
    return 0;
  }
  *(char *)buf = string[*count - 1];
  ++*count;
  return nmemb;
}


x86 assembly (clang, -O0):
<eof_test_read>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    %rcx,-0x28(%rbp)
cmpq   $0x1,-0x18(%rbp)
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1030 <assert@plt>
cmpq   $0x1,-0x20(%rbp)
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1030 <assert@plt>
mov    -0x28(%rbp),%rax
mov    %rax,-0x30(%rbp)
mov    -0x30(%rbp),%rax
cmpq   $0x23,(%rax)
jae    1194 <eof_test_read+0x84>
mov    -0x30(%rbp),%rax
mov    (%rax),%rcx
lea    0xe90(%rip),%rax
mov    (%rax,%rcx,1),%cl
mov    -0x10(%rbp),%rax
mov    %cl,(%rax)
mov    -0x30(%rbp),%rax
mov    (%rax),%rcx
add    $0x1,%rcx
mov    %rcx,(%rax)
mov    -0x20(%rbp),%rax
mov    %rax,-0x8(%rbp)
jmp    122b <eof_test_read+0x11b>
mov    -0x30(%rbp),%rax
cmpq   $0x23,(%rax)
jne    11df <eof_test_read+0xcf>
mov    -0x30(%rbp),%rax
mov    (%rax),%rcx
lea    0xe50(%rip),%rax
movsbl (%rax,%rcx,1),%eax
cmp    $0x5f,%eax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1030 <assert@plt>
mov    -0x30(%rbp),%rax
mov    (%rax),%rcx
add    $0x1,%rcx
mov    %rcx,(%rax)
movq   $0x0,-0x8(%rbp)
jmp    122b <eof_test_read+0x11b>
mov    -0x30(%rbp),%rax
cmpq   $0x46,(%rax)
jb     11fa <eof_test_read+0xea>
movq   $0x0,-0x8(%rbp)
jmp    122b <eof_test_read+0x11b>
mov    -0x30(%rbp),%rax
mov    (%rax),%rcx
sub    $0x1,%rcx
lea    0xdf4(%rip),%rax
mov    (%rax,%rcx,1),%cl
mov    -0x10(%rbp),%rax
mov    %cl,(%rax)
mov    -0x30(%rbp),%rax
mov    (%rax),%rcx
add    $0x1,%rcx
mov    %rcx,(%rax)
mov    -0x20(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<eof_test_read>:
push   %r15
push   %r14
push   %rbx
mov    %rcx,%r14
mov    %rdx,%rbx
mov    %rdi,%r15
xor    %edi,%edi
cmp    $0x1,%rsi
sete   %dil
call   1030 <assert@plt>
xor    %edi,%edi
cmp    $0x1,%rbx
sete   %dil
call   1030 <assert@plt>
mov    (%r14),%rax
cmp    $0x22,%rax
ja     1151 <eof_test_read+0x41>
lea    0xeb4(%rip),%rcx
mov    (%rax,%rcx,1),%al
jmp    117a <eof_test_read+0x6a>
cmp    $0x23,%rax
jne    1165 <eof_test_read+0x55>
mov    $0x1,%edi
call   1030 <assert@plt>
xor    %ebx,%ebx
jmp    117d <eof_test_read+0x6d>
cmp    $0x45,%rax
jbe    116f <eof_test_read+0x5f>
xor    %ebx,%ebx
jmp    1181 <eof_test_read+0x71>
lea    0xe8a(%rip),%rcx
mov    -0x1(%rax,%rcx,1),%al
mov    %al,(%r15)
addq   $0x1,(%r14)
mov    %rbx,%rax
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@eof_test_read.string = internal constant i8* getelementptr inbounds ([71 x i8], [71 x i8]* @.str, i32 0, i32 0)
@.str = [71 x i8] c"_:s1 <http://example.org/p> _:o1 .\0A_:s2 <http://example.org/p> _:o2 .\0A\00"
define i64 @eof_test_read(i8* %0, i64 %1, i64 %2, i8* %3) {
%5 = alloca i64
%6 = alloca i8*
%7 = alloca i64
%8 = alloca i64
%9 = alloca i8*
%10 = alloca i64*
store i8* %0, i8** %6
store i64 %1, i64* %7
store i64 %2, i64* %8
store i8* %3, i8** %9
%11 = load i64, i64* %7
%12 = icmp eq i64 %11, 1
%13 = zext i1 %12 to i32
%14 = call i32 @assert(i32 %13)
%15 = load i64, i64* %8
%16 = icmp eq i64 %15, 1
%17 = zext i1 %16 to i32
%18 = call i32 @assert(i32 %17)
%19 = load i64, i64* %7
%20 = load i8*, i8** %9
%21 = bitcast i8* %20 to i64*
store i64* %21, i64** %10
%22 = load i64*, i64** %10
%23 = load i64, i64* %22
%24 = icmp ult i64 %23, 35
br i1 %24, label %25, label %35
25: ; preds = %4
%26 = load i64*, i64** %10
%27 = load i64, i64* %26
%28 = getelementptr inbounds i8, i8* getelementptr inbounds ([71 x i8], [71 x i8]* @.str, i32 0, i32 0), i64 %27
%29 = load i8, i8* %28
%30 = load i8*, i8** %6
store i8 %29, i8* %30
%31 = load i64*, i64** %10
%32 = load i64, i64* %31
%33 = add i64 %32, 1
store i64 %33, i64* %31
%34 = load i64, i64* %8
store i64 %34, i64* %5
br label %67
35: ; preds = %4
%36 = load i64*, i64** %10
%37 = load i64, i64* %36
%38 = icmp eq i64 %37, 35
br i1 %38, label %39, label %51
39: ; preds = %35
%40 = load i64*, i64** %10
%41 = load i64, i64* %40
%42 = getelementptr inbounds i8, i8* getelementptr inbounds ([71 x i8], [71 x i8]* @.str, i32 0, i32 0), i64 %41
%43 = load i8, i8* %42
%44 = sext i8 %43 to i32
%45 = icmp eq i32 %44, 95
%46 = zext i1 %45 to i32
%47 = call i32 @assert(i32 %46)
%48 = load i64*, i64** %10
%49 = load i64, i64* %48
%50 = add i64 %49, 1
store i64 %50, i64* %48
store i64 0, i64* %5
br label %67
51: ; preds = %35
%52 = load i64*, i64** %10
%53 = load i64, i64* %52
%54 = icmp uge i64 %53, 70
br i1 %54, label %55, label %56
55: ; preds = %51
store i64 0, i64* %5
br label %67
56: ; preds = %51
%57 = load i64*, i64** %10
%58 = load i64, i64* %57
%59 = sub i64 %58, 1
%60 = getelementptr inbounds i8, i8* getelementptr inbounds ([71 x i8], [71 x i8]* @.str, i32 0, i32 0), i64 %59
%61 = load i8, i8* %60
%62 = load i8*, i8** %6
store i8 %61, i8* %62
%63 = load i64*, i64** %10
%64 = load i64, i64* %63
%65 = add i64 %64, 1
store i64 %65, i64* %63
%66 = load i64, i64* %8
store i64 %66, i64* %5
br label %67
67: ; preds = %56, %55, %39, %25
%68 = load i64, i64* %5
ret i64 %68
}

LLVM IR (-O2):
@.str = [71 x i8] c"_:s1 <http://example.org/p> _:o1 .\0A_:s2 <http://example.org/p> _:o2 .\0A\00"
define i64 @eof_test_read(i8* nocapture writeonly %0, i64 %1, i64 %2, i8* nocapture %3) {
%5 = icmp eq i64 %1, 1
%6 = zext i1 %5 to i32
%7 = tail call i32 @assert(i32 %6)
%8 = icmp eq i64 %2, 1
%9 = zext i1 %8 to i32
%10 = tail call i32 @assert(i32 %9)
%11 = bitcast i8* %3 to i64*
%12 = load i64, i64* %11
%13 = icmp ult i64 %12, 35
br i1 %13, label %14, label %17
14: ; preds = %4
%15 = getelementptr inbounds [71 x i8], [71 x i8]* @.str, i64 0, i64 %12
%16 = load i8, i8* %15
store i8 %16, i8* %0
br label %27
17: ; preds = %4
%18 = icmp eq i64 %12, 35
br i1 %18, label %19, label %21
19: ; preds = %17
%20 = tail call i32 @assert(i32 1)
br label %27
21: ; preds = %17
%22 = icmp ugt i64 %12, 69
br i1 %22, label %31, label %23
23: ; preds = %21
%24 = add nsw i64 %12, -1
%25 = getelementptr inbounds [71 x i8], [71 x i8]* @.str, i64 0, i64 %24
%26 = load i8, i8* %25
store i8 %26, i8* %0
br label %27
27: ; preds = %14, %19, %23
%28 = phi i64 [ %2, %23 ], [ 0, %19 ], [ %2, %14 ]
%29 = load i64, i64* %11
%30 = add i64 %29, 1
store i64 %30, i64* %11
br label %31
31: ; preds = %27, %21
%32 = phi i64 [ 0, %21 ], [ %28, %27 ]
ret i64 %32
}