#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 */
struct twopence_pipe_target {
  int dummy;
};

/* Variables and functions */
scalar_t__ __twopence_pipe_open_link(struct twopence_pipe_target *);
scalar_t__ __twopence_pipe_send(struct twopence_pipe_target *,
                                int /*<<< orphan*/);
int /*<<< orphan*/ twopence_protocol_build_simple_packet(char);
int __twopence_pipe_exit_remote(struct twopence_pipe_target *handle) {
  if (__twopence_pipe_open_link(handle) < 0)
    return -2;
  if (__twopence_pipe_send(handle, twopence_protocol_build_simple_packet('q')) <
      0)
    return -11;
  return 0;
}


x86 assembly (clang, -O0):
<__twopence_pipe_exit_remote>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
call   1050 <__twopence_pipe_open_link@plt>
cmp    $0x0,%rax
jge    115b <__twopence_pipe_exit_remote+0x2b>
movl   $0xfffffffe,-0x4(%rbp)
jmp    1195 <__twopence_pipe_exit_remote+0x65>
mov    -0x10(%rbp),%rax
mov    %rax,-0x18(%rbp)
mov    $0x71,%edi
call   1030 <twopence_protocol_build_simple_packet@plt>
mov    -0x18(%rbp),%rdi
mov    %eax,%esi
call   1040 <__twopence_pipe_send@plt>
cmp    $0x0,%rax
jge    118e <__twopence_pipe_exit_remote+0x5e>
movl   $0xfffffff5,-0x4(%rbp)
jmp    1195 <__twopence_pipe_exit_remote+0x65>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<__twopence_pipe_exit_remote>:
push   %rbx
mov    %rdi,%rbx
call   1050 <__twopence_pipe_open_link@plt>
test   %rax,%rax
js     115b <__twopence_pipe_exit_remote+0x2b>
mov    $0x71,%edi
call   1030 <twopence_protocol_build_simple_packet@plt>
mov    %rbx,%rdi
mov    %eax,%esi
call   1040 <__twopence_pipe_send@plt>
sar    $0x3f,%rax
and    $0xfffffff5,%eax
pop    %rbx
ret
mov    $0xfffffffe,%eax
pop    %rbx
ret

LLVM IR (-O0):
%struct.twopence_pipe_target = type { i32 }
define i32 @__twopence_pipe_exit_remote(%struct.twopence_pipe_target* %0) {
%2 = alloca i32
%3 = alloca %struct.twopence_pipe_target*
store %struct.twopence_pipe_target* %0, %struct.twopence_pipe_target** %3
%4 = load %struct.twopence_pipe_target*, %struct.twopence_pipe_target** %3
%5 = call i64 @__twopence_pipe_open_link(%struct.twopence_pipe_target* %4)
%6 = icmp slt i64 %5, 0
br i1 %6, label %7, label %8
7: ; preds = %1
store i32 -2, i32* %2
br label %15
8: ; preds = %1
%9 = load %struct.twopence_pipe_target*, %struct.twopence_pipe_target** %3
%10 = call i32 @twopence_protocol_build_simple_packet(i8 signext 113)
%11 = call i64 @__twopence_pipe_send(%struct.twopence_pipe_target* %9, i32 %10)
%12 = icmp slt i64 %11, 0
br i1 %12, label %13, label %14
13: ; preds = %8
store i32 -11, i32* %2
br label %15
14: ; preds = %8
store i32 0, i32* %2
br label %15
15: ; preds = %14, %13, %7
%16 = load i32, i32* %2
ret i32 %16
}

LLVM IR (-O2):
%struct.twopence_pipe_target = type { i32 }
define i32 @__twopence_pipe_exit_remote(%struct.twopence_pipe_target* %0) {
%2 = tail call i64 @__twopence_pipe_open_link(%struct.twopence_pipe_target* %0)
%3 = icmp slt i64 %2, 0
br i1 %3, label %9, label %4
4: ; preds = %1
%5 = tail call i32 @twopence_protocol_build_simple_packet(i8 signext 113)
%6 = tail call i64 @__twopence_pipe_send(%struct.twopence_pipe_target* %0, i32 %5)
%7 = icmp slt i64 %6, 0
%8 = select i1 %7, i32 -11, i32 0
br label %9
9: ; preds = %4, %1
%10 = phi i32 [ -2, %1 ], [ %8, %4 ]
ret i32 %10
}