#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 unsigned long long uint64_t;

/* Variables and functions */
int /*<<< orphan*/ cpu_has_feature(int);
int /*<<< orphan*/ fatal(char *, unsigned long long);
int COUNT(uint64_t timings, uint64_t deps, int op_32) {
  if ((timings & (4ull << 29)) && !(deps & (1ull << 33)))
    return ((timings & 0xff) - ((timings >> 41) & 0xff));
  if (timings & (1 << 28)) {
    if (op_32 & 0x100)
      return ((uintptr_t)timings >> 8) & 0xff;
    return (uintptr_t)timings & 0xff;
  }
  if (!(timings & (7ull << 29)))
    return timings & 0xffff;
  if ((timings & (7ull << 29)) == (5ull << 29))
    return timings & 0xffff;
  if ((timings & (7ull << 29)) == (6ull << 29))
    return timings & 0xffff;
  if ((timings & (3ull << 29)) && !(timings & (4ull << 29)))
    timings &= 3;
  switch (timings & ((1ull << 7) - 1)) {
  case (0ull << 0):
    return 1;
  case (1ull << 0):
    return 2;
  case (2ull << 0):
    return 3;
  case (3ull << 0):
    return cpu_has_feature((1 << 2)) ? 1 : 2;
  }
  fatal("Illegal COUNT %016llx\n", timings);
  return timings;
}


x86 assembly (clang, -O0):
<COUNT>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %edx,-0x1c(%rbp)
movabs $0x80000000,%rax
and    -0x10(%rbp),%rax
cmp    $0x0,%rax
je     1187 <COUNT+0x67>
movabs $0x200000000,%rax
and    -0x18(%rbp),%rax
cmp    $0x0,%rax
jne    1187 <COUNT+0x67>
mov    -0x10(%rbp),%rax
and    $0xff,%rax
mov    -0x10(%rbp),%rcx
shr    $0x29,%rcx
and    $0xff,%rcx
sub    %rcx,%rax
mov    %eax,-0x4(%rbp)
jmp    131a <COUNT+0x1fa>
mov    -0x10(%rbp),%rax
and    $0x10000000,%rax
cmp    $0x0,%rax
je     11d4 <COUNT+0xb4>
mov    -0x1c(%rbp),%eax
and    $0x100,%eax
cmp    $0x0,%eax
je     11c2 <COUNT+0xa2>
mov    -0x10(%rbp),%rax
shr    $0x8,%rax
and    $0xff,%rax
mov    %eax,-0x4(%rbp)
jmp    131a <COUNT+0x1fa>
mov    -0x10(%rbp),%rax
and    $0xff,%rax
mov    %eax,-0x4(%rbp)
jmp    131a <COUNT+0x1fa>
movabs $0xe0000000,%rax
and    -0x10(%rbp),%rax
cmp    $0x0,%rax
jne    11fe <COUNT+0xde>
mov    -0x10(%rbp),%rax
and    $0xffff,%rax
mov    %eax,-0x4(%rbp)
jmp    131a <COUNT+0x1fa>
movabs $0xe0000000,%rax
and    -0x10(%rbp),%rax
mov    $0xa0000000,%ecx
cmp    %rcx,%rax
jne    122c <COUNT+0x10c>
mov    -0x10(%rbp),%rax
and    $0xffff,%rax
mov    %eax,-0x4(%rbp)
jmp    131a <COUNT+0x1fa>
movabs $0xe0000000,%rax
and    -0x10(%rbp),%rax
mov    $0xc0000000,%ecx
cmp    %rcx,%rax
jne    125a <COUNT+0x13a>
mov    -0x10(%rbp),%rax
and    $0xffff,%rax
mov    %eax,-0x4(%rbp)
jmp    131a <COUNT+0x1fa>
mov    -0x10(%rbp),%rax
and    $0x60000000,%rax
cmp    $0x0,%rax
je     1292 <COUNT+0x172>
movabs $0x80000000,%rax
and    -0x10(%rbp),%rax
cmp    $0x0,%rax
jne    1292 <COUNT+0x172>
mov    -0x10(%rbp),%rax
and    $0x3,%rax
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rax
and    $0x7f,%eax
mov    %rax,-0x28(%rbp)
sub    $0x3,%rax
ja     1303 <COUNT+0x1e3>
mov    -0x28(%rbp),%rax
lea    0xd4e(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
movl   $0x1,-0x4(%rbp)
jmp    131a <COUNT+0x1fa>
movl   $0x2,-0x4(%rbp)
jmp    131a <COUNT+0x1fa>
movl   $0x3,-0x4(%rbp)
jmp    131a <COUNT+0x1fa>
mov    $0x4,%edi
call   1030 <cpu_has_feature@plt>
mov    %eax,%edx
mov    $0x2,%eax
mov    $0x1,%ecx
cmp    $0x0,%edx
cmovne %ecx,%eax
mov    %eax,-0x4(%rbp)
jmp    131a <COUNT+0x1fa>
mov    -0x10(%rbp),%rsi
lea    0xd02(%rip),%rdi
call   1040 <fatal@plt>
mov    -0x10(%rbp),%rax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<COUNT>:
push   %rbx
mov    %rdi,%rax
test   $0x80000000,%eax
je     1148 <COUNT+0x28>
movabs $0x200000000,%rcx
and    %rcx,%rsi
jne    1148 <COUNT+0x28>
movzbl %al,%ebx
shr    $0x29,%rax
movzbl %al,%eax
sub    %eax,%ebx
jmp    1180 <COUNT+0x60>
test   $0x10000000,%eax
jne    1170 <COUNT+0x50>
mov    %eax,%ecx
and    $0xe0000000,%ecx
cmp    $0xa0000000,%ecx
je     116b <COUNT+0x4b>
cmp    $0xc0000000,%ecx
je     116b <COUNT+0x4b>
test   %ecx,%ecx
jne    1184 <COUNT+0x64>
movzwl %ax,%ebx
jmp    1180 <COUNT+0x60>
test   $0x100,%edx
jne    117d <COUNT+0x5d>
movzbl %al,%ebx
jmp    1180 <COUNT+0x60>
movzbl %ah,%ebx
mov    %ebx,%eax
pop    %rbx
ret
mov    %eax,%ebx
and    $0x3,%ebx
test   $0x80000000,%eax
cmovne %rax,%rbx
test   $0x60000000,%eax
cmove  %rax,%rbx
mov    %ebx,%eax
and    $0x7f,%eax
cmp    $0x3,%rax
ja     11c2 <COUNT+0xa2>
mov    $0x1,%ebx
lea    0xe4e(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
mov    $0x2,%ebx
jmp    1180 <COUNT+0x60>
lea    0xe47(%rip),%rdi
mov    %rbx,%rsi
call   1040 <fatal@plt>
jmp    1180 <COUNT+0x60>
mov    $0x3,%ebx
jmp    1180 <COUNT+0x60>
mov    $0x4,%edi
call   1030 <cpu_has_feature@plt>
cmp    $0x1,%eax
mov    $0x1,%ebx
adc    $0x0,%ebx
jmp    1180 <COUNT+0x60>

LLVM IR (-O0):
@.str = [23 x i8] c"Illegal COUNT %016llx\0A\00"
define i32 @COUNT(i64 %0, i64 %1, i32 %2) {
%4 = alloca i32
%5 = alloca i64
%6 = alloca i64
%7 = alloca i32
store i64 %0, i64* %5
store i64 %1, i64* %6
store i32 %2, i32* %7
%8 = load i64, i64* %5
%9 = and i64 %8, 2147483648
%10 = icmp ne i64 %9, 0
br i1 %10, label %11, label %23
11: ; preds = %3
%12 = load i64, i64* %6
%13 = and i64 %12, 8589934592
%14 = icmp ne i64 %13, 0
br i1 %14, label %23, label %15
15: ; preds = %11
%16 = load i64, i64* %5
%17 = and i64 %16, 255
%18 = load i64, i64* %5
%19 = lshr i64 %18, 41
%20 = and i64 %19, 255
%21 = sub i64 %17, %20
%22 = trunc i64 %21 to i32
store i32 %22, i32* %4
br label %91
23: ; preds = %11, %3
%24 = load i64, i64* %5
%25 = and i64 %24, 268435456
%26 = icmp ne i64 %25, 0
br i1 %26, label %27, label %40
27: ; preds = %23
%28 = load i32, i32* %7
%29 = and i32 %28, 256
%30 = icmp ne i32 %29, 0
br i1 %30, label %31, label %36
31: ; preds = %27
%32 = load i64, i64* %5
%33 = lshr i64 %32, 8
%34 = and i64 %33, 255
%35 = trunc i64 %34 to i32
store i32 %35, i32* %4
br label %91
36: ; preds = %27
%37 = load i64, i64* %5
%38 = and i64 %37, 255
%39 = trunc i64 %38 to i32
store i32 %39, i32* %4
br label %91
40: ; preds = %23
%41 = load i64, i64* %5
%42 = and i64 %41, 3758096384
%43 = icmp ne i64 %42, 0
br i1 %43, label %48, label %44
44: ; preds = %40
%45 = load i64, i64* %5
%46 = and i64 %45, 65535
%47 = trunc i64 %46 to i32
store i32 %47, i32* %4
br label %91
48: ; preds = %40
%49 = load i64, i64* %5
%50 = and i64 %49, 3758096384
%51 = icmp eq i64 %50, 2684354560
br i1 %51, label %52, label %56
52: ; preds = %48
%53 = load i64, i64* %5
%54 = and i64 %53, 65535
%55 = trunc i64 %54 to i32
store i32 %55, i32* %4
br label %91
56: ; preds = %48
%57 = load i64, i64* %5
%58 = and i64 %57, 3758096384
%59 = icmp eq i64 %58, 3221225472
br i1 %59, label %60, label %64
60: ; preds = %56
%61 = load i64, i64* %5
%62 = and i64 %61, 65535
%63 = trunc i64 %62 to i32
store i32 %63, i32* %4
br label %91
64: ; preds = %56
%65 = load i64, i64* %5
%66 = and i64 %65, 1610612736
%67 = icmp ne i64 %66, 0
br i1 %67, label %68, label %75
68: ; preds = %64
%69 = load i64, i64* %5
%70 = and i64 %69, 2147483648
%71 = icmp ne i64 %70, 0
br i1 %71, label %75, label %72
72: ; preds = %68
%73 = load i64, i64* %5
%74 = and i64 %73, 3
store i64 %74, i64* %5
br label %75
75: ; preds = %72, %68, %64
%76 = load i64, i64* %5
%77 = and i64 %76, 127
switch i64 %77, label %86 [
i64 0, label %78
i64 1, label %79
i64 2, label %80
i64 3, label %81
]
78: ; preds = %75
store i32 1, i32* %4
br label %91
79: ; preds = %75
store i32 2, i32* %4
br label %91
80: ; preds = %75
store i32 3, i32* %4
br label %91
81: ; preds = %75
%82 = call i32 @cpu_has_feature(i32 4)
%83 = icmp ne i32 %82, 0
%84 = zext i1 %83 to i64
%85 = select i1 %83, i32 1, i32 2
store i32 %85, i32* %4
br label %91
86: ; preds = %75
%87 = load i64, i64* %5
%88 = call i32 @fatal(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0), i64 %87)
%89 = load i64, i64* %5
%90 = trunc i64 %89 to i32
store i32 %90, i32* %4
br label %91
91: ; preds = %86, %81, %80, %79, %78, %60, %52, %44, %36, %31, %15
%92 = load i32, i32* %4
ret i32 %92
}

LLVM IR (-O2):
@.str = [23 x i8] c"Illegal COUNT %016llx\0A\00"
define i32 @COUNT(i64 %0, i64 %1, i32 %2) {
%4 = and i64 %0, 2147483648
%5 = icmp eq i64 %4, 0
%6 = and i64 %1, 8589934592
%7 = icmp ne i64 %6, 0
%8 = or i1 %5, %7
br i1 %8, label %15, label %9
9: ; preds = %3
%10 = and i64 %0, 255
%11 = lshr i64 %0, 41
%12 = and i64 %11, 255
%13 = sub nsw i64 %10, %12
%14 = trunc i64 %13 to i32
br label %52
15: ; preds = %3
%16 = and i64 %0, 268435456
%17 = icmp eq i64 %16, 0
br i1 %17, label %27, label %18
18: ; preds = %15
%19 = and i32 %2, 256
%20 = icmp eq i32 %19, 0
%21 = trunc i64 %0 to i32
br i1 %20, label %25, label %22
22: ; preds = %18
%23 = lshr i32 %21, 8
%24 = and i32 %23, 255
br label %52
25: ; preds = %18
%26 = and i32 %21, 255
br label %52
27: ; preds = %15
%28 = trunc i64 %0 to i32
%29 = and i32 %28, -536870912
switch i32 %29, label %36 [
i32 0, label %30
i32 -1610612736, label %32
i32 -1073741824, label %34
]
30: ; preds = %27
%31 = and i32 %28, 65535
br label %52
32: ; preds = %27
%33 = and i32 %28, 65535
br label %52
34: ; preds = %27
%35 = and i32 %28, 65535
br label %52
36: ; preds = %27
%37 = and i64 %0, 1610612736
%38 = icmp eq i64 %37, 0
%39 = and i64 %0, 3
%40 = select i1 %5, i64 %39, i64 %0
%41 = select i1 %38, i64 %0, i64 %40
%42 = and i64 %41, 127
switch i64 %42, label %49 [
i64 0, label %52
i64 1, label %43
i64 2, label %44
i64 3, label %45
]
43: ; preds = %36
br label %52
44: ; preds = %36
br label %52
45: ; preds = %36
%46 = tail call i32 @cpu_has_feature(i32 4)
%47 = icmp eq i32 %46, 0
%48 = select i1 %47, i32 2, i32 1
br label %52
49: ; preds = %36
%50 = tail call i32 @fatal(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0), i64 %41)
%51 = trunc i64 %41 to i32
br label %52
52: ; preds = %36, %49, %45, %44, %43, %34, %32, %30, %25, %22, %9
%53 = phi i32 [ %24, %22 ], [ %26, %25 ], [ %33, %32 ], [ %35, %34 ], [ %51, %49 ], [ %48, %45 ], [ 3, %44 ], [ 2, %43 ], [ %31, %30 ], [ %14, %9 ], [ 1, %36 ]
ret i32 %53
}