#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 /*<<< orphan*/ se16(int);
bool is_branch(uint32_t insn, int *off) {
  switch (insn >> 26) {
  case 0x04:
  case 0x14:
  case 0x05:
  case 0x15:
  case 0x07:
  case 0x17:
  case 0x06:
  case 0x16:
    *off = se16(insn) + 1;
    return true;
  case 0x01:
    switch ((insn >> 16) & 0x1f) {
    case 0x01:
    case 0x03:
    case 0x11:
    case 0x13:
    case 0x00:
    case 0x02:
    case 0x10:
    case 0x12:
      *off = se16(insn) + 1;
      return true;
    default:
      return false;
    }
  default:
    return false;
  }
}


x86 assembly (clang, -O0):
<is_branch>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%eax
sar    $0x1a,%eax
mov    %eax,-0x14(%rbp)
sub    $0x1,%eax
je     117d <is_branch+0x6d>
jmp    1136 <is_branch+0x26>
mov    -0x14(%rbp),%eax
add    $0xfffffffc,%eax
sub    $0x4,%eax
jb     115e <is_branch+0x4e>
jmp    114a <is_branch+0x3a>
mov    -0x14(%rbp),%eax
add    $0xffffffec,%eax
sub    $0x3,%eax
ja     11d4 <is_branch+0xc4>
jmp    115e <is_branch+0x4e>
mov    -0x8(%rbp),%edi
call   1030 <se16@plt>
mov    %eax,%ecx
add    $0x1,%ecx
mov    -0x10(%rbp),%rax
mov    %ecx,(%rax)
movl   $0x1,-0x4(%rbp)
jmp    11db <is_branch+0xcb>
movzwl -0x6(%rbp),%eax
and    $0x1f,%eax
mov    %eax,-0x18(%rbp)
sub    $0x4,%eax
jb     11a9 <is_branch+0x99>
jmp    1195 <is_branch+0x85>
mov    -0x18(%rbp),%eax
add    $0xfffffff0,%eax
sub    $0x3,%eax
ja     11c8 <is_branch+0xb8>
jmp    11a9 <is_branch+0x99>
mov    -0x8(%rbp),%edi
call   1030 <se16@plt>
mov    %eax,%ecx
add    $0x1,%ecx
mov    -0x10(%rbp),%rax
mov    %ecx,(%rax)
movl   $0x1,-0x4(%rbp)
jmp    11db <is_branch+0xcb>
movl   $0x0,-0x4(%rbp)
jmp    11db <is_branch+0xcb>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<is_branch>:
push   %rbx
mov    %edi,%ecx
sar    $0x1a,%ecx
xor    %eax,%eax
cmp    $0x17,%ecx
ja     1139 <is_branch+0x29>
mov    %rsi,%rbx
mov    $0xf000f0,%edx
bt     %ecx,%edx
jae    113b <is_branch+0x2b>
call   1030 <se16@plt>
add    $0x1,%eax
mov    %eax,(%rbx)
mov    $0x1,%eax
pop    %rbx
ret
cmp    $0x1,%ecx
jne    1139 <is_branch+0x29>
mov    %edi,%ecx
shr    $0x10,%ecx
and    $0x1f,%ecx
cmp    $0x13,%ecx
ja     1139 <is_branch+0x29>
mov    $0xf000f,%edx
bt     %ecx,%edx
jb     112a <is_branch+0x1a>
jmp    1139 <is_branch+0x29>

LLVM IR (-O0):
define i32 @is_branch(i32 %0, i32* %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32*
store i32 %0, i32* %4
store i32* %1, i32** %5
%6 = load i32, i32* %4
%7 = ashr i32 %6, 26
switch i32 %7, label %23 [
i32 4, label %8
i32 20, label %8
i32 5, label %8
i32 21, label %8
i32 7, label %8
i32 23, label %8
i32 6, label %8
i32 22, label %8
i32 1, label %13
]
8: ; preds = %2, %2, %2, %2, %2, %2, %2, %2
%9 = load i32, i32* %4
%10 = call i32 @se16(i32 %9)
%11 = add nsw i32 %10, 1
%12 = load i32*, i32** %5
store i32 %11, i32* %12
store i32 1, i32* %3
br label %24
13: ; preds = %2
%14 = load i32, i32* %4
%15 = ashr i32 %14, 16
%16 = and i32 %15, 31
switch i32 %16, label %22 [
i32 1, label %17
i32 3, label %17
i32 17, label %17
i32 19, label %17
i32 0, label %17
i32 2, label %17
i32 16, label %17
i32 18, label %17
]
17: ; preds = %13, %13, %13, %13, %13, %13, %13, %13
%18 = load i32, i32* %4
%19 = call i32 @se16(i32 %18)
%20 = add nsw i32 %19, 1
%21 = load i32*, i32** %5
store i32 %20, i32* %21
store i32 1, i32* %3
br label %24
22: ; preds = %13
store i32 0, i32* %3
br label %24
23: ; preds = %2
store i32 0, i32* %3
br label %24
24: ; preds = %23, %22, %17, %8
%25 = load i32, i32* %3
ret i32 %25
}

LLVM IR (-O2):
define i32 @is_branch(i32 %0, i32* nocapture writeonly %1) {
%3 = ashr i32 %0, 26
switch i32 %3, label %10 [
i32 4, label %7
i32 20, label %7
i32 5, label %7
i32 21, label %7
i32 7, label %7
i32 23, label %7
i32 6, label %7
i32 22, label %7
i32 1, label %4
]
4: ; preds = %2
%5 = lshr i32 %0, 16
%6 = and i32 %5, 31
switch i32 %6, label %10 [
i32 1, label %7
i32 3, label %7
i32 17, label %7
i32 19, label %7
i32 0, label %7
i32 2, label %7
i32 16, label %7
i32 18, label %7
]
7: ; preds = %4, %4, %4, %4, %4, %4, %4, %4, %2, %2, %2, %2, %2, %2, %2, %2
%8 = tail call i32 @se16(i32 %0)
%9 = add nsw i32 %8, 1
store i32 %9, i32* %1
br label %10
10: ; preds = %7, %2, %4
%11 = phi i32 [ 0, %4 ], [ 0, %2 ], [ 1, %7 ]
ret i32 %11
}