#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*/ errx(int, char *);
float get14(unsigned char const *);
scalar_t__ memcmp(unsigned char const *, unsigned char const *, int);
void load_samples(float *samples, const unsigned char *buffer,
                  size_t num_samples) {
  const unsigned char *p = buffer + num_samples * 2 - 2048 * 4;
  if (memcmp(p, p + 2048 * 2, 2048 * 2) != 0)
    errx(1, "Copies do not match.");
  for (int i = 0; i < 2048; ++i)
    samples[i] = get14(p + 2 * i);
}


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    -0x10(%rbp),%rax
mov    -0x18(%rbp),%rcx
shl    $0x1,%rcx
add    %rcx,%rax
add    $0xffffffffffffe000,%rax
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rdi
mov    -0x20(%rbp),%rsi
add    $0x1000,%rsi
mov    $0x1000,%edx
call   1040 <memcmp@plt>
cmp    $0x0,%rax
je     1191 <load_samples+0x61>
mov    $0x1,%edi
lea    0xe74(%rip),%rsi
call   1030 <errx@plt>
movl   $0x0,-0x24(%rbp)
cmpl   $0x800,-0x24(%rbp)
jge    11d4 <load_samples+0xa4>
mov    -0x20(%rbp),%rdi
mov    -0x24(%rbp),%eax
shl    $0x1,%eax
cltq
add    %rax,%rdi
call   1050 <get14@plt>
mov    -0x8(%rbp),%rax
movslq -0x24(%rbp),%rcx
movss  %xmm0,(%rax,%rcx,4)
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    1198 <load_samples+0x68>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<load_samples>:
push   %r15
push   %r14
push   %rbx
mov    %rdi,%r14
lea    -0x2000(%rsi,%rdx,2),%r15
ff
lea    (%rsi,%rdx,2),%rsi
add    $0xfffffffffffff000,%rsi
mov    %r15,%rdi
mov    $0x1000,%edx
call   1040 <memcmp@plt>
test   %rax,%rax
je     116e <load_samples+0x3e>
lea    0xe9c(%rip),%rsi
mov    $0x1,%edi
call   1030 <errx@plt>
xor    %ebx,%ebx
lea    (%r15,%rbx,1),%rdi
call   1050 <get14@plt>
movss  %xmm0,(%r14,%rbx,2)
add    $0x2,%rbx
cmp    $0x1000,%rbx
jne    1170 <load_samples+0x40>
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [21 x i8] c"Copies do not match.\00"
define void @load_samples(float* %0, i8* %1, i64 %2) {
%4 = alloca float*
%5 = alloca i8*
%6 = alloca i64
%7 = alloca i8*
%8 = alloca i32
store float* %0, float** %4
store i8* %1, i8** %5
store i64 %2, i64* %6
%9 = load i8*, i8** %5
%10 = load i64, i64* %6
%11 = mul i64 %10, 2
%12 = getelementptr inbounds i8, i8* %9, i64 %11
%13 = getelementptr inbounds i8, i8* %12, i64 -8192
store i8* %13, i8** %7
%14 = load i8*, i8** %7
%15 = load i8*, i8** %7
%16 = getelementptr inbounds i8, i8* %15, i64 4096
%17 = call i64 @memcmp(i8* %14, i8* %16, i32 4096)
%18 = icmp ne i64 %17, 0
br i1 %18, label %19, label %21
19: ; preds = %3
%20 = call i32 @errx(i32 1, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0))
br label %21
21: ; preds = %19, %3
store i32 0, i32* %8
br label %22
22: ; preds = %36, %21
%23 = load i32, i32* %8
%24 = icmp slt i32 %23, 2048
br i1 %24, label %25, label %39
25: ; preds = %22
%26 = load i8*, i8** %7
%27 = load i32, i32* %8
%28 = mul nsw i32 2, %27
%29 = sext i32 %28 to i64
%30 = getelementptr inbounds i8, i8* %26, i64 %29
%31 = call float @get14(i8* %30)
%32 = load float*, float** %4
%33 = load i32, i32* %8
%34 = sext i32 %33 to i64
%35 = getelementptr inbounds float, float* %32, i64 %34
store float %31, float* %35
br label %36
36: ; preds = %25
%37 = load i32, i32* %8
%38 = add nsw i32 %37, 1
store i32 %38, i32* %8
br label %22
39: ; preds = %22
ret void
}

LLVM IR (-O2):
@.str = [21 x i8] c"Copies do not match.\00"
define void @load_samples(float* nocapture writeonly %0, i8* %1, i64 %2) {
%4 = shl i64 %2, 1
%5 = getelementptr inbounds i8, i8* %1, i64 %4
%6 = getelementptr inbounds i8, i8* %5, i64 -8192
%7 = getelementptr inbounds i8, i8* %6, i64 4096
%8 = tail call i64 @memcmp(i8* %6, i8* %7, i32 4096)
%9 = icmp eq i64 %8, 0
br i1 %9, label %10, label %11
10: ; preds = %11, %3
br label %14
11: ; preds = %3
%12 = tail call i32 @errx(i32 1, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0))
br label %10
13: ; preds = %14
ret void
14: ; preds = %10, %14
%15 = phi i64 [ %20, %14 ], [ 0, %10 ]
%16 = shl nuw nsw i64 %15, 1
%17 = getelementptr inbounds i8, i8* %6, i64 %16
%18 = tail call float @get14(i8* %17)
%19 = getelementptr inbounds float, float* %0, i64 %15
store float %18, float* %19
%20 = add nuw nsw i64 %15, 1
%21 = icmp eq i64 %20, 2048
br i1 %21, label %13, label %14
}