#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*/ best_flag(unsigned char const **, size_t, size_t, int);
float get18(unsigned char const *);
void load_samples(float *samples, const unsigned char *buffer, size_t bytes,
                  size_t num_samples) {
  const unsigned char *best = buffer + 4096 * 3;
  best_flag(&best, num_samples, bytes - 4096 - 3, 3);
  for (size_t i = 0; i < num_samples; ++i)
    samples[i] = get18(best + i * 3);
}


x86 assembly (clang, -O0):
<load_samples>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    -0x10(%rbp),%rax
add    $0x3000,%rax
mov    %rax,-0x28(%rbp)
mov    -0x20(%rbp),%rsi
mov    -0x18(%rbp),%rdx
sub    $0x1000,%rdx
sub    $0x3,%rdx
lea    -0x28(%rbp),%rdi
mov    $0x3,%ecx
call   1040 <best_flag@plt>
movq   $0x0,-0x30(%rbp)
mov    -0x30(%rbp),%rax
cmp    -0x20(%rbp),%rax
jae    11ac <load_samples+0x8c>
mov    -0x28(%rbp),%rdi
imul   $0x3,-0x30(%rbp),%rax
add    %rax,%rdi
call   1030 <get18@plt>
mov    -0x8(%rbp),%rax
mov    -0x30(%rbp),%rcx
movss  %xmm0,(%rax,%rcx,4)
mov    -0x30(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x30(%rbp)
jmp    116f <load_samples+0x4f>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<load_samples>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    %rcx,%r15
mov    %rdi,%r14
add    $0x3000,%rsi
mov    %rsi,(%rsp)
add    $0xffffffffffffeffd,%rdx
mov    %rsp,%rdi
mov    %rcx,%rsi
mov    $0x3,%ecx
call   1040 <best_flag@plt>
test   %r15,%r15
je     117f <load_samples+0x5f>
xor    %r12d,%r12d
xor    %ebx,%ebx
nopw   0x0(%rax,%rax,1)
mov    (%rsp),%rdi
add    %r12,%rdi
call   1030 <get18@plt>
movss  %xmm0,(%r14,%rbx,4)
add    $0x1,%rbx
add    $0x3,%r12
cmp    %rbx,%r15
jne    1160 <load_samples+0x40>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define void @load_samples(float* %0, i8* %1, i64 %2, i64 %3) {
%5 = alloca float*
%6 = alloca i8*
%7 = alloca i64
%8 = alloca i64
%9 = alloca i8*
%10 = alloca i64
store float* %0, float** %5
store i8* %1, i8** %6
store i64 %2, i64* %7
store i64 %3, i64* %8
%11 = load i8*, i8** %6
%12 = getelementptr inbounds i8, i8* %11, i64 12288
store i8* %12, i8** %9
%13 = load i64, i64* %8
%14 = load i64, i64* %7
%15 = sub i64 %14, 4096
%16 = sub i64 %15, 3
%17 = call i32 @best_flag(i8** %9, i64 %13, i64 %16, i32 3)
store i64 0, i64* %10
br label %18
18: ; preds = %31, %4
%19 = load i64, i64* %10
%20 = load i64, i64* %8
%21 = icmp ult i64 %19, %20
br i1 %21, label %22, label %34
22: ; preds = %18
%23 = load i8*, i8** %9
%24 = load i64, i64* %10
%25 = mul i64 %24, 3
%26 = getelementptr inbounds i8, i8* %23, i64 %25
%27 = call float @get18(i8* %26)
%28 = load float*, float** %5
%29 = load i64, i64* %10
%30 = getelementptr inbounds float, float* %28, i64 %29
store float %27, float* %30
br label %31
31: ; preds = %22
%32 = load i64, i64* %10
%33 = add i64 %32, 1
store i64 %33, i64* %10
br label %18
34: ; preds = %18
ret void
}

LLVM IR (-O2):
define void @load_samples(float* nocapture writeonly %0, i8* %1, i64 %2, i64 %3) {
%5 = alloca i8*
%6 = bitcast i8** %5 to i8*
%7 = getelementptr inbounds i8, i8* %1, i64 12288
store i8* %7, i8** %5
%8 = add i64 %2, -4099
%9 = call i32 @best_flag(i8** %5, i64 %3, i64 %8, i32 3)
%10 = icmp eq i64 %3, 0
br i1 %10, label %11, label %12
11: ; preds = %12, %4
ret void
12: ; preds = %4, %12
%13 = phi i64 [ %19, %12 ], [ 0, %4 ]
%14 = load i8*, i8** %5
%15 = mul i64 %13, 3
%16 = getelementptr inbounds i8, i8* %14, i64 %15
%17 = call float @get18(i8* %16)
%18 = getelementptr inbounds float, float* %0, i64 %13
store float %17, float* %18
%19 = add nuw i64 %13, 1
%20 = icmp eq i64 %19, %3
br i1 %20, label %11, label %12
}