#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*/ printf(char *, ...);
int main(void) {
  int i, j, p;
  int n = 1000000;
  for (i = 2; i <= n; i++) {
    p = 0;
    for (j = 2; j <= i / 2; j++) {
      if (i % j == 0) {
        p = 1;
        break;
      }
    }
    if (p == 0) {
      printf("\n%d ", i);
    } else {
      printf(".");
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0xf4240,-0x14(%rbp)
movl   $0x2,-0x8(%rbp)
mov    -0x8(%rbp),%eax
cmp    -0x14(%rbp),%eax
jg     11d5 <main+0xc5>
movl   $0x0,-0x10(%rbp)
movl   $0x2,-0xc(%rbp)
mov    -0xc(%rbp),%eax
mov    %eax,-0x18(%rbp)
mov    -0x8(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %eax,%ecx
mov    -0x18(%rbp),%eax
cmp    %ecx,%eax
jg     1194 <main+0x84>
mov    -0x8(%rbp),%eax
cltd
idivl  -0xc(%rbp)
cmp    $0x0,%edx
jne    1181 <main+0x71>
movl   $0x1,-0x10(%rbp)
jmp    1194 <main+0x84>
jmp    1186 <main+0x76>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1147 <main+0x37>
cmpl   $0x0,-0x10(%rbp)
jne    11b4 <main+0xa4>
mov    -0x8(%rbp),%esi
lea    0xe58(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11c2 <main+0xb2>
lea    0xe4a(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11c7 <main+0xb7>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    112d <main+0x1d>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r14
push   %rbx
mov    $0x2,%ebx
lea    0xed0(%rip),%r14
mov    $0x2,%ebp
jmp    1157 <main+0x37>
nopw   0x0(%rax,%rax,1)
mov    %r14,%rdi
mov    %ebp,%esi
xor    %eax,%eax
call   1040 <printf@plt>
add    $0x1,%ebp
cmp    $0xf4241,%ebp
je     119c <main+0x7c>
mov    %ebp,%ecx
shr    %ecx
cmp    $0x3,%ecx
cmovb  %ebx,%ecx
cmp    $0x4,%ebp
jb     1140 <main+0x20>
neg    %ecx
mov    $0x2,%esi
nopl   (%rax)
mov    %ebp,%eax
xor    %edx,%edx
div    %esi
test   %edx,%edx
je     1190 <main+0x70>
lea    (%rcx,%rsi,1),%eax
add    $0x1,%eax
mov    %esi,%edx
add    $0x1,%edx
mov    %edx,%esi
cmp    $0x1,%eax
jne    1170 <main+0x50>
jmp    1140 <main+0x20>
xchg   %ax,%ax
mov    $0x2e,%edi
call   1030 <putchar@plt>
jmp    114c <main+0x2c>
xor    %eax,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret

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

LLVM IR (-O2):
@.str = [5 x i8] c"\0A%d \00"
define i32 @main() {
br label %1
1: ; preds = %0, %17
%2 = phi i32 [ 2, %0 ], [ %18, %17 ]
%3 = lshr i32 %2, 1
%4 = call i32 @llvm.umax.i32(i32 %3, i32 2)
%5 = icmp ult i32 %2, 4
br i1 %5, label %13, label %9
6: ; preds = %9
%7 = add nuw nsw i32 %10, 1
%8 = icmp eq i32 %10, %4
br i1 %8, label %13, label %9
9: ; preds = %1, %6
%10 = phi i32 [ %7, %6 ], [ 2, %1 ]
%11 = urem i32 %2, %10
%12 = icmp eq i32 %11, 0
br i1 %12, label %15, label %6
13: ; preds = %6, %1
%14 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i32 %2)
br label %17
15: ; preds = %9
%16 = tail call i32 @putchar(i32 46)
br label %17
17: ; preds = %13, %15
%18 = add nuw nsw i32 %2, 1
%19 = icmp eq i32 %18, 1000001
br i1 %19, label %20, label %1
20: ; preds = %17
ret i32 0
}