#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 fun(int);
int /*<<< orphan*/ printf(char *, int, int);
void main() {
  int a, b;
  for (a = 1; a < 3000; a++) {
    b = fun(a);
    if (a == fun(b) && a != b)
      printf("%3d %3d\n", a, b);
  }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x1,-0x4(%rbp)
cmpl   $0xbb8,-0x4(%rbp)
jge    1193 <main+0x73>
mov    -0x4(%rbp),%edi
call   1030 <fun@plt>
mov    %eax,-0x8(%rbp)
mov    -0x4(%rbp),%eax
mov    %eax,-0xc(%rbp)
mov    -0x8(%rbp),%edi
call   1030 <fun@plt>
mov    %eax,%ecx
mov    -0xc(%rbp),%eax
cmp    %ecx,%eax
jne    1180 <main+0x60>
mov    -0x4(%rbp),%eax
cmp    -0x8(%rbp),%eax
je     1180 <main+0x60>
mov    -0x4(%rbp),%esi
mov    -0x8(%rbp),%edx
lea    0xe85(%rip),%rdi
call   1040 <printf@plt>
jmp    1185 <main+0x65>
mov    -0x4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x4(%rbp)
jmp    112f <main+0xf>
add    $0x10,%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    $0xbb8,%ebx
je     1171 <main+0x51>
mov    %ebx,%edi
call   1030 <fun@plt>
mov    %eax,%ebp
mov    %eax,%edi
call   1030 <fun@plt>
cmp    %ebp,%ebx
je     1140 <main+0x20>
cmp    %eax,%ebx
jne    1140 <main+0x20>
mov    %r14,%rdi
mov    %ebx,%esi
mov    %ebp,%edx
call   1040 <printf@plt>
jmp    1140 <main+0x20>
pop    %rbx
pop    %r14
pop    %rbp
ret

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

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