#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 is_prime(int);
int *next_prime(int, int);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ scanf(char *, int *);
int main() {
  int i, m, n;
  printf("Insert a number(n): ");
  scanf("%d", &n);
  printf("Insert a number(m): ");
  scanf("%d", &m);
  int *vect = next_prime(n, m);
  int prova = is_prime(5);
  printf("%d\n\n", prova);
  for (i = 0; i < m - n; i++) {
    printf("%d ", vect[i]);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeaa(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xeb1(%rip),%rdi
lea    -0x10(%rbp),%rsi
call   1060 <scanf@plt>
lea    0xea4(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe93(%rip),%rdi
lea    -0xc(%rbp),%rsi
call   1060 <scanf@plt>
mov    -0x10(%rbp),%edi
mov    -0xc(%rbp),%esi
call   1040 <next_prime@plt>
mov    %rax,-0x18(%rbp)
mov    $0x5,%edi
call   1050 <is_prime@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x1c(%rbp),%esi
lea    0xe7c(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x8(%rbp)
mov    -0x8(%rbp),%eax
mov    -0xc(%rbp),%ecx
sub    -0x10(%rbp),%ecx
cmp    %ecx,%eax
jge    11f7 <main+0xb7>
mov    -0x18(%rbp),%rax
movslq -0x8(%rbp),%rcx
mov    (%rax,%rcx,4),%esi
lea    0xe50(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    11bf <main+0x7f>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
sub    $0x10,%rsp
lea    0xeb0(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xeb7(%rip),%rbx
lea    0x8(%rsp),%rsi
mov    %rbx,%rdi
call   1060 <scanf@plt>
lea    0xea6(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xc(%rsp),%rsi
mov    %rbx,%rdi
call   1060 <scanf@plt>
mov    0x8(%rsp),%edi
mov    0xc(%rsp),%esi
call   1040 <next_prime@plt>
mov    %rax,%r15
mov    $0x5,%edi
call   1050 <is_prime@plt>
lea    0xe86(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1030 <printf@plt>
mov    0xc(%rsp),%eax
cmp    0x8(%rsp),%eax
jle    11f4 <main+0xb4>
lea    0xe71(%rip),%r14
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    (%r15,%rbx,4),%esi
mov    %r14,%rdi
xor    %eax,%eax
call   1030 <printf@plt>
add    $0x1,%rbx
movslq 0xc(%rsp),%rax
movslq 0x8(%rsp),%rcx
sub    %rcx,%rax
cmp    %rax,%rbx
jl     11d0 <main+0x90>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [21 x i8] c"Insert a number(n): \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [21 x i8] c"Insert a number(m): \00"
@.str.3 = [5 x i8] c"%d\0A\0A\00"
@.str.4 = [4 x i8] c"%d \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 (i8*, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 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)
%9 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.2, i64 0, i64 0))
%10 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %3)
%11 = load i32, i32* %4
%12 = load i32, i32* %3
%13 = call i32* @next_prime(i32 %11, i32 %12)
store i32* %13, i32** %5
%14 = call i32 @is_prime(i32 5)
store i32 %14, i32* %6
%15 = load i32, i32* %6
%16 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0), i32 %15)
store i32 0, i32* %2
br label %17
17: ; preds = %30, %0
%18 = load i32, i32* %2
%19 = load i32, i32* %3
%20 = load i32, i32* %4
%21 = sub nsw i32 %19, %20
%22 = icmp slt i32 %18, %21
br i1 %22, label %23, label %33
23: ; preds = %17
%24 = load i32*, i32** %5
%25 = load i32, i32* %2
%26 = sext i32 %25 to i64
%27 = getelementptr inbounds i32, i32* %24, i64 %26
%28 = load i32, i32* %27
%29 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0), i32 %28)
br label %30
30: ; preds = %23
%31 = load i32, i32* %2
%32 = add nsw i32 %31, 1
store i32 %32, i32* %2
br label %17
33: ; preds = %17
ret i32 0
}

LLVM IR (-O2):
@.str = [21 x i8] c"Insert a number(n): \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [21 x i8] c"Insert a number(m): \00"
@.str.3 = [5 x i8] c"%d\0A\0A\00"
@.str.4 = [4 x i8] c"%d \00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = bitcast i32* %1 to i8*
%4 = bitcast i32* %2 to i8*
%5 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 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* %2)
%7 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @.str.2, i64 0, i64 0))
%8 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %1)
%9 = load i32, i32* %2
%10 = load i32, i32* %1
%11 = call i32* @next_prime(i32 %9, i32 %10)
%12 = call i32 @is_prime(i32 5)
%13 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0), i32 %12)
%14 = load i32, i32* %1
%15 = load i32, i32* %2
%16 = icmp sgt i32 %14, %15
br i1 %16, label %17, label %28
17: ; preds = %0, %17
%18 = phi i64 [ %22, %17 ], [ 0, %0 ]
%19 = getelementptr inbounds i32, i32* %11, i64 %18
%20 = load i32, i32* %19
%21 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0), i32 %20)
%22 = add nuw nsw i64 %18, 1
%23 = load i32, i32* %1
%24 = load i32, i32* %2
%25 = sub nsw i32 %23, %24
%26 = sext i32 %25 to i64
%27 = icmp slt i64 %22, %26
br i1 %27, label %17, label %28
28: ; preds = %17, %0
ret i32 0
}