#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 */

/* Variables and functions */
int /*<<< orphan*/ assert(int);
void GetParamsForHashChainFindCopy(int quality, int xsize, int cache_bits,
                                   int *window_size, int *iter_pos,
                                   int *iter_limit) {
  const int iter_mult = (quality < 27) ? 1 : 1 + ((quality - 27) >> 4);
  const int iter_neg = -iter_mult * (quality >> 1);
  const int max_window_size = (quality > 50)   ? ((1 << 20) - 120)
                              : (quality > 25) ? (xsize << 8)
                                               : (xsize << 4);
  assert(xsize > 0);
  *window_size = (max_window_size > ((1 << 20) - 120)) ? ((1 << 20) - 120)
                                                       : max_window_size;
  *iter_pos = 8 + (quality >> 3);
  *iter_limit = (cache_bits > 0) ? iter_neg : iter_neg / 2;
}


x86 assembly (clang, -O0):
<GetParamsForHashChainFindCopy>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %edx,-0xc(%rbp)
mov    %rcx,-0x18(%rbp)
mov    %r8,-0x20(%rbp)
mov    %r9,-0x28(%rbp)
cmpl   $0x1b,-0x4(%rbp)
jge    1144 <GetParamsForHashChainFindCopy+0x34>
mov    $0x1,%eax
mov    %eax,-0x38(%rbp)
jmp    1153 <GetParamsForHashChainFindCopy+0x43>
mov    -0x4(%rbp),%eax
sub    $0x1b,%eax
sar    $0x4,%eax
add    $0x1,%eax
mov    %eax,-0x38(%rbp)
mov    -0x38(%rbp),%eax
mov    %eax,-0x2c(%rbp)
xor    %eax,%eax
sub    -0x2c(%rbp),%eax
mov    -0x4(%rbp),%ecx
sar    $0x1,%ecx
imul   %ecx,%eax
mov    %eax,-0x30(%rbp)
cmpl   $0x32,-0x4(%rbp)
jle    1181 <GetParamsForHashChainFindCopy+0x71>
mov    $0xfff88,%eax
mov    %eax,-0x3c(%rbp)
jmp    11a8 <GetParamsForHashChainFindCopy+0x98>
cmpl   $0x19,-0x4(%rbp)
jle    1199 <GetParamsForHashChainFindCopy+0x89>
mov    -0x8(%rbp),%eax
shl    $0x8,%eax
mov    %eax,-0x40(%rbp)
jmp    11a2 <GetParamsForHashChainFindCopy+0x92>
mov    -0x8(%rbp),%eax
shl    $0x4,%eax
mov    %eax,-0x40(%rbp)
mov    -0x40(%rbp),%eax
mov    %eax,-0x3c(%rbp)
mov    -0x3c(%rbp),%eax
mov    %eax,-0x34(%rbp)
cmpl   $0x0,-0x8(%rbp)
setg   %al
and    $0x1,%al
movzbl %al,%edi
call   1030 <assert@plt>
cmpl   $0xfff88,-0x34(%rbp)
jle    11d9 <GetParamsForHashChainFindCopy+0xc9>
mov    $0xfff88,%eax
mov    %eax,-0x44(%rbp)
jmp    11df <GetParamsForHashChainFindCopy+0xcf>
mov    -0x34(%rbp),%eax
mov    %eax,-0x44(%rbp)
mov    -0x44(%rbp),%ecx
mov    -0x18(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x4(%rbp),%ecx
sar    $0x3,%ecx
add    $0x8,%ecx
mov    -0x20(%rbp),%rax
mov    %ecx,(%rax)
cmpl   $0x0,-0xc(%rbp)
jle    120c <GetParamsForHashChainFindCopy+0xfc>
mov    -0x30(%rbp),%eax
mov    %eax,-0x48(%rbp)
jmp    121a <GetParamsForHashChainFindCopy+0x10a>
mov    -0x30(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %eax,-0x48(%rbp)
mov    -0x48(%rbp),%ecx
mov    -0x28(%rbp),%rax
mov    %ecx,(%rax)
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<GetParamsForHashChainFindCopy>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %rcx,0x10(%rsp)
mov    %edi,%ebx
lea    -0x1b(%rbx),%eax
sar    $0x4,%eax
cmp    $0x1b,%edi
not    %eax
mov    $0xffffffff,%ecx
cmovge %eax,%ecx
mov    %edi,%ebp
sar    %ebp
imul   %ecx,%ebp
cmp    $0x1a,%edi
setge  %cl
shl    $0x2,%cl
add    $0x4,%cl
mov    %esi,%r14d
shl    %cl,%r14d
cmp    $0x33,%edi
mov    $0xfff88,%r15d
cmovge %r15d,%r14d
mov    %r9,0x8(%rsp)
mov    %r8,%r12
mov    %edx,%r13d
xor    %edi,%edi
test   %esi,%esi
setg   %dil
call   1030 <assert@plt>
cmp    $0xfff88,%r14d
cmovge %r15d,%r14d
mov    0x10(%rsp),%rax
mov    %r14d,(%rax)
sar    $0x3,%ebx
add    $0x8,%ebx
mov    %ebx,(%r12)
test   %r13d,%r13d
jg     11a3 <GetParamsForHashChainFindCopy+0x93>
mov    %ebp,%eax
shr    $0x1f,%eax
add    %ebp,%eax
sar    %eax
mov    %eax,%ebp
mov    0x8(%rsp),%rax
mov    %ebp,(%rax)
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define void @GetParamsForHashChainFindCopy(i32 %0, i32 %1, i32 %2, i32* %3, i32* %4, i32* %5) {
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32*
%11 = alloca i32*
%12 = alloca i32*
%13 = alloca i32
%14 = alloca i32
%15 = alloca i32
store i32 %0, i32* %7
store i32 %1, i32* %8
store i32 %2, i32* %9
store i32* %3, i32** %10
store i32* %4, i32** %11
store i32* %5, i32** %12
%16 = load i32, i32* %7
%17 = icmp slt i32 %16, 27
br i1 %17, label %18, label %19
18: ; preds = %6
br label %24
19: ; preds = %6
%20 = load i32, i32* %7
%21 = sub nsw i32 %20, 27
%22 = ashr i32 %21, 4
%23 = add nsw i32 1, %22
br label %24
24: ; preds = %19, %18
%25 = phi i32 [ 1, %18 ], [ %23, %19 ]
store i32 %25, i32* %13
%26 = load i32, i32* %13
%27 = sub nsw i32 0, %26
%28 = load i32, i32* %7
%29 = ashr i32 %28, 1
%30 = mul nsw i32 %27, %29
store i32 %30, i32* %14
%31 = load i32, i32* %7
%32 = icmp sgt i32 %31, 50
br i1 %32, label %33, label %34
33: ; preds = %24
br label %45
34: ; preds = %24
%35 = load i32, i32* %7
%36 = icmp sgt i32 %35, 25
br i1 %36, label %37, label %40
37: ; preds = %34
%38 = load i32, i32* %8
%39 = shl i32 %38, 8
br label %43
40: ; preds = %34
%41 = load i32, i32* %8
%42 = shl i32 %41, 4
br label %43
43: ; preds = %40, %37
%44 = phi i32 [ %39, %37 ], [ %42, %40 ]
br label %45
45: ; preds = %43, %33
%46 = phi i32 [ 1048456, %33 ], [ %44, %43 ]
store i32 %46, i32* %15
%47 = load i32, i32* %8
%48 = icmp sgt i32 %47, 0
%49 = zext i1 %48 to i32
%50 = call i32 @assert(i32 %49)
%51 = load i32, i32* %15
%52 = icmp sgt i32 %51, 1048456
br i1 %52, label %53, label %54
53: ; preds = %45
br label %56
54: ; preds = %45
%55 = load i32, i32* %15
br label %56
56: ; preds = %54, %53
%57 = phi i32 [ 1048456, %53 ], [ %55, %54 ]
%58 = load i32*, i32** %10
store i32 %57, i32* %58
%59 = load i32, i32* %7
%60 = ashr i32 %59, 3
%61 = add nsw i32 8, %60
%62 = load i32*, i32** %11
store i32 %61, i32* %62
%63 = load i32, i32* %9
%64 = icmp sgt i32 %63, 0
br i1 %64, label %65, label %67
65: ; preds = %56
%66 = load i32, i32* %14
br label %70
67: ; preds = %56
%68 = load i32, i32* %14
%69 = sdiv i32 %68, 2
br label %70
70: ; preds = %67, %65
%71 = phi i32 [ %66, %65 ], [ %69, %67 ]
%72 = load i32*, i32** %12
store i32 %71, i32* %72
ret void
}

LLVM IR (-O2):
define void @GetParamsForHashChainFindCopy(i32 %0, i32 %1, i32 %2, i32* nocapture writeonly %3, i32* nocapture writeonly %4, i32* nocapture writeonly %5) {
%7 = icmp slt i32 %0, 27
%8 = add nsw i32 %0, -27
%9 = ashr i32 %8, 4
%10 = xor i32 %9, -1
%11 = select i1 %7, i32 -1, i32 %10
%12 = ashr i32 %0, 1
%13 = mul nsw i32 %11, %12
%14 = icmp sgt i32 %0, 50
%15 = icmp sgt i32 %0, 25
%16 = select i1 %15, i32 8, i32 4
%17 = shl i32 %1, %16
%18 = select i1 %14, i32 1048456, i32 %17
%19 = icmp sgt i32 %1, 0
%20 = zext i1 %19 to i32
%21 = tail call i32 @assert(i32 %20)
%22 = icmp slt i32 %18, 1048456
%23 = select i1 %22, i32 %18, i32 1048456
store i32 %23, i32* %3
%24 = ashr i32 %0, 3
%25 = add nsw i32 %24, 8
store i32 %25, i32* %4
%26 = icmp sgt i32 %2, 0
%27 = sdiv i32 %13, 2
%28 = select i1 %26, i32 %13, i32 %27
store i32 %28, i32* %5
ret void
}