#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 sigaction {
  int /*<<< orphan*/ sa_handler;
  int /*<<< orphan*/ sa_flags;
};

/* Variables and functions */
int /*<<< orphan*/ SA_RESTART;
int /*<<< orphan*/ SIGPIPE;
int /*<<< orphan*/ SIG_IGN;
int /*<<< orphan*/ done(int);
int /*<<< orphan*/ msg(char *);
int /*<<< orphan*/ sigaction(int /*<<< orphan*/, struct sigaction *,
                             struct sigaction *);
void lostpeer(int signo) {
  struct sigaction sa;
  sa.sa_flags = SA_RESTART;
  sa.sa_handler = SIG_IGN;
  (void)sigaction(SIGPIPE, &sa, (struct sigaction *)0);
  msg("\aconnection closed.");
  done(1);
}


x86 assembly (clang, -O0):
<lostpeer>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
mov    0x2ea6(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0xc(%rbp)
mov    0x2e92(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x10(%rbp)
mov    0x2e76(%rip),%rax
mov    (%rax),%edi
lea    -0x10(%rbp),%rsi
xor    %eax,%eax
mov    %eax,%edx
call   1030 <sigaction@plt>
lea    0xe90(%rip),%rdi
call   1050 <msg@plt>
mov    $0x1,%edi
call   1040 <done@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<lostpeer>:
push   %rax
mov    0x2eb0(%rip),%rax
mov    (%rax),%eax
mov    %eax,0x4(%rsp)
mov    0x2e9b(%rip),%rax
mov    (%rax),%eax
mov    %eax,(%rsp)
mov    0x2e7f(%rip),%rax
mov    (%rax),%edi
mov    %rsp,%rsi
xor    %edx,%edx
call   1030 <sigaction@plt>
lea    0xe9c(%rip),%rdi
call   1050 <msg@plt>
mov    $0x1,%edi
call   1040 <done@plt>
pop    %rax
ret

LLVM IR (-O0):
%struct.sigaction = type { i32, i32 }
@SA_RESTART = global i32 0
@SIG_IGN = global i32 0
@SIGPIPE = global i32 0
@.str = [20 x i8] c"\07connection closed.\00"
define void @lostpeer(i32 %0) {
%2 = alloca i32
%3 = alloca %struct.sigaction
store i32 %0, i32* %2
%4 = load i32, i32* @SA_RESTART
%5 = getelementptr inbounds %struct.sigaction, %struct.sigaction* %3, i32 0, i32 1
store i32 %4, i32* %5
%6 = load i32, i32* @SIG_IGN
%7 = getelementptr inbounds %struct.sigaction, %struct.sigaction* %3, i32 0, i32 0
store i32 %6, i32* %7
%8 = load i32, i32* @SIGPIPE
%9 = call i32 @sigaction(i32 %8, %struct.sigaction* %3, %struct.sigaction* null)
%10 = call i32 @msg(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0))
%11 = call i32 @done(i32 1)
ret void
}

LLVM IR (-O2):
%struct.sigaction = type { i32, i32 }
@SA_RESTART = global i32 0
@SIG_IGN = global i32 0
@SIGPIPE = global i32 0
@.str = [20 x i8] c"\07connection closed.\00"
define void @lostpeer(i32 %0) {
%2 = alloca %struct.sigaction
%3 = bitcast %struct.sigaction* %2 to i8*
%4 = load i32, i32* @SA_RESTART
%5 = getelementptr inbounds %struct.sigaction, %struct.sigaction* %2, i64 0, i32 1
store i32 %4, i32* %5
%6 = load i32, i32* @SIG_IGN
%7 = getelementptr inbounds %struct.sigaction, %struct.sigaction* %2, i64 0, i32 0
store i32 %6, i32* %7
%8 = load i32, i32* @SIGPIPE
%9 = call i32 @sigaction(i32 %8, %struct.sigaction* %2, %struct.sigaction* null)
%10 = call i32 @msg(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0))
%11 = call i32 @done(i32 1)
ret void
}