#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*/ output_line(char *);
void gen_get_indirect(char typeobj, int reg) {
  if (typeobj == (1 << 2) || typeobj == ((1 << 2) + 1)) {
    if (reg & 1 << 2)
      output_line("ldb ,x");
    else {
      output_line("tfr d,x");
      output_line("ldb ,x");
    }
    if (typeobj == (1 << 2))
      output_line("sex");
  } else {
    if (reg & 1 << 2)
      output_line("ldd ,x");
    else {
      output_line("tfr d,x");
      output_line("ldd ,x");
    }
  }
}


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
je     113b <gen_get_indirect+0x2b>
movsbl -0x1(%rbp),%eax
cmp    $0x5,%eax
jne    1191 <gen_get_indirect+0x81>
mov    -0x8(%rbp),%eax
and    $0x4,%eax
cmp    $0x0,%eax
je     115b <gen_get_indirect+0x4b>
lea    0xeaf(%rip),%rdi
call   1030 <output_line@plt>
jmp    1173 <gen_get_indirect+0x63>
lea    0xea5(%rip),%rdi
call   1030 <output_line@plt>
lea    0xe92(%rip),%rdi
call   1030 <output_line@plt>
movsbl -0x1(%rbp),%eax
cmp    $0x4,%eax
jne    118c <gen_get_indirect+0x7c>
lea    0xe88(%rip),%rdi
call   1030 <output_line@plt>
jmp    11ce <gen_get_indirect+0xbe>
mov    -0x8(%rbp),%eax
and    $0x4,%eax
cmp    $0x0,%eax
je     11b1 <gen_get_indirect+0xa1>
lea    0xe6c(%rip),%rdi
call   1030 <output_line@plt>
jmp    11c9 <gen_get_indirect+0xb9>
lea    0xe4f(%rip),%rdi
call   1030 <output_line@plt>
lea    0xe4f(%rip),%rdi
call   1030 <output_line@plt>
jmp    11ce <gen_get_indirect+0xbe>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<gen_get_indirect>:
push   %rbx
mov    %edi,%ebx
mov    %ebx,%eax
and    $0xfe,%al
cmp    $0x4,%al
jne    1147 <gen_get_indirect+0x37>
test   $0x4,%sil
jne    112d <gen_get_indirect+0x1d>
lea    0xedf(%rip),%rdi
call   1030 <output_line@plt>
lea    0xecc(%rip),%rdi
call   1030 <output_line@plt>
cmp    $0x4,%bl
jne    1169 <gen_get_indirect+0x59>
lea    0xeca(%rip),%rbx
jmp    1160 <gen_get_indirect+0x50>
lea    0xec5(%rip),%rbx
test   $0x4,%sil
jne    1160 <gen_get_indirect+0x50>
lea    0xeac(%rip),%rdi
call   1030 <output_line@plt>
mov    %rbx,%rdi
pop    %rbx
jmp    1030 <output_line@plt>
pop    %rbx
ret

LLVM IR (-O0):
@.str = [7 x i8] c"ldb ,x\00"
@.str.1 = [8 x i8] c"tfr d,x\00"
@.str.2 = [4 x i8] c"sex\00"
@.str.3 = [7 x i8] c"ldd ,x\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 %12, label %8
8: ; preds = %2
%9 = load i8, i8* %3
%10 = sext i8 %9 to i32
%11 = icmp eq i32 %10, 5
br i1 %11, label %12, label %28
12: ; preds = %8, %2
%13 = load i32, i32* %4
%14 = and i32 %13, 4
%15 = icmp ne i32 %14, 0
br i1 %15, label %16, label %18
16: ; preds = %12
%17 = call i32 @output_line(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0))
br label %21
18: ; preds = %12
%19 = call i32 @output_line(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0))
%20 = call i32 @output_line(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0))
br label %21
21: ; preds = %18, %16
%22 = load i8, i8* %3
%23 = sext i8 %22 to i32
%24 = icmp eq i32 %23, 4
br i1 %24, label %25, label %27
25: ; preds = %21
%26 = call i32 @output_line(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0))
br label %27
27: ; preds = %25, %21
br label %38
28: ; preds = %8
%29 = load i32, i32* %4
%30 = and i32 %29, 4
%31 = icmp ne i32 %30, 0
br i1 %31, label %32, label %34
32: ; preds = %28
%33 = call i32 @output_line(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0))
br label %37
34: ; preds = %28
%35 = call i32 @output_line(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0))
%36 = call i32 @output_line(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0))
br label %37
37: ; preds = %34, %32
br label %38
38: ; preds = %37, %27
ret void
}

LLVM IR (-O2):
@.str = [7 x i8] c"ldb ,x\00"
@.str.1 = [8 x i8] c"tfr d,x\00"
@.str.2 = [4 x i8] c"sex\00"
@.str.3 = [7 x i8] c"ldd ,x\00"
define void @gen_get_indirect(i8 signext %0, i32 %1) {
%3 = icmp eq i8 %0, 4
%4 = and i8 %0, -2
%5 = icmp eq i8 %4, 4
%6 = and i32 %1, 4
%7 = icmp eq i32 %6, 0
br i1 %5, label %8, label %13
8: ; preds = %2
br i1 %7, label %9, label %11
9: ; preds = %8
%10 = tail call i32 @output_line(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0))
br label %11
11: ; preds = %8, %9
%12 = tail call i32 @output_line(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0))
br i1 %3, label %16, label %19
13: ; preds = %2
br i1 %7, label %14, label %16
14: ; preds = %13
%15 = tail call i32 @output_line(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0))
br label %16
16: ; preds = %13, %11, %14
%17 = phi i8* [ getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0), %14 ], [ getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), %11 ], [ getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0), %13 ]
%18 = tail call i32 @output_line(i8* %17)
br label %19
19: ; preds = %16, %11
ret void
}