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

/* Variables and functions */
int /*<<< orphan*/ SIGTERM;
int /*<<< orphan*/ SIGTSTP;
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ fork();
int /*<<< orphan*/ getpid();
scalar_t__ kill(int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ perror(char *);
int main(int argc, char **argv) {
  pid_t child_pid;
  if ((child_pid = fork()) == 0) {
    while (1)
      ;
    exit(0);
  }
  if (kill(child_pid, SIGTSTP) < 0) {
    perror("kill1");
    exit(1);
  }
  if (kill(getpid(), SIGTSTP) < 0) {
    perror("kill2");
    exit(1);
  }
  if (kill(child_pid, SIGTERM) < 0) {
    perror("kill3");
    exit(1);
  }
  exit(0);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    $0x0,%al
call   1070 <fork@plt>
mov    %eax,-0x14(%rbp)
cmp    $0x0,%eax
jne    1183 <main+0x33>
jmp    117e <main+0x2e>
jmp    117e <main+0x2e>
mov    -0x14(%rbp),%edi
mov    0x2e53(%rip),%rax
mov    (%rax),%esi
call   1040 <kill@plt>
cmp    $0x0,%rax
jge    11b4 <main+0x64>
lea    0xe5b(%rip),%rdi
call   1050 <perror@plt>
mov    $0x1,%edi
call   1060 <exit@plt>
mov    $0x0,%al
call   1030 <getpid@plt>
mov    %eax,%edi
mov    0x2e1c(%rip),%rax
mov    (%rax),%esi
call   1040 <kill@plt>
cmp    $0x0,%rax
jge    11eb <main+0x9b>
lea    0xe2a(%rip),%rdi
call   1050 <perror@plt>
mov    $0x1,%edi
call   1060 <exit@plt>
mov    -0x14(%rbp),%edi
mov    0x2df3(%rip),%rax
mov    (%rax),%esi
call   1040 <kill@plt>
cmp    $0x0,%rax
jge    121c <main+0xcc>
lea    0xdff(%rip),%rdi
call   1050 <perror@plt>
mov    $0x1,%edi
call   1060 <exit@plt>
xor    %edi,%edi
call   1060 <exit@plt>

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
push   %rax
xor    %eax,%eax
call   1070 <fork@plt>
test   %eax,%eax
jne    1162 <main+0x12>
nop
jmp    1160 <main+0x10>
mov    %eax,%ebx
mov    0x2e75(%rip),%r14
mov    (%r14),%esi
mov    %eax,%edi
call   1040 <kill@plt>
test   %rax,%rax
jns    1183 <main+0x33>
lea    0xe7f(%rip),%rdi
jmp    11be <main+0x6e>
xor    %eax,%eax
call   1030 <getpid@plt>
mov    (%r14),%esi
mov    %eax,%edi
call   1040 <kill@plt>
test   %rax,%rax
jns    11a2 <main+0x52>
lea    0xe66(%rip),%rdi
jmp    11be <main+0x6e>
mov    0x2e3f(%rip),%rax
mov    (%rax),%esi
mov    %ebx,%edi
call   1040 <kill@plt>
test   %rax,%rax
jns    11cd <main+0x7d>
lea    0xe4e(%rip),%rdi
call   1050 <perror@plt>
mov    $0x1,%edi
call   1060 <exit@plt>
xor    %edi,%edi
call   1060 <exit@plt>

LLVM IR (-O0):
@SIGTSTP = global i32 0
@.str = [6 x i8] c"kill1\00"
@.str.1 = [6 x i8] c"kill2\00"
@SIGTERM = global i32 0
@.str.2 = [6 x i8] c"kill3\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%7 = call i32 (...) @fork()
store i32 %7, i32* %6
%8 = icmp eq i32 %7, 0
br i1 %8, label %9, label %11
9: ; preds = %2
br label %10
10: ; preds = %9, %10
br label %10
11: ; preds = %2
%12 = load i32, i32* %6
%13 = load i32, i32* @SIGTSTP
%14 = call i64 @kill(i32 %12, i32 %13)
%15 = icmp slt i64 %14, 0
br i1 %15, label %16, label %19
16: ; preds = %11
%17 = call i32 @perror(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0))
%18 = call i32 @exit(i32 1)
unreachable
19: ; preds = %11
%20 = call i32 (...) @getpid()
%21 = load i32, i32* @SIGTSTP
%22 = call i64 @kill(i32 %20, i32 %21)
%23 = icmp slt i64 %22, 0
br i1 %23, label %24, label %27
24: ; preds = %19
%25 = call i32 @perror(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0))
%26 = call i32 @exit(i32 1)
unreachable
27: ; preds = %19
%28 = load i32, i32* %6
%29 = load i32, i32* @SIGTERM
%30 = call i64 @kill(i32 %28, i32 %29)
%31 = icmp slt i64 %30, 0
br i1 %31, label %32, label %35
32: ; preds = %27
%33 = call i32 @perror(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0))
%34 = call i32 @exit(i32 1)
unreachable
35: ; preds = %27
%36 = call i32 @exit(i32 0)
unreachable
}

LLVM IR (-O2):
@SIGTSTP = global i32 0
@.str = [6 x i8] c"kill1\00"
@.str.1 = [6 x i8] c"kill2\00"
@SIGTERM = global i32 0
@.str.2 = [6 x i8] c"kill3\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = tail call i32 (...) @fork()
%4 = icmp eq i32 %3, 0
br i1 %4, label %5, label %6
5: ; preds = %2, %5
br label %5
6: ; preds = %2
%7 = load i32, i32* @SIGTSTP
%8 = tail call i64 @kill(i32 %3, i32 %7)
%9 = icmp slt i64 %8, 0
br i1 %9, label %10, label %13
10: ; preds = %6
%11 = tail call i32 @perror(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0))
%12 = tail call i32 @exit(i32 1)
unreachable
13: ; preds = %6
%14 = tail call i32 (...) @getpid()
%15 = load i32, i32* @SIGTSTP
%16 = tail call i64 @kill(i32 %14, i32 %15)
%17 = icmp slt i64 %16, 0
br i1 %17, label %18, label %21
18: ; preds = %13
%19 = tail call i32 @perror(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0))
%20 = tail call i32 @exit(i32 1)
unreachable
21: ; preds = %13
%22 = load i32, i32* @SIGTERM
%23 = tail call i64 @kill(i32 %3, i32 %22)
%24 = icmp slt i64 %23, 0
br i1 %24, label %25, label %28
25: ; preds = %21
%26 = tail call i32 @perror(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0))
%27 = tail call i32 @exit(i32 1)
unreachable
28: ; preds = %21
%29 = tail call i32 @exit(i32 0)
unreachable
}