#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*/ addToCache(unsigned int, int /*<<< orphan*/);
int /*<<< orphan*/ findLine(unsigned int, int /*<<< orphan*/);
int findMatch(unsigned int, int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *, ...);
void read(unsigned int address) {
  if (findMatch(address, 0) >= 0) {
    printf("\tmatch found! %d\n", findMatch(address, 0));
  } else {
    printf("no match found\n");
    addToCache(address, findLine(address, 0));
  }
}


x86 assembly (clang, -O0):
<read>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
mov    -0x4(%rbp),%edi
xor    %esi,%esi
call   1050 <findMatch@plt>
cmp    $0x0,%eax
jl     117d <read+0x3d>
mov    -0x4(%rbp),%edi
xor    %esi,%esi
call   1050 <findMatch@plt>
mov    %eax,%esi
lea    0xe8f(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    11a5 <read+0x65>
lea    0xe8e(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x4(%rbp),%eax
mov    %eax,-0x8(%rbp)
mov    -0x4(%rbp),%edi
xor    %esi,%esi
call   1060 <findLine@plt>
mov    -0x8(%rbp),%edi
mov    %eax,%esi
call   1030 <addToCache@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<read>:
push   %rbx
mov    %edi,%ebx
xor    %esi,%esi
call   1060 <findMatch@plt>
test   %eax,%eax
js     1178 <read+0x28>
mov    %ebx,%edi
xor    %esi,%esi
call   1060 <findMatch@plt>
lea    0xe92(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
pop    %rbx
jmp    1050 <printf@plt>
lea    0xe93(%rip),%rdi
call   1030 <puts@plt>
mov    %ebx,%edi
xor    %esi,%esi
call   1070 <findLine@plt>
mov    %ebx,%edi
mov    %eax,%esi
pop    %rbx
jmp    1040 <addToCache@plt>

LLVM IR (-O0):
@.str = [18 x i8] c"\09match found! %d\0A\00"
@.str.1 = [16 x i8] c"no match found\0A\00"
define void @read(i32 %0) {
%2 = alloca i32
store i32 %0, i32* %2
%3 = load i32, i32* %2
%4 = call i32 @findMatch(i32 %3, i32 0)
%5 = icmp sge i32 %4, 0
br i1 %5, label %6, label %10
6: ; preds = %1
%7 = load i32, i32* %2
%8 = call i32 @findMatch(i32 %7, i32 0)
%9 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0), i32 %8)
br label %16
10: ; preds = %1
%11 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.1, i64 0, i64 0))
%12 = load i32, i32* %2
%13 = load i32, i32* %2
%14 = call i32 @findLine(i32 %13, i32 0)
%15 = call i32 @addToCache(i32 %12, i32 %14)
br label %16
16: ; preds = %10, %6
ret void
}

LLVM IR (-O2):
@.str = [18 x i8] c"\09match found! %d\0A\00"
@str = [15 x i8] c"no match found\00"
define void @read(i32 %0) {
%2 = tail call i32 @findMatch(i32 %0, i32 0)
%3 = icmp sgt i32 %2, -1
br i1 %3, label %4, label %7
4: ; preds = %1
%5 = tail call i32 @findMatch(i32 %0, i32 0)
%6 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0), i32 %5)
br label %11
7: ; preds = %1
%8 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @str, i64 0, i64 0))
%9 = tail call i32 @findLine(i32 %0, i32 0)
%10 = tail call i32 @addToCache(i32 %0, i32 %9)
br label %11
11: ; preds = %7, %4
ret void
}