#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 divisor_sum(int);
int /*<<< orphan*/ printf(char *, int, int);
int main(int argc, const char *argv[]) {
  int i, j;
  for (i = 1; i <= 3000; i++) {
    j = divisor_sum(i);
    if (divisor_sum(j) == i && i < j)
      printf("(%d,%d)", i, j);
  }
  return 0;
}


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   $0x1,-0x14(%rbp)
cmpl   $0xbb8,-0x14(%rbp)
jg     1197 <main+0x77>
mov    -0x14(%rbp),%edi
call   1040 <divisor_sum@plt>
mov    %eax,-0x18(%rbp)
mov    -0x18(%rbp),%edi
call   1040 <divisor_sum@plt>
cmp    -0x14(%rbp),%eax
jne    1184 <main+0x64>
mov    -0x14(%rbp),%eax
cmp    -0x18(%rbp),%eax
jge    1184 <main+0x64>
mov    -0x14(%rbp),%esi
mov    -0x18(%rbp),%edx
lea    0xe81(%rip),%rdi
call   1030 <printf@plt>
jmp    1189 <main+0x69>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    113d <main+0x1d>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r14
push   %rbx
mov    $0x1,%ebx
lea    0xed0(%rip),%r14
jmp    114b <main+0x2b>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
add    $0x1,%ebx
cmp    $0xbb9,%ebx
je     1171 <main+0x51>
mov    %ebx,%edi
call   1040 <divisor_sum@plt>
mov    %eax,%ebp
mov    %eax,%edi
call   1040 <divisor_sum@plt>
cmp    %ebp,%ebx
jge    1140 <main+0x20>
cmp    %eax,%ebx
jne    1140 <main+0x20>
mov    %r14,%rdi
mov    %ebx,%esi
mov    %ebp,%edx
call   1030 <printf@plt>
jmp    1140 <main+0x20>
xor    %eax,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret

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

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