#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 EXIT_SUCCESS;
int /*<<< orphan*/ printf(char *, int);
int sumDivisors(int);
int main(int argc, char *argv[]) {
  int i, sum = 0;
  for (i = 2; i < 10000; i++) {
    int b = sumDivisors(i);
    if (i < b && sumDivisors(b) == i) {
      sum += b + i;
    }
  }
  printf("Solution: %d.\n", sum);
  return EXIT_SUCCESS;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x18(%rbp)
movl   $0x2,-0x14(%rbp)
cmpl   $0x2710,-0x14(%rbp)
jge    1198 <main+0x78>
mov    -0x14(%rbp),%edi
call   1040 <sumDivisors@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x1c(%rbp),%eax
jge    1185 <main+0x65>
mov    -0x1c(%rbp),%edi
call   1040 <sumDivisors@plt>
cmp    -0x14(%rbp),%eax
jne    1185 <main+0x65>
mov    -0x1c(%rbp),%eax
add    -0x14(%rbp),%eax
add    -0x18(%rbp),%eax
mov    %eax,-0x18(%rbp)
jmp    118a <main+0x6a>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1144 <main+0x24>
mov    -0x18(%rbp),%esi
lea    0xe5e(%rip),%rdi
call   1030 <printf@plt>
mov    0x2e32(%rip),%rax
mov    (%rax),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r14
push   %rbx
xor    %r14d,%r14d
mov    $0x2,%ebp
jmp    113b <main+0x1b>
xchg   %ax,%ax
add    $0x1,%ebp
cmp    $0x2710,%ebp
je     115d <main+0x3d>
mov    %ebp,%edi
call   1040 <sumDivisors@plt>
cmp    %eax,%ebp
jge    1130 <main+0x10>
mov    %eax,%ebx
mov    %eax,%edi
call   1040 <sumDivisors@plt>
cmp    %eax,%ebp
jne    1130 <main+0x10>
add    %r14d,%ebx
add    %ebp,%ebx
mov    %ebx,%r14d
jmp    1130 <main+0x10>
lea    0xe9c(%rip),%rdi
mov    %r14d,%esi
call   1030 <printf@plt>
mov    0x2e6d(%rip),%rax
mov    (%rax),%eax
pop    %rbx
pop    %r14
pop    %rbp
ret

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

LLVM IR (-O2):
@.str = [15 x i8] c"Solution: %d.\0A\00"
@EXIT_SUCCESS = global i32 0
define i32 @main(i32 %0, i8** nocapture readnone %1) {
br label %3
3: ; preds = %2, %14
%4 = phi i32 [ 2, %2 ], [ %16, %14 ]
%5 = phi i32 [ 0, %2 ], [ %15, %14 ]
%6 = tail call i32 @sumDivisors(i32 %4)
%7 = icmp slt i32 %4, %6
br i1 %7, label %8, label %14
8: ; preds = %3
%9 = tail call i32 @sumDivisors(i32 %6)
%10 = icmp eq i32 %9, %4
br i1 %10, label %11, label %14
11: ; preds = %8
%12 = add i32 %4, %5
%13 = add i32 %12, %6
br label %14
14: ; preds = %11, %8, %3
%15 = phi i32 [ %13, %11 ], [ %5, %8 ], [ %5, %3 ]
%16 = add nuw nsw i32 %4, 1
%17 = icmp eq i32 %16, 10000
br i1 %17, label %18, label %3
18: ; preds = %14
%19 = tail call i32 @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0), i32 %15)
%20 = load i32, i32* @EXIT_SUCCESS
ret i32 %20
}