#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__ ECONNRESET;
scalar_t__ EINTR;
scalar_t__ EWOULDBLOCK;
scalar_t__ errno;
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *, int, char *,
                           char *);
int read(int, unsigned char *, int);
int /*<<< orphan*/ stderr;
char *strerror(scalar_t__);
int Read(int fd, unsigned char *p, int max) {
  int n;
  do {
    n = read(fd, p, max);
  } while (n < 0 && errno == EINTR);
  if (n < 0 && errno != EWOULDBLOCK && errno != ECONNRESET)
    do {
      fprintf(stderr, "ERROR: [%s:%d] %s: %s\n",
              "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/"
              "2022-01-22/02-19-57/repos/ystk/debian-freeipmi/refs/heads/"
              "master/ipmipower/src/wrappers.c",
              412, "read", strerror(errno));
    } while (0);
  return n;
}


x86 assembly (clang, -O0):
<Read>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    -0x4(%rbp),%edi
mov    -0x10(%rbp),%rsi
mov    -0x14(%rbp),%edx
call   1030 <read@plt>
mov    %eax,-0x18(%rbp)
xor    %eax,%eax
cmpl   $0x0,-0x18(%rbp)
mov    %al,-0x19(%rbp)
jge    117d <Read+0x4d>
mov    0x2e66(%rip),%rax
mov    (%rax),%rax
mov    0x2e4c(%rip),%rcx
cmp    (%rcx),%rax
sete   %al
mov    %al,-0x19(%rbp)
mov    -0x19(%rbp),%al
test   $0x1,%al
jne    1142 <Read+0x12>
cmpl   $0x0,-0x18(%rbp)
jge    1210 <Read+0xe0>
mov    0x2e37(%rip),%rax
mov    (%rax),%rax
mov    0x2e25(%rip),%rcx
cmp    (%rcx),%rax
je     1210 <Read+0xe0>
mov    0x2e1d(%rip),%rax
mov    (%rax),%rax
mov    0x2e23(%rip),%rcx
cmp    (%rcx),%rax
je     1210 <Read+0xe0>
jmp    11cb <Read+0x9b>
mov    0x2e06(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x20(%rbp)
mov    0x2df2(%rip),%rax
mov    (%rax),%rdi
call   1050 <strerror@plt>
mov    -0x20(%rbp),%edi
mov    %rax,%r9
lea    0xe0d(%rip),%rsi
lea    0xe1d(%rip),%rdx
mov    $0x19c,%ecx
lea    0xeab(%rip),%r8
call   1040 <fprintf@plt>
jmp    1210 <Read+0xe0>
mov    -0x18(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<Read>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %edx,%r14d
mov    %rsi,%r15
mov    %edi,%ebp
mov    0x2e86(%rip),%r12
mov    0x2e6f(%rip),%r13
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    %ebp,%edi
mov    %r15,%rsi
mov    %r14d,%edx
call   1030 <read@plt>
mov    %eax,%ebx
mov    (%r12),%rdi
test   %eax,%eax
jns    117d <Read+0x4d>
cmp    0x0(%r13),%rdi
je     1160 <Read+0x30>
test   %ebx,%ebx
jns    11cb <Read+0x9b>
mov    0x2e40(%rip),%rax
cmp    (%rax),%rdi
je     11cb <Read+0x9b>
mov    0x2e4c(%rip),%rax
cmp    (%rax),%rdi
je     11cb <Read+0x9b>
mov    0x2e38(%rip),%rax
mov    (%rax),%ebp
call   1050 <strerror@plt>
lea    0xe52(%rip),%rsi
lea    0xe62(%rip),%rdx
lea    0xef5(%rip),%r8
mov    %ebp,%edi
mov    $0x19c,%ecx
mov    %rax,%r9
call   1040 <fprintf@plt>
mov    %ebx,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@errno = global i64 0
@EINTR = global i64 0
@EWOULDBLOCK = global i64 0
@ECONNRESET = global i64 0
@stderr = global i32 0
@.str = [23 x i8] c"ERROR: [%s:%d] %s: %s\0A\00"
@.str.1 = [154 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/ystk/debian-freeipmi/refs/heads/master/ipmipower/src/wrappers.c\00"
@.str.2 = [5 x i8] c"read\00"
define i32 @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
br label %8
8: ; preds = %20, %3
%9 = load i32, i32* %4
%10 = load i8*, i8** %5
%11 = load i32, i32* %6
%12 = call i32 @read(i32 %9, i8* %10, i32 %11)
store i32 %12, i32* %7
br label %13
13: ; preds = %8
%14 = load i32, i32* %7
%15 = icmp slt i32 %14, 0
br i1 %15, label %16, label %20
16: ; preds = %13
%17 = load i64, i64* @errno
%18 = load i64, i64* @EINTR
%19 = icmp eq i64 %17, %18
br label %20
20: ; preds = %16, %13
%21 = phi i1 [ false, %13 ], [ %19, %16 ]
br i1 %21, label %8, label %22
22: ; preds = %20
%23 = load i32, i32* %7
%24 = icmp slt i32 %23, 0
br i1 %24, label %25, label %40
25: ; preds = %22
%26 = load i64, i64* @errno
%27 = load i64, i64* @EWOULDBLOCK
%28 = icmp ne i64 %26, %27
br i1 %28, label %29, label %40
29: ; preds = %25
%30 = load i64, i64* @errno
%31 = load i64, i64* @ECONNRESET
%32 = icmp ne i64 %30, %31
br i1 %32, label %33, label %40
33: ; preds = %29
br label %34
34: ; preds = %33
%35 = load i32, i32* @stderr
%36 = load i64, i64* @errno
%37 = call i8* @strerror(i64 %36)
%38 = call i32 @fprintf(i32 %35, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([154 x i8], [154 x i8]* @.str.1, i64 0, i64 0), i32 412, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i8* %37)
br label %39
39: ; preds = %34
br label %40
40: ; preds = %39, %29, %25, %22
%41 = load i32, i32* %7
ret i32 %41
}

LLVM IR (-O2):
@errno = global i64 0
@EINTR = global i64 0
@EWOULDBLOCK = global i64 0
@ECONNRESET = global i64 0
@stderr = global i32 0
@.str = [23 x i8] c"ERROR: [%s:%d] %s: %s\0A\00"
@.str.1 = [154 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/ystk/debian-freeipmi/refs/heads/master/ipmipower/src/wrappers.c\00"
@.str.2 = [5 x i8] c"read\00"
define i32 @Read(i32 %0, i8* nocapture %1, i32 %2) {
br label %4
4: ; preds = %4, %3
%5 = tail call i32 @read(i32 %0, i8* %1, i32 %2)
%6 = icmp slt i32 %5, 0
%7 = load i64, i64* @errno
%8 = load i64, i64* @EINTR
%9 = icmp eq i64 %7, %8
%10 = select i1 %6, i1 %9, i1 false
br i1 %10, label %4, label %11
11: ; preds = %4
%12 = xor i1 %6, true
%13 = load i64, i64* @EWOULDBLOCK
%14 = icmp eq i64 %7, %13
%15 = select i1 %12, i1 true, i1 %14
%16 = load i64, i64* @ECONNRESET
%17 = icmp eq i64 %7, %16
%18 = select i1 %15, i1 true, i1 %17
br i1 %18, label %23, label %19
19: ; preds = %11
%20 = load i32, i32* @stderr
%21 = tail call i8* @strerror(i64 %7)
%22 = tail call i32 @fprintf(i32 %20, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([154 x i8], [154 x i8]* @.str.1, i64 0, i64 0), i32 412, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i8* %21)
br label %23
23: ; preds = %19, %11
ret i32 %5
}