#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__ EOF;
int add_divisors(int);
int /*<<< orphan*/ printf(char *, int);
int /*<<< orphan*/ puts(char *);
scalar_t__ scanf(char *, int *);
int main() {
  int num, sum;
  puts("PERFECTION OUTPUT");
  while (scanf("%d", &num) != EOF && num != 0) {
    sum = add_divisors(num);
    if (sum == num) {
      printf("%5u  PERFECT\n", num);
    } else if (sum < num) {
      printf("%5u  DEFICIENT\n", num);
    } else {
      printf("%5u  ABUNDANT\n", num);
    }
  }
  puts("END OF OUTPUT");
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeaa(%rip),%rdi
call   1030 <puts@plt>
lea    0xeb0(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1060 <scanf@plt>
mov    %rax,%rcx
xor    %eax,%eax
mov    0x2e71(%rip),%rdx
cmp    (%rdx),%rcx
mov    %al,-0xd(%rbp)
je     118d <main+0x4d>
cmpl   $0x0,-0x8(%rbp)
setne  %al
mov    %al,-0xd(%rbp)
mov    -0xd(%rbp),%al
test   $0x1,%al
jne    119d <main+0x5d>
jmp    1201 <main+0xc1>
mov    -0x8(%rbp),%edi
call   1040 <add_divisors@plt>
mov    %eax,-0xc(%rbp)
mov    -0xc(%rbp),%eax
cmp    -0x8(%rbp),%eax
jne    11c8 <main+0x88>
mov    -0x8(%rbp),%esi
lea    0xe57(%rip),%rdi
call   1050 <printf@plt>
jmp    11fc <main+0xbc>
mov    -0xc(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    11e8 <main+0xa8>
mov    -0x8(%rbp),%esi
lea    0xe45(%rip),%rdi
call   1050 <printf@plt>
jmp    11f7 <main+0xb7>
mov    -0x8(%rbp),%esi
lea    0xe41(%rip),%rdi
call   1050 <printf@plt>
jmp    11fc <main+0xbc>
jmp    115b <main+0x1b>
lea    0xe3a(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
lea    0xeae(%rip),%rdi
call   1030 <puts@plt>
lea    0xeb4(%rip),%rdi
lea    0x4(%rsp),%rsi
call   1060 <scanf@plt>
mov    0x2e79(%rip),%rbp
cmp    0x0(%rbp),%rax
je     11f1 <main+0xb1>
mov    0x4(%rsp),%edi
test   %edi,%edi
je     11f1 <main+0xb1>
lea    0xe91(%rip),%r14
lea    0xe87(%rip),%r15
lea    0x4(%rsp),%rbx
lea    0xe8c(%rip),%r12
lea    0xe95(%rip),%r13
xchg   %ax,%ax
call   1040 <add_divisors@plt>
mov    0x4(%rsp),%esi
cmp    %esi,%eax
jne    11c0 <main+0x80>
mov    %r14,%rdi
mov    %eax,%esi
jmp    11d3 <main+0x93>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
jge    11d0 <main+0x90>
mov    %r12,%rdi
jmp    11d3 <main+0x93>
nopw   0x0(%rax,%rax,1)
mov    %r13,%rdi
call   1050 <printf@plt>
mov    %r15,%rdi
mov    %rbx,%rsi
call   1060 <scanf@plt>
cmp    0x0(%rbp),%rax
je     11f1 <main+0xb1>
mov    0x4(%rsp),%edi
test   %edi,%edi
jne    11a0 <main+0x60>
lea    0xe4a(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [18 x i8] c"PERFECTION OUTPUT\00"
@.str.1 = [3 x i8] c"%d\00"
@EOF = global i64 0
@.str.2 = [14 x i8] c"%5u PERFECT\0A\00"
@.str.3 = [16 x i8] c"%5u DEFICIENT\0A\00"
@.str.4 = [15 x i8] c"%5u ABUNDANT\0A\00"
@.str.5 = [14 x i8] c"END OF OUTPUT\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
store i32 0, i32* %1
%4 = call i32 @puts(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0))
br label %5
5: ; preds = %34, %0
%6 = call i64 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %2)
%7 = load i64, i64* @EOF
%8 = icmp ne i64 %6, %7
br i1 %8, label %9, label %12
9: ; preds = %5
%10 = load i32, i32* %2
%11 = icmp ne i32 %10, 0
br label %12
12: ; preds = %9, %5
%13 = phi i1 [ false, %5 ], [ %11, %9 ]
br i1 %13, label %14, label %35
14: ; preds = %12
%15 = load i32, i32* %2
%16 = call i32 @add_divisors(i32 %15)
store i32 %16, i32* %3
%17 = load i32, i32* %3
%18 = load i32, i32* %2
%19 = icmp eq i32 %17, %18
br i1 %19, label %20, label %23
20: ; preds = %14
%21 = load i32, i32* %2
%22 = call i32 @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.2, i64 0, i64 0), i32 %21)
br label %34
23: ; preds = %14
%24 = load i32, i32* %3
%25 = load i32, i32* %2
%26 = icmp slt i32 %24, %25
br i1 %26, label %27, label %30
27: ; preds = %23
%28 = load i32, i32* %2
%29 = call i32 @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.3, i64 0, i64 0), i32 %28)
br label %33
30: ; preds = %23
%31 = load i32, i32* %2
%32 = call i32 @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.4, i64 0, i64 0), i32 %31)
br label %33
33: ; preds = %30, %27
br label %34
34: ; preds = %33, %20
br label %5
35: ; preds = %12
%36 = call i32 @puts(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.5, i64 0, i64 0))
ret i32 0
}

LLVM IR (-O2):
@.str = [18 x i8] c"PERFECTION OUTPUT\00"
@.str.1 = [3 x i8] c"%d\00"
@EOF = global i64 0
@.str.2 = [14 x i8] c"%5u PERFECT\0A\00"
@.str.3 = [16 x i8] c"%5u DEFICIENT\0A\00"
@.str.4 = [15 x i8] c"%5u ABUNDANT\0A\00"
@.str.5 = [14 x i8] c"END OF OUTPUT\00"
define i32 @main() {
%1 = alloca i32
%2 = bitcast i32* %1 to i8*
%3 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0))
%4 = call i64 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %1)
%5 = load i64, i64* @EOF
%6 = icmp ne i64 %4, %5
%7 = load i32, i32* %1
%8 = icmp ne i32 %7, 0
%9 = select i1 %6, i1 %8, i1 false
br i1 %9, label %10, label %30
10: ; preds = %0, %23
%11 = phi i32 [ %27, %23 ], [ %7, %0 ]
%12 = call i32 @add_divisors(i32 %11)
%13 = load i32, i32* %1
%14 = icmp eq i32 %12, %13
br i1 %14, label %15, label %17
15: ; preds = %10
%16 = call i32 @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.2, i64 0, i64 0), i32 %12)
br label %23
17: ; preds = %10
%18 = icmp slt i32 %12, %13
br i1 %18, label %19, label %21
19: ; preds = %17
%20 = call i32 @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.3, i64 0, i64 0), i32 %13)
br label %23
21: ; preds = %17
%22 = call i32 @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.4, i64 0, i64 0), i32 %13)
br label %23
23: ; preds = %19, %21, %15
%24 = call i64 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %1)
%25 = load i64, i64* @EOF
%26 = icmp ne i64 %24, %25
%27 = load i32, i32* %1
%28 = icmp ne i32 %27, 0
%29 = select i1 %26, i1 %28, i1 false
br i1 %29, label %10, label %30
30: ; preds = %23, %0
%31 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @.str.5, i64 0, i64 0))
ret i32 0
}