#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*/ printf(char *, int);
int element_size(uint32_t typeword) {
  int m = 0;
  if (typeword & 0x100)
    return 0;
  switch (typeword & 0xFFA00) {
  case 0x800:
  case 0x1000:
  case 0x2000:
    m = 1;
    break;
  case 0x4000:
  case 0x8000:
    m = 2;
    break;
  case 0x10000:
  case 0x20000:
  case 0x40000:
    m = 4;
    break;
  case 0x200:
  case 0x80000:
    m = 8;
    break;
  default:
    printf("Unknown register type 0x%lx\n", typeword & 0xFFA00);
  }
  if (typeword & 0x1)
    m *= 2;
  return m;
}


x86 assembly (clang, -O0):
<element_size>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
mov    -0x8(%rbp),%eax
and    $0x100,%eax
cmp    $0x0,%eax
je     113f <element_size+0x2f>
movl   $0x0,-0x4(%rbp)
jmp    1268 <element_size+0x158>
mov    -0x8(%rbp),%eax
and    $0xffa00,%eax
mov    %eax,-0x10(%rbp)
sub    $0x200,%eax
je     1229 <element_size+0x119>
jmp    115a <element_size+0x4a>
mov    -0x10(%rbp),%eax
sub    $0x800,%eax
je     1205 <element_size+0xf5>
jmp    116d <element_size+0x5d>
mov    -0x10(%rbp),%eax
sub    $0x1000,%eax
je     1205 <element_size+0xf5>
jmp    1180 <element_size+0x70>
mov    -0x10(%rbp),%eax
sub    $0x2000,%eax
je     1205 <element_size+0xf5>
jmp    1193 <element_size+0x83>
mov    -0x10(%rbp),%eax
sub    $0x4000,%eax
je     1211 <element_size+0x101>
jmp    11a6 <element_size+0x96>
mov    -0x10(%rbp),%eax
sub    $0x8000,%eax
je     1211 <element_size+0x101>
jmp    11b9 <element_size+0xa9>
mov    -0x10(%rbp),%eax
sub    $0x10000,%eax
je     121d <element_size+0x10d>
jmp    11cc <element_size+0xbc>
mov    -0x10(%rbp),%eax
sub    $0x20000,%eax
je     121d <element_size+0x10d>
jmp    11df <element_size+0xcf>
mov    -0x10(%rbp),%eax
sub    $0x40000,%eax
je     121d <element_size+0x10d>
jmp    11f2 <element_size+0xe2>
mov    -0x10(%rbp),%eax
sub    $0x80000,%eax
je     1229 <element_size+0x119>
jmp    1235 <element_size+0x125>
movl   $0x1,-0xc(%rbp)
jmp    124a <element_size+0x13a>
movl   $0x2,-0xc(%rbp)
jmp    124a <element_size+0x13a>
movl   $0x4,-0xc(%rbp)
jmp    124a <element_size+0x13a>
movl   $0x8,-0xc(%rbp)
jmp    124a <element_size+0x13a>
mov    -0x8(%rbp),%esi
and    $0xffa00,%esi
lea    0xdbb(%rip),%rdi
call   1030 <printf@plt>
mov    -0x8(%rbp),%eax
and    $0x1,%eax
cmp    $0x0,%eax
je     1262 <element_size+0x152>
mov    -0xc(%rbp),%eax
shl    $0x1,%eax
mov    %eax,-0xc(%rbp)
mov    -0xc(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<element_size>:
xor    %eax,%eax
test   $0x100,%edi
jne    11c7 <element_size+0xb7>
push   %rbx
mov    %edi,%ebx
mov    %edi,%esi
and    $0xffa00,%esi
cmp    $0x7fff,%esi
jg     1158 <element_size+0x48>
mov    $0x1,%eax
cmp    $0xfff,%esi
jle    117a <element_size+0x6a>
cmp    $0x1000,%esi
je     11bf <element_size+0xaf>
cmp    $0x2000,%esi
je     11bf <element_size+0xaf>
cmp    $0x4000,%esi
je     11aa <element_size+0x9a>
jmp    11b1 <element_size+0xa1>
cmp    $0x1ffff,%esi
jle    118c <element_size+0x7c>
cmp    $0x20000,%esi
je     119c <element_size+0x8c>
cmp    $0x40000,%esi
je     119c <element_size+0x8c>
cmp    $0x80000,%esi
je     11a3 <element_size+0x93>
jmp    11b1 <element_size+0xa1>
cmp    $0x200,%esi
je     11a3 <element_size+0x93>
cmp    $0x800,%esi
je     11bf <element_size+0xaf>
jmp    11b1 <element_size+0xa1>
cmp    $0x8000,%esi
je     11aa <element_size+0x9a>
cmp    $0x10000,%esi
jne    11b1 <element_size+0xa1>
mov    $0x4,%eax
jmp    11bf <element_size+0xaf>
mov    $0x8,%eax
jmp    11bf <element_size+0xaf>
mov    $0x2,%eax
jmp    11bf <element_size+0xaf>
lea    0xe48(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
and    $0x1,%bl
mov    %ebx,%ecx
shl    %cl,%eax
pop    %rbx
ret

LLVM IR (-O0):
@.str = [29 x i8] c"Unknown register type 0x%lx\0A\00"
define i32 @element_size(i32 %0) {
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
store i32 %0, i32* %3
store i32 0, i32* %4
%5 = load i32, i32* %3
%6 = and i32 %5, 256
%7 = icmp ne i32 %6, 0
br i1 %7, label %8, label %9
8: ; preds = %1
store i32 0, i32* %2
br label %29
9: ; preds = %1
%10 = load i32, i32* %3
%11 = and i32 %10, 1047040
switch i32 %11, label %16 [
i32 2048, label %12
i32 4096, label %12
i32 8192, label %12
i32 16384, label %13
i32 32768, label %13
i32 65536, label %14
i32 131072, label %14
i32 262144, label %14
i32 512, label %15
i32 524288, label %15
]
12: ; preds = %9, %9, %9
store i32 1, i32* %4
br label %20
13: ; preds = %9, %9
store i32 2, i32* %4
br label %20
14: ; preds = %9, %9, %9
store i32 4, i32* %4
br label %20
15: ; preds = %9, %9
store i32 8, i32* %4
br label %20
16: ; preds = %9
%17 = load i32, i32* %3
%18 = and i32 %17, 1047040
%19 = call i32 @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str, i64 0, i64 0), i32 %18)
br label %20
20: ; preds = %16, %15, %14, %13, %12
%21 = load i32, i32* %3
%22 = and i32 %21, 1
%23 = icmp ne i32 %22, 0
br i1 %23, label %24, label %27
24: ; preds = %20
%25 = load i32, i32* %4
%26 = mul nsw i32 %25, 2
store i32 %26, i32* %4
br label %27
27: ; preds = %24, %20
%28 = load i32, i32* %4
store i32 %28, i32* %2
br label %29
29: ; preds = %27, %8
%30 = load i32, i32* %2
ret i32 %30
}

LLVM IR (-O2):
@.str = [29 x i8] c"Unknown register type 0x%lx\0A\00"
define i32 @element_size(i32 %0) {
%2 = and i32 %0, 256
%3 = icmp eq i32 %2, 0
br i1 %3, label %4, label %15
4: ; preds = %1
%5 = and i32 %0, 1047040
switch i32 %5, label %9 [
i32 2048, label %11
i32 4096, label %11
i32 8192, label %11
i32 16384, label %6
i32 32768, label %6
i32 65536, label %7
i32 131072, label %7
i32 262144, label %7
i32 512, label %8
i32 524288, label %8
]
6: ; preds = %4, %4
br label %11
7: ; preds = %4, %4, %4
br label %11
8: ; preds = %4, %4
br label %11
9: ; preds = %4
%10 = tail call i32 @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str, i64 0, i64 0), i32 %5)
br label %11
11: ; preds = %4, %4, %4, %9, %8, %7, %6
%12 = phi i32 [ 0, %9 ], [ 8, %8 ], [ 4, %7 ], [ 2, %6 ], [ 1, %4 ], [ 1, %4 ], [ 1, %4 ]
%13 = and i32 %0, 1
%14 = shl nuw nsw i32 %12, %13
br label %15
15: ; preds = %1, %11
%16 = phi i32 [ %14, %11 ], [ 0, %1 ]
ret i32 %16
}