#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 */
typedef int uint32_t;

/* Variables and functions */
int handle_dqform(int, unsigned long *, unsigned long *);
int handle_dsform(int, unsigned long *, unsigned long *);
bool extended_61(uint32_t insn, unsigned long *gprs, unsigned long *addr,
                 unsigned long *size) {
  int subopc = (((insn) >> (32 - (29) - (3))) & ((1 << (3)) - 1));
  switch (subopc) {
  case 0:
  case 4:
    *size = 16;
    return handle_dsform(insn, gprs, addr);
  case 1:
  case 5:
    *size = 16;
    return handle_dqform(insn, gprs, addr);
  case 2:
  case 6:
    *size = 8;
    return handle_dsform(insn, gprs, addr);
  case 3:
  case 7:
    *size = 4;
    return handle_dsform(insn, gprs, addr);
  }
  return false;
}


x86 assembly (clang, -O0):
<extended_61>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    -0x8(%rbp),%eax
and    $0x7,%eax
mov    %eax,-0x24(%rbp)
mov    -0x24(%rbp),%eax
mov    %rax,-0x30(%rbp)
sub    $0x7,%rax
ja     11f1 <extended_61+0xd1>
mov    -0x30(%rbp),%rax
lea    0xea4(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
mov    -0x20(%rbp),%rax
movq   $0x10,(%rax)
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%rsi
mov    -0x18(%rbp),%rdx
call   1040 <handle_dsform@plt>
mov    %eax,-0x4(%rbp)
jmp    11f8 <extended_61+0xd8>
mov    -0x20(%rbp),%rax
movq   $0x10,(%rax)
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%rsi
mov    -0x18(%rbp),%rdx
call   1030 <handle_dqform@plt>
mov    %eax,-0x4(%rbp)
jmp    11f8 <extended_61+0xd8>
mov    -0x20(%rbp),%rax
movq   $0x8,(%rax)
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%rsi
mov    -0x18(%rbp),%rdx
call   1040 <handle_dsform@plt>
mov    %eax,-0x4(%rbp)
jmp    11f8 <extended_61+0xd8>
mov    -0x20(%rbp),%rax
movq   $0x4,(%rax)
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%rsi
mov    -0x18(%rbp),%rdx
call   1040 <handle_dsform@plt>
mov    %eax,-0x4(%rbp)
jmp    11f8 <extended_61+0xd8>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<extended_61>:
mov    %edi,%eax
and    $0x7,%eax
lea    0xed4(%rip),%r8
movslq (%r8,%rax,4),%rax
add    %r8,%rax
jmp    *%rax
movq   $0x10,(%rcx)
jmp    1040 <handle_dsform@plt>
movq   $0x8,(%rcx)
jmp    1040 <handle_dsform@plt>
movq   $0x4,(%rcx)
jmp    1040 <handle_dsform@plt>
movq   $0x10,(%rcx)
jmp    1030 <handle_dqform@plt>

LLVM IR (-O0):
define i32 @extended_61(i32 %0, i64* %1, i64* %2, i64* %3) {
%5 = alloca i32
%6 = alloca i32
%7 = alloca i64*
%8 = alloca i64*
%9 = alloca i64*
%10 = alloca i32
store i32 %0, i32* %6
store i64* %1, i64** %7
store i64* %2, i64** %8
store i64* %3, i64** %9
%11 = load i32, i32* %6
%12 = ashr i32 %11, 0
%13 = and i32 %12, 7
store i32 %13, i32* %10
%14 = load i32, i32* %10
switch i32 %14, label %39 [
i32 0, label %15
i32 4, label %15
i32 1, label %21
i32 5, label %21
i32 2, label %27
i32 6, label %27
i32 3, label %33
i32 7, label %33
]
15: ; preds = %4, %4
%16 = load i64*, i64** %9
store i64 16, i64* %16
%17 = load i32, i32* %6
%18 = load i64*, i64** %7
%19 = load i64*, i64** %8
%20 = call i32 @handle_dsform(i32 %17, i64* %18, i64* %19)
store i32 %20, i32* %5
br label %40
21: ; preds = %4, %4
%22 = load i64*, i64** %9
store i64 16, i64* %22
%23 = load i32, i32* %6
%24 = load i64*, i64** %7
%25 = load i64*, i64** %8
%26 = call i32 @handle_dqform(i32 %23, i64* %24, i64* %25)
store i32 %26, i32* %5
br label %40
27: ; preds = %4, %4
%28 = load i64*, i64** %9
store i64 8, i64* %28
%29 = load i32, i32* %6
%30 = load i64*, i64** %7
%31 = load i64*, i64** %8
%32 = call i32 @handle_dsform(i32 %29, i64* %30, i64* %31)
store i32 %32, i32* %5
br label %40
33: ; preds = %4, %4
%34 = load i64*, i64** %9
store i64 4, i64* %34
%35 = load i32, i32* %6
%36 = load i64*, i64** %7
%37 = load i64*, i64** %8
%38 = call i32 @handle_dsform(i32 %35, i64* %36, i64* %37)
store i32 %38, i32* %5
br label %40
39: ; preds = %4
store i32 0, i32* %5
br label %40
40: ; preds = %39, %33, %27, %21, %15
%41 = load i32, i32* %5
ret i32 %41
}

LLVM IR (-O2):
define i32 @extended_61(i32 %0, i64* %1, i64* %2, i64* nocapture writeonly %3) {
%5 = and i32 %0, 7
switch i32 %5, label %14 [
i32 0, label %6
i32 4, label %6
i32 1, label %8
i32 5, label %8
i32 2, label %10
i32 6, label %10
i32 3, label %12
i32 7, label %12
]
6: ; preds = %4, %4
store i64 16, i64* %3
%7 = tail call i32 @handle_dsform(i32 %0, i64* %1, i64* %2)
br label %15
8: ; preds = %4, %4
store i64 16, i64* %3
%9 = tail call i32 @handle_dqform(i32 %0, i64* %1, i64* %2)
br label %15
10: ; preds = %4, %4
store i64 8, i64* %3
%11 = tail call i32 @handle_dsform(i32 %0, i64* %1, i64* %2)
br label %15
12: ; preds = %4, %4
store i64 4, i64* %3
%13 = tail call i32 @handle_dsform(i32 %0, i64* %1, i64* %2)
br label %15
14: ; preds = %4
unreachable
15: ; preds = %12, %10, %8, %6
%16 = phi i32 [ %13, %12 ], [ %11, %10 ], [ %9, %8 ], [ %7, %6 ]
ret i32 %16
}