#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 COUNT(int *c, int op_32) {
  if ((uintptr_t)c <= 10000)
    return (int)(uintptr_t)c;
  if (((uintptr_t)c & ~0xffff) == (-1 & ~0xffff)) {
    if (op_32 & 0x100)
      return ((uintptr_t)c >> 8) & 0xff;
    return (uintptr_t)c & 0xff;
  }
  return *c;
}


x86 assembly (clang, -O0):
<COUNT>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
mov    -0x10(%rbp),%rax
cmp    $0x2710,%rax
ja     1127 <COUNT+0x27>
mov    -0x10(%rbp),%rax
mov    %eax,-0x4(%rbp)
jmp    117f <COUNT+0x7f>
mov    -0x10(%rbp),%rax
and    $0xffffffffffff0000,%rax
cmp    $0xffffffffffff0000,%rax
jne    1176 <COUNT+0x76>
mov    -0x14(%rbp),%eax
and    $0x100,%eax
cmp    $0x0,%eax
je     1164 <COUNT+0x64>
mov    -0x10(%rbp),%rax
shr    $0x8,%rax
and    $0xff,%rax
mov    %eax,-0x4(%rbp)
jmp    117f <COUNT+0x7f>
mov    -0x10(%rbp),%rax
and    $0xff,%rax
mov    %eax,-0x4(%rbp)
jmp    117f <COUNT+0x7f>
mov    -0x10(%rbp),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<COUNT>:
mov    %rdi,%rax
cmp    $0x2710,%rdi
jbe    1122 <COUNT+0x22>
cmp    $0xffffffffffff0000,%rax
jb     1120 <COUNT+0x20>
test   $0x100,%esi
jne    1123 <COUNT+0x23>
movzbl %al,%eax
ret
mov    (%rax),%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 = ptrtoint i32* %6 to i64
%8 = icmp ule i64 %7, 10000
br i1 %8, label %9, label %13
9: ; preds = %2
%10 = load i32*, i32** %4
%11 = ptrtoint i32* %10 to i64
%12 = trunc i64 %11 to i32
store i32 %12, i32* %3
br label %36
13: ; preds = %2
%14 = load i32*, i32** %4
%15 = ptrtoint i32* %14 to i64
%16 = and i64 %15, -65536
%17 = icmp eq i64 %16, -65536
br i1 %17, label %18, label %33
18: ; preds = %13
%19 = load i32, i32* %5
%20 = and i32 %19, 256
%21 = icmp ne i32 %20, 0
br i1 %21, label %22, label %28
22: ; preds = %18
%23 = load i32*, i32** %4
%24 = ptrtoint i32* %23 to i64
%25 = lshr i64 %24, 8
%26 = and i64 %25, 255
%27 = trunc i64 %26 to i32
store i32 %27, i32* %3
br label %36
28: ; preds = %18
%29 = load i32*, i32** %4
%30 = ptrtoint i32* %29 to i64
%31 = and i64 %30, 255
%32 = trunc i64 %31 to i32
store i32 %32, i32* %3
br label %36
33: ; preds = %13
%34 = load i32*, i32** %4
%35 = load i32, i32* %34
store i32 %35, i32* %3
br label %36
36: ; preds = %33, %28, %22, %9
%37 = load i32, i32* %3
ret i32 %37
}

LLVM IR (-O2):
define i32 @COUNT(i32* %0, i32 %1) {
%3 = ptrtoint i32* %0 to i64
%4 = icmp ult i32* %0, inttoptr (i64 10001 to i32*)
br i1 %4, label %5, label %7
5: ; preds = %2
%6 = trunc i64 %3 to i32
br label %20
7: ; preds = %2
%8 = icmp ugt i32* %0, inttoptr (i64 -65537 to i32*)
br i1 %8, label %9, label %18
9: ; preds = %7
%10 = and i32 %1, 256
%11 = icmp eq i32 %10, 0
%12 = trunc i64 %3 to i32
br i1 %11, label %16, label %13
13: ; preds = %9
%14 = lshr i32 %12, 8
%15 = and i32 %14, 255
br label %20
16: ; preds = %9
%17 = and i32 %12, 255
br label %20
18: ; preds = %7
%19 = load i32, i32* %0
br label %20
20: ; preds = %18, %16, %13, %5
%21 = phi i32 [ %6, %5 ], [ %15, %13 ], [ %17, %16 ], [ %19, %18 ]
ret i32 %21
}