#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*/ assert(int);
double **ls_allocate_blockmatrix(size_t const, size_t const *, size_t const);
double **ls_copy_block_matrix(const double *const *B, const size_t dimension,
                              const size_t *block_sizes,
                              const size_t nb_blocks) {
  double **dest;
  size_t i, j, idx_blocksize, current_blocksize, next_bs_change;
  dest = ls_allocate_blockmatrix(dimension, block_sizes, nb_blocks);
  idx_blocksize = 0;
  current_blocksize = block_sizes[idx_blocksize];
  next_bs_change = block_sizes[idx_blocksize];
  assert(nb_blocks != 0);
  for (i = 0; i < dimension; i++) {
    if (i >= next_bs_change) {
      idx_blocksize++;
      next_bs_change += block_sizes[idx_blocksize];
    }
    current_blocksize = block_sizes[idx_blocksize];
    for (j = 0; j < current_blocksize; j++) {
      dest[i][j] = B[i][j];
    }
  }
  return dest;
}


x86 assembly (clang, -O0):
<ls_copy_block_matrix>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    -0x20(%rbp),%rdx
call   1040 <ls_allocate_blockmatrix@plt>
mov    %rax,-0x28(%rbp)
movq   $0x0,-0x40(%rbp)
mov    -0x18(%rbp),%rax
mov    -0x40(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
mov    %rax,-0x48(%rbp)
mov    -0x18(%rbp),%rax
mov    -0x40(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
mov    %rax,-0x50(%rbp)
cmpq   $0x0,-0x20(%rbp)
setne  %al
and    $0x1,%al
movzbl %al,%edi
call   1030 <assert@plt>
movq   $0x0,-0x30(%rbp)
mov    -0x30(%rbp),%rax
cmp    -0x10(%rbp),%rax
jae    1242 <ls_copy_block_matrix+0x122>
mov    -0x30(%rbp),%rax
cmp    -0x50(%rbp),%rax
jb     11cb <ls_copy_block_matrix+0xab>
mov    -0x40(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x40(%rbp)
mov    -0x18(%rbp),%rax
mov    -0x40(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
add    -0x50(%rbp),%rax
mov    %rax,-0x50(%rbp)
mov    -0x18(%rbp),%rax
mov    -0x40(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
mov    %rax,-0x48(%rbp)
movq   $0x0,-0x38(%rbp)
mov    -0x38(%rbp),%rax
cmp    -0x48(%rbp),%rax
jae    122c <ls_copy_block_matrix+0x10c>
mov    -0x8(%rbp),%rax
mov    -0x30(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
mov    -0x38(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
mov    -0x28(%rbp),%rax
mov    -0x30(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
mov    -0x38(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x38(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x38(%rbp)
jmp    11e3 <ls_copy_block_matrix+0xc3>
jmp    1231 <ls_copy_block_matrix+0x111>
mov    -0x30(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x30(%rbp)
jmp    118f <ls_copy_block_matrix+0x6f>
mov    -0x28(%rbp),%rax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ls_copy_block_matrix>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rcx,%r13
mov    %rdx,%r14
mov    %rsi,%r15
mov    %rdi,%rbx
mov    %rsi,%rdi
mov    %rdx,%rsi
mov    %rcx,%rdx
call   1040 <ls_allocate_blockmatrix@plt>
mov    (%r14),%r12
xor    %edi,%edi
test   %r13,%r13
mov    %rax,%r13
setne  %dil
call   1030 <assert@plt>
test   %r15,%r15
je     131a <ls_copy_block_matrix+0x1fa>
mov    %rbx,%r11
xor    %r8d,%r8d
xor    %r9d,%r9d
jmp    117d <ls_copy_block_matrix+0x5d>
nopl   (%rax)
add    $0x1,%r9
cmp    %r15,%r9
je     131a <ls_copy_block_matrix+0x1fa>
cmp    %r12,%r9
jae    1190 <ls_copy_block_matrix+0x70>
mov    (%r14,%r8,8),%rbx
test   %rbx,%rbx
jne    11a1 <ls_copy_block_matrix+0x81>
jmp    1170 <ls_copy_block_matrix+0x50>
nopl   (%rax)
mov    0x8(%r14,%r8,8),%rbx
add    $0x1,%r8
add    %rbx,%r12
test   %rbx,%rbx
je     1170 <ls_copy_block_matrix+0x50>
mov    (%r11,%r9,8),%rsi
mov    0x0(%r13,%r9,8),%rdi
cmp    $0x4,%rbx
jb     11c6 <ls_copy_block_matrix+0xa6>
lea    (%rsi,%rbx,8),%rax
cmp    %rax,%rdi
jae    123c <ls_copy_block_matrix+0x11c>
lea    (%rdi,%rbx,8),%rax
cmp    %rax,%rsi
jae    123c <ls_copy_block_matrix+0x11c>
xor    %edx,%edx
mov    %rdx,%rax
not    %rax
add    %rbx,%rax
mov    %rbx,%rcx
and    $0x3,%rcx
je     11f4 <ls_copy_block_matrix+0xd4>
nopw   0x0(%rax,%rax,1)
movsd  (%rsi,%rdx,8),%xmm0
movsd  %xmm0,(%rdi,%rdx,8)
add    $0x1,%rdx
add    $0xffffffffffffffff,%rcx
jne    11e0 <ls_copy_block_matrix+0xc0>
cmp    $0x3,%rax
jb     1170 <ls_copy_block_matrix+0x50>
xchg   %ax,%ax
movsd  (%rsi,%rdx,8),%xmm0
movsd  %xmm0,(%rdi,%rdx,8)
movsd  0x8(%rsi,%rdx,8),%xmm0
movsd  %xmm0,0x8(%rdi,%rdx,8)
movsd  0x10(%rsi,%rdx,8),%xmm0
movsd  %xmm0,0x10(%rdi,%rdx,8)
movsd  0x18(%rsi,%rdx,8),%xmm0
movsd  %xmm0,0x18(%rdi,%rdx,8)
add    $0x4,%rdx
cmp    %rdx,%rbx
jne    1200 <ls_copy_block_matrix+0xe0>
jmp    1170 <ls_copy_block_matrix+0x50>
mov    %rbx,%rdx
and    $0xfffffffffffffffc,%rdx
lea    -0x4(%rdx),%rax
mov    %rax,%rbp
shr    $0x2,%rbp
add    $0x1,%rbp
mov    %ebp,%r10d
and    $0x3,%r10d
cmp    $0xc,%rax
jae    1263 <ls_copy_block_matrix+0x143>
xor    %ecx,%ecx
jmp    12c8 <ls_copy_block_matrix+0x1a8>
and    $0xfffffffffffffffc,%rbp
xor    %ecx,%ecx
nopl   0x0(%rax)
movups (%rsi,%rcx,8),%xmm0
movups 0x10(%rsi,%rcx,8),%xmm1
movups %xmm0,(%rdi,%rcx,8)
movups %xmm1,0x10(%rdi,%rcx,8)
movups 0x20(%rsi,%rcx,8),%xmm0
movups 0x30(%rsi,%rcx,8),%xmm1
movups %xmm0,0x20(%rdi,%rcx,8)
movups %xmm1,0x30(%rdi,%rcx,8)
movups 0x40(%rsi,%rcx,8),%xmm0
movups 0x50(%rsi,%rcx,8),%xmm1
movups %xmm0,0x40(%rdi,%rcx,8)
movups %xmm1,0x50(%rdi,%rcx,8)
movups 0x60(%rsi,%rcx,8),%xmm0
movups 0x70(%rsi,%rcx,8),%xmm1
movups %xmm0,0x60(%rdi,%rcx,8)
movups %xmm1,0x70(%rdi,%rcx,8)
add    $0x10,%rcx
add    $0xfffffffffffffffc,%rbp
jne    1270 <ls_copy_block_matrix+0x150>
test   %r10,%r10
je     130c <ls_copy_block_matrix+0x1ec>
lea    (%rdi,%rcx,8),%rbp
add    $0x10,%rbp
lea    (%rsi,%rcx,8),%rcx
add    $0x10,%rcx
shl    $0x5,%r10
xor    %eax,%eax
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
movups -0x10(%rcx,%rax,1),%xmm0
movups (%rcx,%rax,1),%xmm1
movups %xmm0,-0x10(%rbp,%rax,1)
movups %xmm1,0x0(%rbp,%rax,1)
add    $0x20,%rax
cmp    %rax,%r10
jne    12f0 <ls_copy_block_matrix+0x1d0>
cmp    %rdx,%rbx
je     1170 <ls_copy_block_matrix+0x50>
jmp    11c8 <ls_copy_block_matrix+0xa8>
mov    %r13,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define double** @ls_copy_block_matrix(double** %0, i64 %1, i64* %2, i64 %3) {
%5 = alloca double**
%6 = alloca i64
%7 = alloca i64*
%8 = alloca i64
%9 = alloca double**
%10 = alloca i64
%11 = alloca i64
%12 = alloca i64
%13 = alloca i64
%14 = alloca i64
store double** %0, double*** %5
store i64 %1, i64* %6
store i64* %2, i64** %7
store i64 %3, i64* %8
%15 = load i64, i64* %6
%16 = load i64*, i64** %7
%17 = load i64, i64* %8
%18 = call double** @ls_allocate_blockmatrix(i64 %15, i64* %16, i64 %17)
store double** %18, double*** %9
store i64 0, i64* %12
%19 = load i64*, i64** %7
%20 = load i64, i64* %12
%21 = getelementptr inbounds i64, i64* %19, i64 %20
%22 = load i64, i64* %21
store i64 %22, i64* %13
%23 = load i64*, i64** %7
%24 = load i64, i64* %12
%25 = getelementptr inbounds i64, i64* %23, i64 %24
%26 = load i64, i64* %25
store i64 %26, i64* %14
%27 = load i64, i64* %8
%28 = icmp ne i64 %27, 0
%29 = zext i1 %28 to i32
%30 = call i32 @assert(i32 %29)
store i64 0, i64* %10
br label %31
31: ; preds = %75, %4
%32 = load i64, i64* %10
%33 = load i64, i64* %6
%34 = icmp ult i64 %32, %33
br i1 %34, label %35, label %78
35: ; preds = %31
%36 = load i64, i64* %10
%37 = load i64, i64* %14
%38 = icmp uge i64 %36, %37
br i1 %38, label %39, label %48
39: ; preds = %35
%40 = load i64, i64* %12
%41 = add i64 %40, 1
store i64 %41, i64* %12
%42 = load i64*, i64** %7
%43 = load i64, i64* %12
%44 = getelementptr inbounds i64, i64* %42, i64 %43
%45 = load i64, i64* %44
%46 = load i64, i64* %14
%47 = add i64 %46, %45
store i64 %47, i64* %14
br label %48
48: ; preds = %39, %35
%49 = load i64*, i64** %7
%50 = load i64, i64* %12
%51 = getelementptr inbounds i64, i64* %49, i64 %50
%52 = load i64, i64* %51
store i64 %52, i64* %13
store i64 0, i64* %11
br label %53
53: ; preds = %71, %48
%54 = load i64, i64* %11
%55 = load i64, i64* %13
%56 = icmp ult i64 %54, %55
br i1 %56, label %57, label %74
57: ; preds = %53
%58 = load double**, double*** %5
%59 = load i64, i64* %10
%60 = getelementptr inbounds double*, double** %58, i64 %59
%61 = load double*, double** %60
%62 = load i64, i64* %11
%63 = getelementptr inbounds double, double* %61, i64 %62
%64 = load double, double* %63
%65 = load double**, double*** %9
%66 = load i64, i64* %10
%67 = getelementptr inbounds double*, double** %65, i64 %66
%68 = load double*, double** %67
%69 = load i64, i64* %11
%70 = getelementptr inbounds double, double* %68, i64 %69
store double %64, double* %70
br label %71
71: ; preds = %57
%72 = load i64, i64* %11
%73 = add i64 %72, 1
store i64 %73, i64* %11
br label %53
74: ; preds = %53
br label %75
75: ; preds = %74
%76 = load i64, i64* %10
%77 = add i64 %76, 1
store i64 %77, i64* %10
br label %31
78: ; preds = %31
%79 = load double**, double*** %9
ret double** %79
}

LLVM IR (-O2):
define double** @ls_copy_block_matrix(double** nocapture %0, i64 %1, i64* %2, i64 %3) {
%5 = tail call double** @ls_allocate_blockmatrix(i64 %1, i64* %2, i64 %3)
%6 = load i64, i64* %2
%7 = icmp ne i64 %3, 0
%8 = zext i1 %7 to i32
%9 = tail call i32 @assert(i32 %8)
%10 = icmp eq i64 %1, 0
br i1 %10, label %160, label %11
11: ; preds = %4, %157
%12 = phi i64 [ %27, %157 ], [ %6, %4 ]
%13 = phi i64 [ %26, %157 ], [ 0, %4 ]
%14 = phi i64 [ %158, %157 ], [ 0, %4 ]
%15 = icmp ult i64 %14, %12
br i1 %15, label %16, label %19
16: ; preds = %11
%17 = getelementptr inbounds i64, i64* %2, i64 %13
%18 = load i64, i64* %17
br label %24
19: ; preds = %11
%20 = add i64 %13, 1
%21 = getelementptr inbounds i64, i64* %2, i64 %20
%22 = load i64, i64* %21
%23 = add i64 %22, %12
br label %24
24: ; preds = %16, %19
%25 = phi i64 [ %22, %19 ], [ %18, %16 ]
%26 = phi i64 [ %20, %19 ], [ %13, %16 ]
%27 = phi i64 [ %23, %19 ], [ %12, %16 ]
%28 = icmp eq i64 %25, 0
br i1 %28, label %157, label %29
29: ; preds = %24
%30 = getelementptr inbounds double*, double** %0, i64 %14
%31 = load double*, double** %30
%32 = getelementptr inbounds double*, double** %5, i64 %14
%33 = load double*, double** %32
%34 = icmp ult i64 %25, 4
br i1 %34, label %120, label %35
35: ; preds = %29
%36 = getelementptr double, double* %33, i64 %25
%37 = getelementptr double, double* %31, i64 %25
%38 = icmp ult double* %33, %37
%39 = icmp ult double* %31, %36
%40 = and i1 %38, %39
br i1 %40, label %120, label %41
41: ; preds = %35
%42 = and i64 %25, -4
%43 = add i64 %42, -4
%44 = lshr exact i64 %43, 2
%45 = add nuw nsw i64 %44, 1
%46 = and i64 %45, 3
%47 = icmp ult i64 %43, 12
br i1 %47, label %99, label %48
48: ; preds = %41
%49 = and i64 %45, 9223372036854775804
br label %50
50: ; preds = %50, %48
%51 = phi i64 [ 0, %48 ], [ %96, %50 ]
%52 = phi i64 [ 0, %48 ], [ %97, %50 ]
%53 = getelementptr inbounds double, double* %31, i64 %51
%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* %33, i64 %51
%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 %51, 4
%64 = getelementptr inbounds double, double* %31, 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* %33, 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 %51, 8
%75 = getelementptr inbounds double, double* %31, 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* %33, 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 = or i64 %51, 12
%86 = getelementptr inbounds double, double* %31, i64 %85
%87 = bitcast double* %86 to <2 x double>*
%88 = load <2 x double>, <2 x double>* %87
%89 = getelementptr inbounds double, double* %86, i64 2
%90 = bitcast double* %89 to <2 x double>*
%91 = load <2 x double>, <2 x double>* %90
%92 = getelementptr inbounds double, double* %33, i64 %85
%93 = bitcast double* %92 to <2 x double>*
store <2 x double> %88, <2 x double>* %93
%94 = getelementptr inbounds double, double* %92, i64 2
%95 = bitcast double* %94 to <2 x double>*
store <2 x double> %91, <2 x double>* %95
%96 = add nuw i64 %51, 16
%97 = add nuw i64 %52, 4
%98 = icmp eq i64 %97, %49
br i1 %98, label %99, label %50
99: ; preds = %50, %41
%100 = phi i64 [ 0, %41 ], [ %96, %50 ]
%101 = icmp eq i64 %46, 0
br i1 %101, label %118, label %102
102: ; preds = %99, %102
%103 = phi i64 [ %115, %102 ], [ %100, %99 ]
%104 = phi i64 [ %116, %102 ], [ 0, %99 ]
%105 = getelementptr inbounds double, double* %31, i64 %103
%106 = bitcast double* %105 to <2 x double>*
%107 = load <2 x double>, <2 x double>* %106
%108 = getelementptr inbounds double, double* %105, i64 2
%109 = bitcast double* %108 to <2 x double>*
%110 = load <2 x double>, <2 x double>* %109
%111 = getelementptr inbounds double, double* %33, i64 %103
%112 = bitcast double* %111 to <2 x double>*
store <2 x double> %107, <2 x double>* %112
%113 = getelementptr inbounds double, double* %111, i64 2
%114 = bitcast double* %113 to <2 x double>*
store <2 x double> %110, <2 x double>* %114
%115 = add nuw i64 %103, 4
%116 = add i64 %104, 1
%117 = icmp eq i64 %116, %46
br i1 %117, label %118, label %102
118: ; preds = %102, %99
%119 = icmp eq i64 %25, %42
br i1 %119, label %157, label %120
120: ; preds = %35, %29, %118
%121 = phi i64 [ 0, %35 ], [ 0, %29 ], [ %42, %118 ]
%122 = xor i64 %121, -1
%123 = add i64 %25, %122
%124 = and i64 %25, 3
%125 = icmp eq i64 %124, 0
br i1 %125, label %135, label %126
126: ; preds = %120, %126
%127 = phi i64 [ %132, %126 ], [ %121, %120 ]
%128 = phi i64 [ %133, %126 ], [ 0, %120 ]
%129 = getelementptr inbounds double, double* %31, i64 %127
%130 = load double, double* %129
%131 = getelementptr inbounds double, double* %33, i64 %127
store double %130, double* %131
%132 = add nuw i64 %127, 1
%133 = add i64 %128, 1
%134 = icmp eq i64 %133, %124
br i1 %134, label %135, label %126
135: ; preds = %126, %120
%136 = phi i64 [ %121, %120 ], [ %132, %126 ]
%137 = icmp ult i64 %123, 3
br i1 %137, label %157, label %138
138: ; preds = %135, %138
%139 = phi i64 [ %155, %138 ], [ %136, %135 ]
%140 = getelementptr inbounds double, double* %31, i64 %139
%141 = load double, double* %140
%142 = getelementptr inbounds double, double* %33, i64 %139
store double %141, double* %142
%143 = add nuw i64 %139, 1
%144 = getelementptr inbounds double, double* %31, i64 %143
%145 = load double, double* %144
%146 = getelementptr inbounds double, double* %33, i64 %143
store double %145, double* %146
%147 = add nuw i64 %139, 2
%148 = getelementptr inbounds double, double* %31, i64 %147
%149 = load double, double* %148
%150 = getelementptr inbounds double, double* %33, i64 %147
store double %149, double* %150
%151 = add nuw i64 %139, 3
%152 = getelementptr inbounds double, double* %31, i64 %151
%153 = load double, double* %152
%154 = getelementptr inbounds double, double* %33, i64 %151
store double %153, double* %154
%155 = add nuw i64 %139, 4
%156 = icmp eq i64 %155, %25
br i1 %156, label %157, label %138
157: ; preds = %135, %138, %118, %24
%158 = add nuw i64 %14, 1
%159 = icmp eq i64 %158, %1
br i1 %159, label %160, label %11
160: ; preds = %157, %4
ret double** %5
}