#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*/ errno;
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, int, char *);
scalar_t__ lwwire_writedata(void *, int);
int /*<<< orphan*/ stderr;
char *strerror(int /*<<< orphan*/);
void lwwire_write(void *buf, int len) {
  if (lwwire_writedata(buf, len) < 0) {
    fprintf(stderr, "Error writing %d bytes to client: %s\n", len,
            strerror(errno));
    exit(1);
  }
}


x86 assembly (clang, -O0):
<lwwire_write>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%esi
call   1060 <lwwire_writedata@plt>
cmp    $0x0,%rax
jge    11a4 <lwwire_write+0x64>
mov    0x2e74(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x14(%rbp)
mov    -0xc(%rbp),%eax
mov    %eax,-0x10(%rbp)
mov    0x2e5a(%rip),%rax
mov    (%rax),%edi
call   1050 <strerror@plt>
mov    -0x14(%rbp),%edi
mov    -0x10(%rbp),%edx
mov    %rax,%rcx
lea    0xe6b(%rip),%rsi
call   1030 <fprintf@plt>
mov    $0x1,%edi
call   1040 <exit@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<lwwire_write>:
push   %rbp
push   %rbx
push   %rax
mov    %esi,%ebx
call   1060 <lwwire_writedata@plt>
test   %rax,%rax
js     1156 <lwwire_write+0x16>
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret
mov    0x2e83(%rip),%rax
mov    (%rax),%ebp
mov    0x2e72(%rip),%rax
mov    (%rax),%edi
call   1050 <strerror@plt>
lea    0xe8c(%rip),%rsi
mov    %ebp,%edi
mov    %ebx,%edx
mov    %rax,%rcx
call   1030 <fprintf@plt>
mov    $0x1,%edi
call   1040 <exit@plt>

LLVM IR (-O0):
@stderr = global i32 0
@.str = [38 x i8] c"Error writing %d bytes to client: %s\0A\00"
@errno = global i32 0
define void @lwwire_write(i8* %0, i32 %1) {
%3 = alloca i8*
%4 = alloca i32
store i8* %0, i8** %3
store i32 %1, i32* %4
%5 = load i8*, i8** %3
%6 = load i32, i32* %4
%7 = call i64 @lwwire_writedata(i8* %5, i32 %6)
%8 = icmp slt i64 %7, 0
br i1 %8, label %9, label %16
9: ; preds = %2
%10 = load i32, i32* @stderr
%11 = load i32, i32* %4
%12 = load i32, i32* @errno
%13 = call i8* @strerror(i32 %12)
%14 = call i32 @fprintf(i32 %10, i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str, i64 0, i64 0), i32 %11, i8* %13)
%15 = call i32 @exit(i32 1)
unreachable
16: ; preds = %2
ret void
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [38 x i8] c"Error writing %d bytes to client: %s\0A\00"
@errno = global i32 0
define void @lwwire_write(i8* %0, i32 %1) {
%3 = tail call i64 @lwwire_writedata(i8* %0, i32 %1)
%4 = icmp slt i64 %3, 0
br i1 %4, label %5, label %11
5: ; preds = %2
%6 = load i32, i32* @stderr
%7 = load i32, i32* @errno
%8 = tail call i8* @strerror(i32 %7)
%9 = tail call i32 @fprintf(i32 %6, i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str, i64 0, i64 0), i32 %1, i8* %8)
%10 = tail call i32 @exit(i32 1)
unreachable
11: ; preds = %2
ret void
}