#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*/ free(double *);
double *malloc(int);
int /*<<< orphan*/ matrix_tran(double *, int, int, double *, int, int);
void dyaddown_2D_keep_even_row(double *matrixIn, int matrixInRow,
                               int matrixInCol, double *matrixOut,
                               int matrixOutRow, int matrixOutCol) {
  int row, col;
  double *matrixInTemp, *matrixOutPre;
  matrixInTemp = malloc(matrixInRow * matrixInCol * sizeof(double));
  matrix_tran(matrixIn, matrixInCol, matrixInRow, matrixInTemp, matrixOutCol,
              matrixInRow);
  matrixOutPre = malloc(matrixOutRow * matrixInCol * sizeof(double));
  for (row = 0; row < matrixOutRow; row++) {
    for (col = 0; col < matrixInCol; col++)
      matrixOutPre[col + row * matrixInCol] =
          matrixInTemp[col + (2 * row + 1) * matrixInCol];
  }
  free(matrixInTemp);
  matrix_tran(matrixOutPre, matrixOutRow, matrixInCol, matrixOut, matrixInRow,
              matrixOutCol);
  free(matrixOutPre);
  return;
}


x86 assembly (clang, -O0):
<dyaddown_2D_keep_even_row>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
mov    %rcx,-0x18(%rbp)
mov    %r8d,-0x1c(%rbp)
mov    %r9d,-0x20(%rbp)
mov    -0xc(%rbp),%eax
imul   -0x10(%rbp),%eax
cltq
shl    $0x3,%rax
mov    %eax,%edi
call   1040 <malloc@plt>
mov    %rax,-0x30(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%esi
mov    -0xc(%rbp),%edx
mov    -0x30(%rbp),%rcx
mov    -0x20(%rbp),%r8d
mov    -0xc(%rbp),%r9d
call   1050 <matrix_tran@plt>
mov    -0x1c(%rbp),%eax
imul   -0x10(%rbp),%eax
cltq
shl    $0x3,%rax
mov    %eax,%edi
call   1040 <malloc@plt>
mov    %rax,-0x38(%rbp)
movl   $0x0,-0x24(%rbp)
mov    -0x24(%rbp),%eax
cmp    -0x1c(%rbp),%eax
jge    1216 <dyaddown_2D_keep_even_row+0xe6>
movl   $0x0,-0x28(%rbp)
mov    -0x28(%rbp),%eax
cmp    -0x10(%rbp),%eax
jge    1203 <dyaddown_2D_keep_even_row+0xd3>
mov    -0x30(%rbp),%rax
mov    -0x28(%rbp),%ecx
mov    -0x24(%rbp),%edx
shl    $0x1,%edx
add    $0x1,%edx
imul   -0x10(%rbp),%edx
add    %edx,%ecx
movslq %ecx,%rcx
movsd  (%rax,%rcx,8),%xmm0
mov    -0x38(%rbp),%rax
mov    -0x28(%rbp),%ecx
mov    -0x24(%rbp),%edx
imul   -0x10(%rbp),%edx
add    %edx,%ecx
movslq %ecx,%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x28(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x28(%rbp)
jmp    11b3 <dyaddown_2D_keep_even_row+0x83>
jmp    1208 <dyaddown_2D_keep_even_row+0xd8>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    11a0 <dyaddown_2D_keep_even_row+0x70>
mov    -0x30(%rbp),%rdi
call   1030 <free@plt>
mov    -0x38(%rbp),%rdi
mov    -0x1c(%rbp),%esi
mov    -0x10(%rbp),%edx
mov    -0x18(%rbp),%rcx
mov    -0xc(%rbp),%r8d
mov    -0x20(%rbp),%r9d
call   1050 <matrix_tran@plt>
mov    -0x38(%rbp),%rdi
call   1030 <free@plt>
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<dyaddown_2D_keep_even_row>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x58,%rsp
mov    %r9d,%ebx
mov    %r8d,%r12d
mov    %rcx,0x48(%rsp)
mov    %edx,%ebp
mov    %esi,%r15d
mov    %rdi,%r14
mov    %esi,%edi
imul   %edx,%edi
shl    $0x3,%edi
call   1050 <malloc@plt>
mov    %r14,%rdi
mov    %ebx,%r14d
mov    %ebp,%esi
mov    %r15d,%edx
mov    %rax,0x18(%rsp)
mov    %rax,%rcx
mov    %ebx,%r8d
mov    %r15d,%r9d
call   1060 <matrix_tran@plt>
mov    %ebp,%edi
imul   %r12d,%edi
shl    $0x3,%edi
call   1050 <malloc@plt>
mov    %rbp,%rcx
mov    %rax,0x10(%rsp)
test   %r12d,%r12d
jle    12d6 <dyaddown_2D_keep_even_row+0x196>
lea    (%rcx,%rcx,1),%eax
mov    %eax,0xc(%rsp)
mov    %ecx,%eax
shl    $0x3,%rax
mov    %rax,0x20(%rsp)
mov    %r12d,%eax
xor    %r13d,%r13d
cmp    $0x1,%r12d
mov    %rcx,0x28(%rsp)
je     129a <dyaddown_2D_keep_even_row+0x15a>
mov    %r12d,0x34(%rsp)
mov    %r15d,0x38(%rsp)
mov    %r14d,0x3c(%rsp)
lea    (%rcx,%rcx,2),%ebx
lea    0x0(,%rcx,4),%r14d
mov    %rax,0x40(%rsp)
and    $0xfffffffe,%eax
neg    %rax
mov    %rax,0x50(%rsp)
xor    %r15d,%r15d
mov    %ecx,%ebp
xor    %r13d,%r13d
mov    %ecx,%r12d
jmp    122b <dyaddown_2D_keep_even_row+0xeb>
nopl   0x0(%rax)
add    %r14d,%ebx
mov    0xc(%rsp),%eax
add    %eax,%r12d
add    $0xfffffffffffffffe,%r13
add    %r14d,%ebp
add    %eax,%r15d
cmp    %r13,0x50(%rsp)
je     1283 <dyaddown_2D_keep_even_row+0x143>
test   %ecx,%ecx
jle    1256 <dyaddown_2D_keep_even_row+0x116>
movslq %ebp,%rax
mov    0x18(%rsp),%rcx
lea    (%rcx,%rax,8),%rsi
movslq %r15d,%rax
mov    0x10(%rsp),%rcx
lea    (%rcx,%rax,8),%rdi
mov    0x20(%rsp),%rdx
call   1040 <memcpy@plt>
mov    0x28(%rsp),%rcx
test   %ecx,%ecx
jle    1210 <dyaddown_2D_keep_even_row+0xd0>
movslq %ebx,%rax
mov    0x18(%rsp),%rcx
lea    (%rcx,%rax,8),%rsi
movslq %r12d,%rax
mov    0x10(%rsp),%rcx
lea    (%rcx,%rax,8),%rdi
mov    0x20(%rsp),%rdx
call   1040 <memcpy@plt>
mov    0x28(%rsp),%rcx
jmp    1210 <dyaddown_2D_keep_even_row+0xd0>
neg    %r13d
mov    0x3c(%rsp),%r14d
mov    0x38(%rsp),%r15d
mov    0x34(%rsp),%r12d
mov    0x40(%rsp),%rax
test   $0x1,%al
je     12d6 <dyaddown_2D_keep_even_row+0x196>
test   %ecx,%ecx
jle    12d6 <dyaddown_2D_keep_even_row+0x196>
mov    0xc(%rsp),%eax
imul   %r13d,%eax
add    %ecx,%eax
cltq
mov    0x18(%rsp),%rdx
lea    (%rdx,%rax,8),%rsi
imul   %ecx,%r13d
movslq %r13d,%rax
mov    0x10(%rsp),%rcx
lea    (%rcx,%rax,8),%rdi
mov    0x20(%rsp),%rdx
call   1040 <memcpy@plt>
mov    0x28(%rsp),%rcx
mov    0x18(%rsp),%rdi
mov    %rcx,%rbp
call   1030 <free@plt>
mov    0x10(%rsp),%rbx
mov    %rbx,%rdi
mov    %r12d,%esi
mov    %ebp,%edx
mov    0x48(%rsp),%rcx
mov    %r15d,%r8d
mov    %r14d,%r9d
call   1060 <matrix_tran@plt>
mov    %rbx,%rdi
add    $0x58,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <free@plt>

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

LLVM IR (-O2):
define void @dyaddown_2D_keep_even_row(double* %0, i32 %1, i32 %2, double* %3, i32 %4, i32 %5) {
%7 = shl i32 %1, 3
%8 = mul i32 %7, %2
%9 = tail call double* @malloc(i32 %8)
%10 = tail call i32 @matrix_tran(double* %0, i32 %2, i32 %1, double* %9, i32 %5, i32 %1)
%11 = shl i32 %2, 3
%12 = mul i32 %11, %4
%13 = tail call double* @malloc(i32 %12)
%14 = icmp sgt i32 %4, 0
br i1 %14, label %15, label %73
15: ; preds = %6
%16 = icmp sgt i32 %2, 0
%17 = shl i32 %2, 1
%18 = zext i32 %2 to i64
%19 = shl nuw nsw i64 %18, 3
%20 = zext i32 %4 to i64
%21 = and i64 %20, 1
%22 = icmp eq i32 %4, 1
br i1 %22, label %58, label %23
23: ; preds = %15
%24 = and i64 %20, 4294967294
br label %25
25: ; preds = %52, %23
%26 = phi i64 [ 0, %23 ], [ %53, %52 ]
%27 = phi i64 [ 0, %23 ], [ %54, %52 ]
%28 = trunc i64 %26 to i32
br i1 %16, label %29, label %39
29: ; preds = %25
%30 = mul i32 %17, %28
%31 = add i32 %30, %2
%32 = sext i32 %31 to i64
%33 = getelementptr double, double* %9, i64 %32
%34 = bitcast double* %33 to i8*
%35 = mul i32 %28, %2
%36 = sext i32 %35 to i64
%37 = getelementptr double, double* %13, i64 %36
%38 = bitcast double* %37 to i8*
br label %39
39: ; preds = %29, %25
%40 = trunc i64 %26 to i32
%41 = or i32 %40, 1
br i1 %16, label %42, label %52
42: ; preds = %39
%43 = mul i32 %17, %41
%44 = add i32 %43, %2
%45 = sext i32 %44 to i64
%46 = getelementptr double, double* %9, i64 %45
%47 = bitcast double* %46 to i8*
%48 = mul i32 %41, %2
%49 = sext i32 %48 to i64
%50 = getelementptr double, double* %13, i64 %49
%51 = bitcast double* %50 to i8*
br label %52
52: ; preds = %42, %39
%53 = add nuw nsw i64 %26, 2
%54 = add i64 %27, 2
%55 = icmp eq i64 %54, %24
br i1 %55, label %56, label %25
56: ; preds = %52
%57 = trunc i64 %53 to i32
br label %58
58: ; preds = %56, %15
%59 = phi i32 [ 0, %15 ], [ %57, %56 ]
%60 = icmp eq i64 %21, 0
%61 = xor i1 %16, true
%62 = or i1 %60, %61
br i1 %62, label %73, label %63
63: ; preds = %58
%64 = mul i32 %17, %59
%65 = add i32 %64, %2
%66 = sext i32 %65 to i64
%67 = getelementptr double, double* %9, i64 %66
%68 = bitcast double* %67 to i8*
%69 = mul i32 %59, %2
%70 = sext i32 %69 to i64
%71 = getelementptr double, double* %13, i64 %70
%72 = bitcast double* %71 to i8*
br label %73
73: ; preds = %58, %63, %6
%74 = tail call i32 @free(double* %9)
%75 = tail call i32 @matrix_tran(double* %13, i32 %4, i32 %2, double* %3, i32 %1, i32 %5)
%76 = tail call i32 @free(double* %13)
ret void
}