#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 */
size_t rnd();
size_t randomSizeAligned(unsigned long i) {
  size_t maxSize = 2 * 160 * 0x2000;
  return (((rnd() % ((((maxSize >> (i / 10))) > (2)) ? ((maxSize >> (i / 10)))
                                                     : (2)) +
            1) +
           (8) - 1) &
          ~((size_t)(8) - 1));
}


x86 assembly (clang, -O0):
<randomSizeAligned>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
movq   $0x280000,-0x10(%rbp)
mov    $0x0,%al
call   1030 <rnd@plt>
mov    %rax,-0x20(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x18(%rbp)
mov    -0x8(%rbp),%rax
mov    $0xa,%ecx
xor    %edx,%edx
div    %rcx
mov    %rax,%rcx
mov    -0x18(%rbp),%rax
shr    %cl,%rax
cmp    $0x2,%rax
jbe    1182 <randomSizeAligned+0x72>
mov    -0x10(%rbp),%rax
mov    %rax,-0x30(%rbp)
mov    -0x8(%rbp),%rax
mov    $0xa,%ecx
xor    %edx,%edx
div    %rcx
mov    %rax,%rcx
mov    -0x30(%rbp),%rax
shr    %cl,%rax
mov    %rax,-0x28(%rbp)
jmp    1190 <randomSizeAligned+0x80>
mov    $0x2,%eax
mov    %rax,-0x28(%rbp)
jmp    1190 <randomSizeAligned+0x80>
mov    -0x20(%rbp),%rax
mov    -0x28(%rbp),%rcx
xor    %edx,%edx
div    %rcx
mov    %rdx,%rax
add    $0x1,%rax
add    $0x8,%rax
sub    $0x1,%rax
and    $0xfffffffffffffff8,%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<randomSizeAligned>:
push   %rbx
mov    %rdi,%rbx
xor    %eax,%eax
call   1030 <rnd@plt>
mov    %rax,%rsi
movabs $0xcccccccccccccccd,%rcx
cc cc cc
mov    %rbx,%rax
mul    %rcx
mov    %rdx,%rcx
shr    $0x3,%rcx
mov    $0x280000,%eax
shr    %cl,%rax
cmp    $0x3,%rax
mov    $0x2,%ecx
cmovae %rax,%rcx
mov    %rsi,%rax
shr    $0x20,%rax
je     1160 <randomSizeAligned+0x50>
mov    %rsi,%rax
xor    %edx,%edx
div    %rcx
mov    %rdx,%rax
jmp    1168 <randomSizeAligned+0x58>
mov    %esi,%eax
xor    %edx,%edx
div    %ecx
mov    %edx,%eax
add    $0x8,%eax
and    $0x7ffff8,%eax
pop    %rbx
ret

LLVM IR (-O0):
define i64 @randomSizeAligned(i64 %0) {
%2 = alloca i64
%3 = alloca i64
store i64 %0, i64* %2
store i64 2621440, i64* %3
%4 = call i64 (...) @rnd()
%5 = load i64, i64* %3
%6 = load i64, i64* %2
%7 = udiv i64 %6, 10
%8 = lshr i64 %5, %7
%9 = icmp ugt i64 %8, 2
br i1 %9, label %10, label %15
10: ; preds = %1
%11 = load i64, i64* %3
%12 = load i64, i64* %2
%13 = udiv i64 %12, 10
%14 = lshr i64 %11, %13
br label %16
15: ; preds = %1
br label %16
16: ; preds = %15, %10
%17 = phi i64 [ %14, %10 ], [ 2, %15 ]
%18 = urem i64 %4, %17
%19 = add i64 %18, 1
%20 = add i64 %19, 8
%21 = sub i64 %20, 1
%22 = and i64 %21, -8
ret i64 %22
}

LLVM IR (-O2):
define i64 @randomSizeAligned(i64 %0) {
%2 = tail call i64 (...) @rnd()
%3 = udiv i64 %0, 10
%4 = lshr i64 2621440, %3
%5 = icmp ugt i64 %4, 2
%6 = select i1 %5, i64 %4, i64 2
%7 = urem i64 %2, %6
%8 = add nuw nsw i64 %7, 8
%9 = and i64 %8, 8388600
ret i64 %9
}