#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 uint16_t;

/* Variables and functions */
uint16_t vc4_get_instruction_length(uint16_t b0) {
  if ((b0 & 0x8000) == 0)
    return 1;
  else if ((b0 & 0x4000) == 0)
    return 2;
  else if ((b0 & 0x2000) == 0)
    return 2;
  else if ((b0 & 0x1000) == 0)
    return 3;
  else if ((b0 & 0x0800) == 0)
    return 3;
  else
    return 5;
}


x86 assembly (clang, -O0):
<vc4_get_instruction_length>:
push   %rbp
mov    %rsp,%rbp
mov    %edi,-0x8(%rbp)
mov    -0x8(%rbp),%eax
and    $0x8000,%eax
cmp    $0x0,%eax
jne    1124 <vc4_get_instruction_length+0x24>
movl   $0x1,-0x4(%rbp)
jmp    119f <vc4_get_instruction_length+0x9f>
mov    -0x8(%rbp),%eax
and    $0x4000,%eax
cmp    $0x0,%eax
jne    1141 <vc4_get_instruction_length+0x41>
movl   $0x2,-0x4(%rbp)
jmp    119f <vc4_get_instruction_length+0x9f>
mov    -0x8(%rbp),%eax
and    $0x2000,%eax
cmp    $0x0,%eax
jne    115e <vc4_get_instruction_length+0x5e>
movl   $0x2,-0x4(%rbp)
jmp    119f <vc4_get_instruction_length+0x9f>
mov    -0x8(%rbp),%eax
and    $0x1000,%eax
cmp    $0x0,%eax
jne    117b <vc4_get_instruction_length+0x7b>
movl   $0x3,-0x4(%rbp)
jmp    119f <vc4_get_instruction_length+0x9f>
mov    -0x8(%rbp),%eax
and    $0x800,%eax
cmp    $0x0,%eax
jne    1198 <vc4_get_instruction_length+0x98>
movl   $0x3,-0x4(%rbp)
jmp    119f <vc4_get_instruction_length+0x9f>
movl   $0x5,-0x4(%rbp)
mov    -0x4(%rbp),%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<vc4_get_instruction_length>:
mov    $0x1,%eax
test   $0x8000,%edi
je     1136 <vc4_get_instruction_length+0x36>
mov    %edi,%ecx
not    %ecx
mov    $0x2,%eax
test   $0x6000,%ecx
jne    1136 <vc4_get_instruction_length+0x36>
mov    $0x3,%eax
test   $0x1000,%edi
je     1136 <vc4_get_instruction_length+0x36>
shr    $0xa,%edi
and    $0x2,%edi
add    $0x3,%edi
mov    %edi,%eax
ret

LLVM IR (-O0):
define i32 @vc4_get_instruction_length(i32 %0) {
%2 = alloca i32
%3 = alloca i32
store i32 %0, i32* %3
%4 = load i32, i32* %3
%5 = and i32 %4, 32768
%6 = icmp eq i32 %5, 0
br i1 %6, label %7, label %8
7: ; preds = %1
store i32 1, i32* %2
br label %29
8: ; preds = %1
%9 = load i32, i32* %3
%10 = and i32 %9, 16384
%11 = icmp eq i32 %10, 0
br i1 %11, label %12, label %13
12: ; preds = %8
store i32 2, i32* %2
br label %29
13: ; preds = %8
%14 = load i32, i32* %3
%15 = and i32 %14, 8192
%16 = icmp eq i32 %15, 0
br i1 %16, label %17, label %18
17: ; preds = %13
store i32 2, i32* %2
br label %29
18: ; preds = %13
%19 = load i32, i32* %3
%20 = and i32 %19, 4096
%21 = icmp eq i32 %20, 0
br i1 %21, label %22, label %23
22: ; preds = %18
store i32 3, i32* %2
br label %29
23: ; preds = %18
%24 = load i32, i32* %3
%25 = and i32 %24, 2048
%26 = icmp eq i32 %25, 0
br i1 %26, label %27, label %28
27: ; preds = %23
store i32 3, i32* %2
br label %29
28: ; preds = %23
store i32 5, i32* %2
br label %29
29: ; preds = %28, %27, %22, %17, %12, %7
%30 = load i32, i32* %2
ret i32 %30
}

LLVM IR (-O2):
define i32 @vc4_get_instruction_length(i32 %0) {
%2 = and i32 %0, 32768
%3 = icmp eq i32 %2, 0
br i1 %3, label %14, label %4
4: ; preds = %1
%5 = and i32 %0, 24576
%6 = icmp eq i32 %5, 24576
br i1 %6, label %7, label %14
7: ; preds = %4
%8 = and i32 %0, 4096
%9 = icmp eq i32 %8, 0
br i1 %9, label %14, label %10
10: ; preds = %7
%11 = and i32 %0, 2048
%12 = icmp eq i32 %11, 0
%13 = select i1 %12, i32 3, i32 5
br label %14
14: ; preds = %10, %7, %4, %1
%15 = phi i32 [ 1, %1 ], [ 2, %4 ], [ 3, %7 ], [ %13, %10 ]
ret i32 %15
}