#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*/ gen_call(char *);
int /*<<< orphan*/ output_line(char *);
void gen_get_indirect(char typeobj, int reg) {
  if (typeobj == (1 << 2)) {
    if (reg & 1 << 2) {
      output_line("ldab ,x");
      output_line("sex");
    } else
      gen_call("_ldas_d");
  } else if (typeobj == ((1 << 2) + 1)) {
    if (reg & 1 << 2) {
      output_line("ldab ,x");
      output_line("clra");
    } else
      gen_call("_ldau_d");
  } else {
    if (reg & 1 << 2)
      output_line("ldd ,x");
    else
      gen_call("_ldd_d");
  }
}


x86 assembly (clang, -O0):
<gen_get_indirect>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %dil,%al
mov    %al,-0x1(%rbp)
mov    %esi,-0x8(%rbp)
movsbl -0x1(%rbp),%eax
cmp    $0x4,%eax
jne    117b <gen_get_indirect+0x5b>
mov    -0x8(%rbp),%eax
and    $0x4,%eax
cmp    $0x0,%eax
je     116a <gen_get_indirect+0x4a>
lea    0xeac(%rip),%rdi
call   1030 <output_line@plt>
lea    0xea8(%rip),%rdi
call   1030 <output_line@plt>
jmp    1176 <gen_get_indirect+0x56>
lea    0xe9b(%rip),%rdi
call   1040 <gen_call@plt>
jmp    11fb <gen_get_indirect+0xdb>
movsbl -0x1(%rbp),%eax
cmp    $0x5,%eax
jne    11c5 <gen_get_indirect+0xa5>
mov    -0x8(%rbp),%eax
and    $0x4,%eax
cmp    $0x0,%eax
je     11b4 <gen_get_indirect+0x94>
lea    0xe62(%rip),%rdi
call   1030 <output_line@plt>
lea    0xe6a(%rip),%rdi
call   1030 <output_line@plt>
jmp    11c0 <gen_get_indirect+0xa0>
lea    0xe5e(%rip),%rdi
call   1040 <gen_call@plt>
jmp    11f6 <gen_get_indirect+0xd6>
mov    -0x8(%rbp),%eax
and    $0x4,%eax
cmp    $0x0,%eax
je     11e5 <gen_get_indirect+0xc5>
lea    0xe46(%rip),%rdi
call   1030 <output_line@plt>
jmp    11f1 <gen_get_indirect+0xd1>
lea    0xe3c(%rip),%rdi
call   1040 <gen_call@plt>
jmp    11f6 <gen_get_indirect+0xd6>
jmp    11fb <gen_get_indirect+0xdb>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<gen_get_indirect>:
push   %rax
cmp    $0x5,%dil
je     1140 <gen_get_indirect+0x20>
cmp    $0x4,%dil
jne    1153 <gen_get_indirect+0x33>
test   $0x4,%sil
jne    1166 <gen_get_indirect+0x46>
lea    0xed2(%rip),%rdi
pop    %rax
jmp    1040 <gen_call@plt>
test   $0x4,%sil
jne    117f <gen_get_indirect+0x5f>
lea    0xecc(%rip),%rdi
pop    %rax
jmp    1040 <gen_call@plt>
test   $0x4,%sil
jne    1198 <gen_get_indirect+0x78>
lea    0xec8(%rip),%rdi
pop    %rax
jmp    1040 <gen_call@plt>
lea    0xe93(%rip),%rdi
call   1030 <output_line@plt>
lea    0xe8f(%rip),%rdi
pop    %rax
jmp    1030 <output_line@plt>
lea    0xe7a(%rip),%rdi
call   1030 <output_line@plt>
lea    0xe82(%rip),%rdi
pop    %rax
jmp    1030 <output_line@plt>
lea    0xe82(%rip),%rdi
pop    %rax
jmp    1030 <output_line@plt>

LLVM IR (-O0):
@.str = [8 x i8] c"ldab ,x\00"
@.str.1 = [4 x i8] c"sex\00"
@.str.2 = [8 x i8] c"_ldas_d\00"
@.str.3 = [5 x i8] c"clra\00"
@.str.4 = [8 x i8] c"_ldau_d\00"
@.str.5 = [7 x i8] c"ldd ,x\00"
@.str.6 = [7 x i8] c"_ldd_d\00"
define void @gen_get_indirect(i8 signext %0, i32 %1) {
%3 = alloca i8
%4 = alloca i32
store i8 %0, i8* %3
store i32 %1, i32* %4
%5 = load i8, i8* %3
%6 = sext i8 %5 to i32
%7 = icmp eq i32 %6, 4
br i1 %7, label %8, label %18
8: ; preds = %2
%9 = load i32, i32* %4
%10 = and i32 %9, 4
%11 = icmp ne i32 %10, 0
br i1 %11, label %12, label %15
12: ; preds = %8
%13 = call i32 @output_line(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0))
%14 = call i32 @output_line(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0))
br label %17
15: ; preds = %8
%16 = call i32 @gen_call(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0))
br label %17
17: ; preds = %15, %12
br label %42
18: ; preds = %2
%19 = load i8, i8* %3
%20 = sext i8 %19 to i32
%21 = icmp eq i32 %20, 5
br i1 %21, label %22, label %32
22: ; preds = %18
%23 = load i32, i32* %4
%24 = and i32 %23, 4
%25 = icmp ne i32 %24, 0
br i1 %25, label %26, label %29
26: ; preds = %22
%27 = call i32 @output_line(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0))
%28 = call i32 @output_line(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0))
br label %31
29: ; preds = %22
%30 = call i32 @gen_call(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.4, i64 0, i64 0))
br label %31
31: ; preds = %29, %26
br label %41
32: ; preds = %18
%33 = load i32, i32* %4
%34 = and i32 %33, 4
%35 = icmp ne i32 %34, 0
br i1 %35, label %36, label %38
36: ; preds = %32
%37 = call i32 @output_line(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.5, i64 0, i64 0))
br label %40
38: ; preds = %32
%39 = call i32 @gen_call(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.6, i64 0, i64 0))
br label %40
40: ; preds = %38, %36
br label %41
41: ; preds = %40, %31
br label %42
42: ; preds = %41, %17
ret void
}

LLVM IR (-O2):
@.str = [8 x i8] c"ldab ,x\00"
@.str.1 = [4 x i8] c"sex\00"
@.str.2 = [8 x i8] c"_ldas_d\00"
@.str.3 = [5 x i8] c"clra\00"
@.str.4 = [8 x i8] c"_ldau_d\00"
@.str.5 = [7 x i8] c"ldd ,x\00"
@.str.6 = [7 x i8] c"_ldd_d\00"
define void @gen_get_indirect(i8 signext %0, i32 %1) {
switch i8 %0, label %19 [
i8 4, label %3
i8 5, label %11
]
3: ; preds = %2
%4 = and i32 %1, 4
%5 = icmp eq i32 %4, 0
br i1 %5, label %9, label %6
6: ; preds = %3
%7 = tail call i32 @output_line(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0))
%8 = tail call i32 @output_line(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0))
br label %26
9: ; preds = %3
%10 = tail call i32 @gen_call(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0))
br label %26
11: ; preds = %2
%12 = and i32 %1, 4
%13 = icmp eq i32 %12, 0
br i1 %13, label %17, label %14
14: ; preds = %11
%15 = tail call i32 @output_line(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0))
%16 = tail call i32 @output_line(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0))
br label %26
17: ; preds = %11
%18 = tail call i32 @gen_call(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.4, i64 0, i64 0))
br label %26
19: ; preds = %2
%20 = and i32 %1, 4
%21 = icmp eq i32 %20, 0
br i1 %21, label %24, label %22
22: ; preds = %19
%23 = tail call i32 @output_line(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.5, i64 0, i64 0))
br label %26
24: ; preds = %19
%25 = tail call i32 @gen_call(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.6, i64 0, i64 0))
br label %26
26: ; preds = %17, %14, %24, %22, %6, %9
ret void
}