#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 /*<<< orphan*/ scanf(char *, int *);
int main() {
  int entered_number;
  scanf("%d", &entered_number);
  int counter = 1;
  for (int begin = 2; begin < entered_number; begin++) {
    int isPrime = 1;
    for (int i = 2; i < begin; i++) {
      isPrime = begin % i;
      if (isPrime == 0) {
        break;
      }
    }
    if (isPrime != 0) {
      printf("%d  ", begin);
      counter++;
      if (counter % 5 == 0) {
        printf("\n");
      }
    }
  }
  printf("\nThere are %d primes less than %d\n", counter, entered_number);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeca(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1040 <scanf@plt>
movl   $0x1,-0xc(%rbp)
movl   $0x2,-0x10(%rbp)
mov    -0x10(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    11fd <main+0xdd>
movl   $0x1,-0x14(%rbp)
movl   $0x2,-0x18(%rbp)
mov    -0x18(%rbp),%eax
cmp    -0x10(%rbp),%eax
jge    119f <main+0x7f>
mov    -0x10(%rbp),%eax
cltd
idivl  -0x18(%rbp)
mov    %edx,-0x14(%rbp)
cmpl   $0x0,-0x14(%rbp)
jne    118c <main+0x6c>
jmp    119f <main+0x7f>
jmp    1191 <main+0x71>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    1167 <main+0x47>
cmpl   $0x0,-0x14(%rbp)
je     11ea <main+0xca>
mov    -0x10(%rbp),%esi
lea    0xe50(%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    $0x5,%ecx
cltd
idiv   %ecx
cmp    $0x0,%edx
jne    11e5 <main+0xc5>
lea    0xe4b(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11ea <main+0xca>
jmp    11ef <main+0xcf>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    114d <main+0x2d>
mov    -0xc(%rbp),%esi
mov    -0x8(%rbp),%edx
lea    0xdfe(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
lea    0xec2(%rip),%rdi
lea    0x4(%rsp),%rsi
call   1050 <scanf@plt>
mov    0x4(%rsp),%edx
mov    $0x1,%r15d
cmp    $0x3,%edx
jl     11ec <main+0xbc>
mov    $0x1,%r15d
mov    $0x2,%ebp
lea    0xe96(%rip),%r14
xor    %ebx,%ebx
jmp    11b1 <main+0x81>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    %r14,%rdi
mov    %ebp,%esi
xor    %eax,%eax
call   1040 <printf@plt>
add    $0x1,%r15d
imul   $0xcccccccd,%r15d,%eax
add    $0x19999999,%eax
cmp    $0x33333332,%eax
jbe    11e0 <main+0xb0>
add    $0x1,%ebp
mov    0x4(%rsp),%edx
add    $0xffffffff,%ebx
cmp    %edx,%ebp
jge    11ec <main+0xbc>
cmp    $0x3,%ebp
jb     1180 <main+0x50>
mov    $0x2,%ecx
nopl   0x0(%rax,%rax,1)
mov    %ebp,%eax
xor    %edx,%edx
div    %ecx
test   %edx,%edx
je     11a3 <main+0x73>
add    $0x1,%ecx
lea    (%rbx,%rcx,1),%eax
cmp    $0x2,%eax
jne    11c0 <main+0x90>
jmp    1180 <main+0x50>
nopw   0x0(%rax,%rax,1)
mov    $0xa,%edi
call   1030 <putchar@plt>
jmp    11a3 <main+0x73>
lea    0xe15(%rip),%rdi
mov    %r15d,%esi
xor    %eax,%eax
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

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

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