#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 /*<<< orphan*/ scanf(char *, int *);
int main() {
  int n, m = 0, i;
  printf("请输入n:\n");
  scanf("%d", &n);
  for (i = 1; i < n; i++) {
    if (n % i == 0)
      m += i;
  }
  if (m == n)
    printf("是完数\n");
  else
    printf("不是完数\n");
  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
call   1030 <printf@plt>
lea    0xec4(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1040 <scanf@plt>
movl   $0x1,-0x10(%rbp)
mov    -0x10(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    1191 <main+0x71>
mov    -0x8(%rbp),%eax
cltd
idivl  -0x10(%rbp)
cmp    $0x0,%edx
jne    117e <main+0x5e>
mov    -0x10(%rbp),%eax
add    -0xc(%rbp),%eax
mov    %eax,-0xc(%rbp)
jmp    1183 <main+0x63>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    1159 <main+0x39>
mov    -0xc(%rbp),%eax
cmp    -0x8(%rbp),%eax
jne    11ae <main+0x8e>
lea    0xe6f(%rip),%rdi
call   1030 <printf@plt>
jmp    11ba <main+0x9a>
lea    0xe5b(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rax
lea    0xedb(%rip),%rdi
call   1030 <puts@plt>
lea    0xecc(%rip),%rdi
lea    0x4(%rsp),%rsi
call   1040 <scanf@plt>
mov    0x4(%rsp),%r10d
xor    %esi,%esi
cmp    $0x2,%r10d
jl     1171 <main+0x51>
lea    -0x1(%r10),%r8d
cmp    $0x2,%r10d
jne    118f <main+0x6f>
xor    %esi,%esi
mov    $0x1,%edi
test   $0x1,%r8b
je     1171 <main+0x51>
mov    %r10d,%eax
cltd
idiv   %edi
xor    %eax,%eax
test   %edx,%edx
cmove  %edi,%eax
add    %eax,%esi
cmp    %r10d,%esi
lea    0xe97(%rip),%rax
lea    0xe8d(%rip),%rdi
cmove  %rax,%rdi
call   1030 <puts@plt>
xor    %eax,%eax
pop    %rcx
ret
mov    %r8d,%r9d
and    $0xfffffffe,%r9d
xor    %esi,%esi
mov    $0x1,%edi
jmp    11aa <main+0x8a>
nop
add    %eax,%esi
add    $0x2,%edi
cmp    %r9d,%ecx
je     115c <main+0x3c>
mov    %r10d,%eax
cltd
idiv   %edi
mov    %edi,%eax
test   %edx,%edx
je     11b8 <main+0x98>
xor    %eax,%eax
add    %eax,%esi
lea    0x1(%rdi),%ecx
mov    %r10d,%eax
cltd
idiv   %ecx
mov    %ecx,%eax
test   %edx,%edx
je     11a0 <main+0x80>
xor    %eax,%eax
jmp    11a0 <main+0x80>

LLVM IR (-O0):
@.str = [13 x i8] c"\E8\AF\B7\E8\BE\93\E5\85\A5n:\0A\00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [11 x i8] c"\E6\98\AF\E5\AE\8C\E6\95\B0\0A\00"
@.str.3 = [14 x i8] c"\E4\B8\8D\E6\98\AF\E5\AE\8C\E6\95\B0\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 @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0))
%6 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %2)
store i32 1, 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 %30
28: ; preds = %24
%29 = call i32 @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.2, i64 0, i64 0))
br label %32
30: ; preds = %24
%31 = call i32 @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.3, i64 0, i64 0))
br label %32
32: ; preds = %30, %28
ret i32 0
}

LLVM IR (-O2):
@.str.1 = [3 x i8] c"%d\00"
@str = [12 x i8] c"\E8\AF\B7\E8\BE\93\E5\85\A5n:\00"
@str.4 = [13 x i8] c"\E4\B8\8D\E6\98\AF\E5\AE\8C\E6\95\B0\00"
@str.5 = [10 x i8] c"\E6\98\AF\E5\AE\8C\E6\95\B0\00"
define i32 @main() {
%1 = alloca i32
%2 = bitcast i32* %1 to i8*
%3 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 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 sgt i32 %5, 1
br i1 %6, label %7, label %39
7: ; preds = %0
%8 = add i32 %5, -1
%9 = and i32 %8, 1
%10 = icmp eq i32 %5, 2
br i1 %10, label %29, label %11
11: ; preds = %7
%12 = and i32 %8, -2
br label %13
13: ; preds = %13, %11
%14 = phi i32 [ 1, %11 ], [ %26, %13 ]
%15 = phi i32 [ 0, %11 ], [ %25, %13 ]
%16 = phi i32 [ 0, %11 ], [ %27, %13 ]
%17 = srem i32 %5, %14
%18 = icmp eq i32 %17, 0
%19 = select i1 %18, i32 %14, i32 0
%20 = add nuw nsw i32 %19, %15
%21 = add nuw nsw i32 %14, 1
%22 = srem i32 %5, %21
%23 = icmp eq i32 %22, 0
%24 = select i1 %23, i32 %21, i32 0
%25 = add nuw nsw i32 %24, %20
%26 = add nuw nsw i32 %14, 2
%27 = add i32 %16, 2
%28 = icmp eq i32 %27, %12
br i1 %28, label %29, label %13
29: ; preds = %13, %7
%30 = phi i32 [ undef, %7 ], [ %25, %13 ]
%31 = phi i32 [ 1, %7 ], [ %26, %13 ]
%32 = phi i32 [ 0, %7 ], [ %25, %13 ]
%33 = icmp eq i32 %9, 0
br i1 %33, label %39, label %34
34: ; preds = %29
%35 = srem i32 %5, %31
%36 = icmp eq i32 %35, 0
%37 = select i1 %36, i32 %31, i32 0
%38 = add nuw nsw i32 %37, %32
br label %39
39: ; preds = %34, %29, %0
%40 = phi i32 [ 0, %0 ], [ %30, %29 ], [ %38, %34 ]
%41 = icmp eq i32 %40, %5
%42 = select i1 %41, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @str.5, i64 0, i64 0), i8* getelementptr inbounds ([13 x i8], [13 x i8]* @str.4, i64 0, i64 0)
%43 = call i32 @puts(i8* dereferenceable(1) %42)
ret i32 0
}