#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*/ printf(char *, ...);
int sum_of_divisors(int);
void amicable_below(int a) {
  for (int i = 0; i < a; ++i) {
    for (int j = 0; j < a; ++j) {
      if (i < j && sum_of_divisors(i) == j && sum_of_divisors(j) == i)
        printf("(%d, %d) ", i, j);
    }
  }
  printf("\n");
}


x86 assembly (clang, -O0):
<amicable_below>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
movl   $0x0,-0x8(%rbp)
mov    -0x8(%rbp),%eax
cmp    -0x4(%rbp),%eax
jge    11b9 <amicable_below+0x99>
movl   $0x0,-0xc(%rbp)
mov    -0xc(%rbp),%eax
cmp    -0x4(%rbp),%eax
jge    11a6 <amicable_below+0x86>
mov    -0x8(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    1193 <amicable_below+0x73>
mov    -0x8(%rbp),%edi
call   1040 <sum_of_divisors@plt>
cmp    -0xc(%rbp),%eax
jne    1193 <amicable_below+0x73>
mov    -0xc(%rbp),%edi
call   1040 <sum_of_divisors@plt>
cmp    -0x8(%rbp),%eax
jne    1193 <amicable_below+0x73>
mov    -0x8(%rbp),%esi
mov    -0xc(%rbp),%edx
lea    0xe74(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1198 <amicable_below+0x78>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1145 <amicable_below+0x25>
jmp    11ab <amicable_below+0x8b>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    1132 <amicable_below+0x12>
lea    0xe4a(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<amicable_below>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
test   %edi,%edi
jle    1192 <amicable_below+0x62>
mov    %edi,%r15d
lea    0xebb(%rip),%r14
xor    %ebp,%ebp
jmp    1158 <amicable_below+0x28>
nopl   0x0(%rax)
add    $0x1,%ebp
cmp    %r15d,%ebp
je     1192 <amicable_below+0x62>
xor    %ebx,%ebx
jmp    1168 <amicable_below+0x38>
nopl   0x0(%rax)
add    $0x1,%ebx
cmp    %ebx,%r15d
je     1150 <amicable_below+0x20>
cmp    %ebx,%ebp
jae    1160 <amicable_below+0x30>
mov    %ebp,%edi
call   1050 <sum_of_divisors@plt>
cmp    %eax,%ebx
jne    1160 <amicable_below+0x30>
mov    %ebx,%edi
call   1050 <sum_of_divisors@plt>
cmp    %ebp,%eax
jne    1160 <amicable_below+0x30>
mov    %r14,%rdi
mov    %ebp,%esi
mov    %ebx,%edx
xor    %eax,%eax
call   1040 <printf@plt>
jmp    1160 <amicable_below+0x30>
mov    $0xa,%edi
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <putchar@plt>

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

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