#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 */
scalar_t__ isMersenne(long long);
scalar_t__ isPrime(long long);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ scanf(char *, long long *);
int main() {
  long long num = 0, i = 3, count = 0;
  printf("How many Mersenne Primes would you like to generate?\n");
  scanf("%lld", &num);
  printf("The list is:\n");
  while (count != num) {
    if (isPrime(i) && isMersenne(i)) {
      printf("%lld\n", i);
      count++;
    }
    i += 2;
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
movq   $0x0,-0x10(%rbp)
movq   $0x3,-0x18(%rbp)
movq   $0x0,-0x20(%rbp)
lea    0xe92(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xeba(%rip),%rdi
lea    -0x10(%rbp),%rsi
call   1060 <scanf@plt>
lea    0xeaf(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x20(%rbp),%rax
cmp    -0x10(%rbp),%rax
je     11f6 <main+0xb6>
mov    -0x18(%rbp),%rdi
call   1040 <isPrime@plt>
cmp    $0x0,%rax
je     11e5 <main+0xa5>
mov    -0x18(%rbp),%rdi
call   1050 <isMersenne@plt>
cmp    $0x0,%rax
je     11e5 <main+0xa5>
mov    -0x18(%rbp),%rsi
lea    0xe77(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x20(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x20(%rbp)
mov    -0x18(%rbp),%rax
add    $0x2,%rax
mov    %rax,-0x18(%rbp)
jmp    1193 <main+0x53>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
sub    $0x10,%rsp
movq   $0x0,0x8(%rsp)
lea    0xea2(%rip),%rdi
call   1030 <puts@plt>
lea    0xe8b(%rip),%rdi
lea    0x8(%rsp),%rsi
call   1070 <scanf@plt>
lea    0xeba(%rip),%rdi
call   1030 <puts@plt>
cmpq   $0x0,0x8(%rsp)
je     11e8 <main+0x98>
mov    $0x3,%ebx
lea    0xe66(%rip),%r14
xor    %r15d,%r15d
jmp    11bb <main+0x6b>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
add    $0x2,%rbx
cmp    0x8(%rsp),%r15
je     11e8 <main+0x98>
mov    %rbx,%rdi
call   1050 <isPrime@plt>
test   %rax,%rax
je     11b0 <main+0x60>
mov    %rbx,%rdi
call   1060 <isMersenne@plt>
test   %rax,%rax
je     11b0 <main+0x60>
mov    %r14,%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1040 <printf@plt>
add    $0x1,%r15
jmp    11b0 <main+0x60>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [54 x i8] c"How many Mersenne Primes would you like to generate?\0A\00"
@.str.1 = [5 x i8] c"%lld\00"
@.str.2 = [14 x i8] c"The list is:\0A\00"
@.str.3 = [6 x i8] c"%lld\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i64
%3 = alloca i64
%4 = alloca i64
store i32 0, i32* %1
store i64 0, i64* %2
store i64 3, i64* %3
store i64 0, i64* %4
%5 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([54 x i8], [54 x i8]* @.str, i64 0, i64 0))
%6 = call i32 @scanf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i64* %2)
%7 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.2, i64 0, i64 0))
br label %8
8: ; preds = %25, %0
%9 = load i64, i64* %4
%10 = load i64, i64* %2
%11 = icmp ne i64 %9, %10
br i1 %11, label %12, label %28
12: ; preds = %8
%13 = load i64, i64* %3
%14 = call i64 @isPrime(i64 %13)
%15 = icmp ne i64 %14, 0
br i1 %15, label %16, label %25
16: ; preds = %12
%17 = load i64, i64* %3
%18 = call i64 @isMersenne(i64 %17)
%19 = icmp ne i64 %18, 0
br i1 %19, label %20, label %25
20: ; preds = %16
%21 = load i64, i64* %3
%22 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0), i64 %21)
%23 = load i64, i64* %4
%24 = add nsw i64 %23, 1
store i64 %24, i64* %4
br label %25
25: ; preds = %20, %16, %12
%26 = load i64, i64* %3
%27 = add nsw i64 %26, 2
store i64 %27, i64* %3
br label %8
28: ; preds = %8
ret i32 0
}

LLVM IR (-O2):
@.str.1 = [5 x i8] c"%lld\00"
@.str.3 = [6 x i8] c"%lld\0A\00"
@str = [53 x i8] c"How many Mersenne Primes would you like to generate?\00"
@str.4 = [13 x i8] c"The list is:\00"
define i32 @main() {
%1 = alloca i64
%2 = bitcast i64* %1 to i8*
store i64 0, i64* %1
%3 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([53 x i8], [53 x i8]* @str, i64 0, i64 0))
%4 = call i32 @scanf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i64* %1)
%5 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @str.4, i64 0, i64 0))
%6 = load i64, i64* %1
%7 = icmp eq i64 %6, 0
br i1 %7, label %24, label %8
8: ; preds = %0, %19
%9 = phi i64 [ %20, %19 ], [ 0, %0 ]
%10 = phi i64 [ %21, %19 ], [ 3, %0 ]
%11 = call i64 @isPrime(i64 %10)
%12 = icmp eq i64 %11, 0
br i1 %12, label %19, label %13
13: ; preds = %8
%14 = call i64 @isMersenne(i64 %10)
%15 = icmp eq i64 %14, 0
br i1 %15, label %19, label %16
16: ; preds = %13
%17 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0), i64 %10)
%18 = add nsw i64 %9, 1
br label %19
19: ; preds = %16, %13, %8
%20 = phi i64 [ %18, %16 ], [ %9, %13 ], [ %9, %8 ]
%21 = add nuw nsw i64 %10, 2
%22 = load i64, i64* %1
%23 = icmp eq i64 %20, %22
br i1 %23, label %24, label %8
24: ; preds = %19, %0
ret i32 0
}