#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(long double *);
long double *malloc(long);
int /*<<< orphan*/ ref_transpose_column(long double **, long, long double *,
                                        long, long);
int /*<<< orphan*/ ref_transpose_line(long double *, long, long double **, long,
                                      long);
int /*<<< orphan*/ ref_xscale(long double *, long, long double *, long, long);
void ref_yscale(long double **in, long width, long in_height, long double **out,
                long out_height, long cmp) {
  long i;
  long double *transposed, *trans_scaled;
  transposed = malloc(in_height * cmp * sizeof(long double));
  trans_scaled = malloc(out_height * cmp * sizeof(long double));
  for (i = 0; i < width; i++) {
    ref_transpose_column(in, in_height, transposed, i * cmp, cmp);
    ref_xscale(transposed, in_height, trans_scaled, out_height, cmp);
    ref_transpose_line(trans_scaled, out_height, out, i * cmp, cmp);
  }
  free(transposed);
  free(trans_scaled);
}


x86 assembly (clang, -O0):
<ref_yscale>:
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    %r8,-0x28(%rbp)
mov    %r9,-0x30(%rbp)
mov    -0x18(%rbp),%rdi
imul   -0x30(%rbp),%rdi
shl    $0x4,%rdi
call   1070 <malloc@plt>
mov    %rax,-0x40(%rbp)
mov    -0x28(%rbp),%rdi
imul   -0x30(%rbp),%rdi
shl    $0x4,%rdi
call   1070 <malloc@plt>
mov    %rax,-0x48(%rbp)
movq   $0x0,-0x38(%rbp)
mov    -0x38(%rbp),%rax
cmp    -0x10(%rbp),%rax
jge    1218 <ref_yscale+0xc8>
mov    -0x8(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    -0x40(%rbp),%rdx
mov    -0x38(%rbp),%rcx
imul   -0x30(%rbp),%rcx
mov    -0x30(%rbp),%r8
call   1060 <ref_transpose_column@plt>
mov    -0x40(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    -0x48(%rbp),%rdx
mov    -0x28(%rbp),%rcx
mov    -0x30(%rbp),%r8
call   1030 <ref_xscale@plt>
mov    -0x48(%rbp),%rdi
mov    -0x28(%rbp),%rsi
mov    -0x20(%rbp),%rdx
mov    -0x38(%rbp),%rcx
imul   -0x30(%rbp),%rcx
mov    -0x30(%rbp),%r8
call   1050 <ref_transpose_line@plt>
mov    -0x38(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x38(%rbp)
jmp    11a4 <ref_yscale+0x54>
mov    -0x40(%rbp),%rdi
call   1040 <free@plt>
mov    -0x48(%rbp),%rdi
call   1040 <free@plt>
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ref_yscale>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x28,%rsp
mov    %r9,%r13
mov    %r8,%r14
mov    %rcx,%r12
mov    %rdx,%rbx
mov    %rsi,%r15
mov    %rdi,%rbp
mov    %rdx,%rdi
imul   %r9,%rdi
shl    $0x4,%rdi
call   1070 <malloc@plt>
mov    %rax,0x8(%rsp)
mov    %r14,0x20(%rsp)
imul   %r13,%r14
shl    $0x4,%r14
mov    %r14,%rdi
call   1070 <malloc@plt>
mov    %rax,(%rsp)
test   %r15,%r15
jle    1215 <ref_yscale+0xc5>
xor    %r14d,%r14d
mov    %r12,0x18(%rsp)
mov    %rbp,0x10(%rsp)
mov    0x20(%rsp),%r12
cs nopw 0x0(%rax,%rax,1)
nop
mov    %rbp,%rdi
mov    %rbx,%rsi
mov    0x8(%rsp),%rbp
mov    %rbp,%rdx
mov    %r14,%rcx
mov    %r13,%r8
call   1060 <ref_transpose_column@plt>
mov    %rbp,%rdi
mov    %rbx,%rsi
mov    (%rsp),%rbp
mov    %rbp,%rdx
mov    %r12,%rcx
mov    %r13,%r8
call   1030 <ref_xscale@plt>
mov    %rbp,%rdi
mov    %r12,%rsi
mov    0x10(%rsp),%rbp
mov    0x18(%rsp),%rdx
mov    %r14,%rcx
mov    %r13,%r8
call   1050 <ref_transpose_line@plt>
add    %r13,%r14
add    $0xffffffffffffffff,%r15
jne    11c0 <ref_yscale+0x70>
mov    0x8(%rsp),%rdi
call   1040 <free@plt>
mov    (%rsp),%rdi
add    $0x28,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1040 <free@plt>

LLVM IR (-O0):
define void @ref_yscale(x86_fp80** %0, i64 %1, i64 %2, x86_fp80** %3, i64 %4, i64 %5) {
%7 = alloca x86_fp80**
%8 = alloca i64
%9 = alloca i64
%10 = alloca x86_fp80**
%11 = alloca i64
%12 = alloca i64
%13 = alloca i64
%14 = alloca x86_fp80*
%15 = alloca x86_fp80*
store x86_fp80** %0, x86_fp80*** %7
store i64 %1, i64* %8
store i64 %2, i64* %9
store x86_fp80** %3, x86_fp80*** %10
store i64 %4, i64* %11
store i64 %5, i64* %12
%16 = load i64, i64* %9
%17 = load i64, i64* %12
%18 = mul nsw i64 %16, %17
%19 = mul i64 %18, 16
%20 = call x86_fp80* @malloc(i64 %19)
store x86_fp80* %20, x86_fp80** %14
%21 = load i64, i64* %11
%22 = load i64, i64* %12
%23 = mul nsw i64 %21, %22
%24 = mul i64 %23, 16
%25 = call x86_fp80* @malloc(i64 %24)
store x86_fp80* %25, x86_fp80** %15
store i64 0, i64* %13
br label %26
26: ; preds = %53, %6
%27 = load i64, i64* %13
%28 = load i64, i64* %8
%29 = icmp slt i64 %27, %28
br i1 %29, label %30, label %56
30: ; preds = %26
%31 = load x86_fp80**, x86_fp80*** %7
%32 = load i64, i64* %9
%33 = load x86_fp80*, x86_fp80** %14
%34 = load i64, i64* %13
%35 = load i64, i64* %12
%36 = mul nsw i64 %34, %35
%37 = load i64, i64* %12
%38 = call i32 @ref_transpose_column(x86_fp80** %31, i64 %32, x86_fp80* %33, i64 %36, i64 %37)
%39 = load x86_fp80*, x86_fp80** %14
%40 = load i64, i64* %9
%41 = load x86_fp80*, x86_fp80** %15
%42 = load i64, i64* %11
%43 = load i64, i64* %12
%44 = call i32 @ref_xscale(x86_fp80* %39, i64 %40, x86_fp80* %41, i64 %42, i64 %43)
%45 = load x86_fp80*, x86_fp80** %15
%46 = load i64, i64* %11
%47 = load x86_fp80**, x86_fp80*** %10
%48 = load i64, i64* %13
%49 = load i64, i64* %12
%50 = mul nsw i64 %48, %49
%51 = load i64, i64* %12
%52 = call i32 @ref_transpose_line(x86_fp80* %45, i64 %46, x86_fp80** %47, i64 %50, i64 %51)
br label %53
53: ; preds = %30
%54 = load i64, i64* %13
%55 = add nsw i64 %54, 1
store i64 %55, i64* %13
br label %26
56: ; preds = %26
%57 = load x86_fp80*, x86_fp80** %14
%58 = call i32 @free(x86_fp80* %57)
%59 = load x86_fp80*, x86_fp80** %15
%60 = call i32 @free(x86_fp80* %59)
ret void
}

LLVM IR (-O2):
define void @ref_yscale(x86_fp80** %0, i64 %1, i64 %2, x86_fp80** %3, i64 %4, i64 %5) {
%7 = shl i64 %2, 4
%8 = mul i64 %7, %5
%9 = tail call x86_fp80* @malloc(i64 %8)
%10 = shl i64 %4, 4
%11 = mul i64 %10, %5
%12 = tail call x86_fp80* @malloc(i64 %11)
%13 = icmp sgt i64 %1, 0
br i1 %13, label %14, label %22
14: ; preds = %6, %14
%15 = phi i64 [ %20, %14 ], [ 0, %6 ]
%16 = mul nsw i64 %15, %5
%17 = tail call i32 @ref_transpose_column(x86_fp80** %0, i64 %2, x86_fp80* %9, i64 %16, i64 %5)
%18 = tail call i32 @ref_xscale(x86_fp80* %9, i64 %2, x86_fp80* %12, i64 %4, i64 %5)
%19 = tail call i32 @ref_transpose_line(x86_fp80* %12, i64 %4, x86_fp80** %3, i64 %16, i64 %5)
%20 = add nuw nsw i64 %15, 1
%21 = icmp eq i64 %20, %1
br i1 %21, label %22, label %14
22: ; preds = %14, %6
%23 = tail call i32 @free(x86_fp80* %9)
%24 = tail call i32 @free(x86_fp80* %12)
ret void
}