#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*/ SIGPIPE;
int /*<<< orphan*/ print_message(char *, char *);
int /*<<< orphan*/ signal(int /*<<< orphan*/, void (*)(int));
int /*<<< orphan*/ wait(int /*<<< orphan*/);
void sigpipe_handler(int arg) {
  print_message("IRCP013", "Received SIGPIPE signal.");
  print_message("IRCP014", "Waiting for any child processes to die.");
  wait(0);
  print_message("IRCP015", "Resuming parent process execution.");
  signal(SIGPIPE, sigpipe_handler);
}


x86 assembly (clang, -O0):
<sigpipe_handler>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
lea    0xebe(%rip),%rdi
lea    0xebf(%rip),%rsi
call   1030 <print_message@plt>
lea    0xecc(%rip),%rdi
lea    0xecd(%rip),%rsi
call   1030 <print_message@plt>
xor    %edi,%edi
call   1050 <wait@plt>
lea    0xee2(%rip),%rdi
lea    0xee3(%rip),%rsi
call   1030 <print_message@plt>
mov    0x2e56(%rip),%rax
mov    (%rax),%edi
mov    0x2e5d(%rip),%rsi
call   1040 <signal@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<sigpipe_handler>:
push   %rax
lea    0xec8(%rip),%rdi
lea    0xec9(%rip),%rsi
call   1030 <print_message@plt>
lea    0xed6(%rip),%rdi
lea    0xed7(%rip),%rsi
call   1030 <print_message@plt>
xor    %edi,%edi
call   1050 <wait@plt>
lea    0xeec(%rip),%rdi
lea    0xeed(%rip),%rsi
call   1030 <print_message@plt>
mov    0x2e60(%rip),%rax
mov    (%rax),%edi
mov    0x2e67(%rip),%rsi
pop    %rax
jmp    1040 <signal@plt>

LLVM IR (-O0):
@.str = [8 x i8] c"IRCP013\00"
@.str.1 = [25 x i8] c"Received SIGPIPE signal.\00"
@.str.2 = [8 x i8] c"IRCP014\00"
@.str.3 = [40 x i8] c"Waiting for any child processes to die.\00"
@.str.4 = [8 x i8] c"IRCP015\00"
@.str.5 = [35 x i8] c"Resuming parent process execution.\00"
@SIGPIPE = global i32 0
define void @sigpipe_handler(i32 %0) {
%2 = alloca i32
store i32 %0, i32* %2
%3 = call i32 @print_message(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.1, i64 0, i64 0))
%4 = call i32 @print_message(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.3, i64 0, i64 0))
%5 = call i32 @wait(i32 0)
%6 = call i32 @print_message(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.5, i64 0, i64 0))
%7 = load i32, i32* @SIGPIPE
%8 = call i32 @signal(i32 %7, void (i32)* @sigpipe_handler)
ret void
}

LLVM IR (-O2):
@.str = [8 x i8] c"IRCP013\00"
@.str.1 = [25 x i8] c"Received SIGPIPE signal.\00"
@.str.2 = [8 x i8] c"IRCP014\00"
@.str.3 = [40 x i8] c"Waiting for any child processes to die.\00"
@.str.4 = [8 x i8] c"IRCP015\00"
@.str.5 = [35 x i8] c"Resuming parent process execution.\00"
@SIGPIPE = global i32 0
define void @sigpipe_handler(i32 %0) {
%2 = tail call i32 @print_message(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.1, i64 0, i64 0))
%3 = tail call i32 @print_message(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.3, i64 0, i64 0))
%4 = tail call i32 @wait(i32 0)
%5 = tail call i32 @print_message(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.5, i64 0, i64 0))
%6 = load i32, i32* @SIGPIPE
%7 = tail call i32 @signal(i32 %6, void (i32)* @sigpipe_handler)
ret void
}