#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 SIGCONT;
int SIGTSTP;
int SIGUSR1;
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int getpid();
int /*<<< orphan*/ participant();
int /*<<< orphan*/ printf(char *, int);
void childSigHandler(int sig) {
  if (sig == SIGTSTP) {
    printf("+++ Child [%d] : Received signal SIGTSTP from master...\n",
           getpid());
  } else if (sig == SIGCONT) {
    printf("+++ Child [%d] : Received signal SIGCONT from parent...\n",
           getpid());
    participant();
  } else if (sig == SIGUSR1) {
    printf(
        "+++ Child [%d] : Received signal SIGUSR1 from parent... exiting...\n",
        getpid());
    exit(0);
  }
}


x86 assembly (clang, -O0):
<childSigHandler>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
mov    -0x4(%rbp),%eax
mov    0x2e83(%rip),%rcx
cmp    (%rcx),%eax
jne    1177 <childSigHandler+0x37>
mov    $0x0,%al
call   1030 <getpid@plt>
mov    %eax,%esi
lea    0xe93(%rip),%rdi
call   1040 <printf@plt>
jmp    11e2 <childSigHandler+0xa2>
mov    -0x4(%rbp),%eax
mov    0x2e5f(%rip),%rcx
cmp    (%rcx),%eax
jne    11aa <childSigHandler+0x6a>
mov    $0x0,%al
call   1030 <getpid@plt>
mov    %eax,%esi
lea    0xea0(%rip),%rdi
call   1040 <printf@plt>
mov    $0x0,%al
call   1050 <participant@plt>
jmp    11dd <childSigHandler+0x9d>
mov    -0x4(%rbp),%eax
mov    0x2e34(%rip),%rcx
cmp    (%rcx),%eax
jne    11d8 <childSigHandler+0x98>
mov    $0x0,%al
call   1030 <getpid@plt>
mov    %eax,%esi
lea    0xea6(%rip),%rdi
call   1040 <printf@plt>
xor    %edi,%edi
call   1060 <exit@plt>
jmp    11dd <childSigHandler+0x9d>
jmp    11e2 <childSigHandler+0xa2>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<childSigHandler>:
push   %rax
mov    0x2e90(%rip),%rax
cmp    %edi,(%rax)
jne    1162 <childSigHandler+0x22>
xor    %eax,%eax
call   1030 <getpid@plt>
lea    0xea6(%rip),%rdi
mov    %eax,%esi
pop    %rax
jmp    1040 <printf@plt>
mov    0x2e77(%rip),%rax
cmp    %edi,(%rax)
jne    118a <childSigHandler+0x4a>
xor    %eax,%eax
call   1030 <getpid@plt>
lea    0xebe(%rip),%rdi
mov    %eax,%esi
call   1040 <printf@plt>
xor    %eax,%eax
pop    %rcx
jmp    1050 <participant@plt>
mov    0x2e57(%rip),%rax
cmp    %edi,(%rax)
je     1197 <childSigHandler+0x57>
pop    %rax
ret
xor    %eax,%eax
call   1030 <getpid@plt>
lea    0xecd(%rip),%rdi
mov    %eax,%esi
call   1040 <printf@plt>
xor    %edi,%edi
call   1060 <exit@plt>

LLVM IR (-O0):
@SIGTSTP = global i32 0
@.str = [57 x i8] c"+++ Child [%d] : Received signal SIGTSTP from master...\0A\00"
@SIGCONT = global i32 0
@.str.1 = [57 x i8] c"+++ Child [%d] : Received signal SIGCONT from parent...\0A\00"
@SIGUSR1 = global i32 0
@.str.2 = [68 x i8] c"+++ Child [%d] : Received signal SIGUSR1 from parent... exiting...\0A\00"
define void @childSigHandler(i32 %0) {
%2 = alloca i32
store i32 %0, i32* %2
%3 = load i32, i32* %2
%4 = load i32, i32* @SIGTSTP
%5 = icmp eq i32 %3, %4
br i1 %5, label %6, label %9
6: ; preds = %1
%7 = call i32 (...) @getpid()
%8 = call i32 @printf(i8* getelementptr inbounds ([57 x i8], [57 x i8]* @.str, i64 0, i64 0), i32 %7)
br label %27
9: ; preds = %1
%10 = load i32, i32* %2
%11 = load i32, i32* @SIGCONT
%12 = icmp eq i32 %10, %11
br i1 %12, label %13, label %17
13: ; preds = %9
%14 = call i32 (...) @getpid()
%15 = call i32 @printf(i8* getelementptr inbounds ([57 x i8], [57 x i8]* @.str.1, i64 0, i64 0), i32 %14)
%16 = call i32 (...) @participant()
br label %26
17: ; preds = %9
%18 = load i32, i32* %2
%19 = load i32, i32* @SIGUSR1
%20 = icmp eq i32 %18, %19
br i1 %20, label %21, label %25
21: ; preds = %17
%22 = call i32 (...) @getpid()
%23 = call i32 @printf(i8* getelementptr inbounds ([68 x i8], [68 x i8]* @.str.2, i64 0, i64 0), i32 %22)
%24 = call i32 @exit(i32 0)
unreachable
25: ; preds = %17
br label %26
26: ; preds = %25, %13
br label %27
27: ; preds = %26, %6
ret void
}

LLVM IR (-O2):
@SIGTSTP = global i32 0
@.str = [57 x i8] c"+++ Child [%d] : Received signal SIGTSTP from master...\0A\00"
@SIGCONT = global i32 0
@.str.1 = [57 x i8] c"+++ Child [%d] : Received signal SIGCONT from parent...\0A\00"
@SIGUSR1 = global i32 0
@.str.2 = [68 x i8] c"+++ Child [%d] : Received signal SIGUSR1 from parent... exiting...\0A\00"
define void @childSigHandler(i32 %0) {
%2 = load i32, i32* @SIGTSTP
%3 = icmp eq i32 %2, %0
br i1 %3, label %4, label %7
4: ; preds = %1
%5 = tail call i32 (...) @getpid()
%6 = tail call i32 @printf(i8* getelementptr inbounds ([57 x i8], [57 x i8]* @.str, i64 0, i64 0), i32 %5)
br label %21
7: ; preds = %1
%8 = load i32, i32* @SIGCONT
%9 = icmp eq i32 %8, %0
br i1 %9, label %10, label %14
10: ; preds = %7
%11 = tail call i32 (...) @getpid()
%12 = tail call i32 @printf(i8* getelementptr inbounds ([57 x i8], [57 x i8]* @.str.1, i64 0, i64 0), i32 %11)
%13 = tail call i32 (...) @participant()
br label %21
14: ; preds = %7
%15 = load i32, i32* @SIGUSR1
%16 = icmp eq i32 %15, %0
br i1 %16, label %17, label %21
17: ; preds = %14
%18 = tail call i32 (...) @getpid()
%19 = tail call i32 @printf(i8* getelementptr inbounds ([68 x i8], [68 x i8]* @.str.2, i64 0, i64 0), i32 %18)
%20 = tail call i32 @exit(i32 0)
unreachable
21: ; preds = %10, %14, %4
ret void
}