#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__ EPIPE;
scalar_t__ errno;
int /*<<< orphan*/ my_fatal(char *, char *, ...);
int /*<<< orphan*/ strerror(scalar_t__);
int write(int, char const *, int);
void my_write(int fd, const 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",
          323);
  };
  {
    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",
          324);
  };
  {
    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",
          325);
  };
  do {
    n = write(fd, string, size);
    if (n == -1) {
      if (0) {
      } else if (errno == EINTR) {
        n = 0;
      } else if (errno == EPIPE) {
        n = size;
      } else {
        my_fatal("my_write(): write(): %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",
                 344);
    };
    string += n;
    size -= n;
  } while (size > 0);
  {
    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",
          351);
  };
}


x86 assembly (clang, -O0):
<my_write>:
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_write+0x36>
lea    0xead(%rip),%rdi
lea    0xed4(%rip),%rsi
mov    $0x143,%edx
mov    $0x0,%al
call   1040 <my_fatal@plt>
cmpq   $0x0,-0x10(%rbp)
jne    118b <my_write+0x5b>
lea    0xf39(%rip),%rdi
lea    0xeaf(%rip),%rsi
mov    $0x144,%edx
mov    $0x0,%al
call   1040 <my_fatal@plt>
cmpl   $0x0,-0x14(%rbp)
jg     11af <my_write+0x7f>
lea    0xf4a(%rip),%rdi
lea    0xe8b(%rip),%rsi
mov    $0x145,%edx
mov    $0x0,%al
call   1040 <my_fatal@plt>
jmp    11b4 <my_write+0x84>
mov    -0x4(%rbp),%edi
mov    -0x10(%rbp),%rsi
mov    -0x14(%rbp),%edx
call   1030 <write@plt>
mov    %eax,-0x18(%rbp)
cmpl   $0xffffffff,-0x18(%rbp)
jne    1245 <my_write+0x115>
mov    0x2e01(%rip),%rax
mov    (%rax),%rax
mov    0x2def(%rip),%rcx
cmp    (%rcx),%rax
jne    11f6 <my_write+0xc6>
movl   $0x0,-0x18(%rbp)
jmp    1240 <my_write+0x110>
mov    0x2ddb(%rip),%rax
mov    (%rax),%rax
mov    0x2dd9(%rip),%rcx
cmp    (%rcx),%rax
jne    121b <my_write+0xeb>
mov    -0x14(%rbp),%eax
mov    %eax,-0x18(%rbp)
jmp    123b <my_write+0x10b>
mov    0x2db6(%rip),%rax
mov    (%rax),%rdi
call   1050 <strerror@plt>
movslq %eax,%rsi
lea    0xee1(%rip),%rdi
mov    $0x0,%al
call   1040 <my_fatal@plt>
jmp    1240 <my_write+0x110>
jmp    1245 <my_write+0x115>
cmpl   $0x0,-0x18(%rbp)
jge    1269 <my_write+0x139>
lea    0xed8(%rip),%rdi
lea    0xdd1(%rip),%rsi
mov    $0x158,%edx
mov    $0x0,%al
call   1040 <my_fatal@plt>
mov    -0x18(%rbp),%ecx
mov    -0x10(%rbp),%rax
movslq %ecx,%rcx
add    %rcx,%rax
mov    %rax,-0x10(%rbp)
mov    -0x18(%rbp),%ecx
mov    -0x14(%rbp),%eax
sub    %ecx,%eax
mov    %eax,-0x14(%rbp)
cmpl   $0x0,-0x14(%rbp)
jg     11b4 <my_write+0x84>
cmpl   $0x0,-0x14(%rbp)
je     12b3 <my_write+0x183>
lea    0xebb(%rip),%rdi
lea    0xd87(%rip),%rsi
mov    $0x15f,%edx
mov    $0x0,%al
call   1040 <my_fatal@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<my_write>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %edx,%r15d
mov    %rsi,%r14
mov    %edi,%ebp
test   %edi,%edi
js     121b <my_write+0xeb>
test   %r14,%r14
je     123e <my_write+0x10e>
test   %r15d,%r15d
jle    1261 <my_write+0x131>
lea    0xfca(%rip),%r12
lea    0xec3(%rip),%r13
jmp    11a5 <my_write+0x75>
call   1050 <strerror@plt>
movslq %eax,%rsi
lea    0xf99(%rip),%rdi
xor    %eax,%eax
call   1040 <my_fatal@plt>
mov    $0xffffffff,%ebx
mov    %r12,%rdi
mov    %r13,%rsi
mov    $0x158,%edx
xor    %eax,%eax
call   1040 <my_fatal@plt>
movslq %ebx,%rax
add    %rax,%r14
sub    %eax,%r15d
jle    11ed <my_write+0xbd>
mov    %ebp,%edi
mov    %r14,%rsi
mov    %r15d,%edx
call   1030 <write@plt>
mov    %eax,%ebx
cmp    $0xffffffff,%eax
je     11c0 <my_write+0x90>
test   %ebx,%ebx
jns    119a <my_write+0x6a>
jmp    1188 <my_write+0x58>
nop
mov    0x2e11(%rip),%rax
mov    (%rax),%rdi
xor    %ebx,%ebx
mov    0x2dfd(%rip),%rax
cmp    (%rax),%rdi
je     119a <my_write+0x6a>
mov    %r15d,%ebx
mov    0x2dfe(%rip),%rax
cmp    (%rax),%rdi
jne    116d <my_write+0x3d>
jmp    11b9 <my_write+0x89>
je     1280 <my_write+0x150>
lea    0xf61(%rip),%rdi
lea    0xe2d(%rip),%rsi
mov    $0x15f,%edx
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1040 <my_fatal@plt>
lea    0xdde(%rip),%rdi
lea    0xe05(%rip),%rsi
mov    $0x143,%edx
xor    %eax,%eax
call   1040 <my_fatal@plt>
test   %r14,%r14
jne    1154 <my_write+0x24>
lea    0xe6c(%rip),%rdi
lea    0xde2(%rip),%rsi
mov    $0x144,%edx
xor    %eax,%eax
call   1040 <my_fatal@plt>
test   %r15d,%r15d
jg     115d <my_write+0x2d>
lea    0xe7e(%rip),%rdi
lea    0xdbf(%rip),%rsi
mov    $0x145,%edx
xor    %eax,%eax
call   1040 <my_fatal@plt>
jmp    115d <my_write+0x2d>
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
@EPIPE = global i64 0
@.str.4 = [25 x i8] c"my_write(): write(): %s\0A\00"
@.str.5 = [45 x i8] c"file \22%s\22, line %d, assertion \22n>=0\22 failed\0A\00"
@.str.6 = [48 x i8] c"file \22%s\22, line %d, assertion \22size==0\22 failed\0A\00"
define void @my_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
%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 323)
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 324)
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 325)
br label %22
22: ; preds = %20, %17
br label %23
23: ; preds = %62, %22
%24 = load i32, i32* %4
%25 = load i8*, i8** %5
%26 = load i32, i32* %6
%27 = call i32 @write(i32 %24, i8* %25, i32 %26)
store i32 %27, i32* %7
%28 = load i32, i32* %7
%29 = icmp eq i32 %28, -1
br i1 %29, label %30, label %49
30: ; preds = %23
%31 = load i64, i64* @errno
%32 = load i64, i64* @EINTR
%33 = icmp eq i64 %31, %32
br i1 %33, label %34, label %35
34: ; preds = %30
store i32 0, i32* %7
br label %48
35: ; preds = %30
%36 = load i64, i64* @errno
%37 = load i64, i64* @EPIPE
%38 = icmp eq i64 %36, %37
br i1 %38, label %39, label %41
39: ; preds = %35
%40 = load i32, i32* %6
store i32 %40, i32* %7
br label %47
41: ; preds = %35
%42 = load i64, i64* @errno
%43 = call i32 @strerror(i64 %42)
%44 = sext i32 %43 to i64
%45 = inttoptr i64 %44 to i8*
%46 = call i32 (i8*, i8*, ...) @my_fatal(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.4, i64 0, i64 0), i8* %45)
br label %47
47: ; preds = %41, %39
br label %48
48: ; preds = %47, %34
br label %49
49: ; preds = %48, %23
%50 = load i32, i32* %7
%51 = icmp sge i32 %50, 0
br i1 %51, label %54, label %52
52: ; preds = %49
%53 = 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 344)
br label %54
54: ; preds = %52, %49
%55 = load i32, i32* %7
%56 = load i8*, i8** %5
%57 = sext i32 %55 to i64
%58 = getelementptr inbounds i8, i8* %56, i64 %57
store i8* %58, i8** %5
%59 = load i32, i32* %7
%60 = load i32, i32* %6
%61 = sub nsw i32 %60, %59
store i32 %61, i32* %6
br label %62
62: ; preds = %54
%63 = load i32, i32* %6
%64 = icmp sgt i32 %63, 0
br i1 %64, label %23, label %65
65: ; preds = %62
%66 = load i32, i32* %6
%67 = icmp eq i32 %66, 0
br i1 %67, label %70, label %68
68: ; preds = %65
%69 = call i32 (i8*, i8*, ...) @my_fatal(i8* getelementptr inbounds ([48 x i8], [48 x i8]* @.str.6, i64 0, i64 0), i8* getelementptr inbounds ([131 x i8], [131 x i8]* @.str.1, i64 0, i64 0), i32 351)
br label %70
70: ; preds = %68, %65
ret void
}

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
@EPIPE = global i64 0
@.str.4 = [25 x i8] c"my_write(): write(): %s\0A\00"
@.str.5 = [45 x i8] c"file \22%s\22, line %d, assertion \22n>=0\22 failed\0A\00"
@.str.6 = [48 x i8] c"file \22%s\22, line %d, assertion \22size==0\22 failed\0A\00"
define void @my_write(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 323)
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 324)
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 325)
br label %15
15: ; preds = %13, %11
br label %16
16: ; preds = %15, %39
%17 = phi i8* [ %42, %39 ], [ %1, %15 ]
%18 = phi i32 [ %43, %39 ], [ %2, %15 ]
%19 = tail call i32 @write(i32 %0, i8* %17, i32 %18)
%20 = icmp eq i32 %19, -1
br i1 %20, label %21, label %33
21: ; preds = %16
%22 = load i64, i64* @errno
%23 = load i64, i64* @EINTR
%24 = icmp eq i64 %22, %23
br i1 %24, label %39, label %25
25: ; preds = %21
%26 = load i64, i64* @EPIPE
%27 = icmp eq i64 %22, %26
br i1 %27, label %33, label %28
28: ; preds = %25
%29 = tail call i32 @strerror(i64 %22)
%30 = sext i32 %29 to i64
%31 = inttoptr i64 %30 to i8*
%32 = tail call i32 (i8*, i8*, ...) @my_fatal(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.4, i64 0, i64 0), i8* %31)
br label %36
33: ; preds = %25, %16
%34 = phi i32 [ %19, %16 ], [ %18, %25 ]
%35 = icmp sgt i32 %34, -1
br i1 %35, label %39, label %36
36: ; preds = %28, %33
%37 = phi i32 [ -1, %28 ], [ %34, %33 ]
%38 = 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 344)
br label %39
39: ; preds = %21, %36, %33
%40 = phi i32 [ %37, %36 ], [ %34, %33 ], [ 0, %21 ]
%41 = sext i32 %40 to i64
%42 = getelementptr inbounds i8, i8* %17, i64 %41
%43 = sub nsw i32 %18, %40
%44 = icmp sgt i32 %43, 0
br i1 %44, label %16, label %45
45: ; preds = %39
%46 = icmp eq i32 %43, 0
br i1 %46, label %49, label %47
47: ; preds = %45
%48 = tail call i32 (i8*, i8*, ...) @my_fatal(i8* getelementptr inbounds ([48 x i8], [48 x i8]* @.str.6, i64 0, i64 0), i8* getelementptr inbounds ([131 x i8], [131 x i8]* @.str.1, i64 0, i64 0), i32 351)
br label %49
49: ; preds = %47, %45
ret void
}