#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*/ getchar();
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ scanf(char *, int *);
int main() {
  int i, sigma, num;
  do {
    printf("Please, enter a number (-1 to exit): ");
    scanf("%d", &num);
    if (num == -1)
      break;
    if (num < 0)
      num = -num;
    sigma = 0;
    for (i = 1; i <= (num / 2); i++) {
      if ((num % i) == 0) {
        sigma += i;
      }
    }
    if (sigma > num) {
      printf("%d:\tDeficient number\n", num);
    } else if (sigma == num) {
      printf("%d:\tPerfect number\n", num);
    } else if (sigma < num) {
      printf("%d:\tAbundant number\n", num);
    }
    printf("\n");
  } while (1);
  getchar();
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeba(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xed2(%rip),%rdi
lea    -0x10(%rbp),%rsi
call   1050 <scanf@plt>
cmpl   $0xffffffff,-0x10(%rbp)
jne    116c <main+0x3c>
jmp    125e <main+0x12e>
cmpl   $0x0,-0x10(%rbp)
jge    117e <main+0x4e>
xor    %eax,%eax
sub    -0x10(%rbp),%eax
mov    %eax,-0x10(%rbp)
movl   $0x0,-0xc(%rbp)
movl   $0x1,-0x8(%rbp)
mov    -0x8(%rbp),%eax
mov    %eax,-0x14(%rbp)
mov    -0x10(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %eax,%ecx
mov    -0x14(%rbp),%eax
cmp    %ecx,%eax
jg     11d6 <main+0xa6>
mov    -0x10(%rbp),%eax
cltd
idivl  -0x8(%rbp)
cmp    $0x0,%edx
jne    11c3 <main+0x93>
mov    -0x8(%rbp),%eax
add    -0xc(%rbp),%eax
mov    %eax,-0xc(%rbp)
jmp    11c8 <main+0x98>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    118c <main+0x5c>
mov    -0xc(%rbp),%eax
cmp    -0x10(%rbp),%eax
jle    11f8 <main+0xc8>
mov    -0x10(%rbp),%esi
lea    0xe3d(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1241 <main+0x111>
mov    -0xc(%rbp),%eax
cmp    -0x10(%rbp),%eax
jne    121a <main+0xea>
mov    -0x10(%rbp),%esi
lea    0xe31(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    123c <main+0x10c>
mov    -0xc(%rbp),%eax
cmp    -0x10(%rbp),%eax
jge    1237 <main+0x107>
mov    -0x10(%rbp),%esi
lea    0xe23(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    123c <main+0x10c>
jmp    1241 <main+0x111>
lea    0xe09(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    $0x1,%al
test   $0x1,%al
jne    113f <main+0xf>
jmp    125e <main+0x12e>
mov    $0x0,%al
call   1040 <getchar@plt>
xor    %eax,%eax
add    $0x20,%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
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xec6(%rip),%rdi
lea    0x4(%rsp),%rsi
call   1060 <scanf@plt>
mov    0x4(%rsp),%ebp
cmp    $0xffffffff,%ebp
je     128a <main+0x14a>
lea    0xeab(%rip),%r12
lea    0xe7b(%rip),%r14
lea    0xe9a(%rip),%r15
lea    0x4(%rsp),%r13
jmp    11d5 <main+0x95>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    %ebp,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
mov    %r14,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %r15,%rdi
mov    %r13,%rsi
call   1060 <scanf@plt>
mov    0x4(%rsp),%ebp
cmp    $0xffffffff,%ebp
je     128a <main+0x14a>
test   %ebp,%ebp
js     11f0 <main+0xb0>
xor    %ecx,%ecx
cmp    $0x2,%ebp
jae    11f6 <main+0xb6>
jmp    121f <main+0xdf>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
neg    %ebp
mov    %ebp,0x4(%rsp)
mov    %ebp,%esi
shr    %esi
cmp    $0x1,%esi
jne    1250 <main+0x110>
mov    $0x1,%edi
xor    %ecx,%ecx
test   $0x2,%bpl
je     121f <main+0xdf>
mov    %ebp,%eax
cltd
idiv   %edi
test   %edx,%edx
mov    $0x0,%eax
cmovne %eax,%edi
add    %ecx,%edi
mov    %edi,%ecx
mov    %r12,%rdi
cmp    %ebp,%ecx
jg     11a0 <main+0x60>
lea    0xe0e(%rip),%rdi
je     11a0 <main+0x60>
lea    0xe15(%rip),%rdi
jl     11a0 <main+0x60>
jmp    11a9 <main+0x69>
nopl   0x0(%rax)
and    $0xfffffffe,%esi
mov    $0x1,%edi
xor    %ecx,%ecx
jmp    1269 <main+0x129>
nopl   0x0(%rax)
add    %eax,%ecx
add    $0x2,%edi
cmp    %esi,%ebx
je     1206 <main+0xc6>
mov    %ebp,%eax
cltd
idiv   %edi
mov    %edi,%eax
test   %edx,%edx
je     1276 <main+0x136>
xor    %eax,%eax
add    %eax,%ecx
lea    0x1(%rdi),%ebx
mov    %ebp,%eax
cltd
idiv   %ebx
mov    %ebx,%eax
test   %edx,%edx
je     1260 <main+0x120>
xor    %eax,%eax
jmp    1260 <main+0x120>
xor    %eax,%eax
call   1050 <getchar@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [38 x i8] c"Please, enter a number (-1 to exit): \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [22 x i8] c"%d:\09Deficient number\0A\00"
@.str.3 = [20 x i8] c"%d:\09Perfect number\0A\00"
@.str.4 = [21 x i8] c"%d:\09Abundant number\0A\00"
@.str.5 = [2 x i8] c"\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
store i32 0, i32* %1
br label %5
5: ; preds = %61, %0
%6 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str, i64 0, i64 0))
%7 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %4)
%8 = load i32, i32* %4
%9 = icmp eq i32 %8, -1
br i1 %9, label %10, label %11
10: ; preds = %5
br label %62
11: ; preds = %5
%12 = load i32, i32* %4
%13 = icmp slt i32 %12, 0
br i1 %13, label %14, label %17
14: ; preds = %11
%15 = load i32, i32* %4
%16 = sub nsw i32 0, %15
store i32 %16, i32* %4
br label %17
17: ; preds = %14, %11
store i32 0, i32* %3
store i32 1, i32* %2
br label %18
18: ; preds = %33, %17
%19 = load i32, i32* %2
%20 = load i32, i32* %4
%21 = sdiv i32 %20, 2
%22 = icmp sle i32 %19, %21
br i1 %22, label %23, label %36
23: ; preds = %18
%24 = load i32, i32* %4
%25 = load i32, i32* %2
%26 = srem i32 %24, %25
%27 = icmp eq i32 %26, 0
br i1 %27, label %28, label %32
28: ; preds = %23
%29 = load i32, i32* %2
%30 = load i32, i32* %3
%31 = add nsw i32 %30, %29
store i32 %31, i32* %3
br label %32
32: ; preds = %28, %23
br label %33
33: ; preds = %32
%34 = load i32, i32* %2
%35 = add nsw i32 %34, 1
store i32 %35, i32* %2
br label %18
36: ; preds = %18
%37 = load i32, i32* %3
%38 = load i32, i32* %4
%39 = icmp sgt i32 %37, %38
br i1 %39, label %40, label %43
40: ; preds = %36
%41 = load i32, i32* %4
%42 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.2, i64 0, i64 0), i32 %41)
br label %59
43: ; preds = %36
%44 = load i32, i32* %3
%45 = load i32, i32* %4
%46 = icmp eq i32 %44, %45
br i1 %46, label %47, label %50
47: ; preds = %43
%48 = load i32, i32* %4
%49 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.3, i64 0, i64 0), i32 %48)
br label %58
50: ; preds = %43
%51 = load i32, i32* %3
%52 = load i32, i32* %4
%53 = icmp slt i32 %51, %52
br i1 %53, label %54, label %57
54: ; preds = %50
%55 = load i32, i32* %4
%56 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.4, i64 0, i64 0), i32 %55)
br label %57
57: ; preds = %54, %50
br label %58
58: ; preds = %57, %47
br label %59
59: ; preds = %58, %40
%60 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0))
br label %61
61: ; preds = %59
br i1 true, label %5, label %62
62: ; preds = %61, %10
%63 = call i32 (...) @getchar()
ret i32 0
}

LLVM IR (-O2):
@.str = [38 x i8] c"Please, enter a number (-1 to exit): \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [22 x i8] c"%d:\09Deficient number\0A\00"
@.str.3 = [20 x i8] c"%d:\09Perfect number\0A\00"
@.str.4 = [21 x i8] c"%d:\09Abundant number\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = bitcast i32* %1 to i8*
%3 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([38 x i8], [38 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 = load i32, i32* %1
%6 = icmp eq i32 %5, -1
br i1 %6, label %64, label %7
7: ; preds = %0, %58
%8 = phi i32 [ %62, %58 ], [ %5, %0 ]
%9 = icmp slt i32 %8, 0
br i1 %9, label %10, label %12
10: ; preds = %7
%11 = sub nsw i32 0, %8
store i32 %11, i32* %1
br label %14
12: ; preds = %7
%13 = icmp ult i32 %8, 2
br i1 %13, label %47, label %14
14: ; preds = %10, %12
%15 = phi i32 [ %11, %10 ], [ %8, %12 ]
%16 = lshr i32 %15, 1
%17 = icmp eq i32 %16, 1
br i1 %17, label %36, label %18
18: ; preds = %14
%19 = and i32 %16, 2147483646
br label %20
20: ; preds = %20, %18
%21 = phi i32 [ 0, %18 ], [ %32, %20 ]
%22 = phi i32 [ 1, %18 ], [ %33, %20 ]
%23 = phi i32 [ 0, %18 ], [ %34, %20 ]
%24 = srem i32 %15, %22
%25 = icmp eq i32 %24, 0
%26 = select i1 %25, i32 %22, i32 0
%27 = add nuw nsw i32 %26, %21
%28 = add nuw nsw i32 %22, 1
%29 = srem i32 %15, %28
%30 = icmp eq i32 %29, 0
%31 = select i1 %30, i32 %28, i32 0
%32 = add nuw nsw i32 %31, %27
%33 = add nuw nsw i32 %22, 2
%34 = add i32 %23, 2
%35 = icmp eq i32 %34, %19
br i1 %35, label %36, label %20
36: ; preds = %20, %14
%37 = phi i32 [ undef, %14 ], [ %32, %20 ]
%38 = phi i32 [ 0, %14 ], [ %32, %20 ]
%39 = phi i32 [ 1, %14 ], [ %33, %20 ]
%40 = and i32 %15, 2
%41 = icmp eq i32 %40, 0
br i1 %41, label %47, label %42
42: ; preds = %36
%43 = srem i32 %15, %39
%44 = icmp eq i32 %43, 0
%45 = select i1 %44, i32 %39, i32 0
%46 = add nuw nsw i32 %45, %38
br label %47
47: ; preds = %42, %36, %12
%48 = phi i32 [ %8, %12 ], [ %15, %36 ], [ %15, %42 ]
%49 = phi i32 [ 0, %12 ], [ %37, %36 ], [ %46, %42 ]
%50 = icmp sgt i32 %49, %48
br i1 %50, label %55, label %51
51: ; preds = %47
%52 = icmp eq i32 %49, %48
br i1 %52, label %55, label %53
53: ; preds = %51
%54 = icmp slt i32 %49, %48
br i1 %54, label %55, label %58
55: ; preds = %53, %51, %47
%56 = phi i8* [ getelementptr inbounds ([22 x i8], [22 x i8]* @.str.2, i64 0, i64 0), %47 ], [ getelementptr inbounds ([20 x i8], [20 x i8]* @.str.3, i64 0, i64 0), %51 ], [ getelementptr inbounds ([21 x i8], [21 x i8]* @.str.4, i64 0, i64 0), %53 ]
%57 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) %56, i32 %48)
br label %58
58: ; preds = %55, %53
%59 = call i32 @putchar(i32 10)
%60 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([38 x i8], [38 x i8]* @.str, i64 0, i64 0))
%61 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %1)
%62 = load i32, i32* %1
%63 = icmp eq i32 %62, -1
br i1 %63, label %64, label %7
64: ; preds = %58, %0
%65 = call i32 (...) @getchar()
ret i32 0
}