#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*/ dcopy(int const, double const *, int, double *, int);
void pack(const double *datain, const int nzin, double *dataout,
          const int nzout, const int nrep, const int psize) {
  const int nmode = nzin >> 1;
  const int msize = psize << 1;
  int i;
  dcopy(psize, datain, 1, dataout, 1);
  if (nzin > 1)
    dcopy(psize, datain + psize, 1, dataout + psize, 1);
  for (i = 1; i < nmode; i++)
    dcopy(msize, datain + i * msize, 1, dataout + i * nrep * msize, 1);
}


x86 assembly (clang, -O0):
<pack>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %ecx,-0x1c(%rbp)
mov    %r8d,-0x20(%rbp)
mov    %r9d,-0x24(%rbp)
mov    -0xc(%rbp),%eax
sar    $0x1,%eax
mov    %eax,-0x28(%rbp)
mov    -0x24(%rbp),%eax
shl    $0x1,%eax
mov    %eax,-0x2c(%rbp)
mov    -0x24(%rbp),%edi
mov    -0x8(%rbp),%rsi
mov    -0x18(%rbp),%rcx
mov    $0x1,%r8d
mov    %r8d,%edx
call   1030 <dcopy@plt>
cmpl   $0x1,-0xc(%rbp)
jle    1192 <pack+0x82>
mov    -0x24(%rbp),%edi
mov    -0x8(%rbp),%rsi
movslq -0x24(%rbp),%rax
shl    $0x3,%rax
add    %rax,%rsi
mov    -0x18(%rbp),%rcx
movslq -0x24(%rbp),%rax
shl    $0x3,%rax
add    %rax,%rcx
mov    $0x1,%r8d
mov    %r8d,%edx
call   1030 <dcopy@plt>
movl   $0x1,-0x30(%rbp)
mov    -0x30(%rbp),%eax
cmp    -0x28(%rbp),%eax
jge    11f0 <pack+0xe0>
mov    -0x2c(%rbp),%edi
mov    -0x8(%rbp),%rsi
mov    -0x30(%rbp),%eax
imul   -0x2c(%rbp),%eax
cltq
shl    $0x3,%rax
add    %rax,%rsi
mov    -0x18(%rbp),%rcx
mov    -0x30(%rbp),%eax
imul   -0x20(%rbp),%eax
imul   -0x2c(%rbp),%eax
cltq
shl    $0x3,%rax
add    %rax,%rcx
mov    $0x1,%r8d
mov    %r8d,%edx
call   1030 <dcopy@plt>
mov    -0x30(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x30(%rbp)
jmp    1199 <pack+0x89>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<pack>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %r9d,%r12d
mov    %r8d,%r15d
mov    %rdx,%rcx
mov    %esi,%ebx
mov    %rdi,%r14
mov    %r9d,%edi
mov    %r14,%rsi
mov    $0x1,%edx
mov    %rcx,(%rsp)
mov    $0x1,%r8d
call   1030 <dcopy@plt>
cmp    $0x2,%ebx
jl     11dc <pack+0xcc>
movslq %r12d,%rax
lea    (%r14,%rax,8),%rsi
mov    (%rsp),%rcx
lea    (%rcx,%rax,8),%rcx
mov    %r12d,%edi
mov    $0x1,%edx
mov    $0x1,%r8d
call   1030 <dcopy@plt>
cmp    $0x4,%ebx
jb     11dc <pack+0xcc>
sar    %ebx
lea    (%r12,%r12,1),%ebp
mov    %r14,%rax
movslq %ebp,%r14
cmp    $0x3,%ebx
mov    $0x2,%r13d
cmovge %ebx,%r13d
lea    (%rax,%r14,8),%rbx
shl    $0x3,%r14
imul   %r12d,%r15d
add    %r15d,%r15d
add    $0xffffffffffffffff,%r13
mov    %r15d,%r12d
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
movslq %r15d,%r15
mov    (%rsp),%rax
lea    (%rax,%r15,8),%rcx
mov    %ebp,%edi
mov    %rbx,%rsi
mov    $0x1,%edx
mov    $0x1,%r8d
call   1030 <dcopy@plt>
add    %r14,%rbx
add    %r12d,%r15d
add    $0xffffffffffffffff,%r13
jne    11b0 <pack+0xa0>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define void @pack(double* %0, i32 %1, double* %2, i32 %3, i32 %4, i32 %5) {
%7 = alloca double*
%8 = alloca i32
%9 = alloca double*
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32
%13 = alloca i32
%14 = alloca i32
%15 = alloca i32
store double* %0, double** %7
store i32 %1, i32* %8
store double* %2, double** %9
store i32 %3, i32* %10
store i32 %4, i32* %11
store i32 %5, i32* %12
%16 = load i32, i32* %8
%17 = ashr i32 %16, 1
store i32 %17, i32* %13
%18 = load i32, i32* %12
%19 = shl i32 %18, 1
store i32 %19, i32* %14
%20 = load i32, i32* %12
%21 = load double*, double** %7
%22 = load double*, double** %9
%23 = call i32 @dcopy(i32 %20, double* %21, i32 1, double* %22, i32 1)
%24 = load i32, i32* %8
%25 = icmp sgt i32 %24, 1
br i1 %25, label %26, label %37
26: ; preds = %6
%27 = load i32, i32* %12
%28 = load double*, double** %7
%29 = load i32, i32* %12
%30 = sext i32 %29 to i64
%31 = getelementptr inbounds double, double* %28, i64 %30
%32 = load double*, double** %9
%33 = load i32, i32* %12
%34 = sext i32 %33 to i64
%35 = getelementptr inbounds double, double* %32, i64 %34
%36 = call i32 @dcopy(i32 %27, double* %31, i32 1, double* %35, i32 1)
br label %37
37: ; preds = %26, %6
store i32 1, i32* %15
br label %38
38: ; preds = %59, %37
%39 = load i32, i32* %15
%40 = load i32, i32* %13
%41 = icmp slt i32 %39, %40
br i1 %41, label %42, label %62
42: ; preds = %38
%43 = load i32, i32* %14
%44 = load double*, double** %7
%45 = load i32, i32* %15
%46 = load i32, i32* %14
%47 = mul nsw i32 %45, %46
%48 = sext i32 %47 to i64
%49 = getelementptr inbounds double, double* %44, i64 %48
%50 = load double*, double** %9
%51 = load i32, i32* %15
%52 = load i32, i32* %11
%53 = mul nsw i32 %51, %52
%54 = load i32, i32* %14
%55 = mul nsw i32 %53, %54
%56 = sext i32 %55 to i64
%57 = getelementptr inbounds double, double* %50, i64 %56
%58 = call i32 @dcopy(i32 %43, double* %49, i32 1, double* %57, i32 1)
br label %59
59: ; preds = %42
%60 = load i32, i32* %15
%61 = add nsw i32 %60, 1
store i32 %61, i32* %15
br label %38
62: ; preds = %38
ret void
}

LLVM IR (-O2):
define void @pack(double* %0, i32 %1, double* %2, i32 %3, i32 %4, i32 %5) {
%7 = ashr i32 %1, 1
%8 = shl i32 %5, 1
%9 = tail call i32 @dcopy(i32 %5, double* %0, i32 1, double* %2, i32 1)
%10 = icmp sgt i32 %1, 1
br i1 %10, label %11, label %33
11: ; preds = %6
%12 = sext i32 %5 to i64
%13 = getelementptr inbounds double, double* %0, i64 %12
%14 = getelementptr inbounds double, double* %2, i64 %12
%15 = tail call i32 @dcopy(i32 %5, double* %13, i32 1, double* %14, i32 1)
%16 = icmp ugt i32 %1, 3
br i1 %16, label %17, label %33
17: ; preds = %11
%18 = sext i32 %8 to i64
%19 = call i32 @llvm.smax.i32(i32 %7, i32 2)
%20 = zext i32 %19 to i64
br label %21
21: ; preds = %17, %21
%22 = phi i64 [ 1, %17 ], [ %31, %21 ]
%23 = mul nsw i64 %22, %18
%24 = getelementptr inbounds double, double* %0, i64 %23
%25 = trunc i64 %22 to i32
%26 = mul i32 %8, %25
%27 = mul i32 %26, %4
%28 = sext i32 %27 to i64
%29 = getelementptr inbounds double, double* %2, i64 %28
%30 = tail call i32 @dcopy(i32 %8, double* %24, i32 1, double* %29, i32 1)
%31 = add nuw nsw i64 %22, 1
%32 = icmp eq i64 %31, %20
br i1 %32, label %33, label %21
33: ; preds = %21, %6, %11
ret void
}