#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 low_sign_unext(int, int);
int re_assemble_12(int);
int re_assemble_14(int);
int re_assemble_16(int);
int re_assemble_17(int);
int re_assemble_21(int);
int re_assemble_22(int);
int hppa_rebuild_insn(int insn, int value, int r_format) {
  switch (r_format) {
  case 11:
    return (insn & ~0x7ff) | low_sign_unext(value, 11);
  case 12:
    return (insn & ~0x1ffd) | re_assemble_12(value);
  case 10:
    return (insn & ~0x3ff1) | re_assemble_14(value & -8);
  case -11:
    return (insn & ~0x3ff9) | re_assemble_14(value & -4);
  case 14:
    return (insn & ~0x3fff) | re_assemble_14(value);
  case -10:
    return (insn & ~0xfff1) | re_assemble_16(value & -8);
  case -16:
    return (insn & ~0xfff9) | re_assemble_16(value & -4);
  case 16:
    return (insn & ~0xffff) | re_assemble_16(value);
  case 17:
    return (insn & ~0x1f1ffd) | re_assemble_17(value);
  case 21:
    return (insn & ~0x1fffff) | re_assemble_21(value);
  case 22:
    return (insn & ~0x3ff1ffd) | re_assemble_22(value);
  case 32:
    return value;
  default:
    return -1;
  }
  return insn;
}


x86 assembly (clang, -O0):
<hppa_rebuild_insn>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %edi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
mov    -0x10(%rbp),%eax
add    $0x10,%eax
mov    %eax,%ecx
mov    %rcx,-0x18(%rbp)
sub    $0x30,%eax
ja     133c <hppa_rebuild_insn+0x1cc>
mov    -0x18(%rbp),%rax
lea    0xe5f(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
mov    -0x8(%rbp),%eax
and    $0xfffff800,%eax
mov    %eax,-0x1c(%rbp)
mov    -0xc(%rbp),%edi
mov    $0xb,%esi
call   1070 <low_sign_unext@plt>
mov    %eax,%ecx
mov    -0x1c(%rbp),%eax
or     %ecx,%eax
mov    %eax,-0x4(%rbp)
jmp    1343 <hppa_rebuild_insn+0x1d3>
mov    -0x8(%rbp),%eax
and    $0xffffe002,%eax
mov    %eax,-0x20(%rbp)
mov    -0xc(%rbp),%edi
call   1040 <re_assemble_12@plt>
mov    %eax,%ecx
mov    -0x20(%rbp),%eax
or     %ecx,%eax
mov    %eax,-0x4(%rbp)
jmp    1343 <hppa_rebuild_insn+0x1d3>
mov    -0x8(%rbp),%eax
and    $0xffffc00e,%eax
mov    %eax,-0x24(%rbp)
mov    -0xc(%rbp),%edi
and    $0xfffffff8,%edi
call   1050 <re_assemble_14@plt>
mov    %eax,%ecx
mov    -0x24(%rbp),%eax
or     %ecx,%eax
mov    %eax,-0x4(%rbp)
jmp    1343 <hppa_rebuild_insn+0x1d3>
mov    -0x8(%rbp),%eax
and    $0xffffc006,%eax
mov    %eax,-0x28(%rbp)
mov    -0xc(%rbp),%edi
and    $0xfffffffc,%edi
call   1050 <re_assemble_14@plt>
mov    %eax,%ecx
mov    -0x28(%rbp),%eax
or     %ecx,%eax
mov    %eax,-0x4(%rbp)
jmp    1343 <hppa_rebuild_insn+0x1d3>
mov    -0x8(%rbp),%eax
and    $0xffffc000,%eax
mov    %eax,-0x2c(%rbp)
mov    -0xc(%rbp),%edi
call   1050 <re_assemble_14@plt>
mov    %eax,%ecx
mov    -0x2c(%rbp),%eax
or     %ecx,%eax
mov    %eax,-0x4(%rbp)
jmp    1343 <hppa_rebuild_insn+0x1d3>
mov    -0x8(%rbp),%eax
and    $0xffff000e,%eax
mov    %eax,-0x30(%rbp)
mov    -0xc(%rbp),%edi
and    $0xfffffff8,%edi
call   1060 <re_assemble_16@plt>
mov    %eax,%ecx
mov    -0x30(%rbp),%eax
or     %ecx,%eax
mov    %eax,-0x4(%rbp)
jmp    1343 <hppa_rebuild_insn+0x1d3>
mov    -0x8(%rbp),%eax
and    $0xffff0006,%eax
mov    %eax,-0x34(%rbp)
mov    -0xc(%rbp),%edi
and    $0xfffffffc,%edi
call   1060 <re_assemble_16@plt>
mov    %eax,%ecx
mov    -0x34(%rbp),%eax
or     %ecx,%eax
mov    %eax,-0x4(%rbp)
jmp    1343 <hppa_rebuild_insn+0x1d3>
mov    -0x8(%rbp),%eax
and    $0xffff0000,%eax
mov    %eax,-0x38(%rbp)
mov    -0xc(%rbp),%edi
call   1060 <re_assemble_16@plt>
mov    %eax,%ecx
mov    -0x38(%rbp),%eax
or     %ecx,%eax
mov    %eax,-0x4(%rbp)
jmp    1343 <hppa_rebuild_insn+0x1d3>
mov    -0x8(%rbp),%eax
and    $0xffe0e002,%eax
mov    %eax,-0x3c(%rbp)
mov    -0xc(%rbp),%edi
call   1090 <re_assemble_17@plt>
mov    %eax,%ecx
mov    -0x3c(%rbp),%eax
or     %ecx,%eax
mov    %eax,-0x4(%rbp)
jmp    1343 <hppa_rebuild_insn+0x1d3>
mov    -0x8(%rbp),%eax
and    $0xffe00000,%eax
mov    %eax,-0x40(%rbp)
mov    -0xc(%rbp),%edi
call   1030 <re_assemble_21@plt>
mov    %eax,%ecx
mov    -0x40(%rbp),%eax
or     %ecx,%eax
mov    %eax,-0x4(%rbp)
jmp    1343 <hppa_rebuild_insn+0x1d3>
mov    -0x8(%rbp),%eax
and    $0xfc00e002,%eax
mov    %eax,-0x44(%rbp)
mov    -0xc(%rbp),%edi
call   1080 <re_assemble_22@plt>
mov    %eax,%ecx
mov    -0x44(%rbp),%eax
or     %ecx,%eax
mov    %eax,-0x4(%rbp)
jmp    1343 <hppa_rebuild_insn+0x1d3>
mov    -0xc(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    1343 <hppa_rebuild_insn+0x1d3>
movl   $0xffffffff,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<hppa_rebuild_insn>:
push   %rbx
add    $0x10,%edx
cmp    $0x30,%edx
ja     1198 <hppa_rebuild_insn+0x28>
mov    %esi,%eax
mov    %edi,%ebx
lea    0xe7c(%rip),%rcx
movslq (%rcx,%rdx,4),%rdx
add    %rcx,%rdx
jmp    *%rdx
and    $0xffff0006,%ebx
and    $0xfffffffc,%eax
jmp    11f8 <hppa_rebuild_insn+0x88>
mov    $0xffffffff,%eax
pop    %rbx
ret
and    $0xffffc006,%ebx
and    $0xfffffffc,%eax
jmp    11e9 <hppa_rebuild_insn+0x79>
and    $0xffff000e,%ebx
and    $0xfffffff8,%eax
jmp    11f8 <hppa_rebuild_insn+0x88>
and    $0xffffc00e,%ebx
and    $0xfffffff8,%eax
jmp    11e9 <hppa_rebuild_insn+0x79>
and    $0xfffff800,%ebx
mov    %eax,%edi
mov    $0xb,%esi
call   1070 <low_sign_unext@plt>
jmp    122c <hppa_rebuild_insn+0xbc>
and    $0xffffe002,%ebx
mov    %eax,%edi
call   1040 <re_assemble_12@plt>
jmp    122c <hppa_rebuild_insn+0xbc>
and    $0xffffc000,%ebx
mov    %eax,%edi
call   1050 <re_assemble_14@plt>
jmp    122c <hppa_rebuild_insn+0xbc>
and    $0xffff0000,%ebx
mov    %eax,%edi
call   1060 <re_assemble_16@plt>
jmp    122c <hppa_rebuild_insn+0xbc>
and    $0xffe0e002,%ebx
mov    %eax,%edi
call   1090 <re_assemble_17@plt>
jmp    122c <hppa_rebuild_insn+0xbc>
and    $0xffe00000,%ebx
mov    %eax,%edi
call   1030 <re_assemble_21@plt>
jmp    122c <hppa_rebuild_insn+0xbc>
and    $0xfc00e002,%ebx
mov    %eax,%edi
call   1080 <re_assemble_22@plt>
or     %ebx,%eax
pop    %rbx
ret

LLVM IR (-O0):
define i32 @hppa_rebuild_insn(i32 %0, i32 %1, i32 %2) {
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
store i32 %0, i32* %5
store i32 %1, i32* %6
store i32 %2, i32* %7
%8 = load i32, i32* %7
switch i32 %8, label %81 [
i32 11, label %9
i32 12, label %15
i32 10, label %21
i32 -11, label %28
i32 14, label %35
i32 -10, label %41
i32 -16, label %48
i32 16, label %55
i32 17, label %61
i32 21, label %67
i32 22, label %73
i32 32, label %79
]
9: ; preds = %3
%10 = load i32, i32* %5
%11 = and i32 %10, -2048
%12 = load i32, i32* %6
%13 = call i32 @low_sign_unext(i32 %12, i32 11)
%14 = or i32 %11, %13
store i32 %14, i32* %4
br label %82
15: ; preds = %3
%16 = load i32, i32* %5
%17 = and i32 %16, -8190
%18 = load i32, i32* %6
%19 = call i32 @re_assemble_12(i32 %18)
%20 = or i32 %17, %19
store i32 %20, i32* %4
br label %82
21: ; preds = %3
%22 = load i32, i32* %5
%23 = and i32 %22, -16370
%24 = load i32, i32* %6
%25 = and i32 %24, -8
%26 = call i32 @re_assemble_14(i32 %25)
%27 = or i32 %23, %26
store i32 %27, i32* %4
br label %82
28: ; preds = %3
%29 = load i32, i32* %5
%30 = and i32 %29, -16378
%31 = load i32, i32* %6
%32 = and i32 %31, -4
%33 = call i32 @re_assemble_14(i32 %32)
%34 = or i32 %30, %33
store i32 %34, i32* %4
br label %82
35: ; preds = %3
%36 = load i32, i32* %5
%37 = and i32 %36, -16384
%38 = load i32, i32* %6
%39 = call i32 @re_assemble_14(i32 %38)
%40 = or i32 %37, %39
store i32 %40, i32* %4
br label %82
41: ; preds = %3
%42 = load i32, i32* %5
%43 = and i32 %42, -65522
%44 = load i32, i32* %6
%45 = and i32 %44, -8
%46 = call i32 @re_assemble_16(i32 %45)
%47 = or i32 %43, %46
store i32 %47, i32* %4
br label %82
48: ; preds = %3
%49 = load i32, i32* %5
%50 = and i32 %49, -65530
%51 = load i32, i32* %6
%52 = and i32 %51, -4
%53 = call i32 @re_assemble_16(i32 %52)
%54 = or i32 %50, %53
store i32 %54, i32* %4
br label %82
55: ; preds = %3
%56 = load i32, i32* %5
%57 = and i32 %56, -65536
%58 = load i32, i32* %6
%59 = call i32 @re_assemble_16(i32 %58)
%60 = or i32 %57, %59
store i32 %60, i32* %4
br label %82
61: ; preds = %3
%62 = load i32, i32* %5
%63 = and i32 %62, -2039806
%64 = load i32, i32* %6
%65 = call i32 @re_assemble_17(i32 %64)
%66 = or i32 %63, %65
store i32 %66, i32* %4
br label %82
67: ; preds = %3
%68 = load i32, i32* %5
%69 = and i32 %68, -2097152
%70 = load i32, i32* %6
%71 = call i32 @re_assemble_21(i32 %70)
%72 = or i32 %69, %71
store i32 %72, i32* %4
br label %82
73: ; preds = %3
%74 = load i32, i32* %5
%75 = and i32 %74, -67051518
%76 = load i32, i32* %6
%77 = call i32 @re_assemble_22(i32 %76)
%78 = or i32 %75, %77
store i32 %78, i32* %4
br label %82
79: ; preds = %3
%80 = load i32, i32* %6
store i32 %80, i32* %4
br label %82
81: ; preds = %3
store i32 -1, i32* %4
br label %82
82: ; preds = %81, %79, %73, %67, %61, %55, %48, %41, %35, %28, %21, %15, %9
%83 = load i32, i32* %4
ret i32 %83
}

LLVM IR (-O2):
define i32 @hppa_rebuild_insn(i32 %0, i32 %1, i32 %2) {
switch i32 %2, label %52 [
i32 11, label %4
i32 12, label %8
i32 10, label %12
i32 -11, label %17
i32 14, label %22
i32 -10, label %26
i32 -16, label %31
i32 16, label %36
i32 17, label %40
i32 21, label %44
i32 22, label %48
i32 32, label %53
]
4: ; preds = %3
%5 = and i32 %0, -2048
%6 = tail call i32 @low_sign_unext(i32 %1, i32 11)
%7 = or i32 %6, %5
br label %53
8: ; preds = %3
%9 = and i32 %0, -8190
%10 = tail call i32 @re_assemble_12(i32 %1)
%11 = or i32 %10, %9
br label %53
12: ; preds = %3
%13 = and i32 %0, -16370
%14 = and i32 %1, -8
%15 = tail call i32 @re_assemble_14(i32 %14)
%16 = or i32 %15, %13
br label %53
17: ; preds = %3
%18 = and i32 %0, -16378
%19 = and i32 %1, -4
%20 = tail call i32 @re_assemble_14(i32 %19)
%21 = or i32 %20, %18
br label %53
22: ; preds = %3
%23 = and i32 %0, -16384
%24 = tail call i32 @re_assemble_14(i32 %1)
%25 = or i32 %24, %23
br label %53
26: ; preds = %3
%27 = and i32 %0, -65522
%28 = and i32 %1, -8
%29 = tail call i32 @re_assemble_16(i32 %28)
%30 = or i32 %29, %27
br label %53
31: ; preds = %3
%32 = and i32 %0, -65530
%33 = and i32 %1, -4
%34 = tail call i32 @re_assemble_16(i32 %33)
%35 = or i32 %34, %32
br label %53
36: ; preds = %3
%37 = and i32 %0, -65536
%38 = tail call i32 @re_assemble_16(i32 %1)
%39 = or i32 %38, %37
br label %53
40: ; preds = %3
%41 = and i32 %0, -2039806
%42 = tail call i32 @re_assemble_17(i32 %1)
%43 = or i32 %42, %41
br label %53
44: ; preds = %3
%45 = and i32 %0, -2097152
%46 = tail call i32 @re_assemble_21(i32 %1)
%47 = or i32 %46, %45
br label %53
48: ; preds = %3
%49 = and i32 %0, -67051518
%50 = tail call i32 @re_assemble_22(i32 %1)
%51 = or i32 %50, %49
br label %53
52: ; preds = %3
br label %53
53: ; preds = %3, %52, %48, %44, %40, %36, %31, %26, %22, %17, %12, %8, %4
%54 = phi i32 [ -1, %52 ], [ %51, %48 ], [ %47, %44 ], [ %43, %40 ], [ %39, %36 ], [ %35, %31 ], [ %30, %26 ], [ %25, %22 ], [ %21, %17 ], [ %16, %12 ], [ %11, %8 ], [ %7, %4 ], [ %1, %3 ]
ret i32 %54
}