#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*/ intro();
int perfect(int);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ twirly();
int main(void) {
  int num;
  int factor_count;
  int flag;
  int remaind;
  intro();
  for (num = 1; num <= 10000; num++) {
    flag = perfect(num);
    if (flag == 1) {
      for (factor_count = num - 1; 0 < factor_count; factor_count--) {
        remaind = num % factor_count;
        if (remaind == 0) {
          printf("+ %d ", factor_count);
        } else {
        }
      }
      printf("= %d\n", num);
    } else {
      twirly();
    }
  }
  printf(" \r");
  return (0);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    $0x0,%al
call   1030 <intro@plt>
movl   $0x1,-0x8(%rbp)
cmpl   $0x2710,-0x8(%rbp)
jg     1205 <main+0xc5>
mov    -0x8(%rbp),%edi
call   1040 <perfect@plt>
mov    %eax,-0x10(%rbp)
cmpl   $0x1,-0x10(%rbp)
jne    11eb <main+0xab>
mov    -0x8(%rbp),%eax
sub    $0x1,%eax
mov    %eax,-0xc(%rbp)
xor    %eax,%eax
cmp    -0xc(%rbp),%eax
jge    11d5 <main+0x95>
mov    -0x8(%rbp),%eax
cltd
idivl  -0xc(%rbp)
mov    %edx,-0x14(%rbp)
cmpl   $0x0,-0x14(%rbp)
jne    11bd <main+0x7d>
mov    -0xc(%rbp),%esi
lea    0xe4f(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
jmp    11c2 <main+0x82>
jmp    11c2 <main+0x82>
jmp    11c7 <main+0x87>
mov    -0xc(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0xc(%rbp)
jmp    1188 <main+0x48>
mov    -0x8(%rbp),%esi
lea    0xe27(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
jmp    11f2 <main+0xb2>
mov    $0x0,%al
call   1060 <twirly@plt>
jmp    11f7 <main+0xb7>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    115d <main+0x1d>
lea    0xe00(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
xor    %eax,%eax
call   1030 <intro@plt>
mov    $0x1,%ebx
mov    $0x2,%r12d
lea    0xe9f(%rip),%r14
lea    0xe9e(%rip),%r15
jmp    1186 <main+0x46>
nopw   0x0(%rax,%rax,1)
xor    %eax,%eax
call   1060 <twirly@plt>
add    $0x1,%ebx
add    $0x1,%r12d
cmp    $0x2711,%ebx
je     11ce <main+0x8e>
mov    %ebx,%edi
call   1040 <perfect@plt>
cmp    $0x1,%eax
jne    1170 <main+0x30>
cmp    $0x2,%ebx
jb     11c0 <main+0x80>
mov    %r12d,%ebp
jmp    11a8 <main+0x68>
nopl   0x0(%rax)
add    $0xffffffff,%ebp
cmp    $0x2,%ebp
jle    11c0 <main+0x80>
lea    -0x2(%rbp),%esi
mov    %ebx,%eax
cltd
idiv   %esi
test   %edx,%edx
jne    11a0 <main+0x60>
mov    %r14,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
jmp    11a0 <main+0x60>
mov    %r15,%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1050 <printf@plt>
jmp    1177 <main+0x37>
lea    0xe37(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
xor    %eax,%eax
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [6 x i8] c"+ %d \00"
@.str.1 = [6 x i8] c"= %d\0A\00"
@.str.2 = [3 x i8] c" \0D\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
store i32 0, i32* %1
%6 = call i32 (...) @intro()
store i32 1, i32* %2
br label %7
7: ; preds = %41, %0
%8 = load i32, i32* %2
%9 = icmp sle i32 %8, 10000
br i1 %9, label %10, label %44
10: ; preds = %7
%11 = load i32, i32* %2
%12 = call i32 @perfect(i32 %11)
store i32 %12, i32* %4
%13 = load i32, i32* %4
%14 = icmp eq i32 %13, 1
br i1 %14, label %15, label %38
15: ; preds = %10
%16 = load i32, i32* %2
%17 = sub nsw i32 %16, 1
store i32 %17, i32* %3
br label %18
18: ; preds = %32, %15
%19 = load i32, i32* %3
%20 = icmp slt i32 0, %19
br i1 %20, label %21, label %35
21: ; preds = %18
%22 = load i32, i32* %2
%23 = load i32, i32* %3
%24 = srem i32 %22, %23
store i32 %24, i32* %5
%25 = load i32, i32* %5
%26 = icmp eq i32 %25, 0
br i1 %26, label %27, label %30
27: ; preds = %21
%28 = load i32, i32* %3
%29 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i32 %28)
br label %31
30: ; preds = %21
br label %31
31: ; preds = %30, %27
br label %32
32: ; preds = %31
%33 = load i32, i32* %3
%34 = add nsw i32 %33, -1
store i32 %34, i32* %3
br label %18
35: ; preds = %18
%36 = load i32, i32* %2
%37 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i32 %36)
br label %40
38: ; preds = %10
%39 = call i32 (...) @twirly()
br label %40
40: ; preds = %38, %35
br label %41
41: ; preds = %40
%42 = load i32, i32* %2
%43 = add nsw i32 %42, 1
store i32 %43, i32* %2
br label %7
44: ; preds = %7
%45 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
ret i32 0
}

LLVM IR (-O2):
@.str = [6 x i8] c"+ %d \00"
@.str.1 = [6 x i8] c"= %d\0A\00"
@.str.2 = [3 x i8] c" \0D\00"
define i32 @main() {
%1 = tail call i32 (...) @intro()
br label %2
2: ; preds = %0, %21
%3 = phi i32 [ 1, %0 ], [ %22, %21 ]
%4 = tail call i32 @perfect(i32 %3)
%5 = icmp eq i32 %4, 1
br i1 %5, label %6, label %19
6: ; preds = %2
%7 = icmp ugt i32 %3, 1
br i1 %7, label %8, label %17
8: ; preds = %6, %15
%9 = phi i32 [ %10, %15 ], [ %3, %6 ]
%10 = add nsw i32 %9, -1
%11 = srem i32 %3, %10
%12 = icmp eq i32 %11, 0
br i1 %12, label %13, label %15
13: ; preds = %8
%14 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i32 %10)
br label %15
15: ; preds = %13, %8
%16 = icmp sgt i32 %9, 2
br i1 %16, label %8, label %17
17: ; preds = %15, %6
%18 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i32 %3)
br label %21
19: ; preds = %2
%20 = tail call i32 (...) @twirly()
br label %21
21: ; preds = %17, %19
%22 = add nuw nsw i32 %3, 1
%23 = icmp eq i32 %22, 10001
br i1 %23, label %24, label %2
24: ; preds = %21
%25 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
ret i32 0
}