#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 *, ...);
int scanf(char *, int *);
int main() {
  int a, b = 0, i;
  printf("PERFECTION OUTPUT\n");
  while (scanf("%d", &a) == 1) {
    for (i = 1; i < a; i++) {
      if (a % i == 0) {
        b += i;
      }
    }
    if (a == 0) {
      printf("END OF OUTPUT\n");
      break;
    } else if (b == a) {
      printf("%5d  PERFECT\n", a);
    } else if (b > a) {
      printf("%5d  ABUNDANT\n", a);
    } else if (b < a) {
      printf("%5d  DEFICIENT\n", a);
    }
    b = 0;
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0xc(%rbp)
lea    0xec3(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xec8(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1040 <scanf@plt>
cmp    $0x1,%eax
jne    1235 <main+0x115>
movl   $0x1,-0x10(%rbp)
mov    -0x10(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    119c <main+0x7c>
mov    -0x8(%rbp),%eax
cltd
idivl  -0x10(%rbp)
cmp    $0x0,%edx
jne    1189 <main+0x69>
mov    -0x10(%rbp),%eax
add    -0xc(%rbp),%eax
mov    %eax,-0xc(%rbp)
jmp    118e <main+0x6e>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    1164 <main+0x44>
cmpl   $0x0,-0x8(%rbp)
jne    11b9 <main+0x99>
lea    0xe69(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1235 <main+0x115>
mov    -0xc(%rbp),%eax
cmp    -0x8(%rbp),%eax
jne    11db <main+0xbb>
mov    -0x8(%rbp),%esi
lea    0xe56(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1224 <main+0x104>
mov    -0xc(%rbp),%eax
cmp    -0x8(%rbp),%eax
jle    11fd <main+0xdd>
mov    -0x8(%rbp),%esi
lea    0xe42(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    121f <main+0xff>
mov    -0xc(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    121a <main+0xfa>
mov    -0x8(%rbp),%esi
lea    0xe2f(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    121f <main+0xff>
jmp    1224 <main+0x104>
jmp    1229 <main+0x109>
movl   $0x0,-0xc(%rbp)
jmp    1144 <main+0x24>
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    0xeee(%rip),%rdi
call   1030 <puts@plt>
lea    0xeb2(%rip),%rdi
lea    0x4(%rsp),%rsi
call   1050 <scanf@plt>
cmp    $0x1,%eax
jne    1236 <main+0x106>
lea    0xe9b(%rip),%r15
lea    0xe91(%rip),%r14
lea    0x4(%rsp),%r13
lea    0xe96(%rip),%r12
jmp    119b <main+0x6b>
nopl   (%rax)
xor    %eax,%eax
call   1040 <printf@plt>
mov    %r14,%rdi
mov    %r13,%rsi
call   1050 <scanf@plt>
cmp    $0x1,%eax
jne    1236 <main+0x106>
mov    0x4(%rsp),%esi
mov    $0x0,%ecx
cmp    $0x2,%esi
jl     11d2 <main+0xa2>
lea    -0x1(%rsi),%r8d
cmp    $0x2,%esi
jne    11f0 <main+0xc0>
xor    %ecx,%ecx
mov    $0x1,%edi
test   $0x1,%r8b
je     11d2 <main+0xa2>
mov    %esi,%eax
cltd
idiv   %edi
test   %edx,%edx
mov    $0x0,%eax
cmovne %eax,%edi
add    %ecx,%edi
mov    %edi,%ecx
test   %esi,%esi
je     122a <main+0xfa>
mov    %r15,%rdi
cmp    %esi,%ecx
je     1180 <main+0x50>
mov    %r12,%rdi
jg     1180 <main+0x50>
lea    0xe37(%rip),%rdi
jl     1180 <main+0x50>
jmp    1187 <main+0x57>
nopl   (%rax)
mov    %r8d,%ebp
and    $0xfffffffe,%ebp
xor    %ecx,%ecx
mov    $0x1,%edi
jmp    1209 <main+0xd9>
nop
add    %eax,%ecx
add    $0x2,%edi
cmp    %ebp,%ebx
je     11b9 <main+0x89>
mov    %esi,%eax
cltd
idiv   %edi
mov    %edi,%eax
test   %edx,%edx
je     1216 <main+0xe6>
xor    %eax,%eax
add    %eax,%ecx
lea    0x1(%rdi),%ebx
mov    %esi,%eax
cltd
idiv   %ebx
mov    %ebx,%eax
test   %edx,%edx
je     1200 <main+0xd0>
xor    %eax,%eax
jmp    1200 <main+0xd0>
lea    0xe11(%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"
@.str.2 = [15 x i8] c"END OF OUTPUT\0A\00"
@.str.3 = [14 x i8] c"%5d PERFECT\0A\00"
@.str.4 = [15 x i8] c"%5d ABUNDANT\0A\00"
@.str.5 = [16 x i8] c"%5d DEFICIENT\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
store i32 0, i32* %1
store i32 0, i32* %3
%5 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0))
br label %6
6: ; preds = %56, %0
%7 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %2)
%8 = icmp eq i32 %7, 1
br i1 %8, label %9, label %57
9: ; preds = %6
store i32 1, i32* %4
br label %10
10: ; preds = %24, %9
%11 = load i32, i32* %4
%12 = load i32, i32* %2
%13 = icmp slt i32 %11, %12
br i1 %13, label %14, label %27
14: ; preds = %10
%15 = load i32, i32* %2
%16 = load i32, i32* %4
%17 = srem i32 %15, %16
%18 = icmp eq i32 %17, 0
br i1 %18, label %19, label %23
19: ; preds = %14
%20 = load i32, i32* %4
%21 = load i32, i32* %3
%22 = add nsw i32 %21, %20
store i32 %22, i32* %3
br label %23
23: ; preds = %19, %14
br label %24
24: ; preds = %23
%25 = load i32, i32* %4
%26 = add nsw i32 %25, 1
store i32 %26, i32* %4
br label %10
27: ; preds = %10
%28 = load i32, i32* %2
%29 = icmp eq i32 %28, 0
br i1 %29, label %30, label %32
30: ; preds = %27
%31 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.2, i64 0, i64 0))
br label %57
32: ; preds = %27
%33 = load i32, i32* %3
%34 = load i32, i32* %2
%35 = icmp eq i32 %33, %34
br i1 %35, label %36, label %39
36: ; preds = %32
%37 = load i32, i32* %2
%38 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.3, i64 0, i64 0), i32 %37)
br label %55
39: ; preds = %32
%40 = load i32, i32* %3
%41 = load i32, i32* %2
%42 = icmp sgt i32 %40, %41
br i1 %42, label %43, label %46
43: ; preds = %39
%44 = load i32, i32* %2
%45 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.4, i64 0, i64 0), i32 %44)
br label %54
46: ; preds = %39
%47 = load i32, i32* %3
%48 = load i32, i32* %2
%49 = icmp slt i32 %47, %48
br i1 %49, label %50, label %53
50: ; preds = %46
%51 = load i32, i32* %2
%52 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.5, i64 0, i64 0), i32 %51)
br label %53
53: ; preds = %50, %46
br label %54
54: ; preds = %53, %43
br label %55
55: ; preds = %54, %36
br label %56
56: ; preds = %55
store i32 0, i32* %3
br label %6
57: ; preds = %30, %6
ret i32 0
}

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