#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 fork();
int getpgid(int);
int getppid();
int /*<<< orphan*/ kill(int, int /*<<< orphan*/);
int /*<<< orphan*/ setpgrp();
int main(int argc, char **argv) {
  int parentPID = getppid();
  setpgrp();
  int newpgid = getpgid(0);
  kill(-1 * parentPID, SIGKILL);
  while (1) {
    int pid = fork();
    int i = parentPID + 1;
    int max = i + 400;
    for (i; i < max; i++) {
      int grp = getpgid(i);
      if (grp != newpgid) {
        kill(i, SIGKILL);
      }
    }
  }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    $0x0,%al
call   1050 <getppid@plt>
mov    %eax,-0x14(%rbp)
mov    $0x0,%al
call   1060 <setpgrp@plt>
xor    %edi,%edi
call   1040 <getpgid@plt>
mov    %eax,-0x18(%rbp)
imul   $0xffffffff,-0x14(%rbp),%edi
mov    0x2e51(%rip),%rax
mov    (%rax),%esi
call   1030 <kill@plt>
mov    $0x0,%al
call   1070 <fork@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
mov    -0x20(%rbp),%eax
add    $0x190,%eax
mov    %eax,-0x24(%rbp)
mov    -0x20(%rbp),%eax
cmp    -0x24(%rbp),%eax
jge    11fb <main+0xab>
mov    -0x20(%rbp),%edi
call   1040 <getpgid@plt>
mov    %eax,-0x28(%rbp)
mov    -0x28(%rbp),%eax
cmp    -0x18(%rbp),%eax
je     11e8 <main+0x98>
mov    -0x20(%rbp),%edi
mov    0x2dff(%rip),%rax
mov    (%rax),%esi
call   1030 <kill@plt>
jmp    11ed <main+0x9d>
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    11b4 <main+0x64>
jmp    1196 <main+0x46>

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
xor    %eax,%eax
call   1050 <getppid@plt>
mov    %eax,%r14d
xor    %eax,%eax
call   1060 <setpgrp@plt>
xor    %edi,%edi
call   1040 <getpgid@plt>
mov    %eax,%r12d
mov    %r14d,%edi
neg    %edi
mov    0x2e5e(%rip),%r15
mov    (%r15),%esi
call   1030 <kill@plt>
lea    0x18f(%r14),%r13d
add    $0xffffffff,%r14d
cs nopw 0x0(%rax,%rax,1)
nop
xor    %eax,%eax
call   1070 <fork@plt>
mov    %r14d,%ebp
jmp    11b8 <main+0x68>
nopl   0x0(%rax)
add    $0x1,%ebp
cmp    %r13d,%ebp
jge    11a0 <main+0x50>
lea    0x2(%rbp),%ebx
mov    %ebx,%edi
call   1040 <getpgid@plt>
cmp    %r12d,%eax
je     11b0 <main+0x60>
mov    (%r15),%esi
mov    %ebx,%edi
call   1030 <kill@plt>
jmp    11b0 <main+0x60>

LLVM IR (-O0):
@SIGKILL = global i32 0
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%12 = call i32 (...) @getppid()
store i32 %12, i32* %6
%13 = call i32 (...) @setpgrp()
%14 = call i32 @getpgid(i32 0)
store i32 %14, i32* %7
%15 = load i32, i32* %6
%16 = mul nsw i32 -1, %15
%17 = load i32, i32* @SIGKILL
%18 = call i32 @kill(i32 %16, i32 %17)
br label %19
19: ; preds = %2, %44
%20 = call i32 (...) @fork()
store i32 %20, i32* %8
%21 = load i32, i32* %6
%22 = add nsw i32 %21, 1
store i32 %22, i32* %9
%23 = load i32, i32* %9
%24 = add nsw i32 %23, 400
store i32 %24, i32* %10
%25 = load i32, i32* %9
br label %26
26: ; preds = %41, %19
%27 = load i32, i32* %9
%28 = load i32, i32* %10
%29 = icmp slt i32 %27, %28
br i1 %29, label %30, label %44
30: ; preds = %26
%31 = load i32, i32* %9
%32 = call i32 @getpgid(i32 %31)
store i32 %32, i32* %11
%33 = load i32, i32* %11
%34 = load i32, i32* %7
%35 = icmp ne i32 %33, %34
br i1 %35, label %36, label %40
36: ; preds = %30
%37 = load i32, i32* %9
%38 = load i32, i32* @SIGKILL
%39 = call i32 @kill(i32 %37, i32 %38)
br label %40
40: ; preds = %36, %30
br label %41
41: ; preds = %40
%42 = load i32, i32* %9
%43 = add nsw i32 %42, 1
store i32 %43, i32* %9
br label %26
44: ; preds = %26
br label %19
}

LLVM IR (-O2):
@SIGKILL = global i32 0
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = tail call i32 (...) @getppid()
%4 = tail call i32 (...) @setpgrp()
%5 = tail call i32 @getpgid(i32 0)
%6 = sub nsw i32 0, %3
%7 = load i32, i32* @SIGKILL
%8 = tail call i32 @kill(i32 %6, i32 %7)
%9 = add nsw i32 %3, 399
br label %10
10: ; preds = %20, %2
%11 = tail call i32 (...) @fork()
br label %12
12: ; preds = %10, %20
%13 = phi i32 [ %3, %10 ], [ %14, %20 ]
%14 = add nsw i32 %13, 1
%15 = tail call i32 @getpgid(i32 %14)
%16 = icmp eq i32 %15, %5
br i1 %16, label %20, label %17
17: ; preds = %12
%18 = load i32, i32* @SIGKILL
%19 = tail call i32 @kill(i32 %14, i32 %18)
br label %20
20: ; preds = %17, %12
%21 = icmp slt i32 %13, %9
br i1 %21, label %12, label %10
}