#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*/ is_prime(int);
int pow(int, int);
int /*<<< orphan*/ printf(char *, int);
void perfect_below(int a) {
  int num = 0;
  int p = 2;
  while (num < a) {
    while (!is_prime(p))
      p++;
    num = pow(2, p - 1) * (pow(2, p) - 1);
    p++;
    if (num < a)
      printf("%d\n", num);
  }
}


x86 assembly (clang, -O0):
<perfect_below>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
movl   $0x0,-0x8(%rbp)
movl   $0x2,-0xc(%rbp)
mov    -0x8(%rbp),%eax
cmp    -0x4(%rbp),%eax
jge    11dc <perfect_below+0xac>
jmp    115a <perfect_below+0x2a>
mov    -0xc(%rbp),%edi
call   1040 <is_prime@plt>
cmp    $0x0,%eax
setne  %al
xor    $0xff,%al
test   $0x1,%al
jne    1177 <perfect_below+0x47>
jmp    1185 <perfect_below+0x55>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    115a <perfect_below+0x2a>
mov    -0xc(%rbp),%esi
sub    $0x1,%esi
mov    $0x2,%edi
call   1050 <pow@plt>
mov    %eax,-0x10(%rbp)
mov    -0xc(%rbp),%esi
mov    $0x2,%edi
call   1050 <pow@plt>
mov    %eax,%ecx
mov    -0x10(%rbp),%eax
sub    $0x1,%ecx
imul   %ecx,%eax
mov    %eax,-0x8(%rbp)
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
mov    -0x8(%rbp),%eax
cmp    -0x4(%rbp),%eax
jge    11d7 <perfect_below+0xa7>
mov    -0x8(%rbp),%esi
lea    0xe2e(%rip),%rdi
call   1030 <printf@plt>
jmp    1149 <perfect_below+0x19>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<perfect_below>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
test   %edi,%edi
jle    1193 <perfect_below+0x63>
mov    %edi,%r15d
mov    $0x1,%ebx
lea    0xeb6(%rip),%r14
jmp    1152 <perfect_below+0x22>
nopl   0x0(%rax)
mov    %ebp,%ebx
lea    0x1(%rbx),%ebp
mov    %ebp,%edi
call   1040 <is_prime@plt>
test   %eax,%eax
je     1150 <perfect_below+0x20>
mov    $0x2,%edi
mov    %ebx,%esi
call   1050 <pow@plt>
mov    %eax,%ebx
mov    $0x2,%edi
mov    %ebp,%esi
call   1050 <pow@plt>
add    $0xffffffff,%eax
imul   %ebx,%eax
cmp    %r15d,%eax
jge    1193 <perfect_below+0x63>
mov    %r14,%rdi
mov    %eax,%esi
call   1030 <printf@plt>
mov    %ebp,%ebx
jmp    1152 <perfect_below+0x22>
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [4 x i8] c"%d\0A\00"
define void @perfect_below(i32 %0) {
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
store i32 %0, i32* %2
store i32 0, i32* %3
store i32 2, i32* %4
br label %5
5: ; preds = %34, %1
%6 = load i32, i32* %3
%7 = load i32, i32* %2
%8 = icmp slt i32 %6, %7
br i1 %8, label %9, label %35
9: ; preds = %5
br label %10
10: ; preds = %15, %9
%11 = load i32, i32* %4
%12 = call i32 @is_prime(i32 %11)
%13 = icmp ne i32 %12, 0
%14 = xor i1 %13, true
br i1 %14, label %15, label %18
15: ; preds = %10
%16 = load i32, i32* %4
%17 = add nsw i32 %16, 1
store i32 %17, i32* %4
br label %10
18: ; preds = %10
%19 = load i32, i32* %4
%20 = sub nsw i32 %19, 1
%21 = call i32 @pow(i32 2, i32 %20)
%22 = load i32, i32* %4
%23 = call i32 @pow(i32 2, i32 %22)
%24 = sub nsw i32 %23, 1
%25 = mul nsw i32 %21, %24
store i32 %25, i32* %3
%26 = load i32, i32* %4
%27 = add nsw i32 %26, 1
store i32 %27, i32* %4
%28 = load i32, i32* %3
%29 = load i32, i32* %2
%30 = icmp slt i32 %28, %29
br i1 %30, label %31, label %34
31: ; preds = %18
%32 = load i32, i32* %3
%33 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %32)
br label %34
34: ; preds = %31, %18
br label %5
35: ; preds = %5
ret void
}

LLVM IR (-O2):
@.str = [4 x i8] c"%d\0A\00"
define void @perfect_below(i32 %0) {
%2 = icmp sgt i32 %0, 0
br i1 %2, label %3, label %18
3: ; preds = %1, %8
%4 = phi i32 [ %7, %8 ], [ 2, %1 ]
%5 = tail call i32 @is_prime(i32 %4)
%6 = icmp eq i32 %5, 0
%7 = add nuw nsw i32 %4, 1
br i1 %6, label %8, label %9
8: ; preds = %3, %16
br label %3
9: ; preds = %3
%10 = add nsw i32 %4, -1
%11 = tail call i32 @pow(i32 2, i32 %10)
%12 = tail call i32 @pow(i32 2, i32 %4)
%13 = add nsw i32 %12, -1
%14 = mul nsw i32 %13, %11
%15 = icmp slt i32 %14, %0
br i1 %15, label %16, label %18
16: ; preds = %9
%17 = tail call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %14)
br label %8
18: ; preds = %9, %1
ret void
}