#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*/ exit(int);
int /*<<< orphan*/ free(double *);
int /*<<< orphan*/ printf(char *);
void killer(double *combined, int numElements) {
  int i, k;
  double *swap;
  if (numElements % 2 == 1) {
    printf("You can only use the \"-k\" killer data set with an even number of "
           "elements\n");
    exit(-1);
  }
  k = numElements / 2;
  swap = (double *)calloc(numElements, sizeof(double));
  for (i = 1; i <= k; i++) {
    if (i % 2) {
      swap[i - 1] = combined[i];
      swap[i] = combined[k + i];
    }
    swap[k + i - 1] = combined[2 * i];
  }
  for (i = 0; i < numElements; i++) {
    combined[i] = swap[i];
  }
  free(swap);
}


x86 assembly (clang, -O0):
<killer>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    -0xc(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
cmp    $0x1,%edx
jne    1179 <killer+0x39>
lea    0xe96(%rip),%rdi
call   1040 <printf@plt>
mov    $0xffffffff,%edi
call   1060 <exit@plt>
mov    -0xc(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %eax,-0x14(%rbp)
mov    -0xc(%rbp),%edi
mov    $0x8,%esi
call   1050 <calloc@plt>
mov    %rax,-0x20(%rbp)
movl   $0x1,-0x10(%rbp)
mov    -0x10(%rbp),%eax
cmp    -0x14(%rbp),%eax
jg     1232 <killer+0xf2>
mov    -0x10(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
cmp    $0x0,%edx
je     11fd <killer+0xbd>
mov    -0x8(%rbp),%rax
movslq -0x10(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
mov    -0x20(%rbp),%rax
mov    -0x10(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x8(%rbp),%rax
mov    -0x14(%rbp),%ecx
add    -0x10(%rbp),%ecx
movslq %ecx,%rcx
movsd  (%rax,%rcx,8),%xmm0
mov    -0x20(%rbp),%rax
movslq -0x10(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x8(%rbp),%rax
mov    -0x10(%rbp),%ecx
shl    $0x1,%ecx
movslq %ecx,%rcx
movsd  (%rax,%rcx,8),%xmm0
mov    -0x20(%rbp),%rax
mov    -0x14(%rbp),%ecx
add    -0x10(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    119f <killer+0x5f>
movl   $0x0,-0x10(%rbp)
mov    -0x10(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    126d <killer+0x12d>
mov    -0x20(%rbp),%rax
movslq -0x10(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
mov    -0x8(%rbp),%rax
movslq -0x10(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    1239 <killer+0xf9>
mov    -0x20(%rbp),%rdi
call   1030 <free@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<killer>:
push   %rbp
push   %r14
push   %rbx
mov    %esi,%ebp
shr    $0x1f,%ebp
add    %esi,%ebp
mov    %ebp,%eax
and    $0xfffffffe,%eax
mov    %esi,%ecx
sub    %eax,%ecx
cmp    $0x1,%ecx
je     1361 <killer+0x221>
mov    %esi,%r14d
mov    %rdi,%rbx
mov    %esi,%edi
mov    $0x8,%esi
call   1050 <calloc@plt>
cmp    $0x2,%r14d
jge    121c <killer+0xdc>
test   %r14d,%r14d
jle    1355 <killer+0x215>
mov    %r14d,%ecx
cmp    $0x4,%r14d
jb     11a5 <killer+0x65>
lea    (%rax,%rcx,8),%rdx
cmp    %rbx,%rdx
jbe    1281 <killer+0x141>
lea    (%rbx,%rcx,8),%rdx
cmp    %rdx,%rax
jae    1281 <killer+0x141>
xor    %edx,%edx
mov    %rdx,%rsi
not    %rsi
add    %rcx,%rsi
mov    %rcx,%rdi
and    $0x3,%rdi
je     11d4 <killer+0x94>
nopl   0x0(%rax)
movsd  (%rax,%rdx,8),%xmm0
movsd  %xmm0,(%rbx,%rdx,8)
add    $0x1,%rdx
add    $0xffffffffffffffff,%rdi
jne    11c0 <killer+0x80>
cmp    $0x3,%rsi
jb     1355 <killer+0x215>
xchg   %ax,%ax
movsd  (%rax,%rdx,8),%xmm0
movsd  %xmm0,(%rbx,%rdx,8)
movsd  0x8(%rax,%rdx,8),%xmm0
movsd  %xmm0,0x8(%rbx,%rdx,8)
movsd  0x10(%rax,%rdx,8),%xmm0
movsd  %xmm0,0x10(%rbx,%rdx,8)
movsd  0x18(%rax,%rdx,8),%xmm0
movsd  %xmm0,0x18(%rbx,%rdx,8)
add    $0x4,%rdx
cmp    %rdx,%rcx
jne    11e0 <killer+0xa0>
jmp    1355 <killer+0x215>
sar    %ebp
movslq %ebp,%rcx
lea    0x1(%rcx),%edx
lea    0x10(%rbx),%rsi
lea    (%rbx,%rcx,8),%r8
mov    $0x1,%ebp
jmp    1275 <killer+0x135>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
movsd  (%rbx,%rbp,8),%xmm0
movsd  %xmm0,-0x8(%rax,%rbp,8)
lea    (%rcx,%rbp,1),%rdi
movsd  (%r8,%rbp,8),%xmm0
movsd  %xmm0,(%rax,%rbp,8)
movsd  (%rsi),%xmm0
movsd  %xmm0,-0x8(%rax,%rdi,8)
add    $0x1,%rbp
add    $0x10,%rsi
cmp    %rbp,%rdx
je     1179 <killer+0x39>
test   $0x1,%bpl
jne    1240 <killer+0x100>
lea    (%rcx,%rbp,1),%rdi
jmp    125a <killer+0x11a>
mov    %ecx,%edx
and    $0xfffffffc,%edx
lea    -0x4(%rdx),%rsi
mov    %rsi,%rdi
shr    $0x2,%rdi
add    $0x1,%rdi
mov    %edi,%r8d
and    $0x3,%r8d
cmp    $0xc,%rsi
jae    12a6 <killer+0x166>
xor    %ebp,%ebp
jmp    1308 <killer+0x1c8>
and    $0xfffffffffffffffc,%rdi
xor    %ebp,%ebp
nopl   0x0(%rax)
movups (%rax,%rbp,8),%xmm0
movups 0x10(%rax,%rbp,8),%xmm1
movups %xmm0,(%rbx,%rbp,8)
movups %xmm1,0x10(%rbx,%rbp,8)
movups 0x20(%rax,%rbp,8),%xmm0
movups 0x30(%rax,%rbp,8),%xmm1
movups %xmm0,0x20(%rbx,%rbp,8)
movups %xmm1,0x30(%rbx,%rbp,8)
movups 0x40(%rax,%rbp,8),%xmm0
movups 0x50(%rax,%rbp,8),%xmm1
movups %xmm0,0x40(%rbx,%rbp,8)
movups %xmm1,0x50(%rbx,%rbp,8)
movups 0x60(%rax,%rbp,8),%xmm0
movups 0x70(%rax,%rbp,8),%xmm1
movups %xmm0,0x60(%rbx,%rbp,8)
movups %xmm1,0x70(%rbx,%rbp,8)
add    $0x10,%rbp
add    $0xfffffffffffffffc,%rdi
jne    12b0 <killer+0x170>
test   %r8,%r8
je     134c <killer+0x20c>
lea    (%rbx,%rbp,8),%rdi
add    $0x10,%rdi
lea    (%rax,%rbp,8),%rbp
add    $0x10,%rbp
shl    $0x5,%r8
xor    %esi,%esi
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
movups -0x10(%rbp,%rsi,1),%xmm0
movups 0x0(%rbp,%rsi,1),%xmm1
movups %xmm0,-0x10(%rdi,%rsi,1)
movups %xmm1,(%rdi,%rsi,1)
add    $0x20,%rsi
cmp    %rsi,%r8
jne    1330 <killer+0x1f0>
cmp    %rcx,%rdx
jne    11a7 <killer+0x67>
mov    %rax,%rdi
pop    %rbx
pop    %r14
pop    %rbp
jmp    1030 <free@plt>
lea    0xc98(%rip),%rdi
call   1040 <puts@plt>
mov    $0xffffffff,%edi
call   1060 <exit@plt>

LLVM IR (-O0):
@.str = [75 x i8] c"You can only use the \22-k\22 killer data set with an even number of elements\0A\00"
define void @killer(double* %0, i32 %1) {
%3 = alloca double*
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca double*
store double* %0, double** %3
store i32 %1, i32* %4
%8 = load i32, i32* %4
%9 = srem i32 %8, 2
%10 = icmp eq i32 %9, 1
br i1 %10, label %11, label %14
11: ; preds = %2
%12 = call i32 @printf(i8* getelementptr inbounds ([75 x i8], [75 x i8]* @.str, i64 0, i64 0))
%13 = call i32 @exit(i32 -1)
unreachable
14: ; preds = %2
%15 = load i32, i32* %4
%16 = sdiv i32 %15, 2
store i32 %16, i32* %6
%17 = load i32, i32* %4
%18 = call i64 @calloc(i32 %17, i32 8)
%19 = inttoptr i64 %18 to double*
store double* %19, double** %7
store i32 1, i32* %5
br label %20
20: ; preds = %64, %14
%21 = load i32, i32* %5
%22 = load i32, i32* %6
%23 = icmp sle i32 %21, %22
br i1 %23, label %24, label %67
24: ; preds = %20
%25 = load i32, i32* %5
%26 = srem i32 %25, 2
%27 = icmp ne i32 %26, 0
br i1 %27, label %28, label %50
28: ; preds = %24
%29 = load double*, double** %3
%30 = load i32, i32* %5
%31 = sext i32 %30 to i64
%32 = getelementptr inbounds double, double* %29, i64 %31
%33 = load double, double* %32
%34 = load double*, double** %7
%35 = load i32, i32* %5
%36 = sub nsw i32 %35, 1
%37 = sext i32 %36 to i64
%38 = getelementptr inbounds double, double* %34, i64 %37
store double %33, double* %38
%39 = load double*, double** %3
%40 = load i32, i32* %6
%41 = load i32, i32* %5
%42 = add nsw i32 %40, %41
%43 = sext i32 %42 to i64
%44 = getelementptr inbounds double, double* %39, i64 %43
%45 = load double, double* %44
%46 = load double*, double** %7
%47 = load i32, i32* %5
%48 = sext i32 %47 to i64
%49 = getelementptr inbounds double, double* %46, i64 %48
store double %45, double* %49
br label %50
50: ; preds = %28, %24
%51 = load double*, double** %3
%52 = load i32, i32* %5
%53 = mul nsw i32 2, %52
%54 = sext i32 %53 to i64
%55 = getelementptr inbounds double, double* %51, i64 %54
%56 = load double, double* %55
%57 = load double*, double** %7
%58 = load i32, i32* %6
%59 = load i32, i32* %5
%60 = add nsw i32 %58, %59
%61 = sub nsw i32 %60, 1
%62 = sext i32 %61 to i64
%63 = getelementptr inbounds double, double* %57, i64 %62
store double %56, double* %63
br label %64
64: ; preds = %50
%65 = load i32, i32* %5
%66 = add nsw i32 %65, 1
store i32 %66, i32* %5
br label %20
67: ; preds = %20
store i32 0, i32* %5
br label %68
68: ; preds = %82, %67
%69 = load i32, i32* %5
%70 = load i32, i32* %4
%71 = icmp slt i32 %69, %70
br i1 %71, label %72, label %85
72: ; preds = %68
%73 = load double*, double** %7
%74 = load i32, i32* %5
%75 = sext i32 %74 to i64
%76 = getelementptr inbounds double, double* %73, i64 %75
%77 = load double, double* %76
%78 = load double*, double** %3
%79 = load i32, i32* %5
%80 = sext i32 %79 to i64
%81 = getelementptr inbounds double, double* %78, i64 %80
store double %77, double* %81
br label %82
82: ; preds = %72
%83 = load i32, i32* %5
%84 = add nsw i32 %83, 1
store i32 %84, i32* %5
br label %68
85: ; preds = %68
%86 = load double*, double** %7
%87 = call i32 @free(double* %86)
ret void
}

LLVM IR (-O2):
@str = [74 x i8] c"You can only use the \22-k\22 killer data set with an even number of elements\00"
define void @killer(double* nocapture %0, i32 %1) {
%3 = srem i32 %1, 2
%4 = sdiv i32 %1, 2
%5 = icmp eq i32 %3, 1
br i1 %5, label %6, label %9
6: ; preds = %2
%7 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([74 x i8], [74 x i8]* @str, i64 0, i64 0))
%8 = tail call i32 @exit(i32 -1)
unreachable
9: ; preds = %2
%10 = tail call i64 @calloc(i32 %1, i32 8)
%11 = inttoptr i64 %10 to double*
%12 = inttoptr i64 %10 to i8*
%13 = icmp slt i32 %1, 2
br i1 %13, label %18, label %14
14: ; preds = %9
%15 = sext i32 %4 to i64
%16 = add nsw i32 %4, 1
%17 = zext i32 %16 to i64
br label %127
18: ; preds = %142, %9
%19 = icmp sgt i32 %1, 0
br i1 %19, label %20, label %170
20: ; preds = %18
%21 = zext i32 %1 to i64
%22 = icmp ult i32 %1, 4
br i1 %22, label %109, label %23
23: ; preds = %20
%24 = getelementptr double, double* %0, i64 %21
%25 = bitcast double* %24 to i8*
%26 = getelementptr double, double* %11, i64 %21
%27 = icmp ugt double* %26, %0
%28 = icmp ult i8* %12, %25
%29 = and i1 %27, %28
br i1 %29, label %109, label %30
30: ; preds = %23
%31 = and i64 %21, 4294967292
%32 = add nsw i64 %31, -4
%33 = lshr exact i64 %32, 2
%34 = add nuw nsw i64 %33, 1
%35 = and i64 %34, 3
%36 = icmp ult i64 %32, 12
br i1 %36, label %88, label %37
37: ; preds = %30
%38 = and i64 %34, 9223372036854775804
br label %39
39: ; preds = %39, %37
%40 = phi i64 [ 0, %37 ], [ %85, %39 ]
%41 = phi i64 [ 0, %37 ], [ %86, %39 ]
%42 = getelementptr inbounds double, double* %11, i64 %40
%43 = bitcast double* %42 to <2 x double>*
%44 = load <2 x double>, <2 x double>* %43
%45 = getelementptr inbounds double, double* %42, i64 2
%46 = bitcast double* %45 to <2 x double>*
%47 = load <2 x double>, <2 x double>* %46
%48 = getelementptr inbounds double, double* %0, i64 %40
%49 = bitcast double* %48 to <2 x double>*
store <2 x double> %44, <2 x double>* %49
%50 = getelementptr inbounds double, double* %48, i64 2
%51 = bitcast double* %50 to <2 x double>*
store <2 x double> %47, <2 x double>* %51
%52 = or i64 %40, 4
%53 = getelementptr inbounds double, double* %11, i64 %52
%54 = bitcast double* %53 to <2 x double>*
%55 = load <2 x double>, <2 x double>* %54
%56 = getelementptr inbounds double, double* %53, i64 2
%57 = bitcast double* %56 to <2 x double>*
%58 = load <2 x double>, <2 x double>* %57
%59 = getelementptr inbounds double, double* %0, i64 %52
%60 = bitcast double* %59 to <2 x double>*
store <2 x double> %55, <2 x double>* %60
%61 = getelementptr inbounds double, double* %59, i64 2
%62 = bitcast double* %61 to <2 x double>*
store <2 x double> %58, <2 x double>* %62
%63 = or i64 %40, 8
%64 = getelementptr inbounds double, double* %11, i64 %63
%65 = bitcast double* %64 to <2 x double>*
%66 = load <2 x double>, <2 x double>* %65
%67 = getelementptr inbounds double, double* %64, i64 2
%68 = bitcast double* %67 to <2 x double>*
%69 = load <2 x double>, <2 x double>* %68
%70 = getelementptr inbounds double, double* %0, i64 %63
%71 = bitcast double* %70 to <2 x double>*
store <2 x double> %66, <2 x double>* %71
%72 = getelementptr inbounds double, double* %70, i64 2
%73 = bitcast double* %72 to <2 x double>*
store <2 x double> %69, <2 x double>* %73
%74 = or i64 %40, 12
%75 = getelementptr inbounds double, double* %11, i64 %74
%76 = bitcast double* %75 to <2 x double>*
%77 = load <2 x double>, <2 x double>* %76
%78 = getelementptr inbounds double, double* %75, i64 2
%79 = bitcast double* %78 to <2 x double>*
%80 = load <2 x double>, <2 x double>* %79
%81 = getelementptr inbounds double, double* %0, i64 %74
%82 = bitcast double* %81 to <2 x double>*
store <2 x double> %77, <2 x double>* %82
%83 = getelementptr inbounds double, double* %81, i64 2
%84 = bitcast double* %83 to <2 x double>*
store <2 x double> %80, <2 x double>* %84
%85 = add nuw i64 %40, 16
%86 = add nuw i64 %41, 4
%87 = icmp eq i64 %86, %38
br i1 %87, label %88, label %39
88: ; preds = %39, %30
%89 = phi i64 [ 0, %30 ], [ %85, %39 ]
%90 = icmp eq i64 %35, 0
br i1 %90, label %107, label %91
91: ; preds = %88, %91
%92 = phi i64 [ %104, %91 ], [ %89, %88 ]
%93 = phi i64 [ %105, %91 ], [ 0, %88 ]
%94 = getelementptr inbounds double, double* %11, i64 %92
%95 = bitcast double* %94 to <2 x double>*
%96 = load <2 x double>, <2 x double>* %95
%97 = getelementptr inbounds double, double* %94, i64 2
%98 = bitcast double* %97 to <2 x double>*
%99 = load <2 x double>, <2 x double>* %98
%100 = getelementptr inbounds double, double* %0, i64 %92
%101 = bitcast double* %100 to <2 x double>*
store <2 x double> %96, <2 x double>* %101
%102 = getelementptr inbounds double, double* %100, i64 2
%103 = bitcast double* %102 to <2 x double>*
store <2 x double> %99, <2 x double>* %103
%104 = add nuw i64 %92, 4
%105 = add i64 %93, 1
%106 = icmp eq i64 %105, %35
br i1 %106, label %107, label %91
107: ; preds = %91, %88
%108 = icmp eq i64 %31, %21
br i1 %108, label %170, label %109
109: ; preds = %23, %20, %107
%110 = phi i64 [ 0, %23 ], [ 0, %20 ], [ %31, %107 ]
%111 = xor i64 %110, -1
%112 = add nsw i64 %111, %21
%113 = and i64 %21, 3
%114 = icmp eq i64 %113, 0
br i1 %114, label %124, label %115
115: ; preds = %109, %115
%116 = phi i64 [ %121, %115 ], [ %110, %109 ]
%117 = phi i64 [ %122, %115 ], [ 0, %109 ]
%118 = getelementptr inbounds double, double* %11, i64 %116
%119 = load double, double* %118
%120 = getelementptr inbounds double, double* %0, i64 %116
store double %119, double* %120
%121 = add nuw nsw i64 %116, 1
%122 = add i64 %117, 1
%123 = icmp eq i64 %122, %113
br i1 %123, label %124, label %115
124: ; preds = %115, %109
%125 = phi i64 [ %110, %109 ], [ %121, %115 ]
%126 = icmp ult i64 %112, 3
br i1 %126, label %170, label %151
127: ; preds = %14, %142
%128 = phi i64 [ 1, %14 ], [ %149, %142 ]
%129 = and i64 %128, 1
%130 = icmp eq i64 %129, 0
br i1 %130, label %131, label %133
131: ; preds = %127
%132 = add nsw i64 %128, %15
br label %142
133: ; preds = %127
%134 = getelementptr inbounds double, double* %0, i64 %128
%135 = load double, double* %134
%136 = add nsw i64 %128, -1
%137 = getelementptr inbounds double, double* %11, i64 %136
store double %135, double* %137
%138 = add nsw i64 %128, %15
%139 = getelementptr inbounds double, double* %0, i64 %138
%140 = load double, double* %139
%141 = getelementptr inbounds double, double* %11, i64 %128
store double %140, double* %141
br label %142
142: ; preds = %131, %133
%143 = phi i64 [ %132, %131 ], [ %138, %133 ]
%144 = shl nuw nsw i64 %128, 1
%145 = getelementptr inbounds double, double* %0, i64 %144
%146 = load double, double* %145
%147 = add nsw i64 %143, -1
%148 = getelementptr inbounds double, double* %11, i64 %147
store double %146, double* %148
%149 = add nuw nsw i64 %128, 1
%150 = icmp eq i64 %149, %17
br i1 %150, label %18, label %127
151: ; preds = %124, %151
%152 = phi i64 [ %168, %151 ], [ %125, %124 ]
%153 = getelementptr inbounds double, double* %11, i64 %152
%154 = load double, double* %153
%155 = getelementptr inbounds double, double* %0, i64 %152
store double %154, double* %155
%156 = add nuw nsw i64 %152, 1
%157 = getelementptr inbounds double, double* %11, i64 %156
%158 = load double, double* %157
%159 = getelementptr inbounds double, double* %0, i64 %156
store double %158, double* %159
%160 = add nuw nsw i64 %152, 2
%161 = getelementptr inbounds double, double* %11, i64 %160
%162 = load double, double* %161
%163 = getelementptr inbounds double, double* %0, i64 %160
store double %162, double* %163
%164 = add nuw nsw i64 %152, 3
%165 = getelementptr inbounds double, double* %11, i64 %164
%166 = load double, double* %165
%167 = getelementptr inbounds double, double* %0, i64 %164
store double %166, double* %167
%168 = add nuw nsw i64 %152, 4
%169 = icmp eq i64 %168, %21
br i1 %169, label %170, label %151
170: ; preds = %124, %151, %107, %18
%171 = tail call i32 @free(double* %11)
ret void
}