#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*/ close(int);
int /*<<< orphan*/ error(int, int /*<<< orphan*/, char *, char const *);
int write(int, char *, int);
void signal_socketio(int fd, int eof, const char *who) {
  char c = 1;
  if (1 != write(fd, &c, 1))
    error(1, 0, "incomplete pipe write to %s", who);
  if (eof)
    close(fd);
}


x86 assembly (clang, -O0):
<signal_socketio>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %rdx,-0x10(%rbp)
movb   $0x1,-0x11(%rbp)
mov    -0x4(%rbp),%edi
lea    -0x11(%rbp),%rsi
mov    $0x1,%edx
call   1030 <write@plt>
mov    %eax,%ecx
mov    $0x1,%eax
cmp    %ecx,%eax
je     117d <signal_socketio+0x4d>
mov    -0x10(%rbp),%rcx
mov    $0x1,%edi
xor    %esi,%esi
lea    0xe88(%rip),%rdx
call   1050 <error@plt>
cmpl   $0x0,-0x8(%rbp)
je     118f <signal_socketio+0x5f>
mov    -0x4(%rbp),%edi
call   1040 <close@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<signal_socketio>:
push   %rbp
push   %r14
push   %rbx
sub    $0x10,%rsp
mov    %rdx,%r14
mov    %esi,%ebp
mov    %edi,%ebx
movb   $0x1,0xf(%rsp)
lea    0xf(%rsp),%rsi
mov    $0x1,%edx
call   1030 <write@plt>
cmp    $0x1,%eax
je     116e <signal_socketio+0x3e>
lea    0xea1(%rip),%rdx
mov    $0x1,%edi
xor    %esi,%esi
mov    %r14,%rcx
call   1050 <error@plt>
test   %ebp,%ebp
je     1181 <signal_socketio+0x51>
mov    %ebx,%edi
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %rbp
jmp    1040 <close@plt>
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@.str = [28 x i8] c"incomplete pipe write to %s\00"
define void @signal_socketio(i32 %0, i32 %1, i8* %2) {
%4 = alloca i32
%5 = alloca i32
%6 = alloca i8*
%7 = alloca i8
store i32 %0, i32* %4
store i32 %1, i32* %5
store i8* %2, i8** %6
store i8 1, i8* %7
%8 = load i32, i32* %4
%9 = call i32 @write(i32 %8, i8* %7, i32 1)
%10 = icmp ne i32 1, %9
br i1 %10, label %11, label %14
11: ; preds = %3
%12 = load i8*, i8** %6
%13 = call i32 @error(i32 1, i32 0, i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str, i64 0, i64 0), i8* %12)
br label %14
14: ; preds = %11, %3
%15 = load i32, i32* %5
%16 = icmp ne i32 %15, 0
br i1 %16, label %17, label %20
17: ; preds = %14
%18 = load i32, i32* %4
%19 = call i32 @close(i32 %18)
br label %20
20: ; preds = %17, %14
ret void
}

LLVM IR (-O2):
@.str = [28 x i8] c"incomplete pipe write to %s\00"
define void @signal_socketio(i32 %0, i32 %1, i8* %2) {
%4 = alloca i8
store i8 1, i8* %4
%5 = call i32 @write(i32 %0, i8* %4, i32 1)
%6 = icmp eq i32 %5, 1
br i1 %6, label %9, label %7
7: ; preds = %3
%8 = tail call i32 @error(i32 1, i32 0, i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str, i64 0, i64 0), i8* %2)
br label %9
9: ; preds = %7, %3
%10 = icmp eq i32 %1, 0
br i1 %10, label %13, label %11
11: ; preds = %9
%12 = tail call i32 @close(i32 %0)
br label %13
13: ; preds = %11, %9
ret void
}