#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 */
scalar_t__ calloc(int, int);
int /*<<< orphan*/ copyarr(double *, double *, int);
int /*<<< orphan*/ fatalx(char *, int);
int /*<<< orphan*/ free(double *);
void fliparr(double *a, double *b, int n) {
  double *x;
  int k;
  if ((x = (double *)calloc((n), sizeof(double))) == NULL)
    fatalx("Unable to allocate %d unit(s) for item \n", n);
  for (k = 0; k < n; ++k) {
    x[n - 1 - k] = b[k];
  }
  copyarr(x, a, n);
  free(x);
}


x86 assembly (clang, -O0):
<fliparr>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    -0x14(%rbp),%edi
mov    $0x8,%esi
call   1050 <calloc@plt>
mov    %rax,-0x20(%rbp)
cmp    $0x0,%rax
jne    117d <fliparr+0x3d>
mov    -0x14(%rbp),%esi
lea    0xe88(%rip),%rdi
call   1040 <fatalx@plt>
movl   $0x0,-0x24(%rbp)
mov    -0x24(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    11c0 <fliparr+0x80>
mov    -0x10(%rbp),%rax
movslq -0x24(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
mov    -0x20(%rbp),%rax
mov    -0x14(%rbp),%ecx
sub    $0x1,%ecx
sub    -0x24(%rbp),%ecx
movslq %ecx,%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    1184 <fliparr+0x44>
mov    -0x20(%rbp),%rdi
mov    -0x8(%rbp),%rsi
mov    -0x14(%rbp),%edx
call   1060 <copyarr@plt>
mov    -0x20(%rbp),%rdi
call   1030 <free@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<fliparr>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    %edx,%r15d
mov    %rsi,%r12
mov    %rdi,%r14
mov    %edx,%edi
mov    $0x8,%esi
call   1050 <calloc@plt>
mov    %rax,%rbx
test   %rax,%rax
jne    1174 <fliparr+0x34>
lea    0xe94(%rip),%rdi
mov    %r15d,%esi
call   1040 <fatalx@plt>
test   %r15d,%r15d
jle    11fa <fliparr+0xba>
mov    %r15d,%eax
cmp    $0x4,%r15d
jae    121b <fliparr+0xdb>
xor    %r9d,%r9d
mov    %r9,%rdx
not    %rdx
test   $0x1,%al
je     11b1 <fliparr+0x71>
movsd  (%r12,%r9,8),%xmm0
mov    %r9d,%ecx
not    %ecx
add    %r15d,%ecx
movslq %ecx,%rcx
movsd  %xmm0,(%rbx,%rcx,8)
or     $0x1,%r9
add    %rax,%rdx
je     11fa <fliparr+0xba>
sub    %r9,%rax
mov    %r9d,%edx
not    %edx
add    %r15d,%edx
lea    (%r12,%r9,8),%rcx
add    $0x8,%rcx
xor    %esi,%esi
nopl   0x0(%rax,%rax,1)
movsd  -0x8(%rcx,%rsi,8),%xmm0
movslq %edx,%rdx
movsd  %xmm0,(%rbx,%rdx,8)
movsd  (%rcx,%rsi,8),%xmm0
lea    -0x1(%rdx),%edi
movslq %edi,%rdi
movsd  %xmm0,(%rbx,%rdi,8)
add    $0x2,%rsi
add    $0xfffffffe,%edx
cmp    %rsi,%rax
jne    11d0 <fliparr+0x90>
mov    %rbx,%rdi
mov    %r14,%rsi
mov    %r15d,%edx
call   1060 <copyarr@plt>
mov    %rbx,%rdi
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
jmp    1030 <free@plt>
lea    -0x1(%rax),%rsi
lea    -0x1(%r15),%edx
mov    %edx,%edi
sub    %esi,%edi
xor    %r9d,%r9d
cmp    %edx,%edi
jg     118d <fliparr+0x4d>
shr    $0x20,%rsi
jne    118d <fliparr+0x4d>
movslq %edx,%rcx
lea    (%rbx,%rcx,8),%rdx
add    $0x8,%rdx
cmp    %r12,%rdx
jbe    1264 <fliparr+0x124>
lea    (%r12,%rax,8),%rdx
add    $0x1,%rcx
sub    %rax,%rcx
lea    (%rbx,%rcx,8),%rcx
cmp    %rdx,%rcx
jb     118a <fliparr+0x4a>
mov    %eax,%r9d
and    $0xfffffffc,%r9d
lea    -0x4(%r9),%rdx
mov    %rdx,%r8
shr    $0x2,%r8
add    $0x1,%r8
test   %rdx,%rdx
je     131a <fliparr+0x1da>
mov    %r8,%rdi
and    $0xfffffffffffffffe,%rdi
lea    -0x5(%r15),%edx
xor    %esi,%esi
movups (%r12,%rsi,8),%xmm0
movups 0x10(%r12,%rsi,8),%xmm1
lea    0x4(%rdx),%ecx
movslq %ecx,%rcx
shufps $0x4e,%xmm0,%xmm0
movups %xmm0,-0x8(%rbx,%rcx,8)
shufps $0x4e,%xmm1,%xmm1
movups %xmm1,-0x18(%rbx,%rcx,8)
movups 0x20(%r12,%rsi,8),%xmm0
movups 0x30(%r12,%rsi,8),%xmm1
movslq %edx,%rdx
shufps $0x4e,%xmm0,%xmm0
movups %xmm0,-0x8(%rbx,%rdx,8)
shufps $0x4e,%xmm1,%xmm1
movups %xmm1,-0x18(%rbx,%rdx,8)
add    $0x8,%rsi
add    $0xfffffff8,%edx
add    $0xfffffffffffffffe,%rdi
jne    1290 <fliparr+0x150>
test   $0x1,%r8b
je     130c <fliparr+0x1cc>
movups (%r12,%rsi,8),%xmm0
movups 0x10(%r12,%rsi,8),%xmm1
not    %esi
add    %r15d,%esi
movslq %esi,%rcx
shufps $0x4e,%xmm0,%xmm0
movups %xmm0,-0x8(%rbx,%rcx,8)
shufps $0x4e,%xmm1,%xmm1
movups %xmm1,-0x18(%rbx,%rcx,8)
cmp    %rax,%r9
jne    118d <fliparr+0x4d>
jmp    11fa <fliparr+0xba>
xor    %esi,%esi
test   $0x1,%r8b
jne    12e7 <fliparr+0x1a7>
jmp    130c <fliparr+0x1cc>

LLVM IR (-O0):
@.str = [41 x i8] c"Unable to allocate %d unit(s) for item \0A\00"
define void @fliparr(double* %0, double* %1, i32 %2) {
%4 = alloca double*
%5 = alloca double*
%6 = alloca i32
%7 = alloca double*
%8 = alloca i32
store double* %0, double** %4
store double* %1, double** %5
store i32 %2, i32* %6
%9 = load i32, i32* %6
%10 = call i64 @calloc(i32 %9, i32 8)
%11 = inttoptr i64 %10 to double*
store double* %11, double** %7
%12 = icmp eq double* %11, null
br i1 %12, label %13, label %16
13: ; preds = %3
%14 = load i32, i32* %6
%15 = call i32 @fatalx(i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str, i64 0, i64 0), i32 %14)
br label %16
16: ; preds = %13, %3
store i32 0, i32* %8
br label %17
17: ; preds = %34, %16
%18 = load i32, i32* %8
%19 = load i32, i32* %6
%20 = icmp slt i32 %18, %19
br i1 %20, label %21, label %37
21: ; preds = %17
%22 = load double*, double** %5
%23 = load i32, i32* %8
%24 = sext i32 %23 to i64
%25 = getelementptr inbounds double, double* %22, i64 %24
%26 = load double, double* %25
%27 = load double*, double** %7
%28 = load i32, i32* %6
%29 = sub nsw i32 %28, 1
%30 = load i32, i32* %8
%31 = sub nsw i32 %29, %30
%32 = sext i32 %31 to i64
%33 = getelementptr inbounds double, double* %27, i64 %32
store double %26, double* %33
br label %34
34: ; preds = %21
%35 = load i32, i32* %8
%36 = add nsw i32 %35, 1
store i32 %36, i32* %8
br label %17
37: ; preds = %17
%38 = load double*, double** %7
%39 = load double*, double** %4
%40 = load i32, i32* %6
%41 = call i32 @copyarr(double* %38, double* %39, i32 %40)
%42 = load double*, double** %7
%43 = call i32 @free(double* %42)
ret void
}

LLVM IR (-O2):
@.str = [41 x i8] c"Unable to allocate %d unit(s) for item \0A\00"
define void @fliparr(double* %0, double* nocapture %1, i32 %2) {
%4 = tail call i64 @calloc(i32 %2, i32 8)
%5 = inttoptr i64 %4 to double*
%6 = icmp eq i64 %4, 0
br i1 %6, label %7, label %9
7: ; preds = %3
%8 = tail call i32 @fatalx(i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str, i64 0, i64 0), i32 %2)
br label %9
9: ; preds = %7, %3
%10 = icmp sgt i32 %2, 0
br i1 %10, label %11, label %147
11: ; preds = %9
%12 = zext i32 %2 to i64
%13 = icmp ult i32 %2, 4
br i1 %13, label %110, label %14
14: ; preds = %11
%15 = add nsw i64 %12, -1
%16 = add i32 %2, -1
%17 = trunc i64 %15 to i32
%18 = sub i32 %16, %17
%19 = icmp sgt i32 %18, %16
%20 = icmp ugt i64 %15, 4294967295
%21 = or i1 %19, %20
br i1 %21, label %110, label %22
22: ; preds = %14
%23 = getelementptr double, double* %1, i64 %12
%24 = add i32 %2, -1
%25 = sext i32 %24 to i64
%26 = add nsw i64 %25, 1
%27 = sub nsw i64 %26, %12
%28 = getelementptr double, double* %5, i64 %27
%29 = add nsw i64 %25, 1
%30 = getelementptr double, double* %5, i64 %29
%31 = icmp ugt double* %30, %1
%32 = icmp ult double* %28, %23
%33 = and i1 %31, %32
br i1 %33, label %110, label %34
34: ; preds = %22
%35 = and i64 %12, 4294967292
%36 = add nsw i64 %35, -4
%37 = lshr exact i64 %36, 2
%38 = add nuw nsw i64 %37, 1
%39 = and i64 %38, 1
%40 = icmp eq i64 %36, 0
br i1 %40, label %86, label %41
41: ; preds = %34
%42 = and i64 %38, 9223372036854775806
br label %43
43: ; preds = %43, %41
%44 = phi i64 [ 0, %41 ], [ %83, %43 ]
%45 = phi i64 [ 0, %41 ], [ %84, %43 ]
%46 = trunc i64 %44 to i32
%47 = getelementptr inbounds double, double* %1, i64 %44
%48 = bitcast double* %47 to <2 x double>*
%49 = load <2 x double>, <2 x double>* %48
%50 = getelementptr inbounds double, double* %47, i64 2
%51 = bitcast double* %50 to <2 x double>*
%52 = load <2 x double>, <2 x double>* %51
%53 = xor i32 %46, -1
%54 = add i32 %53, %2
%55 = sext i32 %54 to i64
%56 = getelementptr inbounds double, double* %5, i64 %55
%57 = shufflevector <2 x double> %49, <2 x double> poison, <2 x i32> <i32 1, i32 0>
%58 = getelementptr inbounds double, double* %56, i64 -1
%59 = bitcast double* %58 to <2 x double>*
store <2 x double> %57, <2 x double>* %59
%60 = shufflevector <2 x double> %52, <2 x double> poison, <2 x i32> <i32 1, i32 0>
%61 = getelementptr inbounds double, double* %56, i64 -2
%62 = getelementptr inbounds double, double* %61, i64 -1
%63 = bitcast double* %62 to <2 x double>*
store <2 x double> %60, <2 x double>* %63
%64 = or i64 %44, 4
%65 = trunc i64 %64 to i32
%66 = getelementptr inbounds double, double* %1, i64 %64
%67 = bitcast double* %66 to <2 x double>*
%68 = load <2 x double>, <2 x double>* %67
%69 = getelementptr inbounds double, double* %66, i64 2
%70 = bitcast double* %69 to <2 x double>*
%71 = load <2 x double>, <2 x double>* %70
%72 = xor i32 %65, -1
%73 = add i32 %72, %2
%74 = sext i32 %73 to i64
%75 = getelementptr inbounds double, double* %5, i64 %74
%76 = shufflevector <2 x double> %68, <2 x double> poison, <2 x i32> <i32 1, i32 0>
%77 = getelementptr inbounds double, double* %75, i64 -1
%78 = bitcast double* %77 to <2 x double>*
store <2 x double> %76, <2 x double>* %78
%79 = shufflevector <2 x double> %71, <2 x double> poison, <2 x i32> <i32 1, i32 0>
%80 = getelementptr inbounds double, double* %75, i64 -2
%81 = getelementptr inbounds double, double* %80, i64 -1
%82 = bitcast double* %81 to <2 x double>*
store <2 x double> %79, <2 x double>* %82
%83 = add nuw i64 %44, 8
%84 = add i64 %45, 2
%85 = icmp eq i64 %84, %42
br i1 %85, label %86, label %43
86: ; preds = %43, %34
%87 = phi i64 [ 0, %34 ], [ %83, %43 ]
%88 = icmp eq i64 %39, 0
br i1 %88, label %108, label %89
89: ; preds = %86
%90 = trunc i64 %87 to i32
%91 = getelementptr inbounds double, double* %1, i64 %87
%92 = bitcast double* %91 to <2 x double>*
%93 = load <2 x double>, <2 x double>* %92
%94 = getelementptr inbounds double, double* %91, i64 2
%95 = bitcast double* %94 to <2 x double>*
%96 = load <2 x double>, <2 x double>* %95
%97 = xor i32 %90, -1
%98 = add i32 %97, %2
%99 = sext i32 %98 to i64
%100 = getelementptr inbounds double, double* %5, i64 %99
%101 = shufflevector <2 x double> %93, <2 x double> poison, <2 x i32> <i32 1, i32 0>
%102 = getelementptr inbounds double, double* %100, i64 -1
%103 = bitcast double* %102 to <2 x double>*
store <2 x double> %101, <2 x double>* %103
%104 = shufflevector <2 x double> %96, <2 x double> poison, <2 x i32> <i32 1, i32 0>
%105 = getelementptr inbounds double, double* %100, i64 -2
%106 = getelementptr inbounds double, double* %105, i64 -1
%107 = bitcast double* %106 to <2 x double>*
store <2 x double> %104, <2 x double>* %107
br label %108
108: ; preds = %86, %89
%109 = icmp eq i64 %35, %12
br i1 %109, label %147, label %110
110: ; preds = %22, %14, %11, %108
%111 = phi i64 [ 0, %22 ], [ 0, %14 ], [ 0, %11 ], [ %35, %108 ]
%112 = xor i64 %111, -1
%113 = and i64 %12, 1
%114 = icmp eq i64 %113, 0
br i1 %114, label %124, label %115
115: ; preds = %110
%116 = getelementptr inbounds double, double* %1, i64 %111
%117 = load double, double* %116
%118 = trunc i64 %111 to i32
%119 = xor i32 %118, -1
%120 = add i32 %119, %2
%121 = sext i32 %120 to i64
%122 = getelementptr inbounds double, double* %5, i64 %121
store double %117, double* %122
%123 = or i64 %111, 1
br label %124
124: ; preds = %115, %110
%125 = phi i64 [ %111, %110 ], [ %123, %115 ]
%126 = sub nsw i64 0, %12
%127 = icmp eq i64 %112, %126
br i1 %127, label %147, label %128
128: ; preds = %124, %128
%129 = phi i64 [ %145, %128 ], [ %125, %124 ]
%130 = getelementptr inbounds double, double* %1, i64 %129
%131 = load double, double* %130
%132 = trunc i64 %129 to i32
%133 = xor i32 %132, -1
%134 = add i32 %133, %2
%135 = sext i32 %134 to i64
%136 = getelementptr inbounds double, double* %5, i64 %135
store double %131, double* %136
%137 = add nuw nsw i64 %129, 1
%138 = getelementptr inbounds double, double* %1, i64 %137
%139 = load double, double* %138
%140 = trunc i64 %137 to i32
%141 = xor i32 %140, -1
%142 = add i32 %141, %2
%143 = sext i32 %142 to i64
%144 = getelementptr inbounds double, double* %5, i64 %143
store double %139, double* %144
%145 = add nuw nsw i64 %129, 2
%146 = icmp eq i64 %145, %12
br i1 %146, label %147, label %128
147: ; preds = %124, %128, %108, %9
%148 = tail call i32 @copyarr(double* %5, double* %0, i32 %2)
%149 = tail call i32 @free(double* %5)
ret void
}