#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*/ GenPrintInstr2Operands(int, int /*<<< orphan*/, int,
                                          int /*<<< orphan*/, int,
                                          int /*<<< orphan*/);
void GenReadIndirect(int regDst, int regSrc, int opSz) {
  int instr = 0x04;
  if (opSz == -1 || opSz == 1) {
    instr = 0x02;
  } else if (opSz == -2 || opSz == 2) {
    instr = 0x03;
  }
  GenPrintInstr2Operands(instr, 0, regDst, 0, regSrc + 0x30, 0);
  if (opSz == -1) {
    GenPrintInstr2Operands(0x83, 0, regDst, 0, regDst, 0);
  } else if (opSz == -2) {
    GenPrintInstr2Operands(0x84, 0, regDst, 0, regDst, 0);
  }
}


x86 assembly (clang, -O0):
<GenReadIndirect>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %edx,-0xc(%rbp)
movl   $0x4,-0x10(%rbp)
cmpl   $0xffffffff,-0xc(%rbp)
je     113c <GenReadIndirect+0x2c>
cmpl   $0x1,-0xc(%rbp)
jne    1148 <GenReadIndirect+0x38>
movl   $0x2,-0x10(%rbp)
jmp    1168 <GenReadIndirect+0x58>
cmpl   $0xfffffffe,-0xc(%rbp)
je     115c <GenReadIndirect+0x4c>
cmpl   $0x2,-0xc(%rbp)
jne    1163 <GenReadIndirect+0x53>
movl   $0x3,-0x10(%rbp)
jmp    1168 <GenReadIndirect+0x58>
mov    -0x10(%rbp),%edi
mov    -0x4(%rbp),%edx
mov    -0x8(%rbp),%r8d
add    $0x30,%r8d
xor    %r9d,%r9d
mov    %r9d,%esi
mov    %r9d,%ecx
call   1030 <GenPrintInstr2Operands@plt>
cmpl   $0xffffffff,-0xc(%rbp)
jne    11ad <GenReadIndirect+0x9d>
mov    -0x4(%rbp),%edx
mov    -0x4(%rbp),%r8d
mov    $0x83,%edi
xor    %r9d,%r9d
mov    %r9d,%esi
mov    %r9d,%ecx
call   1030 <GenPrintInstr2Operands@plt>
jmp    11d6 <GenReadIndirect+0xc6>
cmpl   $0xfffffffe,-0xc(%rbp)
jne    11d1 <GenReadIndirect+0xc1>
mov    -0x4(%rbp),%edx
mov    -0x4(%rbp),%r8d
mov    $0x84,%edi
xor    %r9d,%r9d
mov    %r9d,%esi
mov    %r9d,%ecx
call   1030 <GenPrintInstr2Operands@plt>
jmp    11d6 <GenReadIndirect+0xc6>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<GenReadIndirect>:
push   %rbp
push   %rbx
push   %rax
mov    %edx,%ebx
mov    %esi,%r8d
mov    %edi,%ebp
lea    0x2(%rbx),%eax
mov    $0x4,%edi
cmp    $0x4,%eax
ja     1133 <GenReadIndirect+0x23>
cltq
lea    0xed0(%rip),%rcx
mov    (%rcx,%rax,4),%edi
add    $0x30,%r8d
xor    %esi,%esi
mov    %ebp,%edx
xor    %ecx,%ecx
xor    %r9d,%r9d
call   1030 <GenPrintInstr2Operands@plt>
cmp    $0xffffffff,%ebx
je     1156 <GenReadIndirect+0x46>
cmp    $0xfffffffe,%ebx
jne    1172 <GenReadIndirect+0x62>
mov    $0x84,%edi
jmp    115b <GenReadIndirect+0x4b>
mov    $0x83,%edi
xor    %esi,%esi
mov    %ebp,%edx
xor    %ecx,%ecx
mov    %ebp,%r8d
xor    %r9d,%r9d
add    $0x8,%rsp
pop    %rbx
pop    %rbp
jmp    1030 <GenPrintInstr2Operands@plt>
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
define void @GenReadIndirect(i32 %0, i32 %1, i32 %2) {
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
store i32 %0, i32* %4
store i32 %1, i32* %5
store i32 %2, i32* %6
store i32 4, i32* %7
%8 = load i32, i32* %6
%9 = icmp eq i32 %8, -1
br i1 %9, label %13, label %10
10: ; preds = %3
%11 = load i32, i32* %6
%12 = icmp eq i32 %11, 1
br i1 %12, label %13, label %14
13: ; preds = %10, %3
store i32 2, i32* %7
br label %22
14: ; preds = %10
%15 = load i32, i32* %6
%16 = icmp eq i32 %15, -2
br i1 %16, label %20, label %17
17: ; preds = %14
%18 = load i32, i32* %6
%19 = icmp eq i32 %18, 2
br i1 %19, label %20, label %21
20: ; preds = %17, %14
store i32 3, i32* %7
br label %21
21: ; preds = %20, %17
br label %22
22: ; preds = %21, %13
%23 = load i32, i32* %7
%24 = load i32, i32* %4
%25 = load i32, i32* %5
%26 = add nsw i32 %25, 48
%27 = call i32 @GenPrintInstr2Operands(i32 %23, i32 0, i32 %24, i32 0, i32 %26, i32 0)
%28 = load i32, i32* %6
%29 = icmp eq i32 %28, -1
br i1 %29, label %30, label %34
30: ; preds = %22
%31 = load i32, i32* %4
%32 = load i32, i32* %4
%33 = call i32 @GenPrintInstr2Operands(i32 131, i32 0, i32 %31, i32 0, i32 %32, i32 0)
br label %42
34: ; preds = %22
%35 = load i32, i32* %6
%36 = icmp eq i32 %35, -2
br i1 %36, label %37, label %41
37: ; preds = %34
%38 = load i32, i32* %4
%39 = load i32, i32* %4
%40 = call i32 @GenPrintInstr2Operands(i32 132, i32 0, i32 %38, i32 0, i32 %39, i32 0)
br label %41
41: ; preds = %37, %34
br label %42
42: ; preds = %41, %30
ret void
}

LLVM IR (-O2):
@switch.table.GenReadIndirect = [5 x i32] [i32 3, i32 2, i32 4, i32 2, i32 3]
define void @GenReadIndirect(i32 %0, i32 %1, i32 %2) {
%4 = add i32 %2, 2
%5 = icmp ult i32 %4, 5
br i1 %5, label %6, label %10
6: ; preds = %3
%7 = sext i32 %4 to i64
%8 = getelementptr inbounds [5 x i32], [5 x i32]* @switch.table.GenReadIndirect, i64 0, i64 %7
%9 = load i32, i32* %8
br label %10
10: ; preds = %3, %6
%11 = phi i32 [ %9, %6 ], [ 4, %3 ]
%12 = add nsw i32 %1, 48
%13 = tail call i32 @GenPrintInstr2Operands(i32 %11, i32 0, i32 %0, i32 0, i32 %12, i32 0)
switch i32 %2, label %18 [
i32 -1, label %15
i32 -2, label %14
]
14: ; preds = %10
br label %15
15: ; preds = %10, %14
%16 = phi i32 [ 132, %14 ], [ 131, %10 ]
%17 = tail call i32 @GenPrintInstr2Operands(i32 %16, i32 0, i32 %0, i32 0, i32 %0, i32 0)
br label %18
18: ; preds = %15, %10
ret void
}