#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 siguientePrimo(int);
void main(int argc, char **argv) {
  int cont;
  int p = 1;
  printf("Cuantos numeros primos quieres calcular? ");
  scanf("%d", &cont);
  while (cont != 0) {
    while (cont != 0) {
      printf("%d", p);
      cont--;
      p = siguientePrimo(p);
    }
  }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x1,-0x18(%rbp)
lea    0xeb3(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xecf(%rip),%rdi
lea    -0x14(%rbp),%rsi
call   1050 <scanf@plt>
cmpl   $0x0,-0x14(%rbp)
je     11ac <main+0x7c>
jmp    1173 <main+0x43>
cmpl   $0x0,-0x14(%rbp)
je     11a7 <main+0x77>
mov    -0x18(%rbp),%esi
lea    0xea3(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x14(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x14(%rbp)
mov    -0x18(%rbp),%edi
call   1040 <siguientePrimo@plt>
mov    %eax,-0x18(%rbp)
jmp    1173 <main+0x43>
jmp    1164 <main+0x34>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %rbx
push   %rax
lea    0xec6(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xee2(%rip),%rdi
lea    0x4(%rsp),%rsi
call   1050 <scanf@plt>
cmpl   $0x0,0x4(%rsp)
je     1191 <main+0x61>
mov    $0x1,%ebp
lea    0xec5(%rip),%rbx
cs nopw 0x0(%rax,%rax,1)
nop
mov    %rbx,%rdi
mov    %ebp,%esi
xor    %eax,%eax
call   1030 <printf@plt>
addl   $0xffffffff,0x4(%rsp)
mov    %ebp,%edi
call   1040 <siguientePrimo@plt>
mov    %eax,%ebp
cmpl   $0x0,0x4(%rsp)
jne    1170 <main+0x40>
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@.str = [42 x i8] c"Cuantos numeros primos quieres calcular? \00"
@.str.1 = [3 x i8] c"%d\00"
define void @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i8**
%5 = alloca i32
%6 = alloca i32
store i32 %0, i32* %3
store i8** %1, i8*** %4
store i32 1, i32* %6
%7 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([42 x i8], [42 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* %5)
br label %9
9: ; preds = %23, %2
%10 = load i32, i32* %5
%11 = icmp ne i32 %10, 0
br i1 %11, label %12, label %24
12: ; preds = %9
br label %13
13: ; preds = %16, %12
%14 = load i32, i32* %5
%15 = icmp ne i32 %14, 0
br i1 %15, label %16, label %23
16: ; preds = %13
%17 = load i32, i32* %6
%18 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32 %17)
%19 = load i32, i32* %5
%20 = add nsw i32 %19, -1
store i32 %20, i32* %5
%21 = load i32, i32* %6
%22 = call i32 @siguientePrimo(i32 %21)
store i32 %22, i32* %6
br label %13
23: ; preds = %13
br label %9
24: ; preds = %9
ret void
}

LLVM IR (-O2):
@.str = [42 x i8] c"Cuantos numeros primos quieres calcular? \00"
@.str.1 = [3 x i8] c"%d\00"
define void @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 ([42 x i8], [42 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 eq i32 %7, 0
br i1 %8, label %17, label %9
9: ; preds = %2, %9
%10 = phi i32 [ %14, %9 ], [ 1, %2 ]
%11 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32 %10)
%12 = load i32, i32* %3
%13 = add nsw i32 %12, -1
store i32 %13, i32* %3
%14 = call i32 @siguientePrimo(i32 %10)
%15 = load i32, i32* %3
%16 = icmp eq i32 %15, 0
br i1 %16, label %17, label %9
17: ; preds = %9, %2
ret void
}