#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 isPerfect(int);
int /*<<< orphan*/ printf(char *, int);
int main(int argc, const char *argv[]) {
  for (int i = 1; i < 9999; i++)
    if (isPerfect(i)) {
      printf("It's a perfect number : %d.\n", isPerfect(i));
    }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x1,-0x14(%rbp)
cmpl   $0x270f,-0x14(%rbp)
jge    1184 <main+0x64>
mov    -0x14(%rbp),%edi
call   1030 <isPerfect@plt>
cmp    $0x0,%eax
je     1171 <main+0x51>
mov    -0x14(%rbp),%edi
call   1030 <isPerfect@plt>
mov    %eax,%esi
lea    0xe94(%rip),%rdi
call   1040 <printf@plt>
jmp    1176 <main+0x56>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    113d <main+0x1d>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
push   %rax
mov    $0x1,%ebx
lea    0xed0(%rip),%r14
jmp    114b <main+0x2b>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
add    $0x1,%ebx
cmp    $0x270f,%ebx
je     1169 <main+0x49>
mov    %ebx,%edi
call   1030 <isPerfect@plt>
test   %eax,%eax
je     1140 <main+0x20>
mov    %ebx,%edi
call   1030 <isPerfect@plt>
mov    %r14,%rdi
mov    %eax,%esi
call   1040 <printf@plt>
jmp    1140 <main+0x20>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [29 x i8] c"It's a perfect number : %d.\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 1, i32* %6
br label %7
7: ; preds = %19, %2
%8 = load i32, i32* %6
%9 = icmp slt i32 %8, 9999
br i1 %9, label %10, label %22
10: ; preds = %7
%11 = load i32, i32* %6
%12 = call i32 @isPerfect(i32 %11)
%13 = icmp ne i32 %12, 0
br i1 %13, label %14, label %18
14: ; preds = %10
%15 = load i32, i32* %6
%16 = call i32 @isPerfect(i32 %15)
%17 = call i32 @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str, i64 0, i64 0), i32 %16)
br label %18
18: ; preds = %14, %10
br label %19
19: ; preds = %18
%20 = load i32, i32* %6
%21 = add nsw i32 %20, 1
store i32 %21, i32* %6
br label %7
22: ; preds = %7
ret i32 0
}

LLVM IR (-O2):
@.str = [29 x i8] c"It's a perfect number : %d.\0A\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
br label %4
3: ; preds = %11
ret i32 0
4: ; preds = %2, %11
%5 = phi i32 [ 1, %2 ], [ %12, %11 ]
%6 = tail call i32 @isPerfect(i32 %5)
%7 = icmp eq i32 %6, 0
br i1 %7, label %11, label %8
8: ; preds = %4
%9 = tail call i32 @isPerfect(i32 %5)
%10 = tail call i32 @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str, i64 0, i64 0), i32 %9)
br label %11
11: ; preds = %4, %8
%12 = add nuw nsw i32 %5, 1
%13 = icmp eq i32 %12, 9999
br i1 %13, label %3, label %4
}