#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*/ print(int, int, int /*<<< orphan*/);
int prime() {
  int i, j;
  for (i = 3; i < 1000; i += 2) {
    for (j = 3; j < i; j += 2) {
      if (i % j == 0) {
        j = 0;
        break;
      }
    }
    if (j) {
      print(i, 10, 0);
      *(volatile unsigned char *)0x20000000 = (unsigned char)(' ');
    }
  }
  *(volatile unsigned char *)0x20000000 = (unsigned char)('\n');
  return 0;
}


x86 assembly (clang, -O0):
<prime>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x3,-0x4(%rbp)
cmpl   $0x3e8,-0x4(%rbp)
jge    11a2 <prime+0x92>
movl   $0x3,-0x8(%rbp)
mov    -0x8(%rbp),%eax
cmp    -0x4(%rbp),%eax
jge    116e <prime+0x5e>
mov    -0x4(%rbp),%eax
cltd
idivl  -0x8(%rbp)
cmp    $0x0,%edx
jne    115b <prime+0x4b>
movl   $0x0,-0x8(%rbp)
jmp    116e <prime+0x5e>
jmp    1160 <prime+0x50>
mov    -0x8(%rbp),%eax
add    $0x2,%eax
mov    %eax,-0x8(%rbp)
jmp    1133 <prime+0x23>
cmpl   $0x0,-0x8(%rbp)
je     118f <prime+0x7f>
mov    -0x4(%rbp),%edi
mov    $0xa,%esi
xor    %edx,%edx
call   1030 <print@plt>
mov    $0x20000000,%eax
movb   $0x20,(%rax)
jmp    1194 <prime+0x84>
mov    -0x4(%rbp),%eax
add    $0x2,%eax
mov    %eax,-0x4(%rbp)
jmp    111f <prime+0xf>
mov    $0x20000000,%eax
movb   $0xa,(%rax)
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<prime>:
push   %rbx
mov    $0x3,%ebx
jmp    1143 <prime+0x33>
nopl   0x0(%rax,%rax,1)
mov    %ebx,%edi
mov    $0xa,%esi
xor    %edx,%edx
call   1030 <print@plt>
movb   $0x20,0x20000000
20
lea    0x2(%rbx),%eax
cmp    $0x3e6,%ebx
mov    %eax,%ebx
jae    1163 <prime+0x53>
cmp    $0x4,%ebx
jb     1120 <prime+0x10>
mov    $0x3,%ecx
nopl   (%rax)
mov    %ebx,%eax
xor    %edx,%edx
div    %ecx
test   %edx,%edx
je     1136 <prime+0x26>
add    $0x2,%ecx
cmp    %ebx,%ecx
jb     1150 <prime+0x40>
jmp    1120 <prime+0x10>
movb   $0xa,0x20000000
0a
xor    %eax,%eax
pop    %rbx
ret

LLVM IR (-O0):
define i32 @prime() {
%1 = alloca i32
%2 = alloca i32
store i32 3, i32* %1
br label %3
3: ; preds = %28, %0
%4 = load i32, i32* %1
%5 = icmp slt i32 %4, 1000
br i1 %5, label %6, label %31
6: ; preds = %3
store i32 3, i32* %2
br label %7
7: ; preds = %18, %6
%8 = load i32, i32* %2
%9 = load i32, i32* %1
%10 = icmp slt i32 %8, %9
br i1 %10, label %11, label %21
11: ; preds = %7
%12 = load i32, i32* %1
%13 = load i32, i32* %2
%14 = srem i32 %12, %13
%15 = icmp eq i32 %14, 0
br i1 %15, label %16, label %17
16: ; preds = %11
store i32 0, i32* %2
br label %21
17: ; preds = %11
br label %18
18: ; preds = %17
%19 = load i32, i32* %2
%20 = add nsw i32 %19, 2
store i32 %20, i32* %2
br label %7
21: ; preds = %16, %7
%22 = load i32, i32* %2
%23 = icmp ne i32 %22, 0
br i1 %23, label %24, label %27
24: ; preds = %21
%25 = load i32, i32* %1
%26 = call i32 @print(i32 %25, i32 10, i32 0)
store volatile i8 32, i8* inttoptr (i64 536870912 to i8*)
br label %27
27: ; preds = %24, %21
br label %28
28: ; preds = %27
%29 = load i32, i32* %1
%30 = add nsw i32 %29, 2
store i32 %30, i32* %1
br label %3
31: ; preds = %3
store volatile i8 10, i8* inttoptr (i64 536870912 to i8*)
ret i32 0
}

LLVM IR (-O2):
define i32 @prime() {
br label %1
1: ; preds = %0, %13
%2 = phi i32 [ 3, %0 ], [ %14, %13 ]
%3 = icmp ugt i32 %2, 3
br i1 %3, label %6, label %11
4: ; preds = %6
%5 = icmp ult i32 %10, %2
br i1 %5, label %6, label %11
6: ; preds = %1, %4
%7 = phi i32 [ %10, %4 ], [ 3, %1 ]
%8 = urem i32 %2, %7
%9 = icmp eq i32 %8, 0
%10 = add nuw nsw i32 %7, 2
br i1 %9, label %13, label %4
11: ; preds = %4, %1
%12 = tail call i32 @print(i32 %2, i32 10, i32 0)
store volatile i8 32, i8* inttoptr (i64 536870912 to i8*)
br label %13
13: ; preds = %6, %11
%14 = add nuw nsw i32 %2, 2
%15 = icmp ult i32 %2, 998
br i1 %15, label %1, label %16
16: ; preds = %13
store volatile i8 10, i8* inttoptr (i64 536870912 to i8*)
ret i32 0
}