#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*/ GenPrintInstr3Operands(int, int /*<<< orphan*/, int,
                                          int /*<<< orphan*/, int,
                                          int /*<<< orphan*/, int, int);
void GenExtendRegIfNeeded(int reg, int opSz) {
  if (opSz == -1) {
    GenPrintInstr3Operands(0x17, 0, reg, 0, reg, 0, 0x80, 24);
    GenPrintInstr3Operands(0x19, 0, reg, 0, reg, 0, 0x80, 24);
  } else if (opSz == 1) {
    GenPrintInstr3Operands(0x13, 0, reg, 0, reg, 0, 0x80, 0xFF);
  } else if (opSz == -2) {
    GenPrintInstr3Operands(0x17, 0, reg, 0, reg, 0, 0x80, 16);
    GenPrintInstr3Operands(0x19, 0, reg, 0, reg, 0, 0x80, 16);
  } else if (opSz == 2) {
    GenPrintInstr3Operands(0x13, 0, reg, 0, reg, 0, 0x80, 0xFFFF);
  }
}


x86 assembly (clang, -O0):
<GenExtendRegIfNeeded>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
cmpl   $0xffffffff,-0x8(%rbp)
jne    117f <GenExtendRegIfNeeded+0x6f>
mov    -0x4(%rbp),%edx
mov    -0x4(%rbp),%r8d
mov    $0x17,%edi
xor    %r9d,%r9d
mov    %r9d,%esi
mov    %r9d,%ecx
movl   $0x80,(%rsp)
movl   $0x18,0x8(%rsp)
call   1030 <GenPrintInstr3Operands@plt>
mov    -0x4(%rbp),%edx
mov    -0x4(%rbp),%r8d
mov    $0x19,%edi
xor    %r9d,%r9d
mov    %r9d,%esi
mov    %r9d,%ecx
movl   $0x80,(%rsp)
movl   $0x18,0x8(%rsp)
call   1030 <GenPrintInstr3Operands@plt>
jmp    125a <GenExtendRegIfNeeded+0x14a>
cmpl   $0x1,-0x8(%rbp)
jne    11b7 <GenExtendRegIfNeeded+0xa7>
mov    -0x4(%rbp),%edx
mov    -0x4(%rbp),%r8d
mov    $0x13,%edi
xor    %r9d,%r9d
mov    %r9d,%esi
mov    %r9d,%ecx
movl   $0x80,(%rsp)
movl   $0xff,0x8(%rsp)
call   1030 <GenPrintInstr3Operands@plt>
jmp    1255 <GenExtendRegIfNeeded+0x145>
cmpl   $0xfffffffe,-0x8(%rbp)
jne    1218 <GenExtendRegIfNeeded+0x108>
mov    -0x4(%rbp),%edx
mov    -0x4(%rbp),%r8d
mov    $0x17,%edi
xor    %r9d,%r9d
mov    %r9d,%esi
mov    %r9d,%ecx
movl   $0x80,(%rsp)
movl   $0x10,0x8(%rsp)
call   1030 <GenPrintInstr3Operands@plt>
mov    -0x4(%rbp),%edx
mov    -0x4(%rbp),%r8d
mov    $0x19,%edi
xor    %r9d,%r9d
mov    %r9d,%esi
mov    %r9d,%ecx
movl   $0x80,(%rsp)
movl   $0x10,0x8(%rsp)
call   1030 <GenPrintInstr3Operands@plt>
jmp    1250 <GenExtendRegIfNeeded+0x140>
cmpl   $0x2,-0x8(%rbp)
jne    124b <GenExtendRegIfNeeded+0x13b>
mov    -0x4(%rbp),%edx
mov    -0x4(%rbp),%r8d
mov    $0x13,%edi
xor    %r9d,%r9d
mov    %r9d,%esi
mov    %r9d,%ecx
movl   $0x80,(%rsp)
movl   $0xffff,0x8(%rsp)
call   1030 <GenPrintInstr3Operands@plt>
jmp    1250 <GenExtendRegIfNeeded+0x140>
jmp    1255 <GenExtendRegIfNeeded+0x145>
jmp    125a <GenExtendRegIfNeeded+0x14a>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<GenExtendRegIfNeeded>:
push   %rbx
add    $0x2,%esi
cmp    $0x4,%esi
ja     1197 <GenExtendRegIfNeeded+0x87>
mov    %edi,%ebx
lea    0xede(%rip),%rax
movslq (%rax,%rsi,4),%rcx
add    %rax,%rcx
jmp    *%rcx
mov    $0x17,%edi
xor    %esi,%esi
mov    %ebx,%edx
xor    %ecx,%ecx
mov    %ebx,%r8d
xor    %r9d,%r9d
push   $0x10
push   $0x80
call   1030 <GenPrintInstr3Operands@plt>
add    $0x10,%rsp
mov    $0x19,%edi
xor    %esi,%esi
mov    %ebx,%edx
xor    %ecx,%ecx
mov    %ebx,%r8d
xor    %r9d,%r9d
push   $0x10
jmp    11c7 <GenExtendRegIfNeeded+0xb7>
mov    $0x17,%edi
xor    %esi,%esi
mov    %ebx,%edx
xor    %ecx,%ecx
mov    %ebx,%r8d
xor    %r9d,%r9d
push   $0x18
push   $0x80
call   1030 <GenPrintInstr3Operands@plt>
add    $0x10,%rsp
mov    $0x19,%edi
xor    %esi,%esi
mov    %ebx,%edx
xor    %ecx,%ecx
mov    %ebx,%r8d
xor    %r9d,%r9d
push   $0x18
jmp    11c7 <GenExtendRegIfNeeded+0xb7>
pop    %rbx
ret
mov    $0x13,%edi
xor    %esi,%esi
mov    %ebx,%edx
xor    %ecx,%ecx
mov    %ebx,%r8d
xor    %r9d,%r9d
push   $0xff
jmp    11c7 <GenExtendRegIfNeeded+0xb7>
mov    $0x13,%edi
xor    %esi,%esi
mov    %ebx,%edx
xor    %ecx,%ecx
mov    %ebx,%r8d
xor    %r9d,%r9d
push   $0xffff
push   $0x80
call   1030 <GenPrintInstr3Operands@plt>
add    $0x10,%rsp
pop    %rbx
ret

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

LLVM IR (-O2):
define void @GenExtendRegIfNeeded(i32 %0, i32 %1) {
switch i32 %1, label %13 [
i32 -1, label %3
i32 1, label %6
i32 -2, label %8
i32 2, label %11
]
3: ; preds = %2
%4 = tail call i32 @GenPrintInstr3Operands(i32 23, i32 0, i32 %0, i32 0, i32 %0, i32 0, i32 128, i32 24)
%5 = tail call i32 @GenPrintInstr3Operands(i32 25, i32 0, i32 %0, i32 0, i32 %0, i32 0, i32 128, i32 24)
br label %13
6: ; preds = %2
%7 = tail call i32 @GenPrintInstr3Operands(i32 19, i32 0, i32 %0, i32 0, i32 %0, i32 0, i32 128, i32 255)
br label %13
8: ; preds = %2
%9 = tail call i32 @GenPrintInstr3Operands(i32 23, i32 0, i32 %0, i32 0, i32 %0, i32 0, i32 128, i32 16)
%10 = tail call i32 @GenPrintInstr3Operands(i32 25, i32 0, i32 %0, i32 0, i32 %0, i32 0, i32 128, i32 16)
br label %13
11: ; preds = %2
%12 = tail call i32 @GenPrintInstr3Operands(i32 19, i32 0, i32 %0, i32 0, i32 %0, i32 0, i32 128, i32 65535)
br label %13
13: ; preds = %2, %6, %11, %8, %3
ret void
}