#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_odd_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 + row * matrixInCol * 2];
  }
  free(matrixInTemp);
  matrix_tran(matrixOutPre, matrixOutRow, matrixInCol, matrixOut, matrixInRow,
              matrixOutCol);
  free(matrixOutPre);
  return;
}


x86 assembly (clang, -O0):
<dyaddown_2D_keep_odd_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    1213 <dyaddown_2D_keep_odd_row+0xe3>
movl   $0x0,-0x28(%rbp)
mov    -0x28(%rbp),%eax
cmp    -0x10(%rbp),%eax
jge    1200 <dyaddown_2D_keep_odd_row+0xd0>
mov    -0x30(%rbp),%rax
mov    -0x28(%rbp),%ecx
mov    -0x24(%rbp),%edx
imul   -0x10(%rbp),%edx
shl    $0x1,%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_odd_row+0x83>
jmp    1205 <dyaddown_2D_keep_odd_row+0xd5>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    11a0 <dyaddown_2D_keep_odd_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_odd_row>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x38,%rsp
mov    %r9d,%r13d
mov    %r8d,%r12d
mov    %rcx,0x30(%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    %r12d,%r14d
mov    %ebp,%esi
mov    %r15d,%edx
mov    %rax,0x8(%rsp)
mov    %rax,%rcx
mov    %r13d,0x20(%rsp)
mov    %r13d,%r8d
mov    %r15d,%r9d
call   1060 <matrix_tran@plt>
mov    %ebp,%edi
imul   %r12d,%edi
shl    $0x3,%edi
call   1050 <malloc@plt>
mov    %rax,(%rsp)
test   %r12d,%r12d
jle    12a5 <dyaddown_2D_keep_odd_row+0x165>
lea    0x0(%rbp,%rbp,1),%r12d
mov    %ebp,%eax
shl    $0x3,%rax
mov    %rax,0x10(%rsp)
mov    %r14d,%eax
xor    %r13d,%r13d
cmp    $0x1,%r14d
je     1274 <dyaddown_2D_keep_odd_row+0x134>
mov    %r14d,0x18(%rsp)
mov    %r15d,0x1c(%rsp)
lea    0x0(,%rbp,4),%ecx
mov    %ecx,0x24(%rsp)
mov    %rax,0x28(%rsp)
mov    %eax,%r14d
and    $0xfffffffe,%r14d
neg    %r14
xor    %r13d,%r13d
xor    %r15d,%r15d
xor    %ebx,%ebx
jmp    1210 <dyaddown_2D_keep_odd_row+0xd0>
nopw   0x0(%rax,%rax,1)
add    0x24(%rsp),%ebx
add    %r12d,%r15d
add    $0xfffffffffffffffe,%r13
cmp    %r13,%r14
je     1262 <dyaddown_2D_keep_odd_row+0x122>
test   %ebp,%ebp
jle    1235 <dyaddown_2D_keep_odd_row+0xf5>
movslq %ebx,%rax
mov    0x8(%rsp),%rcx
lea    (%rcx,%rax,8),%rsi
movslq %r15d,%rax
mov    (%rsp),%rcx
lea    (%rcx,%rax,8),%rdi
mov    0x10(%rsp),%rdx
call   1040 <memcpy@plt>
test   %ebp,%ebp
jle    1200 <dyaddown_2D_keep_odd_row+0xc0>
lea    (%r12,%rbx,1),%eax
cltq
mov    0x8(%rsp),%rcx
lea    (%rcx,%rax,8),%rsi
lea    (%r15,%rbp,1),%eax
cltq
mov    (%rsp),%rcx
lea    (%rcx,%rax,8),%rdi
mov    0x10(%rsp),%rdx
call   1040 <memcpy@plt>
jmp    1200 <dyaddown_2D_keep_odd_row+0xc0>
neg    %r13d
mov    0x1c(%rsp),%r15d
mov    0x18(%rsp),%r14d
mov    0x28(%rsp),%rax
test   $0x1,%al
je     12a5 <dyaddown_2D_keep_odd_row+0x165>
test   %ebp,%ebp
jle    12a5 <dyaddown_2D_keep_odd_row+0x165>
imul   %r13d,%r12d
movslq %r12d,%rax
mov    0x8(%rsp),%rcx
lea    (%rcx,%rax,8),%rsi
imul   %ebp,%r13d
movslq %r13d,%rax
mov    (%rsp),%rcx
lea    (%rcx,%rax,8),%rdi
mov    0x10(%rsp),%rdx
call   1040 <memcpy@plt>
mov    0x8(%rsp),%rdi
call   1030 <free@plt>
mov    (%rsp),%rbx
mov    %rbx,%rdi
mov    %r14d,%esi
mov    %ebp,%edx
mov    0x30(%rsp),%rcx
mov    %r15d,%r8d
mov    0x20(%rsp),%r9d
call   1060 <matrix_tran@plt>
mov    %rbx,%rdi
add    $0x38,%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_odd_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 = %70, %6
%39 = load i32, i32* %13
%40 = load i32, i32* %11
%41 = icmp slt i32 %39, %40
br i1 %41, label %42, label %73
42: ; preds = %38
store i32 0, i32* %14
br label %43
43: ; preds = %66, %42
%44 = load i32, i32* %14
%45 = load i32, i32* %9
%46 = icmp slt i32 %44, %45
br i1 %46, label %47, label %69
47: ; preds = %43
%48 = load double*, double** %15
%49 = load i32, i32* %14
%50 = load i32, i32* %13
%51 = load i32, i32* %9
%52 = mul nsw i32 %50, %51
%53 = mul nsw i32 %52, 2
%54 = add nsw i32 %49, %53
%55 = sext i32 %54 to i64
%56 = getelementptr inbounds double, double* %48, i64 %55
%57 = load double, double* %56
%58 = load double*, double** %16
%59 = load i32, i32* %14
%60 = load i32, i32* %13
%61 = load i32, i32* %9
%62 = mul nsw i32 %60, %61
%63 = add nsw i32 %59, %62
%64 = sext i32 %63 to i64
%65 = getelementptr inbounds double, double* %58, i64 %64
store double %57, double* %65
br label %66
66: ; preds = %47
%67 = load i32, i32* %14
%68 = add nsw i32 %67, 1
store i32 %68, i32* %14
br label %43
69: ; preds = %43
br label %70
70: ; preds = %69
%71 = load i32, i32* %13
%72 = add nsw i32 %71, 1
store i32 %72, i32* %13
br label %38
73: ; preds = %38
%74 = load double*, double** %15
%75 = call i32 @free(double* %74)
%76 = load double*, double** %16
%77 = load i32, i32* %11
%78 = load i32, i32* %9
%79 = load double*, double** %10
%80 = load i32, i32* %8
%81 = load i32, i32* %12
%82 = call i32 @matrix_tran(double* %76, i32 %77, i32 %78, double* %79, i32 %80, i32 %81)
%83 = load double*, double** %16
%84 = call i32 @free(double* %83)
ret void
}

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