#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*/ printf(char *, char *, ...);
int write(int, char *, int);
void writeline(int ofd, char *data, int line_length, char *command,
               char *filename, int line_number) {
  if (write(ofd, data, line_length) != line_length) {
    if (line_number)
      printf("%s ERROR: error writing line %d to %s\n", command, line_number,
             filename);
    else
      printf("%s ERROR: error writing header to %s\n", command, filename);
    exit(1);
  }
  return;
}


x86 assembly (clang, -O0):
<writeline>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    %rcx,-0x20(%rbp)
mov    %r8,-0x28(%rbp)
mov    %r9d,-0x2c(%rbp)
mov    -0x4(%rbp),%edi
mov    -0x10(%rbp),%rsi
mov    -0x14(%rbp),%edx
call   1030 <write@plt>
cmp    -0x14(%rbp),%eax
je     11ae <writeline+0x7e>
cmpl   $0x0,-0x2c(%rbp)
je     118e <writeline+0x5e>
mov    -0x20(%rbp),%rsi
mov    -0x2c(%rbp),%edx
mov    -0x28(%rbp),%rcx
lea    0xe7e(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    11a4 <writeline+0x74>
mov    -0x20(%rbp),%rsi
mov    -0x28(%rbp),%rdx
lea    0xe8a(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    $0x1,%edi
call   1050 <exit@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<writeline>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %r9d,%ebp
mov    %r8,%r14
mov    %rcx,%r15
mov    %edx,%ebx
call   1030 <write@plt>
cmp    %ebx,%eax
jne    1156 <writeline+0x26>
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret
test   %ebp,%ebp
jne    1178 <writeline+0x48>
lea    0xec6(%rip),%rdi
mov    %r15,%rsi
mov    %r14,%rdx
xor    %eax,%eax
call   1040 <printf@plt>
mov    $0x1,%edi
call   1050 <exit@plt>
lea    0xe81(%rip),%rdi
mov    %r15,%rsi
mov    %ebp,%edx
mov    %r14,%rcx
xor    %eax,%eax
call   1040 <printf@plt>
mov    $0x1,%edi
call   1050 <exit@plt>

LLVM IR (-O0):
@.str = [39 x i8] c"%s ERROR: error writing line %d to %s\0A\00"
@.str.1 = [38 x i8] c"%s ERROR: error writing header to %s\0A\00"
define void @writeline(i32 %0, i8* %1, i32 %2, i8* %3, i8* %4, i32 %5) {
%7 = alloca i32
%8 = alloca i8*
%9 = alloca i32
%10 = alloca i8*
%11 = alloca i8*
%12 = alloca i32
store i32 %0, i32* %7
store i8* %1, i8** %8
store i32 %2, i32* %9
store i8* %3, i8** %10
store i8* %4, i8** %11
store i32 %5, i32* %12
%13 = load i32, i32* %7
%14 = load i8*, i8** %8
%15 = load i32, i32* %9
%16 = call i32 @write(i32 %13, i8* %14, i32 %15)
%17 = load i32, i32* %9
%18 = icmp ne i32 %16, %17
br i1 %18, label %19, label %33
19: ; preds = %6
%20 = load i32, i32* %12
%21 = icmp ne i32 %20, 0
br i1 %21, label %22, label %27
22: ; preds = %19
%23 = load i8*, i8** %10
%24 = load i32, i32* %12
%25 = load i8*, i8** %11
%26 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str, i64 0, i64 0), i8* %23, i32 %24, i8* %25)
br label %31
27: ; preds = %19
%28 = load i8*, i8** %10
%29 = load i8*, i8** %11
%30 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.1, i64 0, i64 0), i8* %28, i8* %29)
br label %31
31: ; preds = %27, %22
%32 = call i32 @exit(i32 1)
unreachable
33: ; preds = %6
ret void
}

LLVM IR (-O2):
@.str = [39 x i8] c"%s ERROR: error writing line %d to %s\0A\00"
@.str.1 = [38 x i8] c"%s ERROR: error writing header to %s\0A\00"
define void @writeline(i32 %0, i8* nocapture %1, i32 %2, i8* %3, i8* %4, i32 %5) {
%7 = tail call i32 @write(i32 %0, i8* %1, i32 %2)
%8 = icmp eq i32 %7, %2
br i1 %8, label %17, label %9
9: ; preds = %6
%10 = icmp eq i32 %5, 0
br i1 %10, label %13, label %11
11: ; preds = %9
%12 = tail call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str, i64 0, i64 0), i8* %3, i32 %5, i8* %4)
br label %15
13: ; preds = %9
%14 = tail call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.1, i64 0, i64 0), i8* %3, i8* %4)
br label %15
15: ; preds = %13, %11
%16 = tail call i32 @exit(i32 1)
unreachable
17: ; preds = %6
ret void
}