#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 */
typedef int pid_t;

/* Variables and functions */
int /*<<< orphan*/ SIGINT;
int /*<<< orphan*/ SIGUSR1;
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int fork();
int getppid();
int /*<<< orphan*/ kill(int, int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ sleep(int);
pid_t start_signal_prog(void) {
  pid_t child, parent;
  switch ((child = fork())) {
  case 0:
    parent = getppid();
    kill(parent, SIGINT);
    kill(parent, SIGINT);
    kill(parent, SIGINT);
    kill(parent, SIGINT);
    kill(parent, SIGINT);
    kill(parent, SIGINT);
    kill(parent, SIGINT);
    printf("Sleeping...\n");
    sleep(10);
    kill(parent, SIGUSR1);
    exit(0);
  case -1:
    return -1;
  default:
    break;
  }
  return child;
}


x86 assembly (clang, -O0):
<start_signal_prog>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
xor    %eax,%eax
call   1080 <fork@plt>
mov    %eax,-0x8(%rbp)
mov    %eax,%ecx
mov    %ecx,-0x10(%rbp)
sub    $0xffffffff,%eax
je     1244 <start_signal_prog+0xe4>
jmp    1185 <start_signal_prog+0x25>
mov    -0x10(%rbp),%eax
test   %eax,%eax
jne    1250 <start_signal_prog+0xf0>
jmp    1195 <start_signal_prog+0x35>
mov    $0x0,%al
call   1050 <getppid@plt>
mov    %eax,-0xc(%rbp)
mov    -0xc(%rbp),%edi
mov    0x2e37(%rip),%rax
mov    (%rax),%esi
call   1040 <kill@plt>
mov    -0xc(%rbp),%edi
mov    0x2e26(%rip),%rax
mov    (%rax),%esi
call   1040 <kill@plt>
mov    -0xc(%rbp),%edi
mov    0x2e15(%rip),%rax
mov    (%rax),%esi
call   1040 <kill@plt>
mov    -0xc(%rbp),%edi
mov    0x2e04(%rip),%rax
mov    (%rax),%esi
call   1040 <kill@plt>
mov    -0xc(%rbp),%edi
mov    0x2df3(%rip),%rax
mov    (%rax),%esi
call   1040 <kill@plt>
mov    -0xc(%rbp),%edi
mov    0x2de2(%rip),%rax
mov    (%rax),%esi
call   1040 <kill@plt>
mov    -0xc(%rbp),%edi
mov    0x2dd1(%rip),%rax
mov    (%rax),%esi
call   1040 <kill@plt>
lea    0xde3(%rip),%rdi
call   1030 <printf@plt>
mov    $0xa,%edi
call   1070 <sleep@plt>
mov    -0xc(%rbp),%edi
mov    0x2db2(%rip),%rax
mov    (%rax),%esi
call   1040 <kill@plt>
xor    %edi,%edi
call   1060 <exit@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    125b <start_signal_prog+0xfb>
jmp    1255 <start_signal_prog+0xf5>
mov    -0x8(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<start_signal_prog>:
push   %r14
push   %rbx
push   %rax
xor    %eax,%eax
call   1080 <fork@plt>
test   %eax,%eax
je     1177 <start_signal_prog+0x17>
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret
xor    %eax,%eax
call   1050 <getppid@plt>
mov    %eax,%ebx
mov    0x2e59(%rip),%r14
mov    (%r14),%esi
mov    %eax,%edi
call   1040 <kill@plt>
mov    (%r14),%esi
mov    %ebx,%edi
call   1040 <kill@plt>
mov    (%r14),%esi
mov    %ebx,%edi
call   1040 <kill@plt>
mov    (%r14),%esi
mov    %ebx,%edi
call   1040 <kill@plt>
mov    (%r14),%esi
mov    %ebx,%edi
call   1040 <kill@plt>
mov    (%r14),%esi
mov    %ebx,%edi
call   1040 <kill@plt>
mov    (%r14),%esi
mov    %ebx,%edi
call   1040 <kill@plt>
lea    0xe2c(%rip),%rdi
call   1030 <puts@plt>
mov    $0xa,%edi
call   1070 <sleep@plt>
mov    0x2dfe(%rip),%rax
mov    (%rax),%esi
mov    %ebx,%edi
call   1040 <kill@plt>
xor    %edi,%edi
call   1060 <exit@plt>

LLVM IR (-O0):
@SIGINT = global i32 0
@.str = [13 x i8] c"Sleeping...\0A\00"
@SIGUSR1 = global i32 0
define i32 @start_signal_prog() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = call i32 (...) @fork()
store i32 %4, i32* %2
switch i32 %4, label %35 [
i32 0, label %5
i32 -1, label %34
]
5: ; preds = %0
%6 = call i32 (...) @getppid()
store i32 %6, i32* %3
%7 = load i32, i32* %3
%8 = load i32, i32* @SIGINT
%9 = call i32 @kill(i32 %7, i32 %8)
%10 = load i32, i32* %3
%11 = load i32, i32* @SIGINT
%12 = call i32 @kill(i32 %10, i32 %11)
%13 = load i32, i32* %3
%14 = load i32, i32* @SIGINT
%15 = call i32 @kill(i32 %13, i32 %14)
%16 = load i32, i32* %3
%17 = load i32, i32* @SIGINT
%18 = call i32 @kill(i32 %16, i32 %17)
%19 = load i32, i32* %3
%20 = load i32, i32* @SIGINT
%21 = call i32 @kill(i32 %19, i32 %20)
%22 = load i32, i32* %3
%23 = load i32, i32* @SIGINT
%24 = call i32 @kill(i32 %22, i32 %23)
%25 = load i32, i32* %3
%26 = load i32, i32* @SIGINT
%27 = call i32 @kill(i32 %25, i32 %26)
%28 = call i32 @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0))
%29 = call i32 @sleep(i32 10)
%30 = load i32, i32* %3
%31 = load i32, i32* @SIGUSR1
%32 = call i32 @kill(i32 %30, i32 %31)
%33 = call i32 @exit(i32 0)
unreachable
34: ; preds = %0
store i32 -1, i32* %1
br label %38
35: ; preds = %0
br label %36
36: ; preds = %35
%37 = load i32, i32* %2
store i32 %37, i32* %1
br label %38
38: ; preds = %36, %34
%39 = load i32, i32* %1
ret i32 %39
}

LLVM IR (-O2):
@SIGINT = global i32 0
@SIGUSR1 = global i32 0
@str = [12 x i8] c"Sleeping...\00"
define i32 @start_signal_prog() {
%1 = tail call i32 (...) @fork()
%2 = icmp eq i32 %1, 0
br i1 %2, label %3, label %24
3: ; preds = %0
%4 = tail call i32 (...) @getppid()
%5 = load i32, i32* @SIGINT
%6 = tail call i32 @kill(i32 %4, i32 %5)
%7 = load i32, i32* @SIGINT
%8 = tail call i32 @kill(i32 %4, i32 %7)
%9 = load i32, i32* @SIGINT
%10 = tail call i32 @kill(i32 %4, i32 %9)
%11 = load i32, i32* @SIGINT
%12 = tail call i32 @kill(i32 %4, i32 %11)
%13 = load i32, i32* @SIGINT
%14 = tail call i32 @kill(i32 %4, i32 %13)
%15 = load i32, i32* @SIGINT
%16 = tail call i32 @kill(i32 %4, i32 %15)
%17 = load i32, i32* @SIGINT
%18 = tail call i32 @kill(i32 %4, i32 %17)
%19 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @str, i64 0, i64 0))
%20 = tail call i32 @sleep(i32 10)
%21 = load i32, i32* @SIGUSR1
%22 = tail call i32 @kill(i32 %4, i32 %21)
%23 = tail call i32 @exit(i32 0)
unreachable
24: ; preds = %0
ret i32 %1
}