#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 /*<<< orphan*/ printf(char *, ...);
scalar_t__ scanf(char *, int *);
int sqrt(int);
int main() {
  int x, i, fsum;
  char output[10];
  printf("PERFECTION OUTPUT\n");
  while (scanf("%d", &x) != EOF) {
    if (!x)
      break;
    fsum = 1;
    for (i = 2; i < sqrt(x); i++)
      fsum += (x % i == 0) ? i + x / i : 0;
    fsum += (x / sqrt(x) == sqrt(x)) ? sqrt(x) : 0;
    if (x == 1)
      fsum = 0;
    printf("%5d  ", x);
    if (fsum == x)
      printf("PERFECT\n");
    else if (fsum < x)
      printf("DEFICIENT\n");
    else
      printf("ABUNDANT\n");
  }
  printf("END OF OUTPUT\n");
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeba(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xebf(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1040 <scanf@plt>
mov    0x2e84(%rip),%rcx
cmp    (%rcx),%rax
je     12bb <main+0x18b>
cmpl   $0x0,-0x8(%rbp)
jne    117c <main+0x4c>
jmp    12bb <main+0x18b>
movl   $0x1,-0x10(%rbp)
movl   $0x2,-0xc(%rbp)
mov    -0xc(%rbp),%eax
mov    %eax,-0x20(%rbp)
mov    -0x8(%rbp),%edi
call   1050 <sqrt@plt>
mov    %eax,%ecx
mov    -0x20(%rbp),%eax
cmp    %ecx,%eax
jge    11f2 <main+0xc2>
mov    -0x8(%rbp),%eax
cltd
idivl  -0xc(%rbp)
cmp    $0x0,%edx
jne    11d1 <main+0xa1>
mov    -0xc(%rbp),%eax
mov    %eax,-0x28(%rbp)
mov    -0x8(%rbp),%eax
cltd
idivl  -0xc(%rbp)
mov    %eax,%ecx
mov    -0x28(%rbp),%eax
add    %ecx,%eax
mov    %eax,-0x24(%rbp)
jmp    11db <main+0xab>
xor    %eax,%eax
mov    %eax,-0x24(%rbp)
jmp    11db <main+0xab>
mov    -0x24(%rbp),%eax
add    -0x10(%rbp),%eax
mov    %eax,-0x10(%rbp)
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    118a <main+0x5a>
mov    -0x8(%rbp),%eax
mov    %eax,-0x30(%rbp)
mov    -0x8(%rbp),%edi
call   1050 <sqrt@plt>
mov    %eax,%ecx
mov    -0x30(%rbp),%eax
cltd
idiv   %ecx
mov    %eax,-0x2c(%rbp)
mov    -0x8(%rbp),%edi
call   1050 <sqrt@plt>
mov    %eax,%ecx
mov    -0x2c(%rbp),%eax
cmp    %ecx,%eax
jne    1230 <main+0x100>
mov    -0x8(%rbp),%edi
call   1050 <sqrt@plt>
mov    %eax,-0x34(%rbp)
jmp    123a <main+0x10a>
xor    %eax,%eax
mov    %eax,-0x34(%rbp)
jmp    123a <main+0x10a>
mov    -0x34(%rbp),%eax
add    -0x10(%rbp),%eax
mov    %eax,-0x10(%rbp)
cmpl   $0x1,-0x8(%rbp)
jne    1254 <main+0x124>
movl   $0x0,-0x10(%rbp)
mov    -0x8(%rbp),%esi
lea    0xdb8(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x10(%rbp),%eax
cmp    -0x8(%rbp),%eax
jne    1284 <main+0x154>
lea    0xda4(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    12b6 <main+0x186>
mov    -0x10(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    12a3 <main+0x173>
lea    0xd8e(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    12b1 <main+0x181>
lea    0xd86(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    12b6 <main+0x186>
jmp    114d <main+0x1d>
lea    0xd78(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
lea    0xeb7(%rip),%rdi
call   1030 <puts@plt>
lea    0xea2(%rip),%rdi
lea    0x4(%rsp),%rsi
call   1050 <scanf@plt>
mov    0x2e79(%rip),%rcx
cmp    (%rcx),%rax
je     1273 <main+0x133>
mov    0x4(%rsp),%edi
test   %edi,%edi
je     1273 <main+0x133>
xor    %r14d,%r14d
lea    0xe72(%rip),%r15
lea    0x4(%rsp),%r12
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
call   1060 <sqrt@plt>
mov    $0x1,%r13d
cmp    $0x3,%eax
jl     11e0 <main+0xa0>
mov    $0x1,%r13d
mov    $0x2,%ebx
nopl   0x0(%rax,%rax,1)
mov    0x4(%rsp),%edi
mov    %edi,%eax
cltd
idiv   %ebx
add    %ebx,%eax
test   %edx,%edx
cmovne %r14d,%eax
add    %eax,%r13d
add    $0x1,%ebx
call   1060 <sqrt@plt>
cmp    %eax,%ebx
jl     11c0 <main+0x80>
mov    0x4(%rsp),%ebp
mov    %ebp,%edi
call   1060 <sqrt@plt>
mov    %eax,%ecx
mov    %ebp,%eax
cltd
idiv   %ecx
mov    %eax,%ebx
mov    0x4(%rsp),%edi
call   1060 <sqrt@plt>
xor    %ebp,%ebp
cmp    %eax,%ebx
jne    120e <main+0xce>
mov    0x4(%rsp),%edi
call   1060 <sqrt@plt>
mov    %eax,%ebp
add    %r13d,%ebp
mov    0x4(%rsp),%esi
cmp    $0x1,%esi
cmove  %r14d,%ebp
lea    0xde0(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
cmp    0x4(%rsp),%ebp
lea    0xdf4(%rip),%rdi
lea    0xdf6(%rip),%rax
cmovl  %rax,%rdi
lea    0xdf5(%rip),%rax
cmove  %rax,%rdi
call   1030 <puts@plt>
mov    %r15,%rdi
mov    %r12,%rsi
call   1050 <scanf@plt>
mov    0x2d86(%rip),%rcx
cmp    (%rcx),%rax
je     1273 <main+0x133>
mov    0x4(%rsp),%edi
test   %edi,%edi
jne    11a0 <main+0x60>
lea    0xda1(%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 = [19 x i8] c"PERFECTION OUTPUT\0A\00"
@.str.1 = [3 x i8] c"%d\00"
@EOF = global i64 0
@.str.2 = [6 x i8] c"%5d \00"
@.str.3 = [9 x i8] c"PERFECT\0A\00"
@.str.4 = [11 x i8] c"DEFICIENT\0A\00"
@.str.5 = [10 x i8] c"ABUNDANT\0A\00"
@.str.6 = [15 x i8] c"END OF OUTPUT\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca [10 x i8]
store i32 0, i32* %1
%6 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0))
br label %7
7: ; preds = %76, %0
%8 = call i64 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %2)
%9 = load i64, i64* @EOF
%10 = icmp ne i64 %8, %9
br i1 %10, label %11, label %77
11: ; preds = %7
%12 = load i32, i32* %2
%13 = icmp ne i32 %12, 0
br i1 %13, label %15, label %14
14: ; preds = %11
br label %77
15: ; preds = %11
store i32 1, i32* %4
store i32 2, i32* %3
br label %16
16: ; preds = %37, %15
%17 = load i32, i32* %3
%18 = load i32, i32* %2
%19 = call i32 @sqrt(i32 %18)
%20 = icmp slt i32 %17, %19
br i1 %20, label %21, label %40
21: ; preds = %16
%22 = load i32, i32* %2
%23 = load i32, i32* %3
%24 = srem i32 %22, %23
%25 = icmp eq i32 %24, 0
br i1 %25, label %26, label %32
26: ; preds = %21
%27 = load i32, i32* %3
%28 = load i32, i32* %2
%29 = load i32, i32* %3
%30 = sdiv i32 %28, %29
%31 = add nsw i32 %27, %30
br label %33
32: ; preds = %21
br label %33
33: ; preds = %32, %26
%34 = phi i32 [ %31, %26 ], [ 0, %32 ]
%35 = load i32, i32* %4
%36 = add nsw i32 %35, %34
store i32 %36, i32* %4
br label %37
37: ; preds = %33
%38 = load i32, i32* %3
%39 = add nsw i32 %38, 1
store i32 %39, i32* %3
br label %16
40: ; preds = %16
%41 = load i32, i32* %2
%42 = load i32, i32* %2
%43 = call i32 @sqrt(i32 %42)
%44 = sdiv i32 %41, %43
%45 = load i32, i32* %2
%46 = call i32 @sqrt(i32 %45)
%47 = icmp eq i32 %44, %46
br i1 %47, label %48, label %51
48: ; preds = %40
%49 = load i32, i32* %2
%50 = call i32 @sqrt(i32 %49)
br label %52
51: ; preds = %40
br label %52
52: ; preds = %51, %48
%53 = phi i32 [ %50, %48 ], [ 0, %51 ]
%54 = load i32, i32* %4
%55 = add nsw i32 %54, %53
store i32 %55, i32* %4
%56 = load i32, i32* %2
%57 = icmp eq i32 %56, 1
br i1 %57, label %58, label %59
58: ; preds = %52
store i32 0, i32* %4
br label %59
59: ; preds = %58, %52
%60 = load i32, i32* %2
%61 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), i32 %60)
%62 = load i32, i32* %4
%63 = load i32, i32* %2
%64 = icmp eq i32 %62, %63
br i1 %64, label %65, label %67
65: ; preds = %59
%66 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.3, i64 0, i64 0))
br label %76
67: ; preds = %59
%68 = load i32, i32* %4
%69 = load i32, i32* %2
%70 = icmp slt i32 %68, %69
br i1 %70, label %71, label %73
71: ; preds = %67
%72 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.4, i64 0, i64 0))
br label %75
73: ; preds = %67
%74 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.5, i64 0, i64 0))
br label %75
75: ; preds = %73, %71
br label %76
76: ; preds = %75, %65
br label %7
77: ; preds = %14, %7
%78 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.6, i64 0, i64 0))
ret i32 0
}

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