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

/* Variables and functions */
short fp_weaponImageCount(int64_t enchant) {
  return (((((7) < (((((int)((enchant) / 3 >> 16)) > (1))
                         ? ((int)((enchant) / 3 >> 16))
                         : (1))))
                ? (7)
                : (((((int)((enchant) / 3 >> 16)) > (1))
                        ? ((int)((enchant) / 3 >> 16))
                        : (1))))));
}


x86 assembly (clang, -O0):
<fp_weaponImageCount>:
push   %rbp
mov    %rsp,%rbp
mov    %edi,-0x4(%rbp)
mov    -0x4(%rbp),%eax
mov    $0x3,%ecx
cltd
idiv   %ecx
sar    $0x10,%eax
cmp    $0x1,%eax
jle    1134 <fp_weaponImageCount+0x34>
mov    -0x4(%rbp),%eax
mov    $0x3,%ecx
cltd
idiv   %ecx
sar    $0x10,%eax
mov    %eax,-0x8(%rbp)
jmp    1141 <fp_weaponImageCount+0x41>
mov    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    1141 <fp_weaponImageCount+0x41>
mov    -0x8(%rbp),%ecx
mov    $0x7,%eax
cmp    %ecx,%eax
jge    115e <fp_weaponImageCount+0x5e>
mov    $0x7,%eax
mov    %eax,-0xc(%rbp)
jmp    119e <fp_weaponImageCount+0x9e>
mov    -0x4(%rbp),%eax
mov    $0x3,%ecx
cltd
idiv   %ecx
sar    $0x10,%eax
cmp    $0x1,%eax
jle    118b <fp_weaponImageCount+0x8b>
mov    -0x4(%rbp),%eax
mov    $0x3,%ecx
cltd
idiv   %ecx
sar    $0x10,%eax
mov    %eax,-0x10(%rbp)
jmp    1198 <fp_weaponImageCount+0x98>
mov    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    1198 <fp_weaponImageCount+0x98>
mov    -0x10(%rbp),%eax
mov    %eax,-0xc(%rbp)
mov    -0xc(%rbp),%eax
cwtl
pop    %rbp
ret

x86 assembly (clang, -O2):
<fp_weaponImageCount>:
movslq %edi,%rax
imul   $0x55555556,%rax,%rcx
mov    %rcx,%rdx
shr    $0x3f,%rdx
shr    $0x20,%rcx
add    %edx,%ecx
shr    $0x10,%ecx
cmp    $0x60000,%eax
mov    $0x1,%edx
cmovge %ecx,%edx
cmp    $0x180000,%eax
mov    $0x7,%eax
cmovl  %edx,%eax
ret

LLVM IR (-O0):
define signext i16 @fp_weaponImageCount(i32 %0) {
%2 = alloca i32
store i32 %0, i32* %2
%3 = load i32, i32* %2
%4 = sdiv i32 %3, 3
%5 = ashr i32 %4, 16
%6 = icmp sgt i32 %5, 1
br i1 %6, label %7, label %11
7: ; preds = %1
%8 = load i32, i32* %2
%9 = sdiv i32 %8, 3
%10 = ashr i32 %9, 16
br label %12
11: ; preds = %1
br label %12
12: ; preds = %11, %7
%13 = phi i32 [ %10, %7 ], [ 1, %11 ]
%14 = icmp slt i32 7, %13
br i1 %14, label %15, label %16
15: ; preds = %12
br label %28
16: ; preds = %12
%17 = load i32, i32* %2
%18 = sdiv i32 %17, 3
%19 = ashr i32 %18, 16
%20 = icmp sgt i32 %19, 1
br i1 %20, label %21, label %25
21: ; preds = %16
%22 = load i32, i32* %2
%23 = sdiv i32 %22, 3
%24 = ashr i32 %23, 16
br label %26
25: ; preds = %16
br label %26
26: ; preds = %25, %21
%27 = phi i32 [ %24, %21 ], [ 1, %25 ]
br label %28
28: ; preds = %26, %15
%29 = phi i32 [ 7, %15 ], [ %27, %26 ]
%30 = trunc i32 %29 to i16
ret i16 %30
}

LLVM IR (-O2):
define signext i16 @fp_weaponImageCount(i32 %0) {
%2 = sdiv i32 %0, 3
%3 = ashr i32 %2, 16
%4 = icmp sgt i32 %0, 393215
%5 = icmp sgt i32 %0, 1572863
%6 = trunc i32 %3 to i16
%7 = select i1 %4, i16 %6, i16 1
%8 = select i1 %5, i16 7, i16 %7
ret i16 %8
}