#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 new_rand();
int *transitionCount(int genomeLength) {
  static int count[0x10000000 / 1000];
  int n = genomeLength / 1000;
  int number = n / 3;
  int i = 0;
  for (i = 0; i < number; i++) {
    int index = new_rand() % n;
    count[i] = index;
  }
  return count;
}


x86 assembly (clang, -O0):
<transitionCount>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    -0x4(%rbp),%eax
mov    $0x3e8,%ecx
cltd
idiv   %ecx
mov    %eax,-0x8(%rbp)
mov    -0x8(%rbp),%eax
mov    $0x3,%ecx
cltd
idiv   %ecx
mov    %eax,-0xc(%rbp)
movl   $0x0,-0x10(%rbp)
movl   $0x0,-0x10(%rbp)
mov    -0x10(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    117e <transitionCount+0x6e>
mov    $0x0,%al
call   1030 <new_rand@plt>
cltd
idivl  -0x8(%rbp)
mov    %edx,-0x14(%rbp)
mov    -0x14(%rbp),%edx
movslq -0x10(%rbp),%rcx
lea    0x2ed3(%rip),%rax
mov    %edx,(%rax,%rcx,4)
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    1145 <transitionCount+0x35>
lea    0x2ebb(%rip),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<transitionCount>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
cmp    $0xbb8,%edi
jl     1178 <transitionCount+0x68>
movslq %edi,%rax
imul   $0x10624dd3,%rax,%r14
mov    %r14,%rax
shr    $0x3f,%rax
sar    $0x26,%r14
add    %eax,%r14d
mov    %edi,%eax
imul   $0x57619f1,%rax,%r12
shr    $0x24,%r12
and    $0xfffffffc,%r12d
lea    0x2ef0(%rip),%r15
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
xor    %eax,%eax
call   1030 <new_rand@plt>
cltd
idiv   %r14d
mov    %edx,(%rbx,%r15,1)
add    $0x4,%rbx
cmp    %rbx,%r12
jne    1160 <transitionCount+0x50>
lea    0x2ec1(%rip),%rax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@transitionCount.count = internal global [268435 x i32] zeroinitializer
define i32* @transitionCount(i32 %0) {
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
store i32 %0, i32* %2
%7 = load i32, i32* %2
%8 = sdiv i32 %7, 1000
store i32 %8, i32* %3
%9 = load i32, i32* %3
%10 = sdiv i32 %9, 3
store i32 %10, i32* %4
store i32 0, i32* %5
store i32 0, i32* %5
br label %11
11: ; preds = %23, %1
%12 = load i32, i32* %5
%13 = load i32, i32* %4
%14 = icmp slt i32 %12, %13
br i1 %14, label %15, label %26
15: ; preds = %11
%16 = call i32 (...) @new_rand()
%17 = load i32, i32* %3
%18 = srem i32 %16, %17
store i32 %18, i32* %6
%19 = load i32, i32* %6
%20 = load i32, i32* %5
%21 = sext i32 %20 to i64
%22 = getelementptr inbounds [268435 x i32], [268435 x i32]* @transitionCount.count, i64 0, i64 %21
store i32 %19, i32* %22
br label %23
23: ; preds = %15
%24 = load i32, i32* %5
%25 = add nsw i32 %24, 1
store i32 %25, i32* %5
br label %11
26: ; preds = %11
ret i32* getelementptr inbounds ([268435 x i32], [268435 x i32]* @transitionCount.count, i64 0, i64 0)
}

LLVM IR (-O2):
@transitionCount.count = internal global [268435 x i32] zeroinitializer
define i32* @transitionCount(i32 %0) {
%2 = sdiv i32 %0, 1000
%3 = icmp sgt i32 %0, 2999
br i1 %3, label %4, label %14
4: ; preds = %1
%5 = udiv i32 %0, 3000
%6 = zext i32 %5 to i64
br label %7
7: ; preds = %4, %7
%8 = phi i64 [ 0, %4 ], [ %12, %7 ]
%9 = tail call i32 (...) @new_rand()
%10 = srem i32 %9, %2
%11 = getelementptr inbounds [268435 x i32], [268435 x i32]* @transitionCount.count, i64 0, i64 %8
store i32 %10, i32* %11
%12 = add nuw nsw i64 %8, 1
%13 = icmp eq i64 %12, %6
br i1 %13, label %14, label %7
14: ; preds = %7, %1
ret i32* getelementptr inbounds ([268435 x i32], [268435 x i32]* @transitionCount.count, i64 0, i64 0)
}