#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 size_t uint32_t;

/* Variables and functions */
size_t *malloc(size_t);
size_t rand();
uint32_t *create_search_targets(size_t count, size_t max) {
  uint32_t *targets = malloc(count * sizeof(*targets));
  for (size_t i = 0; i < count; i++)
    targets[i] = rand() % max;
  return targets;
}


x86 assembly (clang, -O0):
<create_search_targets>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%rdi
shl    $0x3,%rdi
call   1030 <malloc@plt>
mov    %rax,-0x18(%rbp)
movq   $0x0,-0x20(%rbp)
mov    -0x20(%rbp),%rax
cmp    -0x8(%rbp),%rax
jae    1183 <create_search_targets+0x63>
mov    $0x0,%al
call   1040 <rand@plt>
xor    %ecx,%ecx
mov    %ecx,%edx
divq   -0x10(%rbp)
mov    -0x18(%rbp),%rax
mov    -0x20(%rbp),%rcx
mov    %rdx,(%rax,%rcx,8)
mov    -0x20(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x20(%rbp)
jmp    1149 <create_search_targets+0x29>
mov    -0x18(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<create_search_targets>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    %rsi,%r12
mov    %rdi,%r14
lea    0x0(,%rdi,8),%rdi
call   1030 <malloc@plt>
mov    %rax,%r15
test   %r14,%r14
je     117c <create_search_targets+0x5c>
xor    %ebx,%ebx
jmp    1162 <create_search_targets+0x42>
nopw   0x0(%rax,%rax,1)
xor    %edx,%edx
div    %r12
mov    %rdx,(%r15,%rbx,8)
add    $0x1,%rbx
cmp    %rbx,%r14
je     117c <create_search_targets+0x5c>
xor    %eax,%eax
call   1040 <rand@plt>
mov    %rax,%rcx
or     %r12,%rcx
shr    $0x20,%rcx
jne    1150 <create_search_targets+0x30>
xor    %edx,%edx
div    %r12d
jmp    1155 <create_search_targets+0x35>
mov    %r15,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define i64* @create_search_targets(i64 %0, i64 %1) {
%3 = alloca i64
%4 = alloca i64
%5 = alloca i64*
%6 = alloca i64
store i64 %0, i64* %3
store i64 %1, i64* %4
%7 = load i64, i64* %3
%8 = mul i64 %7, 8
%9 = call i64* @malloc(i64 %8)
store i64* %9, i64** %5
store i64 0, i64* %6
br label %10
10: ; preds = %21, %2
%11 = load i64, i64* %6
%12 = load i64, i64* %3
%13 = icmp ult i64 %11, %12
br i1 %13, label %14, label %24
14: ; preds = %10
%15 = call i64 (...) @rand()
%16 = load i64, i64* %4
%17 = urem i64 %15, %16
%18 = load i64*, i64** %5
%19 = load i64, i64* %6
%20 = getelementptr inbounds i64, i64* %18, i64 %19
store i64 %17, i64* %20
br label %21
21: ; preds = %14
%22 = load i64, i64* %6
%23 = add i64 %22, 1
store i64 %23, i64* %6
br label %10
24: ; preds = %10
%25 = load i64*, i64** %5
ret i64* %25
}

LLVM IR (-O2):
define noalias i64* @create_search_targets(i64 %0, i64 %1) {
%3 = shl i64 %0, 3
%4 = tail call i64* @malloc(i64 %3)
%5 = icmp eq i64 %0, 0
br i1 %5, label %6, label %7
6: ; preds = %7, %2
ret i64* %4
7: ; preds = %2, %7
%8 = phi i64 [ %12, %7 ], [ 0, %2 ]
%9 = tail call i64 (...) @rand()
%10 = urem i64 %9, %1
%11 = getelementptr inbounds i64, i64* %4, i64 %8
store i64 %10, i64* %11
%12 = add nuw i64 %8, 1
%13 = icmp eq i64 %12, %0
br i1 %13, label %6, label %7
}