#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 *, ...);
int /*<<< orphan*/ sleep(int);
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");
  sleep(1);
  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    0xe68(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xe8e(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    $0x1,%edi
call   1080 <sleep@plt>
mov    -0x10(%rbp),%rax
mov    (%rax),%edi
mov    0x2e1c(%rip),%rax
mov    (%rax),%esi
call   1060 <kill@plt>
cmp    $0xffffffff,%eax
jne    11e0 <catchParentBarrierDown+0x80>
lea    0xe7f(%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    0xe6d(%rip),%rdi
mov    %ebx,%esi
mov    %rax,%rdx
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xea0(%rip),%rdi
call   1030 <puts@plt>
mov    $0x1,%edi
call   1090 <sleep@plt>
mov    (%r14),%edi
mov    0x2e21(%rip),%rax
mov    (%rax),%esi
call   1070 <kill@plt>
cmp    $0xffffffff,%eax
je     11d0 <catchParentBarrierDown+0x60>
pop    %rbx
pop    %r14
pop    %rbp
ret
lea    0xe5d(%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 = call i32 @sleep(i32 1)
%16 = load %struct.TYPE_3__*, %struct.TYPE_3__** %5
%17 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %16, i32 0, i32 0
%18 = load i32, i32* %17
%19 = load i32, i32* @SIGRTMAX
%20 = call i32 @kill(i32 %18, i32 %19)
%21 = icmp eq i32 %20, -1
br i1 %21, label %22, label %24
22: ; preds = %3
%23 = call i32 @syserr(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.2, i64 0, i64 0))
br label %24
24: ; preds = %22, %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 = tail call i32 @sleep(i32 1)
%11 = load i32, i32* %6
%12 = load i32, i32* @SIGRTMAX
%13 = tail call i32 @kill(i32 %11, i32 %12)
%14 = icmp eq i32 %13, -1
br i1 %14, label %15, label %17
15: ; preds = %3
%16 = tail call i32 @syserr(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.2, i64 0, i64 0))
br label %17
17: ; preds = %15, %3
ret void
}