#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 */
scalar_t__ isPrime(int);
int /*<<< orphan*/ printf(char *, ...);
int main() {
  int i = 0, nop = 0, noc = 0;
  printf("Prime : \n");
  for (i = 2; i <= 500; i++) {
    if (isPrime(i)) {
      printf("%d ", i);
      nop++;
    }
  }
  printf("-----%d -> ", nop);
  printf("\n\nComposite : \n");
  for (i = 2; i <= 500; i++) {
    if (!isPrime(i)) {
      printf("%d ", i);
      noc++;
    }
  }
  printf("-----%d -> \n", noc);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
movl   $0x0,-0x10(%rbp)
lea    0xeb5(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x2,-0x8(%rbp)
cmpl   $0x1f4,-0x8(%rbp)
jg     11a5 <main+0x85>
mov    -0x8(%rbp),%edi
call   1040 <isPrime@plt>
cmp    $0x0,%rax
je     1192 <main+0x72>
mov    -0x8(%rbp),%esi
lea    0xe88(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1197 <main+0x77>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    1159 <main+0x39>
mov    -0xc(%rbp),%esi
lea    0xe5f(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe5d(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x2,-0x8(%rbp)
cmpl   $0x1f4,-0x8(%rbp)
jg     1217 <main+0xf7>
mov    -0x8(%rbp),%edi
call   1040 <isPrime@plt>
cmp    $0x0,%rax
jne    1204 <main+0xe4>
mov    -0x8(%rbp),%esi
lea    0xe16(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    1209 <main+0xe9>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    11cb <main+0xab>
mov    -0x10(%rbp),%esi
lea    0xe09(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r14
push   %rbx
lea    0xee2(%rip),%rdi
call   1030 <puts@plt>
mov    $0x2,%ebp
lea    0xeb4(%rip),%r14
xor    %ebx,%ebx
jmp    115b <main+0x2b>
add    $0x1,%ebp
cmp    $0x1f5,%ebp
je     1178 <main+0x48>
mov    %ebp,%edi
call   1050 <isPrime@plt>
test   %rax,%rax
je     1150 <main+0x20>
mov    %r14,%rdi
mov    %ebp,%esi
xor    %eax,%eax
call   1040 <printf@plt>
add    $0x1,%ebx
jmp    1150 <main+0x20>
lea    0xe85(%rip),%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xe97(%rip),%rdi
call   1030 <puts@plt>
mov    $0x2,%ebp
lea    0xe60(%rip),%r14
xor    %ebx,%ebx
jmp    11bb <main+0x8b>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
add    $0x1,%ebp
cmp    $0x1f5,%ebp
je     11d8 <main+0xa8>
mov    %ebp,%edi
call   1050 <isPrime@plt>
test   %rax,%rax
jne    11b0 <main+0x80>
mov    %r14,%rdi
mov    %ebp,%esi
xor    %eax,%eax
call   1040 <printf@plt>
add    $0x1,%ebx
jmp    11b0 <main+0x80>
lea    0xe31(%rip),%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1040 <printf@plt>
xor    %eax,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@.str = [10 x i8] c"Prime : \0A\00"
@.str.1 = [4 x i8] c"%d \00"
@.str.2 = [12 x i8] c"-----%d -> \00"
@.str.3 = [16 x i8] c"\0A\0AComposite : \0A\00"
@.str.4 = [13 x i8] c"-----%d -> \0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
store i32 0, i32* %1
store i32 0, i32* %2
store i32 0, i32* %3
store i32 0, i32* %4
%5 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0))
store i32 2, i32* %2
br label %6
6: ; preds = %19, %0
%7 = load i32, i32* %2
%8 = icmp sle i32 %7, 500
br i1 %8, label %9, label %22
9: ; preds = %6
%10 = load i32, i32* %2
%11 = call i64 @isPrime(i32 %10)
%12 = icmp ne i64 %11, 0
br i1 %12, label %13, label %18
13: ; preds = %9
%14 = load i32, i32* %2
%15 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %14)
%16 = load i32, i32* %3
%17 = add nsw i32 %16, 1
store i32 %17, i32* %3
br label %18
18: ; preds = %13, %9
br label %19
19: ; preds = %18
%20 = load i32, i32* %2
%21 = add nsw i32 %20, 1
store i32 %21, i32* %2
br label %6
22: ; preds = %6
%23 = load i32, i32* %3
%24 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.2, i64 0, i64 0), i32 %23)
%25 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.3, i64 0, i64 0))
store i32 2, i32* %2
br label %26
26: ; preds = %39, %22
%27 = load i32, i32* %2
%28 = icmp sle i32 %27, 500
br i1 %28, label %29, label %42
29: ; preds = %26
%30 = load i32, i32* %2
%31 = call i64 @isPrime(i32 %30)
%32 = icmp ne i64 %31, 0
br i1 %32, label %38, label %33
33: ; preds = %29
%34 = load i32, i32* %2
%35 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %34)
%36 = load i32, i32* %4
%37 = add nsw i32 %36, 1
store i32 %37, i32* %4
br label %38
38: ; preds = %33, %29
br label %39
39: ; preds = %38
%40 = load i32, i32* %2
%41 = add nsw i32 %40, 1
store i32 %41, i32* %2
br label %26
42: ; preds = %26
%43 = load i32, i32* %4
%44 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.4, i64 0, i64 0), i32 %43)
ret i32 0
}

LLVM IR (-O2):
@.str.1 = [4 x i8] c"%d \00"
@.str.2 = [12 x i8] c"-----%d -> \00"
@.str.4 = [13 x i8] c"-----%d -> \0A\00"
@str = [9 x i8] c"Prime : \00"
@str.5 = [15 x i8] c"\0A\0AComposite : \00"
define i32 @main() {
%1 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @str, i64 0, i64 0))
br label %2
2: ; preds = %0, %10
%3 = phi i32 [ 0, %0 ], [ %11, %10 ]
%4 = phi i32 [ 2, %0 ], [ %12, %10 ]
%5 = tail call i64 @isPrime(i32 %4)
%6 = icmp eq i64 %5, 0
br i1 %6, label %10, label %7
7: ; preds = %2
%8 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %4)
%9 = add nsw i32 %3, 1
br label %10
10: ; preds = %2, %7
%11 = phi i32 [ %9, %7 ], [ %3, %2 ]
%12 = add nuw nsw i32 %4, 1
%13 = icmp eq i32 %12, 501
br i1 %13, label %14, label %2
14: ; preds = %10
%15 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str.2, i64 0, i64 0), i32 %11)
%16 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @str.5, i64 0, i64 0))
br label %17
17: ; preds = %14, %25
%18 = phi i32 [ 0, %14 ], [ %26, %25 ]
%19 = phi i32 [ 2, %14 ], [ %27, %25 ]
%20 = tail call i64 @isPrime(i32 %19)
%21 = icmp eq i64 %20, 0
br i1 %21, label %22, label %25
22: ; preds = %17
%23 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %19)
%24 = add nsw i32 %18, 1
br label %25
25: ; preds = %17, %22
%26 = phi i32 [ %18, %17 ], [ %24, %22 ]
%27 = add nuw nsw i32 %19, 1
%28 = icmp eq i32 %27, 501
br i1 %28, label %29, label %17
29: ; preds = %25
%30 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @.str.4, i64 0, i64 0), i32 %26)
ret i32 0
}