#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__ EAGAIN;
scalar_t__ ECONNRESET;
scalar_t__ EINTR;
scalar_t__ EPIPE;
scalar_t__ errno;
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *, int, char *,
                           char *);
int /*<<< orphan*/ stderr;
char *strerror(scalar_t__);
int write(int, unsigned char *, int);
int Write(int fd, unsigned char *p, int max) {
  int n;
  do {
    n = write(fd, p, max);
  } while (n < 0 && errno == EINTR);
  if (n < 0 && errno != EAGAIN && errno != ECONNRESET && errno != EPIPE)
    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",
              424, "write", strerror(errno));
    } while (0);
  return n;
}


x86 assembly (clang, -O0):
<Write>:
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 <write@plt>
mov    %eax,-0x18(%rbp)
xor    %eax,%eax
cmpl   $0x0,-0x18(%rbp)
mov    %al,-0x19(%rbp)
jge    117d <Write+0x4d>
mov    0x2e5e(%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 <Write+0x12>
cmpl   $0x0,-0x18(%rbp)
jge    122a <Write+0xfa>
mov    0x2e2f(%rip),%rax
mov    (%rax),%rax
mov    0x2e0d(%rip),%rcx
cmp    (%rcx),%rax
je     122a <Write+0xfa>
mov    0x2e15(%rip),%rax
mov    (%rax),%rax
mov    0x2e23(%rip),%rcx
cmp    (%rcx),%rax
je     122a <Write+0xfa>
mov    0x2dfb(%rip),%rax
mov    (%rax),%rax
mov    0x2df9(%rip),%rcx
cmp    (%rcx),%rax
je     122a <Write+0xfa>
jmp    11e5 <Write+0xb5>
mov    0x2dec(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x20(%rbp)
mov    0x2dd0(%rip),%rax
mov    (%rax),%rdi
call   1050 <strerror@plt>
mov    -0x20(%rbp),%edi
mov    %rax,%r9
lea    0xdf3(%rip),%rsi
lea    0xe03(%rip),%rdx
mov    $0x1a8,%ecx
lea    0xe91(%rip),%r8
call   1040 <fprintf@plt>
jmp    122a <Write+0xfa>
mov    -0x18(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<Write>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %edx,%r14d
mov    %rsi,%r15
mov    %edi,%ebp
mov    0x2e7e(%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 <write@plt>
mov    %eax,%ebx
mov    (%r12),%rdi
test   %eax,%eax
jns    117d <Write+0x4d>
cmp    0x0(%r13),%rdi
je     1160 <Write+0x30>
test   %ebx,%ebx
jns    11d7 <Write+0xa7>
mov    0x2e28(%rip),%rax
cmp    (%rax),%rdi
je     11d7 <Write+0xa7>
mov    0x2e4c(%rip),%rax
cmp    (%rax),%rdi
je     11d7 <Write+0xa7>
mov    0x2e30(%rip),%rax
cmp    (%rax),%rdi
je     11d7 <Write+0xa7>
mov    0x2e2c(%rip),%rax
mov    (%rax),%ebp
call   1050 <strerror@plt>
lea    0xe46(%rip),%rsi
lea    0xe56(%rip),%rdx
lea    0xee9(%rip),%r8
mov    %ebp,%edi
mov    $0x1a8,%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
@EAGAIN = global i64 0
@ECONNRESET = global i64 0
@EPIPE = 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 = [6 x i8] c"write\00"
define i32 @Write(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 @write(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 %44
25: ; preds = %22
%26 = load i64, i64* @errno
%27 = load i64, i64* @EAGAIN
%28 = icmp ne i64 %26, %27
br i1 %28, label %29, label %44
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 %44
33: ; preds = %29
%34 = load i64, i64* @errno
%35 = load i64, i64* @EPIPE
%36 = icmp ne i64 %34, %35
br i1 %36, label %37, label %44
37: ; preds = %33
br label %38
38: ; preds = %37
%39 = load i32, i32* @stderr
%40 = load i64, i64* @errno
%41 = call i8* @strerror(i64 %40)
%42 = call i32 @fprintf(i32 %39, 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 424, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), i8* %41)
br label %43
43: ; preds = %38
br label %44
44: ; preds = %43, %33, %29, %25, %22
%45 = load i32, i32* %7
ret i32 %45
}

LLVM IR (-O2):
@errno = global i64 0
@EINTR = global i64 0
@EAGAIN = global i64 0
@ECONNRESET = global i64 0
@EPIPE = 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 = [6 x i8] c"write\00"
define i32 @Write(i32 %0, i8* nocapture %1, i32 %2) {
br label %4
4: ; preds = %4, %3
%5 = tail call i32 @write(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* @EAGAIN
%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
%19 = load i64, i64* @EPIPE
%20 = icmp eq i64 %7, %19
%21 = select i1 %18, i1 true, i1 %20
br i1 %21, label %26, label %22
22: ; preds = %11
%23 = load i32, i32* @stderr
%24 = tail call i8* @strerror(i64 %7)
%25 = tail call i32 @fprintf(i32 %23, 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 424, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), i8* %24)
br label %26
26: ; preds = %22, %11
ret i32 %5
}