#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);
int /*<<< orphan*/ scanf(char *, int *);
int main() {
  int n = 0, soma = 0, i = 1;
  scanf("%d", &n);
  for (i; i < n; i++) {
    if (n % i == 0) {
      soma += i;
    }
  }
  if (soma == n) {
    printf("%d é perfeito\n", n);
  } else {
    printf("%d não é perfeito\n", n);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
movl   $0x1,-0x10(%rbp)
lea    0xeb5(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1040 <scanf@plt>
mov    -0x10(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    118c <main+0x6c>
mov    -0x8(%rbp),%eax
cltd
idivl  -0x10(%rbp)
cmp    $0x0,%edx
jne    1179 <main+0x59>
mov    -0x10(%rbp),%eax
add    -0xc(%rbp),%eax
mov    %eax,-0xc(%rbp)
jmp    117e <main+0x5e>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    1154 <main+0x34>
mov    -0xc(%rbp),%eax
cmp    -0x8(%rbp),%eax
jne    11ac <main+0x8c>
mov    -0x8(%rbp),%esi
lea    0xe61(%rip),%rdi
call   1030 <printf@plt>
jmp    11bb <main+0x9b>
mov    -0x8(%rbp),%esi
lea    0xe5d(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rax
movl   $0x0,0x4(%rsp)
lea    0xed0(%rip),%rdi
lea    0x4(%rsp),%rsi
call   1040 <scanf@plt>
mov    0x4(%rsp),%r10d
xor    %ecx,%ecx
cmp    $0x2,%r10d
jl     116d <main+0x4d>
lea    -0x1(%r10),%r8d
cmp    $0x2,%r10d
jne    118e <main+0x6e>
xor    %ecx,%ecx
mov    $0x1,%edi
test   $0x1,%r8b
je     116d <main+0x4d>
mov    %r10d,%eax
cltd
idiv   %edi
xor    %eax,%eax
test   %edx,%edx
cmove  %edi,%eax
add    %eax,%ecx
cmp    %r10d,%ecx
lea    0xe8c(%rip),%rax
lea    0xe95(%rip),%rdi
cmove  %rax,%rdi
mov    %r10d,%esi
call   1030 <printf@plt>
xor    %eax,%eax
pop    %rcx
ret
mov    %r8d,%r9d
and    $0xfffffffe,%r9d
xor    %ecx,%ecx
mov    $0x1,%edi
jmp    11aa <main+0x8a>
xchg   %ax,%ax
add    %eax,%ecx
add    $0x2,%edi
cmp    %r9d,%esi
je     1158 <main+0x38>
mov    %r10d,%eax
cltd
idiv   %edi
mov    %edi,%eax
test   %edx,%edx
je     11b8 <main+0x98>
xor    %eax,%eax
add    %eax,%ecx
lea    0x1(%rdi),%esi
mov    %r10d,%eax
cltd
idiv   %esi
mov    %esi,%eax
test   %edx,%edx
je     11a0 <main+0x80>
xor    %eax,%eax
jmp    11a0 <main+0x80>

LLVM IR (-O0):
@.str = [3 x i8] c"%d\00"
@.str.1 = [16 x i8] c"%d \C3\A9 perfeito\0A\00"
@.str.2 = [21 x i8] c"%d n\C3\A3o \C3\A9 perfeito\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* %2
store i32 0, i32* %3
store i32 1, i32* %4
%5 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %2)
%6 = load i32, i32* %4
br label %7
7: ; preds = %21, %0
%8 = load i32, i32* %4
%9 = load i32, i32* %2
%10 = icmp slt i32 %8, %9
br i1 %10, label %11, label %24
11: ; preds = %7
%12 = load i32, i32* %2
%13 = load i32, i32* %4
%14 = srem i32 %12, %13
%15 = icmp eq i32 %14, 0
br i1 %15, label %16, label %20
16: ; preds = %11
%17 = load i32, i32* %4
%18 = load i32, i32* %3
%19 = add nsw i32 %18, %17
store i32 %19, i32* %3
br label %20
20: ; preds = %16, %11
br label %21
21: ; preds = %20
%22 = load i32, i32* %4
%23 = add nsw i32 %22, 1
store i32 %23, i32* %4
br label %7
24: ; preds = %7
%25 = load i32, i32* %3
%26 = load i32, i32* %2
%27 = icmp eq i32 %25, %26
br i1 %27, label %28, label %31
28: ; preds = %24
%29 = load i32, i32* %2
%30 = call i32 @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.1, i64 0, i64 0), i32 %29)
br label %34
31: ; preds = %24
%32 = load i32, i32* %2
%33 = call i32 @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.2, i64 0, i64 0), i32 %32)
br label %34
34: ; preds = %31, %28
ret i32 0
}

LLVM IR (-O2):
@.str = [3 x i8] c"%d\00"
@.str.1 = [16 x i8] c"%d \C3\A9 perfeito\0A\00"
@.str.2 = [21 x i8] c"%d n\C3\A3o \C3\A9 perfeito\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = bitcast i32* %1 to i8*
store i32 0, i32* %1
%3 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %1)
%4 = load i32, i32* %1
%5 = icmp sgt i32 %4, 1
br i1 %5, label %6, label %38
6: ; preds = %0
%7 = add i32 %4, -1
%8 = and i32 %7, 1
%9 = icmp eq i32 %4, 2
br i1 %9, label %28, label %10
10: ; preds = %6
%11 = and i32 %7, -2
br label %12
12: ; preds = %12, %10
%13 = phi i32 [ 1, %10 ], [ %25, %12 ]
%14 = phi i32 [ 0, %10 ], [ %24, %12 ]
%15 = phi i32 [ 0, %10 ], [ %26, %12 ]
%16 = srem i32 %4, %13
%17 = icmp eq i32 %16, 0
%18 = select i1 %17, i32 %13, i32 0
%19 = add nuw nsw i32 %18, %14
%20 = add nuw nsw i32 %13, 1
%21 = srem i32 %4, %20
%22 = icmp eq i32 %21, 0
%23 = select i1 %22, i32 %20, i32 0
%24 = add nuw nsw i32 %23, %19
%25 = add nuw nsw i32 %13, 2
%26 = add i32 %15, 2
%27 = icmp eq i32 %26, %11
br i1 %27, label %28, label %12
28: ; preds = %12, %6
%29 = phi i32 [ undef, %6 ], [ %24, %12 ]
%30 = phi i32 [ 1, %6 ], [ %25, %12 ]
%31 = phi i32 [ 0, %6 ], [ %24, %12 ]
%32 = icmp eq i32 %8, 0
br i1 %32, label %38, label %33
33: ; preds = %28
%34 = srem i32 %4, %30
%35 = icmp eq i32 %34, 0
%36 = select i1 %35, i32 %30, i32 0
%37 = add nuw nsw i32 %36, %31
br label %38
38: ; preds = %33, %28, %0
%39 = phi i32 [ 0, %0 ], [ %29, %28 ], [ %37, %33 ]
%40 = icmp eq i32 %39, %4
%41 = select i1 %40, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.2, i64 0, i64 0)
%42 = call i32 @printf(i8* %41, i32 %4)
ret i32 0
}