#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 n, i = 3, count, c;
  printf("Enter the number of prime\n");
  scanf("%d", &n);
  if (n >= 1) {
    printf("2\n");
  }
  for (count = 2; count <= n;) {
    for (c = 2; c <= i - 1; c++) {
      if (i % c == 0)
        break;
    }
    if (c == i) {
      printf("%d\n", i);
      ++count;
    }
    ++i;
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x3,-0xc(%rbp)
lea    0xec3(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xed0(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1040 <scanf@plt>
cmpl   $0x1,-0x8(%rbp)
jl     116c <main+0x4c>
lea    0xeb9(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x2,-0x10(%rbp)
mov    -0x10(%rbp),%eax
cmp    -0x8(%rbp),%eax
jg     11f3 <main+0xd3>
movl   $0x2,-0x14(%rbp)
mov    -0x14(%rbp),%eax
mov    -0xc(%rbp),%ecx
sub    $0x1,%ecx
cmp    %ecx,%eax
jg     11bf <main+0x9f>
mov    -0xc(%rbp),%eax
cltd
idivl  -0x14(%rbp)
cmp    $0x0,%edx
jne    11ac <main+0x8c>
jmp    11bf <main+0x9f>
jmp    11b1 <main+0x91>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1186 <main+0x66>
mov    -0x14(%rbp),%eax
cmp    -0xc(%rbp),%eax
jne    11e5 <main+0xc5>
mov    -0xc(%rbp),%esi
lea    0xe4c(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1173 <main+0x53>
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    0xec9(%rip),%rdi
call   1030 <puts@plt>
lea    0xeb6(%rip),%rdi
lea    0x4(%rsp),%rsi
call   1050 <scanf@plt>
cmpl   $0x0,0x4(%rsp)
jle    1170 <main+0x40>
lea    0xebf(%rip),%rdi
call   1030 <puts@plt>
mov    0x4(%rsp),%ecx
cmp    $0x2,%ecx
jge    117d <main+0x4d>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret
mov    $0x3,%ebx
mov    $0x2,%r15d
mov    $0xffffffff,%ebp
lea    0xe6f(%rip),%r14
jmp    11bf <main+0x8f>
cs nopw 0x0(%rax,%rax,1)
mov    %r14,%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1040 <printf@plt>
add    $0x1,%r15d
mov    0x4(%rsp),%ecx
add    $0x1,%ebx
add    $0xffffffff,%ebp
cmp    %ecx,%r15d
jg     1170 <main+0x40>
mov    $0x2,%esi
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    %ebx,%eax
xor    %edx,%edx
div    %esi
test   %edx,%edx
je     11f0 <main+0xc0>
lea    (%rsi,%rbp,1),%eax
add    $0x1,%eax
mov    %esi,%edx
add    $0x1,%edx
mov    %edx,%esi
cmp    $0x2,%eax
jne    11d0 <main+0xa0>
jmp    11a0 <main+0x70>
xchg   %ax,%ax
add    %ebp,%esi
cmp    $0x2,%esi
je     11a0 <main+0x70>
jmp    11b4 <main+0x84>

LLVM IR (-O0):
@.str = [27 x i8] c"Enter the number of prime\0A\00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [3 x i8] c"2\0A\00"
@.str.3 = [4 x i8] c"%d\0A\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 3, i32* %3
%6 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str, i64 0, i64 0))
%7 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %2)
%8 = load i32, i32* %2
%9 = icmp sge i32 %8, 1
br i1 %9, label %10, label %12
10: ; preds = %0
%11 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
br label %12
12: ; preds = %10, %0
store i32 2, i32* %4
br label %13
13: ; preds = %42, %12
%14 = load i32, i32* %4
%15 = load i32, i32* %2
%16 = icmp sle i32 %14, %15
br i1 %16, label %17, label %45
17: ; preds = %13
store i32 2, i32* %5
br label %18
18: ; preds = %30, %17
%19 = load i32, i32* %5
%20 = load i32, i32* %3
%21 = sub nsw i32 %20, 1
%22 = icmp sle i32 %19, %21
br i1 %22, label %23, label %33
23: ; preds = %18
%24 = load i32, i32* %3
%25 = load i32, i32* %5
%26 = srem i32 %24, %25
%27 = icmp eq i32 %26, 0
br i1 %27, label %28, label %29
28: ; preds = %23
br label %33
29: ; preds = %23
br label %30
30: ; preds = %29
%31 = load i32, i32* %5
%32 = add nsw i32 %31, 1
store i32 %32, i32* %5
br label %18
33: ; preds = %28, %18
%34 = load i32, i32* %5
%35 = load i32, i32* %3
%36 = icmp eq i32 %34, %35
br i1 %36, label %37, label %42
37: ; preds = %33
%38 = load i32, i32* %3
%39 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i32 %38)
%40 = load i32, i32* %4
%41 = add nsw i32 %40, 1
store i32 %41, i32* %4
br label %42
42: ; preds = %37, %33
%43 = load i32, i32* %3
%44 = add nsw i32 %43, 1
store i32 %44, i32* %3
br label %13
45: ; preds = %13
ret i32 0
}

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