#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__ pow(int, int);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ scanf(char *, int *);
int main() {
  int m, t = 0, p = 1, flag = 0;
  printf("Enter a prime number. \n");
  scanf("%d", &m);
  while (p <= m) {
    t = (int)pow(2, p);
    if (t == (m + 1)) {
      printf("Number is a Mersenne Prime. \n");
      flag = 1;
      break;
    }
    p++;
  }
  if (flag != 1) {
    printf("Number is not a Mersenne Prime. \n");
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0xc(%rbp)
movl   $0x1,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
lea    0xea5(%rip),%rdi
call   1030 <printf@plt>
lea    0xeb1(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1040 <scanf@plt>
mov    -0x10(%rbp),%eax
cmp    -0x8(%rbp),%eax
jg     11c3 <main+0x93>
mov    -0x10(%rbp),%esi
mov    $0x2,%edi
call   1050 <pow@plt>
mov    %eax,-0xc(%rbp)
mov    -0xc(%rbp),%eax
mov    -0x8(%rbp),%ecx
add    $0x1,%ecx
cmp    %ecx,%eax
jne    11b5 <main+0x85>
lea    0xe77(%rip),%rdi
call   1030 <printf@plt>
movl   $0x1,-0x14(%rbp)
jmp    11c3 <main+0x93>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    1170 <main+0x40>
cmpl   $0x1,-0x14(%rbp)
je     11d9 <main+0xa9>
lea    0xe65(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r14
push   %rbx
sub    $0x10,%rsp
lea    0xec4(%rip),%rdi
call   1030 <puts@plt>
lea    0xeb5(%rip),%rdi
lea    0xc(%rsp),%rsi
call   1040 <scanf@plt>
lea    0xebe(%rip),%rbx
cmpl   $0x0,0xc(%rsp)
jle    1193 <main+0x63>
xor    %ebp,%ebp
lea    0xecf(%rip),%r14
nopl   0x0(%rax)
add    $0x1,%ebp
mov    $0x2,%edi
mov    %ebp,%esi
call   1050 <pow@plt>
mov    0xc(%rsp),%ecx
lea    0x1(%rcx),%edx
cmp    %eax,%edx
je     1190 <main+0x60>
cmp    %ecx,%ebp
jl     1170 <main+0x40>
jmp    1193 <main+0x63>
mov    %r14,%rbx
mov    %rbx,%rdi
call   1030 <puts@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@.str = [24 x i8] c"Enter a prime number. \0A\00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [30 x i8] c"Number is a Mersenne Prime. \0A\00"
@.str.3 = [34 x i8] c"Number is not a Mersenne Prime. \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 0, i32* %3
store i32 1, i32* %4
store i32 0, i32* %5
%6 = call i32 @printf(i8* getelementptr inbounds ([24 x i8], [24 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)
br label %8
8: ; preds = %22, %0
%9 = load i32, i32* %4
%10 = load i32, i32* %2
%11 = icmp sle i32 %9, %10
br i1 %11, label %12, label %25
12: ; preds = %8
%13 = load i32, i32* %4
%14 = call i64 @pow(i32 2, i32 %13)
%15 = trunc i64 %14 to i32
store i32 %15, i32* %3
%16 = load i32, i32* %3
%17 = load i32, i32* %2
%18 = add nsw i32 %17, 1
%19 = icmp eq i32 %16, %18
br i1 %19, label %20, label %22
20: ; preds = %12
%21 = call i32 @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.2, i64 0, i64 0))
store i32 1, i32* %5
br label %25
22: ; preds = %12
%23 = load i32, i32* %4
%24 = add nsw i32 %23, 1
store i32 %24, i32* %4
br label %8
25: ; preds = %20, %8
%26 = load i32, i32* %5
%27 = icmp ne i32 %26, 1
br i1 %27, label %28, label %30
28: ; preds = %25
%29 = call i32 @printf(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.3, i64 0, i64 0))
br label %30
30: ; preds = %28, %25
ret i32 0
}

LLVM IR (-O2):
@.str.1 = [3 x i8] c"%d\00"
@str = [23 x i8] c"Enter a prime number. \00"
@str.4 = [33 x i8] c"Number is not a Mersenne Prime. \00"
@str.5 = [29 x i8] c"Number is a Mersenne Prime. \00"
define i32 @main() {
%1 = alloca i32
%2 = bitcast i32* %1 to i8*
%3 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 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 slt i32 %5, 1
br i1 %6, label %17, label %10
7: ; preds = %10
%8 = add nuw nsw i32 %11, 1
%9 = icmp slt i32 %11, %14
br i1 %9, label %10, label %17
10: ; preds = %0, %7
%11 = phi i32 [ %8, %7 ], [ 1, %0 ]
%12 = call i64 @pow(i32 2, i32 %11)
%13 = trunc i64 %12 to i32
%14 = load i32, i32* %1
%15 = add nsw i32 %14, 1
%16 = icmp eq i32 %15, %13
br i1 %16, label %17, label %7
17: ; preds = %7, %10, %0
%18 = phi i8* [ getelementptr inbounds ([33 x i8], [33 x i8]* @str.4, i64 0, i64 0), %0 ], [ getelementptr inbounds ([29 x i8], [29 x i8]* @str.5, i64 0, i64 0), %10 ], [ getelementptr inbounds ([33 x i8], [33 x i8]* @str.4, i64 0, i64 0), %7 ]
%19 = call i32 @puts(i8* dereferenceable(1) %18)
ret i32 0
}