#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 */
typedef struct TYPE_3__ TYPE_1__;

/* Type definitions */
struct TYPE_3__ {
  int si_pid;
};
typedef TYPE_1__ siginfo_t;

/* Variables and functions */
int /*<<< orphan*/ SIGRTMAX;
int getpid();
int kill(int, int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *, ...);
char *strsignal(int);
int /*<<< orphan*/ syserr(char *);
void catchParentBarrierDown(int sig, siginfo_t *info, void *more) {
  printf("%d received request permission signal (%s) from %d\n", getpid(),
         strsignal(sig), info->si_pid);
  printf("The barrier is down, letting through\n");
  if (kill(info->si_pid, SIGRTMAX) == -1) {
    syserr("kill barrier down");
  }
}


x86 assembly (clang, -O0):
<catchParentBarrierDown>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    $0x0,%al
call   1030 <getpid@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x4(%rbp),%edi
call   1070 <strsignal@plt>
mov    -0x1c(%rbp),%esi
mov    %rax,%rdx
mov    -0x10(%rbp),%rax
mov    (%rax),%ecx
lea    0xe78(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xe9e(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x10(%rbp),%rax
mov    (%rax),%edi
mov    0x2e36(%rip),%rax
mov    (%rax),%esi
call   1060 <kill@plt>
cmp    $0xffffffff,%eax
jne    11c6 <catchParentBarrierDown+0x76>
lea    0xe99(%rip),%rdi
call   1050 <syserr@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<catchParentBarrierDown>:
push   %rbp
push   %r14
push   %rbx
mov    %rsi,%r14
mov    %edi,%ebp
xor    %eax,%eax
call   1040 <getpid@plt>
mov    %eax,%ebx
mov    %ebp,%edi
call   1080 <strsignal@plt>
mov    (%r14),%ecx
lea    0xe7d(%rip),%rdi
mov    %ebx,%esi
mov    %rax,%rdx
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xeb0(%rip),%rdi
call   1030 <puts@plt>
mov    (%r14),%edi
mov    0x2e3b(%rip),%rax
mov    (%rax),%esi
call   1070 <kill@plt>
cmp    $0xffffffff,%eax
je     11b6 <catchParentBarrierDown+0x56>
pop    %rbx
pop    %r14
pop    %rbp
ret
lea    0xe77(%rip),%rdi
pop    %rbx
pop    %r14
pop    %rbp
jmp    1060 <syserr@plt>

LLVM IR (-O0):
%struct.TYPE_3__ = type { i32 }
@.str = [52 x i8] c"%d received request permission signal (%s) from %d\0A\00"
@.str.1 = [38 x i8] c"The barrier is down, letting through\0A\00"
@SIGRTMAX = global i32 0
@.str.2 = [18 x i8] c"kill barrier down\00"
define void @catchParentBarrierDown(i32 %0, %struct.TYPE_3__* %1, i8* %2) {
%4 = alloca i32
%5 = alloca %struct.TYPE_3__*
%6 = alloca i8*
store i32 %0, i32* %4
store %struct.TYPE_3__* %1, %struct.TYPE_3__** %5
store i8* %2, i8** %6
%7 = call i32 (...) @getpid()
%8 = load i32, i32* %4
%9 = call i8* @strsignal(i32 %8)
%10 = load %struct.TYPE_3__*, %struct.TYPE_3__** %5
%11 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %10, i32 0, i32 0
%12 = load i32, i32* %11
%13 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([52 x i8], [52 x i8]* @.str, i64 0, i64 0), i32 %7, i8* %9, i32 %12)
%14 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.1, i64 0, i64 0))
%15 = load %struct.TYPE_3__*, %struct.TYPE_3__** %5
%16 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %15, i32 0, i32 0
%17 = load i32, i32* %16
%18 = load i32, i32* @SIGRTMAX
%19 = call i32 @kill(i32 %17, i32 %18)
%20 = icmp eq i32 %19, -1
br i1 %20, label %21, label %23
21: ; preds = %3
%22 = call i32 @syserr(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.2, i64 0, i64 0))
br label %23
23: ; preds = %21, %3
ret void
}

LLVM IR (-O2):
%struct.TYPE_3__ = type { i32 }
@.str = [52 x i8] c"%d received request permission signal (%s) from %d\0A\00"
@SIGRTMAX = global i32 0
@.str.2 = [18 x i8] c"kill barrier down\00"
@str = [37 x i8] c"The barrier is down, letting through\00"
define void @catchParentBarrierDown(i32 %0, %struct.TYPE_3__* nocapture %1, i8* nocapture readnone %2) {
%4 = tail call i32 (...) @getpid()
%5 = tail call i8* @strsignal(i32 %0)
%6 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %1, i64 0, i32 0
%7 = load i32, i32* %6
%8 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([52 x i8], [52 x i8]* @.str, i64 0, i64 0), i32 %4, i8* %5, i32 %7)
%9 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([37 x i8], [37 x i8]* @str, i64 0, i64 0))
%10 = load i32, i32* %6
%11 = load i32, i32* @SIGRTMAX
%12 = tail call i32 @kill(i32 %10, i32 %11)
%13 = icmp eq i32 %12, -1
br i1 %13, label %14, label %16
14: ; preds = %3
%15 = tail call i32 @syserr(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.2, i64 0, i64 0))
br label %16
16: ; preds = %14, %3
ret void
}