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

/* Variables and functions */
int /*<<< orphan*/ msg_error(char *);
__attribute__((always_)) int32_t normalize_dzpix(int32_t sum) {
  int count;
  if (sum & 0xc000)
    return 0x8000;
  if (!(sum & 0xffff))
    return 1;
  if (sum == 1)
    return 3;
  for (count = 0x2000; count > 0; count >>= 1) {
    if (sum & count)
      return (count << 1);
  }
  msg_error("normalize_dzpix: invalid codepath taken");
  return 0;
}


x86 assembly (clang, -O0):
<normalize_dzpix>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x8(%rbp)
mov    -0x8(%rbp),%eax
and    $0xc000,%eax
cmp    $0x0,%eax
je     1138 <normalize_dzpix+0x28>
movl   $0x8000,-0x4(%rbp)
jmp    11bf <normalize_dzpix+0xaf>
mov    -0x8(%rbp),%eax
and    $0xffff,%eax
cmp    $0x0,%eax
jne    1155 <normalize_dzpix+0x45>
movl   $0x1,-0x4(%rbp)
jmp    11bf <normalize_dzpix+0xaf>
cmpl   $0x1,-0x8(%rbp)
jne    116b <normalize_dzpix+0x5b>
movl   $0x3,-0x4(%rbp)
jmp    11bf <normalize_dzpix+0xaf>
movl   $0x2000,-0xc(%rbp)
cmpl   $0x0,-0xc(%rbp)
jle    11ac <normalize_dzpix+0x9c>
mov    -0x8(%rbp),%eax
and    -0xc(%rbp),%eax
cmp    $0x0,%eax
je     1199 <normalize_dzpix+0x89>
mov    -0xc(%rbp),%eax
shl    $0x1,%eax
mov    %eax,-0x4(%rbp)
jmp    11bf <normalize_dzpix+0xaf>
jmp    119e <normalize_dzpix+0x8e>
mov    -0xc(%rbp),%eax
sar    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1172 <normalize_dzpix+0x62>
lea    0xe4d(%rip),%rdi
call   1030 <msg_error@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<normalize_dzpix>:
mov    $0x8000,%eax
test   $0xc000,%edi
je     111e <normalize_dzpix+0xe>
ret
test   %di,%di
je     1203 <normalize_dzpix+0xf3>
mov    $0x3,%eax
cmp    $0x1,%edi
je     111d <normalize_dzpix+0xd>
mov    $0x4000,%eax
test   $0x2000,%edi
jne    111d <normalize_dzpix+0xd>
mov    $0x2000,%eax
test   $0x1000,%edi
jne    111d <normalize_dzpix+0xd>
mov    $0x1000,%eax
test   $0x800,%edi
jne    111d <normalize_dzpix+0xd>
mov    $0x800,%eax
test   $0x400,%edi
jne    111d <normalize_dzpix+0xd>
mov    $0x400,%eax
test   $0x200,%edi
jne    111d <normalize_dzpix+0xd>
mov    $0x200,%eax
test   $0x100,%edi
jne    111d <normalize_dzpix+0xd>
mov    $0x100,%eax
test   $0x80,%dil
jne    111d <normalize_dzpix+0xd>
mov    $0x80,%eax
test   $0x40,%dil
jne    111d <normalize_dzpix+0xd>
mov    $0x40,%eax
test   $0x20,%dil
jne    111d <normalize_dzpix+0xd>
mov    $0x20,%eax
test   $0x10,%dil
jne    111d <normalize_dzpix+0xd>
mov    $0x10,%eax
test   $0x8,%dil
jne    111d <normalize_dzpix+0xd>
mov    $0x8,%eax
test   $0x4,%dil
jne    111d <normalize_dzpix+0xd>
mov    $0x4,%eax
test   $0x2,%dil
jne    111d <normalize_dzpix+0xd>
mov    $0x2,%eax
test   $0x1,%dil
jne    111d <normalize_dzpix+0xd>
push   %rax
lea    0xe09(%rip),%rdi
call   1030 <msg_error@plt>
xor    %eax,%eax
add    $0x8,%rsp
ret
mov    $0x1,%eax
ret

LLVM IR (-O0):
@.str = [40 x i8] c"normalize_dzpix: invalid codepath taken\00"
define i32 @normalize_dzpix(i32 %0) {
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
store i32 %0, i32* %3
%5 = load i32, i32* %3
%6 = and i32 %5, 49152
%7 = icmp ne i32 %6, 0
br i1 %7, label %8, label %9
8: ; preds = %1
store i32 32768, i32* %2
br label %36
9: ; preds = %1
%10 = load i32, i32* %3
%11 = and i32 %10, 65535
%12 = icmp ne i32 %11, 0
br i1 %12, label %14, label %13
13: ; preds = %9
store i32 1, i32* %2
br label %36
14: ; preds = %9
%15 = load i32, i32* %3
%16 = icmp eq i32 %15, 1
br i1 %16, label %17, label %18
17: ; preds = %14
store i32 3, i32* %2
br label %36
18: ; preds = %14
store i32 8192, i32* %4
br label %19
19: ; preds = %31, %18
%20 = load i32, i32* %4
%21 = icmp sgt i32 %20, 0
br i1 %21, label %22, label %34
22: ; preds = %19
%23 = load i32, i32* %3
%24 = load i32, i32* %4
%25 = and i32 %23, %24
%26 = icmp ne i32 %25, 0
br i1 %26, label %27, label %30
27: ; preds = %22
%28 = load i32, i32* %4
%29 = shl i32 %28, 1
store i32 %29, i32* %2
br label %36
30: ; preds = %22
br label %31
31: ; preds = %30
%32 = load i32, i32* %4
%33 = ashr i32 %32, 1
store i32 %33, i32* %4
br label %19
34: ; preds = %19
%35 = call i32 @msg_error(i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str, i64 0, i64 0))
store i32 0, i32* %2
br label %36
36: ; preds = %34, %27, %17, %13, %8
%37 = load i32, i32* %2
ret i32 %37
}

LLVM IR (-O2):
@.str = [40 x i8] c"normalize_dzpix: invalid codepath taken\00"
define i32 @normalize_dzpix(i32 %0) {
%2 = and i32 %0, 49152
%3 = icmp eq i32 %2, 0
br i1 %3, label %4, label %53
4: ; preds = %1
%5 = and i32 %0, 65535
%6 = icmp eq i32 %5, 0
br i1 %6, label %53, label %7
7: ; preds = %4
%8 = icmp eq i32 %0, 1
br i1 %8, label %53, label %9
9: ; preds = %7
%10 = and i32 %0, 8192
%11 = icmp eq i32 %10, 0
br i1 %11, label %12, label %53
12: ; preds = %9
%13 = and i32 %0, 4096
%14 = icmp eq i32 %13, 0
br i1 %14, label %15, label %53
15: ; preds = %12
%16 = and i32 %0, 2048
%17 = icmp eq i32 %16, 0
br i1 %17, label %18, label %53
18: ; preds = %15
%19 = and i32 %0, 1024
%20 = icmp eq i32 %19, 0
br i1 %20, label %21, label %53
21: ; preds = %18
%22 = and i32 %0, 512
%23 = icmp eq i32 %22, 0
br i1 %23, label %24, label %53
24: ; preds = %21
%25 = and i32 %0, 256
%26 = icmp eq i32 %25, 0
br i1 %26, label %27, label %53
27: ; preds = %24
%28 = and i32 %0, 128
%29 = icmp eq i32 %28, 0
br i1 %29, label %30, label %53
30: ; preds = %27
%31 = and i32 %0, 64
%32 = icmp eq i32 %31, 0
br i1 %32, label %33, label %53
33: ; preds = %30
%34 = and i32 %0, 32
%35 = icmp eq i32 %34, 0
br i1 %35, label %36, label %53
36: ; preds = %33
%37 = and i32 %0, 16
%38 = icmp eq i32 %37, 0
br i1 %38, label %39, label %53
39: ; preds = %36
%40 = and i32 %0, 8
%41 = icmp eq i32 %40, 0
br i1 %41, label %42, label %53
42: ; preds = %39
%43 = and i32 %0, 4
%44 = icmp eq i32 %43, 0
br i1 %44, label %45, label %53
45: ; preds = %42
%46 = and i32 %0, 2
%47 = icmp eq i32 %46, 0
br i1 %47, label %48, label %53
48: ; preds = %45
%49 = and i32 %0, 1
%50 = icmp eq i32 %49, 0
br i1 %50, label %51, label %53
51: ; preds = %48
%52 = tail call i32 @msg_error(i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str, i64 0, i64 0))
br label %53
53: ; preds = %9, %12, %15, %18, %21, %24, %27, %30, %33, %36, %39, %42, %45, %48, %7, %4, %1, %51
%54 = phi i32 [ 0, %51 ], [ 32768, %1 ], [ 1, %4 ], [ 3, %7 ], [ 16384, %9 ], [ 8192, %12 ], [ 4096, %15 ], [ 2048, %18 ], [ 1024, %21 ], [ 512, %24 ], [ 256, %27 ], [ 128, %30 ], [ 64, %33 ], [ 32, %36 ], [ 16, %39 ], [ 8, %42 ], [ 4, %45 ], [ 2, %48 ]
ret i32 %54
}