#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 COUNT(uint32_t c, int op_32) {
  if (c & (1 << 31)) {
    if (op_32 & 0x100)
      return ((uintptr_t)c >> 8) & 0xff;
    return (uintptr_t)c & 0xff;
  }
  if (!(c & (3 << 29)))
    return c & 0xffff;
  return c & ((1 << 7) - 1);
}


x86 assembly (clang, -O0):
<COUNT>:
push   %rbp
mov    %rsp,%rbp
mov    %edi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    -0x8(%rbp),%eax
and    $0x80000000,%eax
cmp    $0x0,%eax
je     1154 <COUNT+0x54>
mov    -0xc(%rbp),%eax
and    $0x100,%eax
cmp    $0x0,%eax
je     1142 <COUNT+0x42>
movslq -0x8(%rbp),%rax
shr    $0x8,%rax
and    $0xff,%rax
mov    %eax,-0x4(%rbp)
jmp    117e <COUNT+0x7e>
movslq -0x8(%rbp),%rax
and    $0xff,%rax
mov    %eax,-0x4(%rbp)
jmp    117e <COUNT+0x7e>
mov    -0x8(%rbp),%eax
and    $0x60000000,%eax
cmp    $0x0,%eax
jne    1175 <COUNT+0x75>
mov    -0x8(%rbp),%eax
and    $0xffff,%eax
mov    %eax,-0x4(%rbp)
jmp    117e <COUNT+0x7e>
mov    -0x8(%rbp),%eax
and    $0x7f,%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<COUNT>:
mov    %edi,%eax
test   %edi,%edi
js     1111 <COUNT+0x11>
test   $0x60000000,%eax
je     111d <COUNT+0x1d>
and    $0x7f,%eax
ret
test   $0x100,%esi
jne    1121 <COUNT+0x21>
movzbl %al,%eax
ret
movzwl %ax,%eax
ret
movzbl %ah,%eax
ret

LLVM IR (-O0):
define i32 @COUNT(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 = and i32 %6, -2147483648
%8 = icmp ne i32 %7, 0
br i1 %8, label %9, label %24
9: ; preds = %2
%10 = load i32, i32* %5
%11 = and i32 %10, 256
%12 = icmp ne i32 %11, 0
br i1 %12, label %13, label %19
13: ; preds = %9
%14 = load i32, i32* %4
%15 = sext i32 %14 to i64
%16 = lshr i64 %15, 8
%17 = and i64 %16, 255
%18 = trunc i64 %17 to i32
store i32 %18, i32* %3
br label %34
19: ; preds = %9
%20 = load i32, i32* %4
%21 = sext i32 %20 to i64
%22 = and i64 %21, 255
%23 = trunc i64 %22 to i32
store i32 %23, i32* %3
br label %34
24: ; preds = %2
%25 = load i32, i32* %4
%26 = and i32 %25, 1610612736
%27 = icmp ne i32 %26, 0
br i1 %27, label %31, label %28
28: ; preds = %24
%29 = load i32, i32* %4
%30 = and i32 %29, 65535
store i32 %30, i32* %3
br label %34
31: ; preds = %24
%32 = load i32, i32* %4
%33 = and i32 %32, 127
store i32 %33, i32* %3
br label %34
34: ; preds = %31, %28, %19, %13
%35 = load i32, i32* %3
ret i32 %35
}

LLVM IR (-O2):
define i32 @COUNT(i32 %0, i32 %1) {
%3 = icmp sgt i32 %0, -1
br i1 %3, label %12, label %4
4: ; preds = %2
%5 = and i32 %1, 256
%6 = icmp eq i32 %5, 0
br i1 %6, label %10, label %7
7: ; preds = %4
%8 = lshr i32 %0, 8
%9 = and i32 %8, 255
br label %19
10: ; preds = %4
%11 = and i32 %0, 255
br label %19
12: ; preds = %2
%13 = and i32 %0, 1610612736
%14 = icmp eq i32 %13, 0
br i1 %14, label %15, label %17
15: ; preds = %12
%16 = and i32 %0, 65535
br label %19
17: ; preds = %12
%18 = and i32 %0, 127
br label %19
19: ; preds = %17, %15, %10, %7
%20 = phi i32 [ %9, %7 ], [ %11, %10 ], [ %18, %17 ], [ %16, %15 ]
ret i32 %20
}