#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 __u64;
typedef int __u32;

/* Variables and functions */
__u32 CalcSectors(const __u64 uiSize) {
  __u64 size = uiSize;
  if (!({
        __u32 __rem = size % 63;
        size /= 63;
        __rem;
      }))
    return 63;
  if (!(uiSize % 32))
    return 32;
  if (!(uiSize % 16))
    return 16;
  if (!(uiSize % 8))
    return 8;
  return ~0;
}


x86 assembly (clang, -O0):
<CalcSectors>:
push   %rbp
mov    %rsp,%rbp
mov    %edi,-0x8(%rbp)
mov    -0x8(%rbp),%eax
mov    %eax,-0xc(%rbp)
mov    -0xc(%rbp),%eax
mov    $0x3f,%ecx
cltd
idiv   %ecx
mov    %edx,-0x10(%rbp)
mov    -0xc(%rbp),%eax
mov    $0x3f,%ecx
cltd
idiv   %ecx
mov    %eax,-0xc(%rbp)
mov    -0x10(%rbp),%eax
mov    %eax,-0x14(%rbp)
cmpl   $0x0,-0x14(%rbp)
jne    1145 <CalcSectors+0x45>
movl   $0x3f,-0x4(%rbp)
jmp    11ac <CalcSectors+0xac>
mov    -0x8(%rbp),%eax
mov    $0x20,%ecx
cltd
idiv   %ecx
cmp    $0x0,%edx
jne    1165 <CalcSectors+0x65>
movl   $0x20,-0x4(%rbp)
jmp    11ac <CalcSectors+0xac>
mov    -0x8(%rbp),%eax
mov    $0x10,%ecx
cltd
idiv   %ecx
cmp    $0x0,%edx
jne    1185 <CalcSectors+0x85>
movl   $0x10,-0x4(%rbp)
jmp    11ac <CalcSectors+0xac>
mov    -0x8(%rbp),%eax
mov    $0x8,%ecx
cltd
idiv   %ecx
cmp    $0x0,%edx
jne    11a5 <CalcSectors+0xa5>
movl   $0x8,-0x4(%rbp)
jmp    11ac <CalcSectors+0xac>
movl   $0xffffffff,-0x4(%rbp)
mov    -0x4(%rbp),%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<CalcSectors>:
imul   $0xbefbefbf,%edi,%eax
add    $0x2082082,%eax
cmp    $0x4104105,%eax
jb     1129 <CalcSectors+0x29>
test   $0x1f,%dil
je     112f <CalcSectors+0x2f>
test   $0xf,%dil
je     1135 <CalcSectors+0x35>
and    $0x7,%edi
neg    %edi
sbb    %eax,%eax
or     $0x8,%eax
ret
mov    $0x3f,%eax
ret
mov    $0x20,%eax
ret
mov    $0x10,%eax
ret

LLVM IR (-O0):
define i32 @CalcSectors(i32 %0) {
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
store i32 %0, i32* %3
%7 = load i32, i32* %3
store i32 %7, i32* %4
%8 = load i32, i32* %4
%9 = srem i32 %8, 63
store i32 %9, i32* %5
%10 = load i32, i32* %4
%11 = sdiv i32 %10, 63
store i32 %11, i32* %4
%12 = load i32, i32* %5
store i32 %12, i32* %6
%13 = load i32, i32* %6
%14 = icmp ne i32 %13, 0
br i1 %14, label %16, label %15
15: ; preds = %1
store i32 63, i32* %2
br label %32
16: ; preds = %1
%17 = load i32, i32* %3
%18 = srem i32 %17, 32
%19 = icmp ne i32 %18, 0
br i1 %19, label %21, label %20
20: ; preds = %16
store i32 32, i32* %2
br label %32
21: ; preds = %16
%22 = load i32, i32* %3
%23 = srem i32 %22, 16
%24 = icmp ne i32 %23, 0
br i1 %24, label %26, label %25
25: ; preds = %21
store i32 16, i32* %2
br label %32
26: ; preds = %21
%27 = load i32, i32* %3
%28 = srem i32 %27, 8
%29 = icmp ne i32 %28, 0
br i1 %29, label %31, label %30
30: ; preds = %26
store i32 8, i32* %2
br label %32
31: ; preds = %26
store i32 -1, i32* %2
br label %32
32: ; preds = %31, %30, %25, %20, %15
%33 = load i32, i32* %2
ret i32 %33
}

LLVM IR (-O2):
define i32 @CalcSectors(i32 %0) {
%2 = srem i32 %0, 63
%3 = icmp eq i32 %2, 0
br i1 %3, label %14, label %4
4: ; preds = %1
%5 = and i32 %0, 31
%6 = icmp eq i32 %5, 0
br i1 %6, label %14, label %7
7: ; preds = %4
%8 = and i32 %0, 15
%9 = icmp eq i32 %8, 0
br i1 %9, label %14, label %10
10: ; preds = %7
%11 = and i32 %0, 7
%12 = icmp eq i32 %11, 0
%13 = select i1 %12, i32 8, i32 -1
br label %14
14: ; preds = %10, %7, %4, %1
%15 = phi i32 [ 63, %1 ], [ 32, %4 ], [ 16, %7 ], [ %13, %10 ]
ret i32 %15
}