#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 */
struct statistics_float {
  int dummy;
};

/* Variables and functions */
int /*<<< orphan*/ memcpy(float *, float *, int);
int /*<<< orphan*/ statistics_getf_spoilable(struct statistics_float *, float *,
                                             int);
int /*<<< orphan*/ xfree(float *);
float *xmalloc(int);
void statistics_getf(struct statistics_float *s, float *fin, int n) {
  if (n > 1000) {
    float *f = xmalloc(n * sizeof *f);
    memcpy(f, fin, n * sizeof *f);
    statistics_getf_spoilable(s, f, n);
    xfree(f);
  } else {
    float f[n];
    memcpy(f, fin, n * sizeof *f);
    statistics_getf_spoilable(s, f, n);
  }
}


x86 assembly (clang, -O0):
<statistics_getf>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
cmpl   $0x3e8,-0x14(%rbp)
jle    11a8 <statistics_getf+0x68>
movslq -0x14(%rbp),%rax
shl    $0x2,%rax
mov    %eax,%edi
call   1040 <xmalloc@plt>
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rdi
mov    -0x10(%rbp),%rsi
movslq -0x14(%rbp),%rax
shl    $0x2,%rax
mov    %eax,%edx
call   1050 <memcpy@plt>
mov    -0x8(%rbp),%rdi
mov    -0x20(%rbp),%rsi
mov    -0x14(%rbp),%edx
call   1060 <statistics_getf_spoilable@plt>
mov    -0x20(%rbp),%rdi
call   1030 <xfree@plt>
jmp    11f9 <statistics_getf+0xb9>
mov    -0x14(%rbp),%eax
mov    %rsp,%rcx
mov    %rcx,-0x28(%rbp)
lea    0xf(,%rax,4),%rcx
and    $0xfffffffffffffff0,%rcx
mov    %rsp,%rdi
sub    %rcx,%rdi
mov    %rdi,-0x38(%rbp)
mov    %rdi,%rsp
mov    %rax,-0x30(%rbp)
mov    -0x10(%rbp),%rsi
movslq -0x14(%rbp),%rax
shl    $0x2,%rax
mov    %eax,%edx
call   1050 <memcpy@plt>
mov    -0x38(%rbp),%rsi
mov    -0x8(%rbp),%rdi
mov    -0x14(%rbp),%edx
call   1060 <statistics_getf_spoilable@plt>
mov    -0x28(%rbp),%rax
mov    %rax,%rsp
mov    %rbp,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<statistics_getf>:
push   %rbp
mov    %rsp,%rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %edx,%r14d
mov    %rsi,%r15
mov    %rdi,%rbx
cmp    $0x3e9,%edx
jl     11a4 <statistics_getf+0x64>
lea    0x0(,%r14,4),%r12d
mov    %r12d,%edi
call   1040 <xmalloc@plt>
mov    %rax,%r13
mov    %rax,%rdi
mov    %r15,%rsi
mov    %r12d,%edx
call   1050 <memcpy@plt>
mov    %rbx,%rdi
mov    %r13,%rsi
mov    %r14d,%edx
call   1060 <statistics_getf_spoilable@plt>
mov    %r13,%rdi
lea    -0x28(%rbp),%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <xfree@plt>
mov    %rsp,%r12
mov    %r14d,%eax
mov    %rbx,%r13
mov    %rsp,%rbx
lea    0xf(,%rax,4),%rax
and    $0xfffffffffffffff0,%rax
sub    %rax,%rbx
mov    %rbx,%rsp
lea    0x0(,%r14,4),%edx
mov    %rbx,%rdi
mov    %r15,%rsi
call   1050 <memcpy@plt>
mov    %r13,%rdi
mov    %rbx,%rsi
mov    %r14d,%edx
call   1060 <statistics_getf_spoilable@plt>
mov    %r12,%rsp
lea    -0x28(%rbp),%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.statistics_float = type { i32 }
define void @statistics_getf(%struct.statistics_float* %0, float* %1, i32 %2) {
%4 = alloca %struct.statistics_float*
%5 = alloca float*
%6 = alloca i32
%7 = alloca float*
%8 = alloca i8*
%9 = alloca i64
store %struct.statistics_float* %0, %struct.statistics_float** %4
store float* %1, float** %5
store i32 %2, i32* %6
%10 = load i32, i32* %6
%11 = icmp sgt i32 %10, 1000
br i1 %11, label %12, label %31
12: ; preds = %3
%13 = load i32, i32* %6
%14 = sext i32 %13 to i64
%15 = mul i64 %14, 4
%16 = trunc i64 %15 to i32
%17 = call float* @xmalloc(i32 %16)
store float* %17, float** %7
%18 = load float*, float** %7
%19 = load float*, float** %5
%20 = load i32, i32* %6
%21 = sext i32 %20 to i64
%22 = mul i64 %21, 4
%23 = trunc i64 %22 to i32
%24 = call i32 @memcpy(float* %18, float* %19, i32 %23)
%25 = load %struct.statistics_float*, %struct.statistics_float** %4
%26 = load float*, float** %7
%27 = load i32, i32* %6
%28 = call i32 @statistics_getf_spoilable(%struct.statistics_float* %25, float* %26, i32 %27)
%29 = load float*, float** %7
%30 = call i32 @xfree(float* %29)
br label %46
31: ; preds = %3
%32 = load i32, i32* %6
%33 = zext i32 %32 to i64
%34 = call i8* @llvm.stacksave()
store i8* %34, i8** %8
%35 = alloca float, i64 %33
store i64 %33, i64* %9
%36 = load float*, float** %5
%37 = load i32, i32* %6
%38 = sext i32 %37 to i64
%39 = mul i64 %38, 4
%40 = trunc i64 %39 to i32
%41 = call i32 @memcpy(float* %35, float* %36, i32 %40)
%42 = load %struct.statistics_float*, %struct.statistics_float** %4
%43 = load i32, i32* %6
%44 = call i32 @statistics_getf_spoilable(%struct.statistics_float* %42, float* %35, i32 %43)
%45 = load i8*, i8** %8
br label %46
46: ; preds = %31, %12
ret void
}

LLVM IR (-O2):
%struct.statistics_float = type { i32 }
define void @statistics_getf(%struct.statistics_float* %0, float* %1, i32 %2) {
%4 = icmp sgt i32 %2, 1000
br i1 %4, label %5, label %11
5: ; preds = %3
%6 = shl i32 %2, 2
%7 = tail call float* @xmalloc(i32 %6)
%8 = tail call i32 @memcpy(float* %7, float* %1, i32 %6)
%9 = tail call i32 @statistics_getf_spoilable(%struct.statistics_float* %0, float* %7, i32 %2)
%10 = tail call i32 @xfree(float* %7)
br label %18
11: ; preds = %3
%12 = zext i32 %2 to i64
%13 = tail call i8* @llvm.stacksave()
%14 = alloca float, i64 %12
%15 = shl i32 %2, 2
%16 = call i32 @memcpy(float* %14, float* %1, i32 %15)
%17 = call i32 @statistics_getf_spoilable(%struct.statistics_float* %0, float* %14, i32 %2)
br label %18
18: ; preds = %11, %5
ret void
}