#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 */
typedef int /*<<< orphan*/ buf;

/* Variables and functions */
int /*<<< orphan*/ assert(int);
int /*<<< orphan*/ oops(char *);
int /*<<< orphan*/ strcat(char *, char *);
int /*<<< orphan*/ strcpy(char *, char const *);
unsigned int strlen(char const *);
int write(int, char *, unsigned int);
void xwrite(int s, const char *l) {
  unsigned int n;
  char buf[512];
  n = strlen(l);
  assert(n < sizeof(buf) - 10);
  strcpy(buf, l);
  strcat(buf, "\r\n");
  if (write(s, buf, n + 2) != (int)(n + 2))
    oops("write");
}


x86 assembly (clang, -O0):
<xwrite>:
push   %rbp
mov    %rsp,%rbp
sub    $0x220,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
call   1060 <strlen@plt>
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    $0x1f6,%rax
setb   %al
and    $0x1,%al
movzbl %al,%edi
call   1070 <assert@plt>
lea    -0x220(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1030 <strcpy@plt>
lea    -0x220(%rbp),%rdi
lea    0xe4e(%rip),%rsi
call   1080 <strcat@plt>
mov    -0x4(%rbp),%edi
lea    -0x220(%rbp),%rsi
mov    -0x14(%rbp),%edx
add    $0x2,%edx
call   1040 <write@plt>
mov    -0x14(%rbp),%ecx
add    $0x2,%ecx
cmp    %ecx,%eax
je     11e6 <xwrite+0x86>
lea    0xe22(%rip),%rdi
call   1050 <oops@plt>
add    $0x220,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<xwrite>:
push   %rbp
push   %r15
push   %r14
push   %rbx
sub    $0x208,%rsp
mov    %rsi,%r14
mov    %edi,%r15d
mov    %rsi,%rdi
call   1060 <strlen@plt>
mov    %eax,%ebx
xor    %edi,%edi
cmp    $0x1f6,%eax
setb   %dil
call   1070 <assert@plt>
mov    %rsp,%rbp
mov    %rbp,%rdi
mov    %r14,%rsi
call   1030 <strcpy@plt>
lea    0xe5e(%rip),%rsi
mov    %rbp,%rdi
call   1080 <strcat@plt>
add    $0x2,%ebx
mov    %r15d,%edi
mov    %rbp,%rsi
mov    %ebx,%edx
call   1040 <write@plt>
cmp    %ebx,%eax
je     11ca <xwrite+0x6a>
lea    0xe3e(%rip),%rdi
call   1050 <oops@plt>
add    $0x208,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [3 x i8] c"\0D\0A\00"
@.str.1 = [6 x i8] c"write\00"
define void @xwrite(i32 %0, i8* %1) {
%3 = alloca i32
%4 = alloca i8*
%5 = alloca i32
%6 = alloca [512 x i8]
store i32 %0, i32* %3
store i8* %1, i8** %4
%7 = load i8*, i8** %4
%8 = call i32 @strlen(i8* %7)
store i32 %8, i32* %5
%9 = load i32, i32* %5
%10 = zext i32 %9 to i64
%11 = icmp ult i64 %10, 502
%12 = zext i1 %11 to i32
%13 = call i32 @assert(i32 %12)
%14 = getelementptr inbounds [512 x i8], [512 x i8]* %6, i64 0, i64 0
%15 = load i8*, i8** %4
%16 = call i32 @strcpy(i8* %14, i8* %15)
%17 = getelementptr inbounds [512 x i8], [512 x i8]* %6, i64 0, i64 0
%18 = call i32 @strcat(i8* %17, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%19 = load i32, i32* %3
%20 = getelementptr inbounds [512 x i8], [512 x i8]* %6, i64 0, i64 0
%21 = load i32, i32* %5
%22 = add i32 %21, 2
%23 = call i32 @write(i32 %19, i8* %20, i32 %22)
%24 = load i32, i32* %5
%25 = add i32 %24, 2
%26 = icmp ne i32 %23, %25
br i1 %26, label %27, label %29
27: ; preds = %2
%28 = call i32 @oops(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0))
br label %29
29: ; preds = %27, %2
ret void
}

LLVM IR (-O2):
@.str = [3 x i8] c"\0D\0A\00"
@.str.1 = [6 x i8] c"write\00"
define void @xwrite(i32 %0, i8* %1) {
%3 = alloca [512 x i8]
%4 = getelementptr inbounds [512 x i8], [512 x i8]* %3, i64 0, i64 0
%5 = tail call i32 @strlen(i8* %1)
%6 = icmp ult i32 %5, 502
%7 = zext i1 %6 to i32
%8 = tail call i32 @assert(i32 %7)
%9 = call i32 @strcpy(i8* %4, i8* %1)
%10 = call i32 @strcat(i8* %4, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%11 = add i32 %5, 2
%12 = call i32 @write(i32 %0, i8* %4, i32 %11)
%13 = icmp eq i32 %12, %11
br i1 %13, label %16, label %14
14: ; preds = %2
%15 = call i32 @oops(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0))
br label %16
16: ; preds = %14, %2
ret void
}