#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 fast(int, int);
int mid(int, int);
int /*<<< orphan*/ printf(char *, int, int, int, int);
int slow(int, int);
int test(int i, int j) {
  int s = slow(i, j);
  int m = mid(i, j);
  int f = fast(i, j);
  if (s != f) {
    printf("[%d, %d], slow = %d, fast = %d\n", i, j, s, f);
    return 1;
  }
  if (s != m) {
    printf("[%d, %d], slow = %d, mid = %d\n", i, j, s, m);
    return 1;
  }
  return 0;
}


x86 assembly (clang, -O0):
<test>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    -0x8(%rbp),%edi
mov    -0xc(%rbp),%esi
call   1060 <slow@plt>
mov    %eax,-0x10(%rbp)
mov    -0x8(%rbp),%edi
mov    -0xc(%rbp),%esi
call   1040 <mid@plt>
mov    %eax,-0x14(%rbp)
mov    -0x8(%rbp),%edi
mov    -0xc(%rbp),%esi
call   1050 <fast@plt>
mov    %eax,-0x18(%rbp)
mov    -0x10(%rbp),%eax
cmp    -0x18(%rbp),%eax
je     11a9 <test+0x69>
mov    -0x8(%rbp),%esi
mov    -0xc(%rbp),%edx
mov    -0x10(%rbp),%ecx
mov    -0x18(%rbp),%r8d
lea    0xe68(%rip),%rdi
call   1030 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    11e1 <test+0xa1>
mov    -0x10(%rbp),%eax
cmp    -0x14(%rbp),%eax
je     11da <test+0x9a>
mov    -0x8(%rbp),%esi
mov    -0xc(%rbp),%edx
mov    -0x10(%rbp),%ecx
mov    -0x14(%rbp),%r8d
lea    0xe57(%rip),%rdi
call   1030 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    11e1 <test+0xa1>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<test>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %esi,%ebx
mov    %edi,%ebp
call   1060 <slow@plt>
mov    %eax,%r14d
mov    %ebp,%edi
mov    %ebx,%esi
call   1040 <mid@plt>
mov    %eax,%r15d
mov    %ebp,%edi
mov    %ebx,%esi
call   1050 <fast@plt>
cmp    %eax,%r14d
jne    1187 <test+0x47>
xor    %eax,%eax
cmp    %r15d,%r14d
je     11a2 <test+0x62>
lea    0xea5(%rip),%rdi
mov    %ebp,%esi
mov    %ebx,%edx
mov    %r14d,%ecx
mov    %r15d,%r8d
jmp    1198 <test+0x58>
lea    0xe72(%rip),%rdi
mov    %ebp,%esi
mov    %ebx,%edx
mov    %r14d,%ecx
mov    %eax,%r8d
call   1030 <printf@plt>
mov    $0x1,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
@.str = [32 x i8] c"[%d, %d], slow = %d, fast = %d\0A\00"
@.str.1 = [31 x i8] c"[%d, %d], slow = %d, mid = %d\0A\00"
define i32 @test(i32 %0, i32 %1) {
%3 = tail call i32 @slow(i32 %0, i32 %1)
%4 = tail call i32 @mid(i32 %0, i32 %1)
%5 = tail call i32 @fast(i32 %0, i32 %1)
%6 = icmp eq i32 %3, %5
br i1 %6, label %9, label %7
7: ; preds = %2
%8 = tail call i32 @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str, i64 0, i64 0), i32 %0, i32 %1, i32 %3, i32 %5)
br label %13
9: ; preds = %2
%10 = icmp eq i32 %3, %4
br i1 %10, label %13, label %11
11: ; preds = %9
%12 = tail call i32 @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.1, i64 0, i64 0), i32 %0, i32 %1, i32 %3, i32 %4)
br label %13
13: ; preds = %9, %11, %7
%14 = phi i32 [ 1, %7 ], [ 1, %11 ], [ 0, %9 ]
ret i32 %14
}