#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 /*<<< orphan*/ SIGKILL;
int /*<<< orphan*/ SIGSTOP;
int fork();
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ raise(int /*<<< orphan*/);
int main() {
  int pid;
  if ((pid = fork()) < 0) {
    printf("error\n");
  } else if (pid == 0) {
    raise(SIGKILL);
    printf("child process \n");
  } else {
    raise(SIGSTOP);
    printf("parent process\n");
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
mov    $0x0,%al
call   1050 <fork@plt>
mov    %eax,-0x8(%rbp)
cmp    $0x0,%eax
jge    1163 <main+0x33>
lea    0xea7(%rip),%rdi
call   1040 <printf@plt>
jmp    11ab <main+0x7b>
cmpl   $0x0,-0x8(%rbp)
jne    118c <main+0x5c>
mov    0x2e6c(%rip),%rax
mov    (%rax),%edi
call   1030 <raise@plt>
lea    0xe85(%rip),%rdi
call   1040 <printf@plt>
jmp    11a6 <main+0x76>
mov    0x2e45(%rip),%rax
mov    (%rax),%edi
call   1030 <raise@plt>
lea    0xe76(%rip),%rdi
call   1040 <printf@plt>
jmp    11ab <main+0x7b>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
xor    %eax,%eax
call   1050 <fork@plt>
test   %eax,%eax
js     1166 <main+0x36>
lea    0xecc(%rip),%rax
lea    0xeb6(%rip),%rbx
cmove  %rax,%rbx
mov    0x2e83(%rip),%rax
cmove  0x2e83(%rip),%rax
mov    (%rax),%edi
call   1030 <raise@plt>
jmp    116d <main+0x3d>
lea    0xeb1(%rip),%rbx
mov    %rbx,%rdi
call   1040 <puts@plt>
xor    %eax,%eax
pop    %rbx
ret

LLVM IR (-O0):
@.str = [7 x i8] c"error\0A\00"
@SIGKILL = global i32 0
@.str.1 = [16 x i8] c"child process \0A\00"
@SIGSTOP = global i32 0
@.str.2 = [16 x i8] c"parent process\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
store i32 0, i32* %1
%3 = call i32 (...) @fork()
store i32 %3, i32* %2
%4 = icmp slt i32 %3, 0
br i1 %4, label %5, label %7
5: ; preds = %0
%6 = call i32 @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0))
br label %19
7: ; preds = %0
%8 = load i32, i32* %2
%9 = icmp eq i32 %8, 0
br i1 %9, label %10, label %14
10: ; preds = %7
%11 = load i32, i32* @SIGKILL
%12 = call i32 @raise(i32 %11)
%13 = call i32 @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.1, i64 0, i64 0))
br label %18
14: ; preds = %7
%15 = load i32, i32* @SIGSTOP
%16 = call i32 @raise(i32 %15)
%17 = call i32 @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.2, i64 0, i64 0))
br label %18
18: ; preds = %14, %10
br label %19
19: ; preds = %18, %5
ret i32 0
}

LLVM IR (-O2):
@SIGKILL = global i32 0
@SIGSTOP = global i32 0
@str = [15 x i8] c"parent process\00"
@str.3 = [15 x i8] c"child process \00"
@str.4 = [6 x i8] c"error\00"
define i32 @main() {
%1 = tail call i32 (...) @fork()
%2 = icmp slt i32 %1, 0
br i1 %2, label %10, label %3
3: ; preds = %0
%4 = icmp eq i32 %1, 0
%5 = select i1 %4, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @str.3, i64 0, i64 0), i8* getelementptr inbounds ([15 x i8], [15 x i8]* @str, i64 0, i64 0)
%6 = load i32, i32* @SIGKILL
%7 = load i32, i32* @SIGSTOP
%8 = select i1 %4, i32 %6, i32 %7
%9 = tail call i32 @raise(i32 %8)
br label %10
10: ; preds = %3, %0
%11 = phi i8* [ getelementptr inbounds ([6 x i8], [6 x i8]* @str.4, i64 0, i64 0), %0 ], [ %5, %3 ]
%12 = tail call i32 @puts(i8* dereferenceable(1) %11)
ret i32 0
}