#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 */
double **bbob2009_reshape(double **B, double *vector, size_t m, size_t n) {
  size_t i, j;
  for (i = 0; i < m; i++) {
    for (j = 0; j < n; j++) {
      B[i][j] = vector[j * m + i];
    }
  }
  return B;
}


x86 assembly (clang, -O0):
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
movq   $0x0,-0x28(%rbp)
mov    -0x28(%rbp),%rax
cmp    -0x18(%rbp),%rax
jae    1192 <bbob2009_reshape+0x92>
movq   $0x0,-0x30(%rbp)
mov    -0x30(%rbp),%rax
cmp    -0x20(%rbp),%rax
jae    117c <bbob2009_reshape+0x7c>
mov    -0x10(%rbp),%rax
mov    -0x30(%rbp),%rcx
imul   -0x18(%rbp),%rcx
add    -0x28(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
mov    -0x8(%rbp),%rax
mov    -0x28(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
mov    -0x30(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x30(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x30(%rbp)
jmp    1132 <bbob2009_reshape+0x32>
jmp    1181 <bbob2009_reshape+0x81>
mov    -0x28(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x28(%rbp)
jmp    111c <bbob2009_reshape+0x1c>
mov    -0x8(%rbp),%rax
pop    %rbp
ret

x86 assembly (clang, -O2):
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
mov    %rdi,-0x30(%rsp)
mov    %rdx,-0x38(%rsp)
test   %rdx,%rdx
je     1351 <bbob2009_reshape+0x251>
lea    -0x4(%rcx),%rax
mov    %rax,-0x10(%rsp)
mov    %rax,%rdx
shr    $0x2,%rdx
add    $0x1,%rdx
cmp    $0x4,%rcx
setae  %al
mov    -0x38(%rsp),%rbp
cmp    $0x1,%rbp
sete   %bl
and    %al,%bl
mov    %bl,-0x39(%rsp)
mov    %rcx,%rax
and    $0xfffffffffffffffc,%rax
mov    %rax,-0x20(%rsp)
mov    %rdx,%rax
mov    %rdx,-0x18(%rsp)
and    $0xfffffffffffffffe,%rdx
mov    %rdx,-0x28(%rsp)
mov    %ecx,%eax
and    $0x3,%eax
mov    %rax,-0x8(%rsp)
mov    %rbp,%rdi
shl    $0x5,%rdi
lea    0x10(%rsi),%r13
mov    %rbp,%rdx
shl    $0x6,%rdx
lea    0x0(,%rbp,8),%r15
xor    %r12d,%r12d
xor    %r11d,%r11d
jmp    11b7 <bbob2009_reshape+0xb7>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
add    $0x1,%r11
add    $0x8,%r13
add    $0x8,%r12
cmp    -0x38(%rsp),%r11
je     1351 <bbob2009_reshape+0x251>
test   %rcx,%rcx
je     11a0 <bbob2009_reshape+0xa0>
mov    -0x30(%rsp),%rax
mov    (%rax,%r11,8),%r8
cmpb   $0x0,-0x39(%rsp)
je     11ee <bbob2009_reshape+0xee>
lea    (%r11,%rcx,1),%rax
lea    (%rsi,%rax,8),%rax
cmp    %rax,%r8
jae    12c5 <bbob2009_reshape+0x1c5>
lea    (%rsi,%r11,8),%rax
lea    (%r8,%rcx,8),%rbp
cmp    %rbp,%rax
jae    12c5 <bbob2009_reshape+0x1c5>
xor    %r14d,%r14d
mov    %r14,%rbp
not    %rbp
add    %rcx,%rbp
mov    -0x8(%rsp),%rbx
test   %rbx,%rbx
je     1237 <bbob2009_reshape+0x137>
mov    -0x38(%rsp),%rax
imul   %r14,%rax
add    %r11,%rax
lea    (%rsi,%rax,8),%rax
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
movsd  (%rax),%xmm0
movsd  %xmm0,(%r8,%r14,8)
add    $0x1,%r14
add    %r15,%rax
add    $0xffffffffffffffff,%rbx
jne    1220 <bbob2009_reshape+0x120>
cmp    $0x3,%rbp
jb     11a0 <bbob2009_reshape+0xa0>
lea    0x3(%r14),%rax
mov    -0x38(%rsp),%rbx
imul   %rbx,%rax
lea    (%rsi,%rax,8),%rbp
lea    0x2(%r14),%rax
imul   %rbx,%rax
lea    (%rsi,%rax,8),%r9
lea    0x1(%r14),%rax
imul   %rbx,%rax
lea    (%rsi,%rax,8),%rax
imul   %r14,%rbx
lea    (%rsi,%rbx,8),%rbx
mov    %r12,%r10
cs nopw 0x0(%rax,%rax,1)
nop
movsd  (%rbx,%r10,1),%xmm0
movsd  %xmm0,(%r8,%r14,8)
movsd  (%rax,%r10,1),%xmm0
movsd  %xmm0,0x8(%r8,%r14,8)
movsd  (%r9,%r10,1),%xmm0
movsd  %xmm0,0x10(%r8,%r14,8)
movsd  0x0(%rbp,%r10,1),%xmm0
movsd  %xmm0,0x18(%r8,%r14,8)
add    $0x4,%r14
add    %rdi,%r10
cmp    %r14,%rcx
jne    1280 <bbob2009_reshape+0x180>
jmp    11a0 <bbob2009_reshape+0xa0>
cmpq   $0x4,-0x10(%rsp)
jae    12d1 <bbob2009_reshape+0x1d1>
xor    %ebp,%ebp
jmp    1314 <bbob2009_reshape+0x214>
mov    -0x28(%rsp),%rax
mov    %r13,%rbx
xor    %ebp,%ebp
nopl   0x0(%rax,%rax,1)
movups -0x10(%rbx),%xmm0
movups (%rbx),%xmm1
movups %xmm0,(%r8,%rbp,8)
movups %xmm1,0x10(%r8,%rbp,8)
movups -0x10(%rbx,%rdi,1),%xmm0
movups (%rbx,%rdi,1),%xmm1
movups %xmm0,0x20(%r8,%rbp,8)
movups %xmm1,0x30(%r8,%rbp,8)
add    $0x8,%rbp
add    %rdx,%rbx
add    $0xfffffffffffffffe,%rax
jne    12e0 <bbob2009_reshape+0x1e0>
testb  $0x1,-0x18(%rsp)
je     133b <bbob2009_reshape+0x23b>
mov    %rbp,%rax
imul   -0x38(%rsp),%rax
add    %r11,%rax
movups (%rsi,%rax,8),%xmm0
movups 0x10(%rsi,%rax,8),%xmm1
movups %xmm0,(%r8,%rbp,8)
movups %xmm1,0x10(%r8,%rbp,8)
mov    -0x20(%rsp),%rax
mov    %rax,%r14
cmp    %rcx,%rax
je     11a0 <bbob2009_reshape+0xa0>
jmp    11f1 <bbob2009_reshape+0xf1>
mov    -0x30(%rsp),%rax
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define double** @bbob2009_reshape(double** %0, double* %1, i64 %2, i64 %3) {
%5 = alloca double**
%6 = alloca double*
%7 = alloca i64
%8 = alloca i64
%9 = alloca i64
%10 = alloca i64
store double** %0, double*** %5
store double* %1, double** %6
store i64 %2, i64* %7
store i64 %3, i64* %8
store i64 0, i64* %9
br label %11
11: ; preds = %39, %4
%12 = load i64, i64* %9
%13 = load i64, i64* %7
%14 = icmp ult i64 %12, %13
br i1 %14, label %15, label %42
15: ; preds = %11
store i64 0, i64* %10
br label %16
16: ; preds = %35, %15
%17 = load i64, i64* %10
%18 = load i64, i64* %8
%19 = icmp ult i64 %17, %18
br i1 %19, label %20, label %38
20: ; preds = %16
%21 = load double*, double** %6
%22 = load i64, i64* %10
%23 = load i64, i64* %7
%24 = mul i64 %22, %23
%25 = load i64, i64* %9
%26 = add i64 %24, %25
%27 = getelementptr inbounds double, double* %21, i64 %26
%28 = load double, double* %27
%29 = load double**, double*** %5
%30 = load i64, i64* %9
%31 = getelementptr inbounds double*, double** %29, i64 %30
%32 = load double*, double** %31
%33 = load i64, i64* %10
%34 = getelementptr inbounds double, double* %32, i64 %33
store double %28, double* %34
br label %35
35: ; preds = %20
%36 = load i64, i64* %10
%37 = add i64 %36, 1
store i64 %37, i64* %10
br label %16
38: ; preds = %16
br label %39
39: ; preds = %38
%40 = load i64, i64* %9
%41 = add i64 %40, 1
store i64 %41, i64* %9
br label %11
42: ; preds = %11
%43 = load double**, double*** %5
ret double** %43
}

LLVM IR (-O2):
define double** @bbob2009_reshape(double** returned %0, double* nocapture %1, i64 %2, i64 %3) {
%5 = icmp eq i64 %2, 0
br i1 %5, label %131, label %6
6: ; preds = %4
%7 = icmp eq i64 %3, 0
%8 = add i64 %3, -4
%9 = lshr i64 %8, 2
%10 = add nuw nsw i64 %9, 1
%11 = icmp ugt i64 %3, 3
%12 = icmp eq i64 %2, 1
%13 = and i1 %11, %12
%14 = and i64 %3, -4
%15 = and i64 %10, 1
%16 = icmp ult i64 %8, 4
%17 = and i64 %10, 9223372036854775806
%18 = icmp eq i64 %15, 0
%19 = icmp eq i64 %14, %3
%20 = and i64 %3, 3
%21 = icmp eq i64 %20, 0
br label %22
22: ; preds = %6, %128
%23 = phi i64 [ 0, %6 ], [ %129, %128 ]
%24 = getelementptr double, double* %1, i64 %23
%25 = add i64 %23, %3
%26 = getelementptr double, double* %1, i64 %25
br i1 %7, label %128, label %27
27: ; preds = %22
%28 = getelementptr inbounds double*, double** %0, i64 %23
%29 = load double*, double** %28
br i1 %13, label %30, label %83
30: ; preds = %27
%31 = getelementptr double, double* %29, i64 %3
%32 = icmp ult double* %29, %26
%33 = icmp ult double* %24, %31
%34 = and i1 %32, %33
br i1 %34, label %83, label %35
35: ; preds = %30
br i1 %16, label %67, label %36
36: ; preds = %35, %36
%37 = phi i64 [ %64, %36 ], [ 0, %35 ]
%38 = phi i64 [ %65, %36 ], [ 0, %35 ]
%39 = mul i64 %37, %2
%40 = add i64 %39, %23
%41 = getelementptr inbounds double, double* %1, i64 %40
%42 = bitcast double* %41 to <2 x double>*
%43 = load <2 x double>, <2 x double>* %42
%44 = getelementptr inbounds double, double* %41, i64 2
%45 = bitcast double* %44 to <2 x double>*
%46 = load <2 x double>, <2 x double>* %45
%47 = getelementptr inbounds double, double* %29, i64 %37
%48 = bitcast double* %47 to <2 x double>*
store <2 x double> %43, <2 x double>* %48
%49 = getelementptr inbounds double, double* %47, i64 2
%50 = bitcast double* %49 to <2 x double>*
store <2 x double> %46, <2 x double>* %50
%51 = or i64 %37, 4
%52 = mul i64 %51, %2
%53 = add i64 %52, %23
%54 = getelementptr inbounds double, double* %1, i64 %53
%55 = bitcast double* %54 to <2 x double>*
%56 = load <2 x double>, <2 x double>* %55
%57 = getelementptr inbounds double, double* %54, i64 2
%58 = bitcast double* %57 to <2 x double>*
%59 = load <2 x double>, <2 x double>* %58
%60 = getelementptr inbounds double, double* %29, i64 %51
%61 = bitcast double* %60 to <2 x double>*
store <2 x double> %56, <2 x double>* %61
%62 = getelementptr inbounds double, double* %60, i64 2
%63 = bitcast double* %62 to <2 x double>*
store <2 x double> %59, <2 x double>* %63
%64 = add nuw i64 %37, 8
%65 = add i64 %38, 2
%66 = icmp eq i64 %65, %17
br i1 %66, label %67, label %36
67: ; preds = %36, %35
%68 = phi i64 [ 0, %35 ], [ %64, %36 ]
br i1 %18, label %82, label %69
69: ; preds = %67
%70 = mul i64 %68, %2
%71 = add i64 %70, %23
%72 = getelementptr inbounds double, double* %1, i64 %71
%73 = bitcast double* %72 to <2 x double>*
%74 = load <2 x double>, <2 x double>* %73
%75 = getelementptr inbounds double, double* %72, i64 2
%76 = bitcast double* %75 to <2 x double>*
%77 = load <2 x double>, <2 x double>* %76
%78 = getelementptr inbounds double, double* %29, i64 %68
%79 = bitcast double* %78 to <2 x double>*
store <2 x double> %74, <2 x double>* %79
%80 = getelementptr inbounds double, double* %78, i64 2
%81 = bitcast double* %80 to <2 x double>*
store <2 x double> %77, <2 x double>* %81
br label %82
82: ; preds = %67, %69
br i1 %19, label %128, label %83
83: ; preds = %30, %27, %82
%84 = phi i64 [ 0, %30 ], [ 0, %27 ], [ %14, %82 ]
%85 = xor i64 %84, -1
%86 = add i64 %85, %3
br i1 %21, label %98, label %87
87: ; preds = %83, %87
%88 = phi i64 [ %95, %87 ], [ %84, %83 ]
%89 = phi i64 [ %96, %87 ], [ 0, %83 ]
%90 = mul i64 %88, %2
%91 = add i64 %90, %23
%92 = getelementptr inbounds double, double* %1, i64 %91
%93 = load double, double* %92
%94 = getelementptr inbounds double, double* %29, i64 %88
store double %93, double* %94
%95 = add nuw i64 %88, 1
%96 = add i64 %89, 1
%97 = icmp eq i64 %96, %20
br i1 %97, label %98, label %87
98: ; preds = %87, %83
%99 = phi i64 [ %84, %83 ], [ %95, %87 ]
%100 = icmp ult i64 %86, 3
br i1 %100, label %128, label %101
101: ; preds = %98, %101
%102 = phi i64 [ %126, %101 ], [ %99, %98 ]
%103 = mul i64 %102, %2
%104 = add i64 %103, %23
%105 = getelementptr inbounds double, double* %1, i64 %104
%106 = load double, double* %105
%107 = getelementptr inbounds double, double* %29, i64 %102
store double %106, double* %107
%108 = add nuw i64 %102, 1
%109 = mul i64 %108, %2
%110 = add i64 %109, %23
%111 = getelementptr inbounds double, double* %1, i64 %110
%112 = load double, double* %111
%113 = getelementptr inbounds double, double* %29, i64 %108
store double %112, double* %113
%114 = add nuw i64 %102, 2
%115 = mul i64 %114, %2
%116 = add i64 %115, %23
%117 = getelementptr inbounds double, double* %1, i64 %116
%118 = load double, double* %117
%119 = getelementptr inbounds double, double* %29, i64 %114
store double %118, double* %119
%120 = add nuw i64 %102, 3
%121 = mul i64 %120, %2
%122 = add i64 %121, %23
%123 = getelementptr inbounds double, double* %1, i64 %122
%124 = load double, double* %123
%125 = getelementptr inbounds double, double* %29, i64 %120
store double %124, double* %125
%126 = add nuw i64 %102, 4
%127 = icmp eq i64 %126, %3
br i1 %127, label %128, label %101
128: ; preds = %98, %101, %82, %22
%129 = add nuw i64 %23, 1
%130 = icmp eq i64 %129, %2
br i1 %130, label %131, label %22
131: ; preds = %128, %4
ret double** %0
}