#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 *);
void main() {
  int n = 0;
  int i;
  int primo;
  int nPrimi;
  int j;
  do {
    printf("Inserire il nr di primi:");
    scanf("%d", &nPrimi);
  } while (nPrimi < 1);
  n = 2;
  j = 1;
  while (j <= nPrimi) {
    for (i = n / 2; i >= 2 && n % i != 0; i--)
      ;
    if (!(i >= 2)) {
      printf(" %d ", n);
      j++;
    }
    n++;
  }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeca(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xed5(%rip),%rdi
lea    -0x10(%rbp),%rsi
call   1040 <scanf@plt>
cmpl   $0x1,-0x10(%rbp)
jl     112f <main+0xf>
movl   $0x2,-0x4(%rbp)
movl   $0x1,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x10(%rbp),%eax
jg     11f3 <main+0xd3>
mov    -0x4(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %eax,-0x8(%rbp)
xor    %eax,%eax
cmpl   $0x2,-0x8(%rbp)
mov    %al,-0x15(%rbp)
jl     119e <main+0x7e>
mov    -0x4(%rbp),%eax
cltd
idivl  -0x8(%rbp)
cmp    $0x0,%edx
setne  %al
mov    %al,-0x15(%rbp)
mov    -0x15(%rbp),%al
test   $0x1,%al
jne    11ae <main+0x8e>
jmp    11c1 <main+0xa1>
jmp    11b3 <main+0x93>
mov    -0x8(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x8(%rbp)
jmp    117f <main+0x5f>
cmpl   $0x2,-0x8(%rbp)
jge    11e5 <main+0xc5>
mov    -0x4(%rbp),%esi
lea    0xe47(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
mov    -0x4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x4(%rbp)
jmp    1165 <main+0x45>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
lea    0xed2(%rip),%r14
lea    0xee4(%rip),%r15
lea    0x4(%rsp),%rbx
nopw   0x0(%rax,%rax,1)
mov    %r14,%rdi
xor    %eax,%eax
call   1030 <printf@plt>
mov    %r15,%rdi
mov    %rbx,%rsi
call   1040 <scanf@plt>
mov    0x4(%rsp),%ecx
test   %ecx,%ecx
jle    1140 <main+0x20>
mov    $0x2,%ebx
mov    $0x1,%ebp
lea    0xeae(%rip),%r14
jmp    118a <main+0x6a>
mov    %r14,%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1030 <printf@plt>
add    $0x1,%ebp
mov    0x4(%rsp),%ecx
add    $0x1,%ebx
cmp    %ecx,%ebp
jg     11b5 <main+0x95>
cmp    $0x4,%ebx
jb     1170 <main+0x50>
mov    %ebx,%esi
shr    %esi
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    %ebx,%eax
cltd
idiv   %esi
test   %edx,%edx
je     1183 <main+0x63>
lea    -0x1(%rsi),%eax
cmp    $0x3,%esi
mov    %eax,%esi
jge    11a0 <main+0x80>
jmp    1170 <main+0x50>
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

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

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