#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*/ exit(int);
int /*<<< orphan*/ free(char *);
int my_strlen(char *);
int write(int, char *, int);
int xwrite(int output, char *str, int len) {
  int i;
  char *err;
  i = write(output, str, len);
  if (i < 0) {
    err = "Get Next Line Error : write error";
    xwrite(2, err, my_strlen(err));
    free(err);
    exit(-1);
  }
  return (i);
}


x86 assembly (clang, -O0):
<xwrite>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%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   1050 <write@plt>
mov    %eax,-0x18(%rbp)
cmpl   $0x0,-0x18(%rbp)
jge    11bd <xwrite+0x6d>
lea    0xe7b(%rip),%rax
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    -0x20(%rbp),%rdi
call   1030 <my_strlen@plt>
mov    -0x28(%rbp),%rsi
mov    %eax,%edx
mov    $0x2,%edi
call   1060 <xwrite@plt>
mov    -0x20(%rbp),%rdi
call   1040 <free@plt>
mov    $0xffffffff,%edi
call   1070 <exit@plt>
mov    -0x18(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<xwrite>:
push   %rbx
call   1050 <write@plt>
test   %eax,%eax
js     115c <xwrite+0xc>
pop    %rbx
ret
lea    0xe9d(%rip),%rbx
mov    %rbx,%rdi
call   1030 <my_strlen@plt>
mov    $0x2,%edi
mov    %rbx,%rsi
mov    %eax,%edx
call   1060 <xwrite@plt>
mov    %rbx,%rdi
call   1040 <free@plt>
mov    $0xffffffff,%edi
call   1070 <exit@plt>

LLVM IR (-O0):
@.str = [34 x i8] c"Get Next Line Error : write error\00"
define i32 @xwrite(i32 %0, i8* %1, i32 %2) {
%4 = alloca i32
%5 = alloca i8*
%6 = alloca i32
%7 = alloca i32
%8 = alloca i8*
store i32 %0, i32* %4
store i8* %1, i8** %5
store i32 %2, i32* %6
%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
%13 = load i32, i32* %7
%14 = icmp slt i32 %13, 0
br i1 %14, label %15, label %23
15: ; preds = %3
store i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str, i64 0, i64 0), i8** %8
%16 = load i8*, i8** %8
%17 = load i8*, i8** %8
%18 = call i32 @my_strlen(i8* %17)
%19 = call i32 @xwrite(i32 2, i8* %16, i32 %18)
%20 = load i8*, i8** %8
%21 = call i32 @free(i8* %20)
%22 = call i32 @exit(i32 -1)
unreachable
23: ; preds = %3
%24 = load i32, i32* %7
ret i32 %24
}

LLVM IR (-O2):
@.str = [34 x i8] c"Get Next Line Error : write error\00"
define i32 @xwrite(i32 %0, i8* nocapture %1, i32 %2) {
%4 = tail call i32 @write(i32 %0, i8* %1, i32 %2)
%5 = icmp slt i32 %4, 0
br i1 %5, label %6, label %11
6: ; preds = %3
%7 = tail call i32 @my_strlen(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str, i64 0, i64 0))
%8 = tail call i32 @xwrite(i32 2, i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str, i64 0, i64 0), i32 %7)
%9 = tail call i32 @free(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str, i64 0, i64 0))
%10 = tail call i32 @exit(i32 -1)
unreachable
11: ; preds = %3
ret i32 %4
}