#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*/ printf(char *, ...);
scalar_t__ scanf(char *, unsigned int *);
void main() {
  unsigned s, n, i;
  printf("PERFECTION OUTPUT\n");
  while (scanf("%u", &n) && n) {
    s = 0;
    printf("%5u  ", n);
    for (i = 2; i <= n / 2; i++)
      if (!(n % i))
        s += i;
    if (n > 1)
      s++;
    if (n > s)
      printf("DEFICIENT");
    else if (n == s)
      printf("PERFECT");
    else
      printf("ABUNDANT");
    printf("\n");
  }
  printf("END OF OUTPUT\n");
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
lea    0xed1(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xed6(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1040 <scanf@plt>
mov    %rax,%rcx
xor    %eax,%eax
cmp    $0x0,%rcx
mov    %al,-0xd(%rbp)
je     1162 <main+0x42>
cmpl   $0x0,-0x8(%rbp)
setne  %al
mov    %al,-0xd(%rbp)
mov    -0xd(%rbp),%al
test   $0x1,%al
jne    1172 <main+0x52>
jmp    1246 <main+0x126>
movl   $0x0,-0x4(%rbp)
mov    -0x8(%rbp),%esi
lea    0xe93(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x2,-0xc(%rbp)
mov    -0xc(%rbp),%eax
mov    -0x8(%rbp),%ecx
shr    $0x1,%ecx
cmp    %ecx,%eax
ja     11cf <main+0xaf>
mov    -0x8(%rbp),%eax
xor    %edx,%edx
divl   -0xc(%rbp)
cmp    $0x0,%edx
jne    11bc <main+0x9c>
mov    -0xc(%rbp),%eax
add    -0x4(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    11c1 <main+0xa1>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1191 <main+0x71>
cmpl   $0x1,-0x8(%rbp)
jbe    11e2 <main+0xc2>
mov    -0x4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x4(%rbp)
mov    -0x8(%rbp),%eax
cmp    -0x4(%rbp),%eax
jbe    1201 <main+0xe1>
lea    0xe27(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1233 <main+0x113>
mov    -0x8(%rbp),%eax
cmp    -0x4(%rbp),%eax
jne    1220 <main+0x100>
lea    0xe12(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    122e <main+0x10e>
lea    0xe07(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1233 <main+0x113>
lea    0xe0a(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1136 <main+0x16>
lea    0xdea(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
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    0xed2(%rip),%rdi
call   1040 <puts@plt>
lea    0xea2(%rip),%rdi
lea    0x4(%rsp),%rsi
call   1060 <scanf@plt>
test   %rax,%rax
je     12a3 <main+0x163>
mov    0x4(%rsp),%esi
test   %esi,%esi
je     12a3 <main+0x163>
lea    0xe7f(%rip),%rbx
lea    0xe88(%rip),%rbp
lea    0xe89(%rip),%r13
lea    0xe70(%rip),%r12
lea    0xe60(%rip),%r15
lea    0x4(%rsp),%r14
cs nopw 0x0(%rax,%rax,1)
nop
mov    %rbx,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    0x4(%rsp),%ecx
mov    $0x0,%esi
cmp    $0x4,%ecx
jb     1263 <main+0x123>
mov    %ecx,%eax
shr    %eax
lea    -0x1(%rax),%r8d
cmp    $0x2,%eax
jne    11f0 <main+0xb0>
xor    %esi,%esi
mov    $0x2,%edi
test   $0x1,%r8b
jne    124f <main+0x10f>
jmp    1263 <main+0x123>
nopl   0x0(%rax,%rax,1)
mov    %rbp,%r10
mov    %rbx,%r9
mov    %r8d,%ebp
and    $0xfffffffe,%ebp
xor    %esi,%esi
mov    $0x3,%edi
jmp    1219 <main+0xd9>
cs nopw 0x0(%rax,%rax,1)
nop
add    %eax,%esi
add    $0x2,%edi
cmp    %ebp,%ebx
je     1240 <main+0x100>
lea    -0x1(%rdi),%ebx
mov    %ecx,%eax
xor    %edx,%edx
div    %ebx
mov    %ebx,%eax
test   %edx,%edx
je     122a <main+0xea>
xor    %eax,%eax
add    %eax,%esi
mov    %ecx,%eax
xor    %edx,%edx
div    %edi
mov    %edi,%eax
test   %edx,%edx
je     1210 <main+0xd0>
xor    %eax,%eax
jmp    1210 <main+0xd0>
nopl   0x0(%rax)
add    $0xffffffff,%edi
mov    %r9,%rbx
mov    %r10,%rbp
test   $0x1,%r8b
je     1263 <main+0x123>
mov    %ecx,%eax
xor    %edx,%edx
div    %edi
test   %edx,%edx
mov    $0x0,%eax
cmovne %eax,%edi
add    %esi,%edi
mov    %edi,%esi
cmp    $0x2,%ecx
sbb    $0xffffffff,%esi
cmp    %esi,%ecx
mov    %r13,%rdi
cmove  %rbp,%rdi
cmova  %r12,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
mov    %r15,%rdi
mov    %r14,%rsi
call   1060 <scanf@plt>
test   %rax,%rax
je     12a3 <main+0x163>
mov    0x4(%rsp),%esi
test   %esi,%esi
jne    11b0 <main+0x70>
lea    0xd8c(%rip),%rdi
call   1040 <puts@plt>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [19 x i8] c"PERFECTION OUTPUT\0A\00"
@.str.1 = [3 x i8] c"%u\00"
@.str.2 = [6 x i8] c"%5u \00"
@.str.3 = [10 x i8] c"DEFICIENT\00"
@.str.4 = [8 x i8] c"PERFECT\00"
@.str.5 = [9 x i8] c"ABUNDANT\00"
@.str.6 = [2 x i8] c"\0A\00"
@.str.7 = [15 x i8] c"END OF OUTPUT\0A\00"
define void @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0))
br label %5
5: ; preds = %55, %0
%6 = call i64 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %2)
%7 = icmp ne i64 %6, 0
br i1 %7, label %8, label %11
8: ; preds = %5
%9 = load i32, i32* %2
%10 = icmp ne i32 %9, 0
br label %11
11: ; preds = %8, %5
%12 = phi i1 [ false, %5 ], [ %10, %8 ]
br i1 %12, label %13, label %57
13: ; preds = %11
store i32 0, i32* %1
%14 = load i32, i32* %2
%15 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), i32 %14)
store i32 2, i32* %3
br label %16
16: ; preds = %31, %13
%17 = load i32, i32* %3
%18 = load i32, i32* %2
%19 = udiv i32 %18, 2
%20 = icmp ule i32 %17, %19
br i1 %20, label %21, label %34
21: ; preds = %16
%22 = load i32, i32* %2
%23 = load i32, i32* %3
%24 = urem i32 %22, %23
%25 = icmp ne i32 %24, 0
br i1 %25, label %30, label %26
26: ; preds = %21
%27 = load i32, i32* %3
%28 = load i32, i32* %1
%29 = add i32 %28, %27
store i32 %29, i32* %1
br label %30
30: ; preds = %26, %21
br label %31
31: ; preds = %30
%32 = load i32, i32* %3
%33 = add i32 %32, 1
store i32 %33, i32* %3
br label %16
34: ; preds = %16
%35 = load i32, i32* %2
%36 = icmp ugt i32 %35, 1
br i1 %36, label %37, label %40
37: ; preds = %34
%38 = load i32, i32* %1
%39 = add i32 %38, 1
store i32 %39, i32* %1
br label %40
40: ; preds = %37, %34
%41 = load i32, i32* %2
%42 = load i32, i32* %1
%43 = icmp ugt i32 %41, %42
br i1 %43, label %44, label %46
44: ; preds = %40
%45 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.3, i64 0, i64 0))
br label %55
46: ; preds = %40
%47 = load i32, i32* %2
%48 = load i32, i32* %1
%49 = icmp eq i32 %47, %48
br i1 %49, label %50, label %52
50: ; preds = %46
%51 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.4, i64 0, i64 0))
br label %54
52: ; preds = %46
%53 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.5, i64 0, i64 0))
br label %54
54: ; preds = %52, %50
br label %55
55: ; preds = %54, %44
%56 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.6, i64 0, i64 0))
br label %5
57: ; preds = %11
%58 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.7, i64 0, i64 0))
ret void
}

LLVM IR (-O2):
@.str.1 = [3 x i8] c"%u\00"
@.str.2 = [6 x i8] c"%5u \00"
@.str.3 = [10 x i8] c"DEFICIENT\00"
@.str.4 = [8 x i8] c"PERFECT\00"
@.str.5 = [9 x i8] c"ABUNDANT\00"
@str = [18 x i8] c"PERFECTION OUTPUT\00"
@str.8 = [14 x i8] c"END OF OUTPUT\00"
define void @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 = icmp ne i64 %4, 0
%6 = load i32, i32* %1
%7 = icmp ne i32 %6, 0
%8 = select i1 %5, i1 %7, i1 false
br i1 %8, label %9, label %63
9: ; preds = %0, %47
%10 = phi i32 [ %60, %47 ], [ %6, %0 ]
%11 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), i32 %10)
%12 = load i32, i32* %1
%13 = icmp ult i32 %12, 4
br i1 %13, label %47, label %14
14: ; preds = %9
%15 = lshr i32 %12, 1
%16 = add nsw i32 %15, -1
%17 = and i32 %16, 1
%18 = icmp eq i32 %15, 2
br i1 %18, label %37, label %19
19: ; preds = %14
%20 = and i32 %16, -2
br label %21
21: ; preds = %21, %19
%22 = phi i32 [ 2, %19 ], [ %34, %21 ]
%23 = phi i32 [ 0, %19 ], [ %33, %21 ]
%24 = phi i32 [ 0, %19 ], [ %35, %21 ]
%25 = urem i32 %12, %22
%26 = icmp eq i32 %25, 0
%27 = select i1 %26, i32 %22, i32 0
%28 = add i32 %27, %23
%29 = or i32 %22, 1
%30 = urem i32 %12, %29
%31 = icmp eq i32 %30, 0
%32 = select i1 %31, i32 %29, i32 0
%33 = add i32 %32, %28
%34 = add nuw i32 %22, 2
%35 = add i32 %24, 2
%36 = icmp eq i32 %35, %20
br i1 %36, label %37, label %21
37: ; preds = %21, %14
%38 = phi i32 [ undef, %14 ], [ %33, %21 ]
%39 = phi i32 [ 2, %14 ], [ %34, %21 ]
%40 = phi i32 [ 0, %14 ], [ %33, %21 ]
%41 = icmp eq i32 %17, 0
br i1 %41, label %47, label %42
42: ; preds = %37
%43 = urem i32 %12, %39
%44 = icmp eq i32 %43, 0
%45 = select i1 %44, i32 %39, i32 0
%46 = add i32 %45, %40
br label %47
47: ; preds = %42, %37, %9
%48 = phi i32 [ 0, %9 ], [ %38, %37 ], [ %46, %42 ]
%49 = icmp ugt i32 %12, 1
%50 = zext i1 %49 to i32
%51 = add i32 %48, %50
%52 = icmp ugt i32 %12, %51
%53 = icmp eq i32 %12, %51
%54 = select i1 %53, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.5, i64 0, i64 0)
%55 = select i1 %52, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.3, i64 0, i64 0), i8* %54
%56 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) %55)
%57 = call i32 @putchar(i32 10)
%58 = call i64 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %1)
%59 = icmp ne i64 %58, 0
%60 = load i32, i32* %1
%61 = icmp ne i32 %60, 0
%62 = select i1 %59, i1 %61, i1 false
br i1 %62, label %9, label %63
63: ; preds = %47, %0
%64 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @str.8, i64 0, i64 0))
ret void
}