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


x86 assembly (clang, -O0):
<emit_writedword_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)
mov    %r9d,-0x18(%rbp)
cmpl   $0x0,-0x14(%rbp)
jge    1194 <emit_writedword_indexed_tlb+0x54>
cmpl   $0x0,-0x4(%rbp)
jl     117e <emit_writedword_indexed_tlb+0x3e>
mov    -0x4(%rbp),%edi
mov    -0xc(%rbp),%esi
mov    -0x10(%rbp),%edx
call   1030 <emit_writeword_indexed@plt>
mov    -0x8(%rbp),%edi
mov    -0xc(%rbp),%esi
add    $0x4,%esi
mov    -0x10(%rbp),%edx
call   1030 <emit_writeword_indexed@plt>
jmp    1226 <emit_writedword_indexed_tlb+0xe6>
cmpl   $0x0,-0x4(%rbp)
setge  %al
and    $0x1,%al
movzbl %al,%edi
call   1040 <assert@plt>
mov    -0x18(%rbp),%eax
cmp    -0x10(%rbp),%eax
je     11c1 <emit_writedword_indexed_tlb+0x81>
mov    -0x14(%rbp),%edi
mov    -0x18(%rbp),%edx
mov    $0x1,%esi
call   1050 <emit_addimm@plt>
mov    -0x4(%rbp),%edi
mov    -0xc(%rbp),%esi
mov    -0x10(%rbp),%edx
mov    -0x14(%rbp),%ecx
mov    -0x18(%rbp),%r8d
call   1060 <emit_writeword_indexed_tlb@plt>
mov    -0x18(%rbp),%eax
cmp    -0x10(%rbp),%eax
je     11fc <emit_writedword_indexed_tlb+0xbc>
mov    -0x8(%rbp),%edi
mov    -0xc(%rbp),%esi
mov    -0x10(%rbp),%edx
mov    -0x18(%rbp),%ecx
mov    -0x18(%rbp),%r8d
call   1060 <emit_writeword_indexed_tlb@plt>
jmp    1221 <emit_writedword_indexed_tlb+0xe1>
mov    -0x10(%rbp),%edi
mov    -0x10(%rbp),%edx
mov    $0x4,%esi
call   1050 <emit_addimm@plt>
mov    -0x8(%rbp),%edi
mov    -0xc(%rbp),%esi
mov    -0x10(%rbp),%edx
mov    -0x14(%rbp),%ecx
mov    -0x18(%rbp),%r8d
call   1060 <emit_writeword_indexed_tlb@plt>
jmp    1226 <emit_writedword_indexed_tlb+0xe6>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<emit_writedword_indexed_tlb>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %ecx,%r15d
mov    %edx,%r12d
mov    %esi,%r14d
mov    %edi,%ebx
test   %r8d,%r8d
js     119f <emit_writedword_indexed_tlb+0x5f>
mov    %r9d,%ebp
mov    %r8d,%r13d
mov    %ebx,%edi
not    %edi
shr    $0x1f,%edi
call   1040 <assert@plt>
cmp    %r15d,%ebp
jne    11d0 <emit_writedword_indexed_tlb+0x90>
mov    %ebx,%edi
mov    %r12d,%esi
mov    %ebp,%edx
mov    %r13d,%ecx
mov    %ebp,%r8d
call   1060 <emit_writeword_indexed_tlb@plt>
mov    %ebp,%edi
mov    $0x4,%esi
mov    %ebp,%edx
call   1050 <emit_addimm@plt>
mov    %r14d,%edi
mov    %r12d,%esi
mov    %ebp,%edx
mov    %r13d,%ecx
jmp    11fd <emit_writedword_indexed_tlb+0xbd>
test   %ebx,%ebx
js     11b0 <emit_writedword_indexed_tlb+0x70>
mov    %ebx,%edi
mov    %r12d,%esi
mov    %r15d,%edx
call   1030 <emit_writeword_indexed@plt>
add    $0x4,%r12d
mov    %r14d,%edi
mov    %r12d,%esi
mov    %r15d,%edx
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <emit_writeword_indexed@plt>
mov    %r13d,%edi
mov    $0x1,%esi
mov    %ebp,%edx
call   1050 <emit_addimm@plt>
mov    %ebx,%edi
mov    %r12d,%esi
mov    %r15d,%edx
mov    %r13d,%ecx
mov    %ebp,%r8d
call   1060 <emit_writeword_indexed_tlb@plt>
mov    %r14d,%edi
mov    %r12d,%esi
mov    %r15d,%edx
mov    %ebp,%ecx
mov    %ebp,%r8d
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1060 <emit_writeword_indexed_tlb@plt>

LLVM IR (-O0):
define void @emit_writedword_indexed_tlb(i32 %0, i32 %1, i32 %2, i32 %3, i32 %4, i32 %5) {
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32
store i32 %0, i32* %7
store i32 %1, i32* %8
store i32 %2, i32* %9
store i32 %3, i32* %10
store i32 %4, i32* %11
store i32 %5, i32* %12
%13 = load i32, i32* %11
%14 = icmp slt i32 %13, 0
br i1 %14, label %15, label %29
15: ; preds = %6
%16 = load i32, i32* %7
%17 = icmp sge i32 %16, 0
br i1 %17, label %18, label %23
18: ; preds = %15
%19 = load i32, i32* %7
%20 = load i32, i32* %9
%21 = load i32, i32* %10
%22 = call i32 @emit_writeword_indexed(i32 %19, i32 %20, i32 %21)
br label %23
23: ; preds = %18, %15
%24 = load i32, i32* %8
%25 = load i32, i32* %9
%26 = add nsw i32 %25, 4
%27 = load i32, i32* %10
%28 = call i32 @emit_writeword_indexed(i32 %24, i32 %26, i32 %27)
br label %69
29: ; preds = %6
%30 = load i32, i32* %7
%31 = icmp sge i32 %30, 0
%32 = zext i1 %31 to i32
%33 = call i32 @assert(i32 %32)
%34 = load i32, i32* %12
%35 = load i32, i32* %10
%36 = icmp ne i32 %34, %35
br i1 %36, label %37, label %41
37: ; preds = %29
%38 = load i32, i32* %11
%39 = load i32, i32* %12
%40 = call i32 @emit_addimm(i32 %38, i32 1, i32 %39)
br label %41
41: ; preds = %37, %29
%42 = load i32, i32* %7
%43 = load i32, i32* %9
%44 = load i32, i32* %10
%45 = load i32, i32* %11
%46 = load i32, i32* %12
%47 = call i32 @emit_writeword_indexed_tlb(i32 %42, i32 %43, i32 %44, i32 %45, i32 %46)
%48 = load i32, i32* %12
%49 = load i32, i32* %10
%50 = icmp ne i32 %48, %49
br i1 %50, label %51, label %58
51: ; preds = %41
%52 = load i32, i32* %8
%53 = load i32, i32* %9
%54 = load i32, i32* %10
%55 = load i32, i32* %12
%56 = load i32, i32* %12
%57 = call i32 @emit_writeword_indexed_tlb(i32 %52, i32 %53, i32 %54, i32 %55, i32 %56)
br label %68
58: ; preds = %41
%59 = load i32, i32* %10
%60 = load i32, i32* %10
%61 = call i32 @emit_addimm(i32 %59, i32 4, i32 %60)
%62 = load i32, i32* %8
%63 = load i32, i32* %9
%64 = load i32, i32* %10
%65 = load i32, i32* %11
%66 = load i32, i32* %12
%67 = call i32 @emit_writeword_indexed_tlb(i32 %62, i32 %63, i32 %64, i32 %65, i32 %66)
br label %68
68: ; preds = %58, %51
br label %69
69: ; preds = %68, %23
ret void
}

LLVM IR (-O2):
define void @emit_writedword_indexed_tlb(i32 %0, i32 %1, i32 %2, i32 %3, i32 %4, i32 %5) {
%7 = icmp slt i32 %4, 0
br i1 %7, label %8, label %15
8: ; preds = %6
%9 = icmp sgt i32 %0, -1
br i1 %9, label %10, label %12
10: ; preds = %8
%11 = tail call i32 @emit_writeword_indexed(i32 %0, i32 %2, i32 %3)
br label %12
12: ; preds = %10, %8
%13 = add nsw i32 %2, 4
%14 = tail call i32 @emit_writeword_indexed(i32 %1, i32 %13, i32 %3)
br label %28
15: ; preds = %6
%16 = xor i32 %0, -1
%17 = lshr i32 %16, 31
%18 = tail call i32 @assert(i32 %17)
%19 = icmp eq i32 %5, %3
br i1 %19, label %24, label %20
20: ; preds = %15
%21 = tail call i32 @emit_addimm(i32 %4, i32 1, i32 %5)
%22 = tail call i32 @emit_writeword_indexed_tlb(i32 %0, i32 %2, i32 %3, i32 %4, i32 %5)
%23 = tail call i32 @emit_writeword_indexed_tlb(i32 %1, i32 %2, i32 %3, i32 %5, i32 %5)
br label %28
24: ; preds = %15
%25 = tail call i32 @emit_writeword_indexed_tlb(i32 %0, i32 %2, i32 %5, i32 %4, i32 %5)
%26 = tail call i32 @emit_addimm(i32 %5, i32 4, i32 %5)
%27 = tail call i32 @emit_writeword_indexed_tlb(i32 %1, i32 %2, i32 %5, i32 %4, i32 %5)
br label %28
28: ; preds = %20, %24, %12
ret void
}