#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 sqrt(int);
int main(int argc, char const *argv[]) {
  int num, i, j, cnt = 0;
  printf("Enter Number : ");
  scanf("%d", &num);
  if (num < 2) {
    printf("Invalid Number \n");
  }
  for (i = 2; i <= num; i++) {
    cnt = 0;
    for (j = 2; j <= sqrt(i); j++) {
      if (i % j == 0)
        cnt++;
    }
    if (cnt == 0)
      printf("%d ", i);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x20(%rbp)
lea    0xeac(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xeae(%rip),%rdi
lea    -0x14(%rbp),%rsi
call   1040 <scanf@plt>
cmpl   $0x2,-0x14(%rbp)
jge    1183 <main+0x53>
lea    0xe97(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x2,-0x18(%rbp)
mov    -0x18(%rbp),%eax
cmp    -0x14(%rbp),%eax
jg     1219 <main+0xe9>
movl   $0x0,-0x20(%rbp)
movl   $0x2,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
mov    %eax,-0x24(%rbp)
mov    -0x18(%rbp),%edi
call   1050 <sqrt@plt>
mov    %eax,%ecx
mov    -0x24(%rbp),%eax
cmp    %ecx,%eax
jg     11eb <main+0xbb>
mov    -0x18(%rbp),%eax
cltd
idivl  -0x1c(%rbp)
cmp    $0x0,%edx
jne    11d8 <main+0xa8>
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    11dd <main+0xad>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    11a4 <main+0x74>
cmpl   $0x0,-0x20(%rbp)
jne    1206 <main+0xd6>
mov    -0x18(%rbp),%esi
lea    0xe25(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    120b <main+0xdb>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    118a <main+0x5a>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
lea    0xeb2(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xeb4(%rip),%rdi
lea    0x4(%rsp),%rsi
call   1050 <scanf@plt>
cmpl   $0x1,0x4(%rsp)
jg     118d <main+0x4d>
lea    0xea3(%rip),%rdi
call   1030 <puts@plt>
cmpl   $0x2,0x4(%rsp)
jge    118d <main+0x4d>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret
mov    $0x2,%r15d
lea    0xe79(%rip),%r14
jmp    11bb <main+0x7b>
nopl   0x0(%rax)
mov    %r14,%rdi
mov    %r15d,%esi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0x1(%r15),%eax
cmp    0x4(%rsp),%r15d
mov    %eax,%r15d
jge    1180 <main+0x40>
mov    %r15d,%edi
call   1060 <sqrt@plt>
cmp    $0x2,%eax
jl     11a0 <main+0x60>
xor    %ebp,%ebp
mov    $0x1,%ebx
nop
add    $0x1,%ebx
mov    %r15d,%eax
xor    %edx,%edx
div    %ebx
cmp    $0x1,%edx
adc    $0x0,%ebp
mov    %r15d,%edi
call   1060 <sqrt@plt>
cmp    %eax,%ebx
jl     11d0 <main+0x90>
test   %ebp,%ebp
jne    11ad <main+0x6d>
jmp    11a0 <main+0x60>

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

LLVM IR (-O2):
@.str = [16 x i8] c"Enter Number : \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.3 = [4 x i8] c"%d \00"
@str = [16 x i8] c"Invalid Number \00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca i32
%4 = bitcast i32* %3 to i8*
%5 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0))
%6 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %3)
%7 = load i32, i32* %3
%8 = icmp slt i32 %7, 2
br i1 %8, label %9, label %13
9: ; preds = %2
%10 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @str, i64 0, i64 0))
%11 = load i32, i32* %3
%12 = icmp slt i32 %11, 2
br i1 %12, label %36, label %13
13: ; preds = %2, %9
br label %14
14: ; preds = %13, %32
%15 = phi i32 [ %33, %32 ], [ 2, %13 ]
%16 = call i32 @sqrt(i32 %15)
%17 = icmp slt i32 %16, 2
br i1 %17, label %30, label %18
18: ; preds = %14, %18
%19 = phi i32 [ %24, %18 ], [ 0, %14 ]
%20 = phi i32 [ %25, %18 ], [ 2, %14 ]
%21 = urem i32 %15, %20
%22 = icmp eq i32 %21, 0
%23 = zext i1 %22 to i32
%24 = add nuw nsw i32 %19, %23
%25 = add nuw nsw i32 %20, 1
%26 = call i32 @sqrt(i32 %15)
%27 = icmp slt i32 %20, %26
br i1 %27, label %18, label %28
28: ; preds = %18
%29 = icmp eq i32 %24, 0
br i1 %29, label %30, label %32
30: ; preds = %14, %28
%31 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i32 %15)
br label %32
32: ; preds = %28, %30
%33 = add nuw nsw i32 %15, 1
%34 = load i32, i32* %3
%35 = icmp slt i32 %15, %34
br i1 %35, label %14, label %36
36: ; preds = %32, %9
ret i32 0
}