#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*/ assert(int);
int /*<<< orphan*/ emit_addimm(int, int, int);
int /*<<< orphan*/ emit_readword_indexed(int, int, int);
int /*<<< orphan*/ emit_readword_indexed_tlb(int, int, int, int);
void emit_readdword_indexed_tlb(int addr, int rs, int map, int rh, int rl) {
  if (map < 0) {
    if (rh >= 0)
      emit_readword_indexed(addr, rs, rh);
    emit_readword_indexed(addr + 4, rs, rl);
  } else {
    assert(rh != rs);
    if (rh >= 0)
      emit_readword_indexed_tlb(addr, rs, map, rh);
    emit_addimm(map, 1, map);
    emit_readword_indexed_tlb(addr, rs, map, rl);
  }
}


x86 assembly (clang, -O0):
<emit_readdword_indexed_tlb>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %edx,-0xc(%rbp)
mov    %ecx,-0x10(%rbp)
mov    %r8d,-0x14(%rbp)
cmpl   $0x0,-0xc(%rbp)
jge    1190 <emit_readdword_indexed_tlb+0x50>
cmpl   $0x0,-0x10(%rbp)
jl     117a <emit_readdword_indexed_tlb+0x3a>
mov    -0x4(%rbp),%edi
mov    -0x8(%rbp),%esi
mov    -0x10(%rbp),%edx
call   1060 <emit_readword_indexed@plt>
mov    -0x4(%rbp),%edi
add    $0x4,%edi
mov    -0x8(%rbp),%esi
mov    -0x14(%rbp),%edx
call   1060 <emit_readword_indexed@plt>
jmp    11df <emit_readdword_indexed_tlb+0x9f>
mov    -0x10(%rbp),%eax
cmp    -0x8(%rbp),%eax
setne  %al
and    $0x1,%al
movzbl %al,%edi
call   1040 <assert@plt>
cmpl   $0x0,-0x10(%rbp)
jl     11be <emit_readdword_indexed_tlb+0x7e>
mov    -0x4(%rbp),%edi
mov    -0x8(%rbp),%esi
mov    -0xc(%rbp),%edx
mov    -0x10(%rbp),%ecx
call   1030 <emit_readword_indexed_tlb@plt>
mov    -0xc(%rbp),%edi
mov    -0xc(%rbp),%edx
mov    $0x1,%esi
call   1050 <emit_addimm@plt>
mov    -0x4(%rbp),%edi
mov    -0x8(%rbp),%esi
mov    -0xc(%rbp),%edx
mov    -0x14(%rbp),%ecx
call   1030 <emit_readword_indexed_tlb@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<emit_readdword_indexed_tlb>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %r8d,%r14d
mov    %ecx,%ebx
mov    %esi,%r15d
mov    %edi,%r12d
test   %edx,%edx
js     11a0 <emit_readdword_indexed_tlb+0x60>
mov    %edx,%ebp
xor    %edi,%edi
cmp    %r15d,%ebx
setne  %dil
call   1040 <assert@plt>
test   %ebx,%ebx
js     117a <emit_readdword_indexed_tlb+0x3a>
mov    %r12d,%edi
mov    %r15d,%esi
mov    %ebp,%edx
mov    %ebx,%ecx
call   1030 <emit_readword_indexed_tlb@plt>
mov    %ebp,%edi
mov    $0x1,%esi
mov    %ebp,%edx
call   1050 <emit_addimm@plt>
mov    %r12d,%edi
mov    %r15d,%esi
mov    %ebp,%edx
mov    %r14d,%ecx
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <emit_readword_indexed_tlb@plt>
test   %ebx,%ebx
js     11b1 <emit_readdword_indexed_tlb+0x71>
mov    %r12d,%edi
mov    %r15d,%esi
mov    %ebx,%edx
call   1060 <emit_readword_indexed@plt>
add    $0x4,%r12d
mov    %r12d,%edi
mov    %r15d,%esi
mov    %r14d,%edx
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
jmp    1060 <emit_readword_indexed@plt>

LLVM IR (-O0):
define void @emit_readdword_indexed_tlb(i32 %0, i32 %1, i32 %2, i32 %3, i32 %4) {
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
store i32 %0, i32* %6
store i32 %1, i32* %7
store i32 %2, i32* %8
store i32 %3, i32* %9
store i32 %4, i32* %10
%11 = load i32, i32* %8
%12 = icmp slt i32 %11, 0
br i1 %12, label %13, label %27
13: ; preds = %5
%14 = load i32, i32* %9
%15 = icmp sge i32 %14, 0
br i1 %15, label %16, label %21
16: ; preds = %13
%17 = load i32, i32* %6
%18 = load i32, i32* %7
%19 = load i32, i32* %9
%20 = call i32 @emit_readword_indexed(i32 %17, i32 %18, i32 %19)
br label %21
21: ; preds = %16, %13
%22 = load i32, i32* %6
%23 = add nsw i32 %22, 4
%24 = load i32, i32* %7
%25 = load i32, i32* %10
%26 = call i32 @emit_readword_indexed(i32 %23, i32 %24, i32 %25)
br label %50
27: ; preds = %5
%28 = load i32, i32* %9
%29 = load i32, i32* %7
%30 = icmp ne i32 %28, %29
%31 = zext i1 %30 to i32
%32 = call i32 @assert(i32 %31)
%33 = load i32, i32* %9
%34 = icmp sge i32 %33, 0
br i1 %34, label %35, label %41
35: ; preds = %27
%36 = load i32, i32* %6
%37 = load i32, i32* %7
%38 = load i32, i32* %8
%39 = load i32, i32* %9
%40 = call i32 @emit_readword_indexed_tlb(i32 %36, i32 %37, i32 %38, i32 %39)
br label %41
41: ; preds = %35, %27
%42 = load i32, i32* %8
%43 = load i32, i32* %8
%44 = call i32 @emit_addimm(i32 %42, i32 1, i32 %43)
%45 = load i32, i32* %6
%46 = load i32, i32* %7
%47 = load i32, i32* %8
%48 = load i32, i32* %10
%49 = call i32 @emit_readword_indexed_tlb(i32 %45, i32 %46, i32 %47, i32 %48)
br label %50
50: ; preds = %41, %21
ret void
}

LLVM IR (-O2):
define void @emit_readdword_indexed_tlb(i32 %0, i32 %1, i32 %2, i32 %3, i32 %4) {
%6 = icmp slt i32 %2, 0
br i1 %6, label %7, label %14
7: ; preds = %5
%8 = icmp sgt i32 %3, -1
br i1 %8, label %9, label %11
9: ; preds = %7
%10 = tail call i32 @emit_readword_indexed(i32 %0, i32 %1, i32 %3)
br label %11
11: ; preds = %9, %7
%12 = add nsw i32 %0, 4
%13 = tail call i32 @emit_readword_indexed(i32 %12, i32 %1, i32 %4)
br label %24
14: ; preds = %5
%15 = icmp ne i32 %3, %1
%16 = zext i1 %15 to i32
%17 = tail call i32 @assert(i32 %16)
%18 = icmp sgt i32 %3, -1
br i1 %18, label %19, label %21
19: ; preds = %14
%20 = tail call i32 @emit_readword_indexed_tlb(i32 %0, i32 %1, i32 %2, i32 %3)
br label %21
21: ; preds = %19, %14
%22 = tail call i32 @emit_addimm(i32 %2, i32 1, i32 %2)
%23 = tail call i32 @emit_readword_indexed_tlb(i32 %0, i32 %1, i32 %2, i32 %4)
br label %24
24: ; preds = %21, %11
ret void
}