#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 find_sum(int);
int /*<<< orphan*/ printf(char *, int, ...);
int main() {
  int i, sum = 0, temp;
  for (i = 3; i <= 10000; i++) {
    temp = find_sum(i);
    if (temp > i && find_sum(temp) == i) {
      printf("%d  %d\n", temp, i);
      sum += (temp + i);
    }
  }
  printf("%d\n", sum);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0xc(%rbp)
movl   $0x3,-0x8(%rbp)
cmpl   $0x2710,-0x8(%rbp)
jg     11a5 <main+0x85>
mov    -0x8(%rbp),%edi
call   1040 <find_sum@plt>
mov    %eax,-0x10(%rbp)
mov    -0x10(%rbp),%eax
cmp    -0x8(%rbp),%eax
jle    1192 <main+0x72>
mov    -0x10(%rbp),%edi
call   1040 <find_sum@plt>
cmp    -0x8(%rbp),%eax
jne    1192 <main+0x72>
mov    -0x10(%rbp),%esi
mov    -0x8(%rbp),%edx
lea    0xe81(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x10(%rbp),%eax
add    -0x8(%rbp),%eax
add    -0xc(%rbp),%eax
mov    %eax,-0xc(%rbp)
jmp    1197 <main+0x77>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    113d <main+0x1d>
mov    -0xc(%rbp),%esi
lea    0xe55(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    $0x3,%ebp
lea    0xecd(%rip),%r14
xor    %r15d,%r15d
jmp    114b <main+0x2b>
nopl   0x0(%rax,%rax,1)
add    $0x1,%ebp
cmp    $0x2711,%ebp
je     117b <main+0x5b>
mov    %ebp,%edi
call   1040 <find_sum@plt>
cmp    %ebp,%eax
jle    1140 <main+0x20>
mov    %eax,%ebx
mov    %eax,%edi
call   1040 <find_sum@plt>
cmp    %eax,%ebp
jne    1140 <main+0x20>
mov    %r14,%rdi
mov    %ebx,%esi
mov    %ebp,%edx
xor    %eax,%eax
call   1030 <printf@plt>
add    %r15d,%ebx
add    %ebp,%ebx
mov    %ebx,%r15d
jmp    1140 <main+0x20>
lea    0xe82(%rip),%rdi
mov    %r15d,%esi
xor    %eax,%eax
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

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

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