#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*/ getchar();
int /*<<< orphan*/ printf(char *, ...);
int sqrt(int);
void main() {
  int i, j, k = 1;
  printf("%6d", 2);
  for (i = 3; i < 500; i = i + 2) {
    for (j = 3; j <= sqrt(i); j = j + 2)
      if (i % j == 0)
        break;
    if (j > sqrt(i)) {
      printf("%6d", i);
      k++;
      if (k % 10 == 0)
        printf("\n");
    }
  }
  getchar();
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x1,-0xc(%rbp)
lea    0xeba(%rip),%rdi
mov    $0x2,%esi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x3,-0x4(%rbp)
cmpl   $0x1f4,-0x4(%rbp)
jge    121f <main+0xef>
movl   $0x3,-0x8(%rbp)
mov    -0x8(%rbp),%eax
mov    %eax,-0x10(%rbp)
mov    -0x4(%rbp),%edi
call   1050 <sqrt@plt>
mov    %eax,%ecx
mov    -0x10(%rbp),%eax
cmp    %ecx,%eax
jg     11b0 <main+0x80>
mov    -0x4(%rbp),%eax
cltd
idivl  -0x8(%rbp)
cmp    $0x0,%edx
jne    119d <main+0x6d>
jmp    11b0 <main+0x80>
jmp    11a2 <main+0x72>
mov    -0x8(%rbp),%eax
add    $0x2,%eax
mov    %eax,-0x8(%rbp)
jmp    116d <main+0x3d>
mov    -0x8(%rbp),%eax
mov    %eax,-0x14(%rbp)
mov    -0x4(%rbp),%edi
call   1050 <sqrt@plt>
mov    %eax,%ecx
mov    -0x14(%rbp),%eax
cmp    %ecx,%eax
jle    120c <main+0xdc>
mov    -0x4(%rbp),%esi
lea    0xe2b(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
mov    -0xc(%rbp),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
cmp    $0x0,%edx
jne    1207 <main+0xd7>
lea    0xe04(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    120c <main+0xdc>
jmp    1211 <main+0xe1>
mov    -0x4(%rbp),%eax
add    $0x2,%eax
mov    %eax,-0x4(%rbp)
jmp    1159 <main+0x29>
mov    $0x0,%al
call   1040 <getchar@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
lea    0xeb2(%rip),%r14
mov    %r14,%rdi
mov    $0x2,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    $0x3,%ebx
mov    $0x1,%r15d
jmp    117d <main+0x3d>
nopw   0x0(%rax,%rax,1)
lea    0x2(%rbx),%eax
cmp    $0x1f2,%ebx
mov    %eax,%ebx
jae    11f7 <main+0xb7>
mov    %ebx,%edi
call   1060 <sqrt@plt>
mov    $0x3,%ebp
cmp    $0x3,%eax
jl     11b8 <main+0x78>
mov    $0x3,%ebp
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    %ebx,%eax
xor    %edx,%edx
div    %ebp
test   %edx,%edx
je     11b8 <main+0x78>
add    $0x2,%ebp
mov    %ebx,%edi
call   1060 <sqrt@plt>
cmp    %eax,%ebp
jle    11a0 <main+0x60>
mov    %ebx,%edi
call   1060 <sqrt@plt>
cmp    %eax,%ebp
jle    1170 <main+0x30>
mov    %r14,%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1040 <printf@plt>
add    $0x1,%r15d
imul   $0xcccccccd,%r15d,%eax
add    $0x19999998,%eax
ror    %eax
cmp    $0x19999998,%eax
ja     1170 <main+0x30>
mov    $0xa,%edi
call   1030 <putchar@plt>
jmp    1170 <main+0x30>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
jmp    1050 <getchar@plt>

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

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