#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 */
scalar_t__ EINTR;
scalar_t__ errno;
int /*<<< orphan*/ my_fatal(char *, char *, ...);
int read(int, char *, int);
int /*<<< orphan*/ strerror(scalar_t__);
int my_read(int fd, char string[], int size) {
  int n;
  {
    if (!(fd >= 0))
      my_fatal(
          "file \"%s\", line %d, assertion \""
          "fd>=0"
          "\" failed\n",
          "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/"
          "2022-01-22/02-19-57/repos/ddugovic/polyglot/refs/heads/master/io.c",
          302);
  };
  {
    if (!(string != NULL))
      my_fatal(
          "file \"%s\", line %d, assertion \""
          "string!=NULL"
          "\" failed\n",
          "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/"
          "2022-01-22/02-19-57/repos/ddugovic/polyglot/refs/heads/master/io.c",
          303);
  };
  {
    if (!(size > 0))
      my_fatal(
          "file \"%s\", line %d, assertion \""
          "size>0"
          "\" failed\n",
          "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/"
          "2022-01-22/02-19-57/repos/ddugovic/polyglot/refs/heads/master/io.c",
          304);
  };
  do {
    n = read(fd, string, size);
  } while (n == -1 && errno == EINTR);
  if (n == -1)
    my_fatal("my_read(): read(): %s\n", strerror(errno));
  {
    if (!(n >= 0))
      my_fatal(
          "file \"%s\", line %d, assertion \""
          "n>=0"
          "\" failed\n",
          "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/"
          "2022-01-22/02-19-57/repos/ddugovic/polyglot/refs/heads/master/io.c",
          312);
  };
  return n;
}


x86 assembly (clang, -O0):
<my_read>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
cmpl   $0x0,-0x4(%rbp)
jge    1166 <my_read+0x36>
lea    0xead(%rip),%rdi
lea    0xed4(%rip),%rsi
mov    $0x12e,%edx
mov    $0x0,%al
call   1040 <my_fatal@plt>
cmpq   $0x0,-0x10(%rbp)
jne    118b <my_read+0x5b>
lea    0xf39(%rip),%rdi
lea    0xeaf(%rip),%rsi
mov    $0x12f,%edx
mov    $0x0,%al
call   1040 <my_fatal@plt>
cmpl   $0x0,-0x14(%rbp)
jg     11af <my_read+0x7f>
lea    0xf4a(%rip),%rdi
lea    0xe8b(%rip),%rsi
mov    $0x130,%edx
mov    $0x0,%al
call   1040 <my_fatal@plt>
jmp    11b4 <my_read+0x84>
mov    -0x4(%rbp),%edi
mov    -0x10(%rbp),%rsi
mov    -0x14(%rbp),%edx
call   1030 <read@plt>
mov    %eax,-0x18(%rbp)
xor    %eax,%eax
cmpl   $0xffffffff,-0x18(%rbp)
mov    %al,-0x19(%rbp)
jne    11ef <my_read+0xbf>
mov    0x2e04(%rip),%rax
mov    (%rax),%rax
mov    0x2df2(%rip),%rcx
cmp    (%rcx),%rax
sete   %al
mov    %al,-0x19(%rbp)
mov    -0x19(%rbp),%al
test   $0x1,%al
jne    11b4 <my_read+0x84>
cmpl   $0xffffffff,-0x18(%rbp)
jne    1224 <my_read+0xf4>
mov    0x2dd5(%rip),%rax
mov    (%rax),%rdi
call   1050 <strerror@plt>
movslq %eax,%rsi
lea    0xef8(%rip),%rdi
mov    $0x0,%al
call   1040 <my_fatal@plt>
cmpl   $0x0,-0x18(%rbp)
jge    1248 <my_read+0x118>
lea    0xef7(%rip),%rdi
lea    0xdf2(%rip),%rsi
mov    $0x138,%edx
mov    $0x0,%al
call   1040 <my_fatal@plt>
mov    -0x18(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<my_read>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %edx,%r14d
mov    %rsi,%r15
mov    %edi,%r12d
test   %edi,%edi
js     118e <my_read+0x5e>
test   %r15,%r15
je     11ad <my_read+0x7d>
test   %r14d,%r14d
jle    11cc <my_read+0x9c>
mov    0x2e87(%rip),%r13
mov    0x2e78(%rip),%rbp
mov    %r12d,%edi
mov    %r15,%rsi
mov    %r14d,%edx
call   1030 <read@plt>
mov    %eax,%ebx
mov    0x0(%r13),%rdi
cmp    $0xffffffff,%eax
jne    117f <my_read+0x4f>
cmp    0x0(%rbp),%rdi
je     1160 <my_read+0x30>
cmp    $0xffffffff,%ebx
je     11eb <my_read+0xbb>
test   %ebx,%ebx
jns    121b <my_read+0xeb>
jmp    1201 <my_read+0xd1>
lea    0xe6b(%rip),%rdi
lea    0xe92(%rip),%rsi
mov    $0x12e,%edx
xor    %eax,%eax
call   1040 <my_fatal@plt>
test   %r15,%r15
jne    114d <my_read+0x1d>
lea    0xefd(%rip),%rdi
lea    0xe73(%rip),%rsi
mov    $0x12f,%edx
xor    %eax,%eax
call   1040 <my_fatal@plt>
test   %r14d,%r14d
jg     1152 <my_read+0x22>
lea    0xf13(%rip),%rdi
lea    0xe54(%rip),%rsi
mov    $0x130,%edx
xor    %eax,%eax
call   1040 <my_fatal@plt>
jmp    1152 <my_read+0x22>
call   1050 <strerror@plt>
movslq %eax,%rsi
lea    0xf1b(%rip),%rdi
xor    %eax,%eax
call   1040 <my_fatal@plt>
lea    0xf24(%rip),%rdi
lea    0xe1f(%rip),%rsi
mov    $0x138,%edx
xor    %eax,%eax
call   1040 <my_fatal@plt>
mov    %ebx,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [46 x i8] c"file \22%s\22, line %d, assertion \22fd>=0\22 failed\0A\00"
@.str.1 = [131 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/ddugovic/polyglot/refs/heads/master/io.c\00"
@.str.2 = [53 x i8] c"file \22%s\22, line %d, assertion \22string!=NULL\22 failed\0A\00"
@.str.3 = [47 x i8] c"file \22%s\22, line %d, assertion \22size>0\22 failed\0A\00"
@errno = global i64 0
@EINTR = global i64 0
@.str.4 = [23 x i8] c"my_read(): read(): %s\0A\00"
@.str.5 = [45 x i8] c"file \22%s\22, line %d, assertion \22n>=0\22 failed\0A\00"
define i32 @my_read(i32 %0, i8* %1, i32 %2) {
%4 = alloca i32
%5 = alloca i8*
%6 = alloca i32
%7 = alloca i32
store i32 %0, i32* %4
store i8* %1, i8** %5
store i32 %2, i32* %6
%8 = load i32, i32* %4
%9 = icmp sge i32 %8, 0
br i1 %9, label %12, label %10
10: ; preds = %3
%11 = call i32 (i8*, i8*, ...) @my_fatal(i8* getelementptr inbounds ([46 x i8], [46 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([131 x i8], [131 x i8]* @.str.1, i64 0, i64 0), i32 302)
br label %12
12: ; preds = %10, %3
%13 = load i8*, i8** %5
%14 = icmp ne i8* %13, null
br i1 %14, label %17, label %15
15: ; preds = %12
%16 = call i32 (i8*, i8*, ...) @my_fatal(i8* getelementptr inbounds ([53 x i8], [53 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([131 x i8], [131 x i8]* @.str.1, i64 0, i64 0), i32 303)
br label %17
17: ; preds = %15, %12
%18 = load i32, i32* %6
%19 = icmp sgt i32 %18, 0
br i1 %19, label %22, label %20
20: ; preds = %17
%21 = call i32 (i8*, i8*, ...) @my_fatal(i8* getelementptr inbounds ([47 x i8], [47 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([131 x i8], [131 x i8]* @.str.1, i64 0, i64 0), i32 304)
br label %22
22: ; preds = %20, %17
br label %23
23: ; preds = %35, %22
%24 = load i32, i32* %4
%25 = load i8*, i8** %5
%26 = load i32, i32* %6
%27 = call i32 @read(i32 %24, i8* %25, i32 %26)
store i32 %27, i32* %7
br label %28
28: ; preds = %23
%29 = load i32, i32* %7
%30 = icmp eq i32 %29, -1
br i1 %30, label %31, label %35
31: ; preds = %28
%32 = load i64, i64* @errno
%33 = load i64, i64* @EINTR
%34 = icmp eq i64 %32, %33
br label %35
35: ; preds = %31, %28
%36 = phi i1 [ false, %28 ], [ %34, %31 ]
br i1 %36, label %23, label %37
37: ; preds = %35
%38 = load i32, i32* %7
%39 = icmp eq i32 %38, -1
br i1 %39, label %40, label %46
40: ; preds = %37
%41 = load i64, i64* @errno
%42 = call i32 @strerror(i64 %41)
%43 = sext i32 %42 to i64
%44 = inttoptr i64 %43 to i8*
%45 = call i32 (i8*, i8*, ...) @my_fatal(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.4, i64 0, i64 0), i8* %44)
br label %46
46: ; preds = %40, %37
%47 = load i32, i32* %7
%48 = icmp sge i32 %47, 0
br i1 %48, label %51, label %49
49: ; preds = %46
%50 = call i32 (i8*, i8*, ...) @my_fatal(i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str.5, i64 0, i64 0), i8* getelementptr inbounds ([131 x i8], [131 x i8]* @.str.1, i64 0, i64 0), i32 312)
br label %51
51: ; preds = %49, %46
%52 = load i32, i32* %7
ret i32 %52
}

LLVM IR (-O2):
@.str = [46 x i8] c"file \22%s\22, line %d, assertion \22fd>=0\22 failed\0A\00"
@.str.1 = [131 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/ddugovic/polyglot/refs/heads/master/io.c\00"
@.str.2 = [53 x i8] c"file \22%s\22, line %d, assertion \22string!=NULL\22 failed\0A\00"
@.str.3 = [47 x i8] c"file \22%s\22, line %d, assertion \22size>0\22 failed\0A\00"
@errno = global i64 0
@EINTR = global i64 0
@.str.4 = [23 x i8] c"my_read(): read(): %s\0A\00"
@.str.5 = [45 x i8] c"file \22%s\22, line %d, assertion \22n>=0\22 failed\0A\00"
define i32 @my_read(i32 %0, i8* %1, i32 %2) {
%4 = icmp sgt i32 %0, -1
br i1 %4, label %7, label %5
5: ; preds = %3
%6 = tail call i32 (i8*, i8*, ...) @my_fatal(i8* getelementptr inbounds ([46 x i8], [46 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([131 x i8], [131 x i8]* @.str.1, i64 0, i64 0), i32 302)
br label %7
7: ; preds = %5, %3
%8 = icmp eq i8* %1, null
br i1 %8, label %9, label %11
9: ; preds = %7
%10 = tail call i32 (i8*, i8*, ...) @my_fatal(i8* getelementptr inbounds ([53 x i8], [53 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([131 x i8], [131 x i8]* @.str.1, i64 0, i64 0), i32 303)
br label %11
11: ; preds = %9, %7
%12 = icmp sgt i32 %2, 0
br i1 %12, label %15, label %13
13: ; preds = %11
%14 = tail call i32 (i8*, i8*, ...) @my_fatal(i8* getelementptr inbounds ([47 x i8], [47 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([131 x i8], [131 x i8]* @.str.1, i64 0, i64 0), i32 304)
br label %15
15: ; preds = %13, %11
br label %16
16: ; preds = %15, %16
%17 = tail call i32 @read(i32 %0, i8* %1, i32 %2)
%18 = icmp eq i32 %17, -1
%19 = load i64, i64* @errno
%20 = load i64, i64* @EINTR
%21 = icmp eq i64 %19, %20
%22 = select i1 %18, i1 %21, i1 false
br i1 %22, label %16, label %23
23: ; preds = %16
br i1 %18, label %24, label %29
24: ; preds = %23
%25 = tail call i32 @strerror(i64 %19)
%26 = sext i32 %25 to i64
%27 = inttoptr i64 %26 to i8*
%28 = tail call i32 (i8*, i8*, ...) @my_fatal(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.4, i64 0, i64 0), i8* %27)
br label %31
29: ; preds = %23
%30 = icmp sgt i32 %17, -1
br i1 %30, label %33, label %31
31: ; preds = %24, %29
%32 = tail call i32 (i8*, i8*, ...) @my_fatal(i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str.5, i64 0, i64 0), i8* getelementptr inbounds ([131 x i8], [131 x i8]* @.str.1, i64 0, i64 0), i32 312)
br label %33
33: ; preds = %31, %29
ret i32 %17
}