#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 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);
    }
  }
  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     1228 <main+0xe8>
mov    $0x0,%al
call   1060 <fork@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jge    118f <main+0x4f>
lea    0xe80(%rip),%rdi
call   1040 <perror@plt>
mov    $0x1,%edi
call   1050 <exit@plt>
cmpq   $0x0,-0x18(%rbp)
jne    1215 <main+0xd5>
movl   $0x1,-0x10(%rbp)
movl   $0x2,-0xc(%rbp)
mov    -0xc(%rbp),%eax
mov    %eax,-0x1c(%rbp)
mov    -0x8(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %eax,%ecx
mov    -0x1c(%rbp),%eax
cmp    %ecx,%eax
jge    11f5 <main+0xb5>
mov    -0x8(%rbp),%eax
cltd
idivl  -0xc(%rbp)
cmp    $0x0,%edx
jne    11e2 <main+0xa2>
movl   $0x0,-0x10(%rbp)
jmp    11f5 <main+0xb5>
jmp    11e7 <main+0xa7>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    11a8 <main+0x68>
cmpl   $0x0,-0x10(%rbp)
je     120e <main+0xce>
mov    -0x8(%rbp),%esi
lea    0xdfe(%rip),%rdi
call   1030 <printf@plt>
xor    %edi,%edi
call   1050 <exit@plt>
jmp    121a <main+0xda>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    1156 <main+0x16>
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   1060 <fork@plt>
test   %rax,%rax
js     1170 <main+0x30>
je     1186 <main+0x46>
add    $0x1,%ebx
cmp    $0x1c9c449,%ebx
jne    1150 <main+0x10>
xor    %edi,%edi
call   1050 <exit@plt>
lea    0xe89(%rip),%rdi
call   1040 <perror@plt>
mov    $0x1,%edi
call   1050 <exit@plt>
cmp    $0x6,%ebx
jb     11b1 <main+0x71>
mov    %ebx,%ecx
shr    %ecx
mov    $0x2,%esi
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    %ebx,%eax
xor    %edx,%edx
div    %esi
test   %edx,%edx
je     1169 <main+0x29>
add    $0x1,%esi
cmp    %esi,%ecx
jne    11a0 <main+0x60>
lea    0xe4f(%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
store i32 0, i32* %1
store i32 30000000, i32* %2
br label %6
6: ; preds = %44, %0
%7 = load i32, i32* %2
%8 = icmp sle i32 %7, 30000200
br i1 %8, label %9, label %47
9: ; preds = %6
%10 = call i64 (...) @fork()
store i64 %10, i64* %5
%11 = load i64, i64* %5
%12 = icmp slt i64 %11, 0
br i1 %12, label %13, label %16
13: ; preds = %9
%14 = call i32 @perror(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0))
%15 = call i32 @exit(i32 1)
unreachable
16: ; preds = %9
%17 = load i64, i64* %5
%18 = icmp eq i64 %17, 0
br i1 %18, label %19, label %43
19: ; preds = %16
store i32 1, i32* %4
store i32 2, i32* %3
br label %20
20: ; preds = %32, %19
%21 = load i32, i32* %3
%22 = load i32, i32* %2
%23 = sdiv i32 %22, 2
%24 = icmp slt i32 %21, %23
br i1 %24, label %25, label %35
25: ; preds = %20
%26 = load i32, i32* %2
%27 = load i32, i32* %3
%28 = srem i32 %26, %27
%29 = icmp eq i32 %28, 0
br i1 %29, label %30, label %31
30: ; preds = %25
store i32 0, i32* %4
br label %35
31: ; preds = %25
br label %32
32: ; preds = %31
%33 = load i32, i32* %3
%34 = add nsw i32 %33, 1
store i32 %34, i32* %3
br label %20
35: ; preds = %30, %20
%36 = load i32, i32* %4
%37 = icmp ne i32 %36, 0
br i1 %37, label %38, label %41
38: ; preds = %35
%39 = load i32, i32* %2
%40 = call i32 @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.1, i64 0, i64 0), i32 %39)
br label %41
41: ; preds = %38, %35
%42 = call i32 @exit(i32 0)
unreachable
43: ; preds = %16
br label %44
44: ; preds = %43
%45 = load i32, i32* %2
%46 = add nsw i32 %45, 1
store i32 %46, i32* %2
br label %6
47: ; preds = %6
%48 = 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
%28 = tail call i32 @exit(i32 0)
unreachable
}