#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 d(int);
int /*<<< orphan*/ printf(char *, int, ...);
int main() {
  int divs[10001];
  int res = 0;
  for (int i = 1; i <= 10000; i++) {
    int div = d(i);
    if (div <= 10000) {
      if (divs[div] == i) {
        printf("%d - %d\n", div, i);
        res += div + i;
      }
      divs[i] = div;
    }
  }
  printf("If you can trust me, the number you are looking for is %d\n", res);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x9c60,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x9c54(%rbp)
movl   $0x1,-0x9c58(%rbp)
cmpl   $0x2710,-0x9c58(%rbp)
jg     11f0 <main+0xd0>
mov    -0x9c58(%rbp),%edi
call   1030 <d@plt>
mov    %eax,-0x9c5c(%rbp)
cmpl   $0x2710,-0x9c5c(%rbp)
jg     11d7 <main+0xb7>
movslq -0x9c5c(%rbp),%rax
mov    -0x9c50(%rbp,%rax,4),%eax
cmp    -0x9c58(%rbp),%eax
jne    11c3 <main+0xa3>
mov    -0x9c5c(%rbp),%esi
mov    -0x9c58(%rbp),%edx
lea    0xe5c(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x9c5c(%rbp),%eax
add    -0x9c58(%rbp),%eax
add    -0x9c54(%rbp),%eax
mov    %eax,-0x9c54(%rbp)
mov    -0x9c5c(%rbp),%ecx
movslq -0x9c58(%rbp),%rax
mov    %ecx,-0x9c50(%rbp,%rax,4)
jmp    11dc <main+0xbc>
mov    -0x9c58(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x9c58(%rbp)
jmp    1146 <main+0x26>
mov    -0x9c54(%rbp),%esi
lea    0xe0c(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x9c60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %rbx
sub    $0x9c48,%rsp
mov    $0x1,%ebx
lea    0xec7(%rip),%r14
xor    %r15d,%r15d
jmp    1150 <main+0x30>
xchg   %ax,%ax
mov    %ebp,(%rsp,%rbx,4)
add    $0x1,%rbx
cmp    $0x2711,%rbx
je     1184 <main+0x64>
mov    %ebx,%edi
call   1030 <d@plt>
cmp    $0x2710,%eax
jg     1143 <main+0x23>
mov    %eax,%ebp
cltq
mov    (%rsp,%rax,4),%eax
cmp    %rax,%rbx
jne    1140 <main+0x20>
mov    %r14,%rdi
mov    %ebp,%esi
mov    %ebx,%edx
xor    %eax,%eax
call   1040 <printf@plt>
mov    %ebp,%eax
add    %r15d,%eax
add    %ebx,%eax
mov    %eax,%r15d
jmp    1140 <main+0x20>
lea    0xe7e(%rip),%rdi
mov    %r15d,%esi
xor    %eax,%eax
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x9c48,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [9 x i8] c"%d - %d\0A\00"
@.str.1 = [59 x i8] c"If you can trust me, the number you are looking for is %d\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [10001 x i32]
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
store i32 0, i32* %1
store i32 0, i32* %3
store i32 1, i32* %4
br label %6
6: ; preds = %36, %0
%7 = load i32, i32* %4
%8 = icmp sle i32 %7, 10000
br i1 %8, label %9, label %39
9: ; preds = %6
%10 = load i32, i32* %4
%11 = call i32 @d(i32 %10)
store i32 %11, i32* %5
%12 = load i32, i32* %5
%13 = icmp sle i32 %12, 10000
br i1 %13, label %14, label %35
14: ; preds = %9
%15 = load i32, i32* %5
%16 = sext i32 %15 to i64
%17 = getelementptr inbounds [10001 x i32], [10001 x i32]* %2, i64 0, i64 %16
%18 = load i32, i32* %17
%19 = load i32, i32* %4
%20 = icmp eq i32 %18, %19
br i1 %20, label %21, label %30
21: ; preds = %14
%22 = load i32, i32* %5
%23 = load i32, i32* %4
%24 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i32 %22, i32 %23)
%25 = load i32, i32* %5
%26 = load i32, i32* %4
%27 = add nsw i32 %25, %26
%28 = load i32, i32* %3
%29 = add nsw i32 %28, %27
store i32 %29, i32* %3
br label %30
30: ; preds = %21, %14
%31 = load i32, i32* %5
%32 = load i32, i32* %4
%33 = sext i32 %32 to i64
%34 = getelementptr inbounds [10001 x i32], [10001 x i32]* %2, i64 0, i64 %33
store i32 %31, i32* %34
br label %35
35: ; preds = %30, %9
br label %36
36: ; preds = %35
%37 = load i32, i32* %4
%38 = add nsw i32 %37, 1
store i32 %38, i32* %4
br label %6
39: ; preds = %6
%40 = load i32, i32* %3
%41 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([59 x i8], [59 x i8]* @.str.1, i64 0, i64 0), i32 %40)
ret i32 0
}

LLVM IR (-O2):
@.str = [9 x i8] c"%d - %d\0A\00"
@.str.1 = [59 x i8] c"If you can trust me, the number you are looking for is %d\0A\00"
define i32 @main() {
%1 = alloca [10001 x i32]
%2 = bitcast [10001 x i32]* %1 to i8*
br label %5
3: ; preds = %24
%4 = tail call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([59 x i8], [59 x i8]* @.str.1, i64 0, i64 0), i32 %25)
ret i32 0
5: ; preds = %0, %24
%6 = phi i64 [ 1, %0 ], [ %26, %24 ]
%7 = phi i32 [ 0, %0 ], [ %25, %24 ]
%8 = trunc i64 %6 to i32
%9 = tail call i32 @d(i32 %8)
%10 = icmp slt i32 %9, 10001
br i1 %10, label %11, label %24
11: ; preds = %5
%12 = sext i32 %9 to i64
%13 = getelementptr inbounds [10001 x i32], [10001 x i32]* %1, i64 0, i64 %12
%14 = load i32, i32* %13
%15 = zext i32 %14 to i64
%16 = icmp eq i64 %6, %15
br i1 %16, label %17, label %21
17: ; preds = %11
%18 = tail call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i32 %9, i32 %8)
%19 = add i32 %7, %8
%20 = add i32 %19, %9
br label %21
21: ; preds = %17, %11
%22 = phi i32 [ %20, %17 ], [ %7, %11 ]
%23 = getelementptr inbounds [10001 x i32], [10001 x i32]* %1, i64 0, i64 %6
store i32 %9, i32* %23
br label %24
24: ; preds = %21, %5
%25 = phi i32 [ %22, %21 ], [ %7, %5 ]
%26 = add nuw nsw i64 %6, 1
%27 = icmp eq i64 %26, 10001
br i1 %27, label %3, label %5
}