#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 uint8_t;
typedef int uint64_t;
typedef scalar_t__ uint32_t;
typedef int int64_t;

/* Variables and functions */
int get_spc(int, scalar_t__);
uint8_t get_sectors_per_cluster(uint32_t DiskSizeSectors,
                                uint32_t BytesPerSect) {
  uint8_t ret = 0x01;
  uint64_t DiskSizeBytes = (uint64_t)DiskSizeSectors * (uint64_t)BytesPerSect;
  int64_t DiskSizeMB = DiskSizeBytes / (1024 * 1024);
  if (DiskSizeMB > 512)
    ret = get_spc(4, BytesPerSect);
  if (DiskSizeMB > 8192)
    ret = get_spc(8, BytesPerSect);
  if (DiskSizeMB > 16384)
    ret = get_spc(16, BytesPerSect);
  if (DiskSizeMB > 32768)
    ret = get_spc(32, BytesPerSect);
  return (ret);
}


x86 assembly (clang, -O0):
<get_sectors_per_cluster>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x1,-0x14(%rbp)
mov    -0x8(%rbp),%rax
mov    -0x10(%rbp),%rcx
imul   %ecx,%eax
mov    %eax,-0x18(%rbp)
mov    -0x18(%rbp),%eax
mov    $0x100000,%ecx
cltd
idiv   %ecx
mov    %eax,-0x1c(%rbp)
cmpl   $0x200,-0x1c(%rbp)
jle    1161 <get_sectors_per_cluster+0x51>
mov    -0x10(%rbp),%rsi
mov    $0x4,%edi
call   1030 <get_spc@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0x2000,-0x1c(%rbp)
jle    117f <get_sectors_per_cluster+0x6f>
mov    -0x10(%rbp),%rsi
mov    $0x8,%edi
call   1030 <get_spc@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0x4000,-0x1c(%rbp)
jle    119d <get_sectors_per_cluster+0x8d>
mov    -0x10(%rbp),%rsi
mov    $0x10,%edi
call   1030 <get_spc@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0x8000,-0x1c(%rbp)
jle    11bb <get_sectors_per_cluster+0xab>
mov    -0x10(%rbp),%rsi
mov    $0x20,%edi
call   1030 <get_spc@plt>
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_sectors_per_cluster>:
imul   %esi,%edi
cmp    $0x20100000,%edi
jl     1125 <get_sectors_per_cluster+0x15>
mov    $0x4,%edi
jmp    1030 <get_spc@plt>
mov    $0x1,%eax
ret

LLVM IR (-O0):
define i32 @get_sectors_per_cluster(i64 %0, i64 %1) {
%3 = alloca i64
%4 = alloca i64
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
store i64 %0, i64* %3
store i64 %1, i64* %4
store i32 1, i32* %5
%8 = load i64, i64* %3
%9 = trunc i64 %8 to i32
%10 = load i64, i64* %4
%11 = trunc i64 %10 to i32
%12 = mul nsw i32 %9, %11
store i32 %12, i32* %6
%13 = load i32, i32* %6
%14 = sdiv i32 %13, 1048576
store i32 %14, i32* %7
%15 = load i32, i32* %7
%16 = icmp sgt i32 %15, 512
br i1 %16, label %17, label %20
17: ; preds = %2
%18 = load i64, i64* %4
%19 = call i32 @get_spc(i32 4, i64 %18)
store i32 %19, i32* %5
br label %20
20: ; preds = %17, %2
%21 = load i32, i32* %7
%22 = icmp sgt i32 %21, 8192
br i1 %22, label %23, label %26
23: ; preds = %20
%24 = load i64, i64* %4
%25 = call i32 @get_spc(i32 8, i64 %24)
store i32 %25, i32* %5
br label %26
26: ; preds = %23, %20
%27 = load i32, i32* %7
%28 = icmp sgt i32 %27, 16384
br i1 %28, label %29, label %32
29: ; preds = %26
%30 = load i64, i64* %4
%31 = call i32 @get_spc(i32 16, i64 %30)
store i32 %31, i32* %5
br label %32
32: ; preds = %29, %26
%33 = load i32, i32* %7
%34 = icmp sgt i32 %33, 32768
br i1 %34, label %35, label %38
35: ; preds = %32
%36 = load i64, i64* %4
%37 = call i32 @get_spc(i32 32, i64 %36)
store i32 %37, i32* %5
br label %38
38: ; preds = %35, %32
%39 = load i32, i32* %5
ret i32 %39
}

LLVM IR (-O2):
define i32 @get_sectors_per_cluster(i64 %0, i64 %1) {
%3 = trunc i64 %0 to i32
%4 = trunc i64 %1 to i32
%5 = mul nsw i32 %4, %3
%6 = icmp sgt i32 %5, 537919487
br i1 %6, label %7, label %9
7: ; preds = %2
%8 = tail call i32 @get_spc(i32 4, i64 %1)
br label %9
9: ; preds = %2, %7
%10 = phi i32 [ %8, %7 ], [ 1, %2 ]
ret i32 %10
}