#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 scalar_t__ pid_t;

/* Variables and functions */
int /*<<< orphan*/ exit(int);
scalar_t__ fork();
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ printf(char *, int);
int /*<<< orphan*/ wait(int /*<<< orphan*/ *);
int main() {
  int i, j, mark;
  pid_t pid;
  for (i = 30000000; i <= 30000200; i++) {
    pid = fork();
    if (pid < 0) {
      perror("fork()");
      exit(1);
    }
    if (pid == 0) {
      mark = 1;
      for (j = 2; j < i / 2; j++) {
        if (i % j == 0) {
          mark = 0;
          break;
        }
      }
      if (mark)
        printf("%d is a primer.\n", i);
      exit(0);
    }
  }
  int st;
  for (i = 30000000; i <= 30000200; i++)
    wait(NULL);
  exit(0);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x1c9c380,-0x8(%rbp)
cmpl   $0x1c9c448,-0x8(%rbp)
jg     1238 <main+0xe8>
mov    $0x0,%al
call   1070 <fork@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jge    119f <main+0x4f>
lea    0xe70(%rip),%rdi
call   1040 <perror@plt>
mov    $0x1,%edi
call   1050 <exit@plt>
cmpq   $0x0,-0x18(%rbp)
jne    1225 <main+0xd5>
movl   $0x1,-0x10(%rbp)
movl   $0x2,-0xc(%rbp)
mov    -0xc(%rbp),%eax
mov    %eax,-0x20(%rbp)
mov    -0x8(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %eax,%ecx
mov    -0x20(%rbp),%eax
cmp    %ecx,%eax
jge    1205 <main+0xb5>
mov    -0x8(%rbp),%eax
cltd
idivl  -0xc(%rbp)
cmp    $0x0,%edx
jne    11f2 <main+0xa2>
movl   $0x0,-0x10(%rbp)
jmp    1205 <main+0xb5>
jmp    11f7 <main+0xa7>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    11b8 <main+0x68>
cmpl   $0x0,-0x10(%rbp)
je     121e <main+0xce>
mov    -0x8(%rbp),%esi
lea    0xdee(%rip),%rdi
call   1030 <printf@plt>
xor    %edi,%edi
call   1050 <exit@plt>
jmp    122a <main+0xda>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    1166 <main+0x16>
movl   $0x1c9c380,-0x8(%rbp)
cmpl   $0x1c9c448,-0x8(%rbp)
jg     1263 <main+0x113>
xor    %eax,%eax
mov    %eax,%edi
call   1060 <wait@plt>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    123f <main+0xef>
xor    %edi,%edi
call   1050 <exit@plt>

x86 assembly (clang, -O2):
<main>:
push   %rbx
mov    $0x1c9c380,%ebx
cs nopw 0x0(%rax,%rax,1)
xor    %eax,%eax
call   1070 <fork@plt>
test   %rax,%rax
js     1193 <main+0x43>
je     11a9 <main+0x59>
add    $0x1,%ebx
cmp    $0x1c9c449,%ebx
jne    1160 <main+0x10>
mov    $0xc9,%ebx
xchg   %ax,%ax
xor    %edi,%edi
call   1060 <wait@plt>
add    $0xffffffff,%ebx
jne    1180 <main+0x30>
xor    %edi,%edi
call   1050 <exit@plt>
lea    0xe66(%rip),%rdi
call   1040 <perror@plt>
mov    $0x1,%edi
call   1050 <exit@plt>
cmp    $0x6,%ebx
jb     11d1 <main+0x81>
mov    %ebx,%ecx
shr    %ecx
mov    $0x2,%esi
nopw   0x0(%rax,%rax,1)
mov    %ebx,%eax
xor    %edx,%edx
div    %esi
test   %edx,%edx
je     118c <main+0x3c>
add    $0x1,%esi
cmp    %esi,%ecx
jne    11c0 <main+0x70>
lea    0xe2f(%rip),%rdi
mov    %ebx,%esi
call   1030 <printf@plt>
xor    %edi,%edi
call   1050 <exit@plt>

LLVM IR (-O0):
@.str = [7 x i8] c"fork()\00"
@.str.1 = [17 x i8] c"%d is a primer.\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i64
%6 = alloca i32
store i32 0, i32* %1
store i32 30000000, i32* %2
br label %7
7: ; preds = %45, %0
%8 = load i32, i32* %2
%9 = icmp sle i32 %8, 30000200
br i1 %9, label %10, label %48
10: ; preds = %7
%11 = call i64 (...) @fork()
store i64 %11, i64* %5
%12 = load i64, i64* %5
%13 = icmp slt i64 %12, 0
br i1 %13, label %14, label %17
14: ; preds = %10
%15 = call i32 @perror(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0))
%16 = call i32 @exit(i32 1)
unreachable
17: ; preds = %10
%18 = load i64, i64* %5
%19 = icmp eq i64 %18, 0
br i1 %19, label %20, label %44
20: ; preds = %17
store i32 1, i32* %4
store i32 2, i32* %3
br label %21
21: ; preds = %33, %20
%22 = load i32, i32* %3
%23 = load i32, i32* %2
%24 = sdiv i32 %23, 2
%25 = icmp slt i32 %22, %24
br i1 %25, label %26, label %36
26: ; preds = %21
%27 = load i32, i32* %2
%28 = load i32, i32* %3
%29 = srem i32 %27, %28
%30 = icmp eq i32 %29, 0
br i1 %30, label %31, label %32
31: ; preds = %26
store i32 0, i32* %4
br label %36
32: ; preds = %26
br label %33
33: ; preds = %32
%34 = load i32, i32* %3
%35 = add nsw i32 %34, 1
store i32 %35, i32* %3
br label %21
36: ; preds = %31, %21
%37 = load i32, i32* %4
%38 = icmp ne i32 %37, 0
br i1 %38, label %39, label %42
39: ; preds = %36
%40 = load i32, i32* %2
%41 = call i32 @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.1, i64 0, i64 0), i32 %40)
br label %42
42: ; preds = %39, %36
%43 = call i32 @exit(i32 0)
unreachable
44: ; preds = %17
br label %45
45: ; preds = %44
%46 = load i32, i32* %2
%47 = add nsw i32 %46, 1
store i32 %47, i32* %2
br label %7
48: ; preds = %7
store i32 30000000, i32* %2
br label %49
49: ; preds = %54, %48
%50 = load i32, i32* %2
%51 = icmp sle i32 %50, 30000200
br i1 %51, label %52, label %57
52: ; preds = %49
%53 = call i32 @wait(i32* null)
br label %54
54: ; preds = %52
%55 = load i32, i32* %2
%56 = add nsw i32 %55, 1
store i32 %56, i32* %2
br label %49
57: ; preds = %49
%58 = call i32 @exit(i32 0)
unreachable
}

LLVM IR (-O2):
@.str = [7 x i8] c"fork()\00"
@.str.1 = [17 x i8] c"%d is a primer.\0A\00"
define i32 @main() {
br label %1
1: ; preds = %0, %24
%2 = phi i32 [ 30000000, %0 ], [ %25, %24 ]
%3 = tail call i64 (...) @fork()
%4 = icmp slt i64 %3, 0
br i1 %4, label %5, label %8
5: ; preds = %1
%6 = tail call i32 @perror(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0))
%7 = tail call i32 @exit(i32 1)
unreachable
8: ; preds = %1
%9 = icmp eq i64 %3, 0
br i1 %9, label %10, label %24
10: ; preds = %8
%11 = lshr i32 %2, 1
%12 = icmp ugt i32 %2, 5
br i1 %12, label %15, label %20
13: ; preds = %15
%14 = icmp eq i32 %19, %11
br i1 %14, label %20, label %15
15: ; preds = %10, %13
%16 = phi i32 [ %19, %13 ], [ 2, %10 ]
%17 = urem i32 %2, %16
%18 = icmp eq i32 %17, 0
%19 = add nuw nsw i32 %16, 1
br i1 %18, label %22, label %13
20: ; preds = %13, %10
%21 = tail call i32 @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.1, i64 0, i64 0), i32 %2)
br label %22
22: ; preds = %15, %20
%23 = tail call i32 @exit(i32 0)
unreachable
24: ; preds = %8
%25 = add nuw nsw i32 %2, 1
%26 = icmp eq i32 %25, 30000201
br i1 %26, label %27, label %1
27: ; preds = %24, %27
%28 = phi i32 [ %30, %27 ], [ 30000000, %24 ]
%29 = tail call i32 @wait(i32* null)
%30 = add nuw nsw i32 %28, 1
%31 = icmp eq i32 %30, 30000201
br i1 %31, label %32, label %27
32: ; preds = %27
%33 = tail call i32 @exit(i32 0)
unreachable
}