#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 */
scalar_t__ imatrix_solve_n_m(double *, double *, double *, int, int, char *);
int itransform_affine(double *m, const double src[], const double dst[]) {
  char buffer[(sizeof(int) * 6 + sizeof(double) * (1 * 6 + 6 * 6))];
  double a[6 * 6], b[6], x[6];
  int i, j, k;
  for (i = 0; i < 3; i++) {
    j = i * 12;
    k = i * 12 + 6;
    a[j + 0] = a[k + 3] = src[i * 2 + 0];
    a[j + 1] = a[k + 4] = src[i * 2 + 1];
    a[j + 2] = a[k + 5] = 1;
    a[j + 3] = a[j + 4] = a[j + 5] = 0;
    a[k + 0] = a[k + 1] = a[k + 2] = 0;
    b[i * 2 + 0] = dst[i * 2 + 0];
    b[i * 2 + 1] = dst[i * 2 + 1];
  }
  if (imatrix_solve_n_m(a, b, x, 6, 1, buffer) != 0)
    return -1;
  for (i = 0; i < 6; i++)
    m[i] = x[i];
  m[6] = 0.0;
  m[7] = 0.0;
  m[8] = 1.0;
  return 0;
}


x86 assembly (clang, -O0):
<itransform_affine>:
push   %rbp
mov    %rsp,%rbp
sub    $0x320,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
movl   $0x0,-0x314(%rbp)
cmpl   $0x3,-0x314(%rbp)
jge    130f <itransform_affine+0x1ff>
imul   $0xc,-0x314(%rbp),%eax
mov    %eax,-0x318(%rbp)
imul   $0xc,-0x314(%rbp),%eax
add    $0x6,%eax
mov    %eax,-0x31c(%rbp)
mov    -0x18(%rbp),%rax
mov    -0x314(%rbp),%ecx
shl    $0x1,%ecx
add    $0x0,%ecx
movslq %ecx,%rcx
movsd  (%rax,%rcx,8),%xmm0
mov    -0x31c(%rbp),%eax
add    $0x3,%eax
cltq
movsd  %xmm0,-0x2b0(%rbp,%rax,8)
ff ff
mov    -0x318(%rbp),%eax
add    $0x0,%eax
cltq
movsd  %xmm0,-0x2b0(%rbp,%rax,8)
ff ff
mov    -0x18(%rbp),%rax
mov    -0x314(%rbp),%ecx
shl    $0x1,%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
movsd  (%rax,%rcx,8),%xmm0
mov    -0x31c(%rbp),%eax
add    $0x4,%eax
cltq
movsd  %xmm0,-0x2b0(%rbp,%rax,8)
ff ff
mov    -0x318(%rbp),%eax
add    $0x1,%eax
cltq
movsd  %xmm0,-0x2b0(%rbp,%rax,8)
ff ff
mov    -0x31c(%rbp),%eax
add    $0x5,%eax
cltq
movsd  0xe12(%rip),%xmm0
movsd  %xmm0,-0x2b0(%rbp,%rax,8)
ff ff
mov    -0x318(%rbp),%eax
add    $0x2,%eax
cltq
movsd  0xdf6(%rip),%xmm0
movsd  %xmm0,-0x2b0(%rbp,%rax,8)
ff ff
mov    -0x318(%rbp),%eax
add    $0x5,%eax
cltq
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x2b0(%rbp,%rax,8)
ff ff
mov    -0x318(%rbp),%eax
add    $0x4,%eax
cltq
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x2b0(%rbp,%rax,8)
ff ff
mov    -0x318(%rbp),%eax
add    $0x3,%eax
cltq
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x2b0(%rbp,%rax,8)
ff ff
mov    -0x31c(%rbp),%eax
add    $0x2,%eax
cltq
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x2b0(%rbp,%rax,8)
ff ff
mov    -0x31c(%rbp),%eax
add    $0x1,%eax
cltq
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x2b0(%rbp,%rax,8)
ff ff
mov    -0x31c(%rbp),%eax
add    $0x0,%eax
cltq
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x2b0(%rbp,%rax,8)
ff ff
mov    -0x20(%rbp),%rax
mov    -0x314(%rbp),%ecx
shl    $0x1,%ecx
add    $0x0,%ecx
movslq %ecx,%rcx
movsd  (%rax,%rcx,8),%xmm0
mov    -0x314(%rbp),%eax
shl    $0x1,%eax
add    $0x0,%eax
cltq
movsd  %xmm0,-0x2e0(%rbp,%rax,8)
ff ff
mov    -0x20(%rbp),%rax
mov    -0x314(%rbp),%ecx
shl    $0x1,%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
movsd  (%rax,%rcx,8),%xmm0
mov    -0x314(%rbp),%eax
shl    $0x1,%eax
add    $0x1,%eax
cltq
movsd  %xmm0,-0x2e0(%rbp,%rax,8)
ff ff
mov    -0x314(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x314(%rbp)
jmp    1131 <itransform_affine+0x21>
lea    -0x2b0(%rbp),%rdi
lea    -0x2e0(%rbp),%rsi
lea    -0x310(%rbp),%rdx
lea    -0x190(%rbp),%r9
mov    $0x6,%ecx
mov    $0x1,%r8d
call   1030 <imatrix_solve_n_m@plt>
cmp    $0x0,%rax
je     1351 <itransform_affine+0x241>
movl   $0xffffffff,-0x4(%rbp)
jmp    13cc <itransform_affine+0x2bc>
movl   $0x0,-0x314(%rbp)
cmpl   $0x6,-0x314(%rbp)
jge    139c <itransform_affine+0x28c>
movslq -0x314(%rbp),%rax
movsd  -0x310(%rbp,%rax,8),%xmm0
ff ff
mov    -0x10(%rbp),%rax
movslq -0x314(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x314(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x314(%rbp)
jmp    135b <itransform_affine+0x24b>
mov    -0x10(%rbp),%rax
xorps  %xmm0,%xmm0
movsd  %xmm0,0x30(%rax)
mov    -0x10(%rbp),%rax
xorps  %xmm0,%xmm0
movsd  %xmm0,0x38(%rax)
mov    -0x10(%rbp),%rax
movsd  0xc40(%rip),%xmm0
movsd  %xmm0,0x40(%rax)
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x320,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<itransform_affine>:
push   %r14
push   %rbx
sub    $0x2e8,%rsp
mov    %rdi,%r14
movups (%rsi),%xmm0
movups %xmm0,0xa8(%rsp)
movaps %xmm0,0x60(%rsp)
movabs $0x3ff0000000000000,%rbx
mov    %rbx,0xb8(%rsp)
mov    %rbx,0x70(%rsp)
xorps  %xmm1,%xmm1
movups %xmm1,0x78(%rsp)
movups %xmm1,0x88(%rsp)
movups %xmm1,0x98(%rsp)
movups (%rdx),%xmm0
movaps %xmm0,0x30(%rsp)
movups 0x10(%rsi),%xmm0
movups %xmm0,0x108(%rsp)
movaps %xmm0,0xc0(%rsp)
mov    %rbx,0x118(%rsp)
mov    %rbx,0xd0(%rsp)
movups %xmm1,0xd8(%rsp)
movups %xmm1,0xe8(%rsp)
movups %xmm1,0xf8(%rsp)
movups 0x10(%rdx),%xmm0
movaps %xmm0,0x40(%rsp)
movups 0x20(%rsi),%xmm0
movups %xmm0,0x168(%rsp)
movaps %xmm0,0x120(%rsp)
mov    %rbx,0x178(%rsp)
mov    %rbx,0x130(%rsp)
movups %xmm1,0x138(%rsp)
movups %xmm1,0x148(%rsp)
movups %xmm1,0x158(%rsp)
movups 0x20(%rdx),%xmm0
movaps %xmm0,0x50(%rsp)
lea    0x60(%rsp),%rdi
lea    0x30(%rsp),%rsi
mov    %rsp,%rdx
lea    0x180(%rsp),%r9
mov    $0x6,%ecx
mov    $0x1,%r8d
call   1030 <imatrix_solve_n_m@plt>
mov    %rax,%rcx
mov    $0xffffffff,%eax
test   %rcx,%rcx
jne    124a <itransform_affine+0x13a>
movaps (%rsp),%xmm0
movaps 0x10(%rsp),%xmm1
movaps 0x20(%rsp),%xmm2
movups %xmm2,0x20(%r14)
movups %xmm1,0x10(%r14)
movups %xmm0,(%r14)
xorps  %xmm0,%xmm0
movups %xmm0,0x30(%r14)
mov    %rbx,0x40(%r14)
xor    %eax,%eax
add    $0x2e8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
define i32 @itransform_affine(double* %0, double* %1, double* %2) {
%4 = alloca i32
%5 = alloca double*
%6 = alloca double*
%7 = alloca double*
%8 = alloca [360 x i8]
%9 = alloca [36 x double]
%10 = alloca [6 x double]
%11 = alloca [6 x double]
%12 = alloca i32
%13 = alloca i32
%14 = alloca i32
store double* %0, double** %5
store double* %1, double** %6
store double* %2, double** %7
store i32 0, i32* %12
br label %15
15: ; preds = %110, %3
%16 = load i32, i32* %12
%17 = icmp slt i32 %16, 3
br i1 %17, label %18, label %113
18: ; preds = %15
%19 = load i32, i32* %12
%20 = mul nsw i32 %19, 12
store i32 %20, i32* %13
%21 = load i32, i32* %12
%22 = mul nsw i32 %21, 12
%23 = add nsw i32 %22, 6
store i32 %23, i32* %14
%24 = load double*, double** %6
%25 = load i32, i32* %12
%26 = mul nsw i32 %25, 2
%27 = add nsw i32 %26, 0
%28 = sext i32 %27 to i64
%29 = getelementptr inbounds double, double* %24, i64 %28
%30 = load double, double* %29
%31 = load i32, i32* %14
%32 = add nsw i32 %31, 3
%33 = sext i32 %32 to i64
%34 = getelementptr inbounds [36 x double], [36 x double]* %9, i64 0, i64 %33
store double %30, double* %34
%35 = load i32, i32* %13
%36 = add nsw i32 %35, 0
%37 = sext i32 %36 to i64
%38 = getelementptr inbounds [36 x double], [36 x double]* %9, i64 0, i64 %37
store double %30, double* %38
%39 = load double*, double** %6
%40 = load i32, i32* %12
%41 = mul nsw i32 %40, 2
%42 = add nsw i32 %41, 1
%43 = sext i32 %42 to i64
%44 = getelementptr inbounds double, double* %39, i64 %43
%45 = load double, double* %44
%46 = load i32, i32* %14
%47 = add nsw i32 %46, 4
%48 = sext i32 %47 to i64
%49 = getelementptr inbounds [36 x double], [36 x double]* %9, i64 0, i64 %48
store double %45, double* %49
%50 = load i32, i32* %13
%51 = add nsw i32 %50, 1
%52 = sext i32 %51 to i64
%53 = getelementptr inbounds [36 x double], [36 x double]* %9, i64 0, i64 %52
store double %45, double* %53
%54 = load i32, i32* %14
%55 = add nsw i32 %54, 5
%56 = sext i32 %55 to i64
%57 = getelementptr inbounds [36 x double], [36 x double]* %9, i64 0, i64 %56
store double 1.000000e+00, double* %57
%58 = load i32, i32* %13
%59 = add nsw i32 %58, 2
%60 = sext i32 %59 to i64
%61 = getelementptr inbounds [36 x double], [36 x double]* %9, i64 0, i64 %60
store double 1.000000e+00, double* %61
%62 = load i32, i32* %13
%63 = add nsw i32 %62, 5
%64 = sext i32 %63 to i64
%65 = getelementptr inbounds [36 x double], [36 x double]* %9, i64 0, i64 %64
store double 0.000000e+00, double* %65
%66 = load i32, i32* %13
%67 = add nsw i32 %66, 4
%68 = sext i32 %67 to i64
%69 = getelementptr inbounds [36 x double], [36 x double]* %9, i64 0, i64 %68
store double 0.000000e+00, double* %69
%70 = load i32, i32* %13
%71 = add nsw i32 %70, 3
%72 = sext i32 %71 to i64
%73 = getelementptr inbounds [36 x double], [36 x double]* %9, i64 0, i64 %72
store double 0.000000e+00, double* %73
%74 = load i32, i32* %14
%75 = add nsw i32 %74, 2
%76 = sext i32 %75 to i64
%77 = getelementptr inbounds [36 x double], [36 x double]* %9, i64 0, i64 %76
store double 0.000000e+00, double* %77
%78 = load i32, i32* %14
%79 = add nsw i32 %78, 1
%80 = sext i32 %79 to i64
%81 = getelementptr inbounds [36 x double], [36 x double]* %9, i64 0, i64 %80
store double 0.000000e+00, double* %81
%82 = load i32, i32* %14
%83 = add nsw i32 %82, 0
%84 = sext i32 %83 to i64
%85 = getelementptr inbounds [36 x double], [36 x double]* %9, i64 0, i64 %84
store double 0.000000e+00, double* %85
%86 = load double*, double** %7
%87 = load i32, i32* %12
%88 = mul nsw i32 %87, 2
%89 = add nsw i32 %88, 0
%90 = sext i32 %89 to i64
%91 = getelementptr inbounds double, double* %86, i64 %90
%92 = load double, double* %91
%93 = load i32, i32* %12
%94 = mul nsw i32 %93, 2
%95 = add nsw i32 %94, 0
%96 = sext i32 %95 to i64
%97 = getelementptr inbounds [6 x double], [6 x double]* %10, i64 0, i64 %96
store double %92, double* %97
%98 = load double*, double** %7
%99 = load i32, i32* %12
%100 = mul nsw i32 %99, 2
%101 = add nsw i32 %100, 1
%102 = sext i32 %101 to i64
%103 = getelementptr inbounds double, double* %98, i64 %102
%104 = load double, double* %103
%105 = load i32, i32* %12
%106 = mul nsw i32 %105, 2
%107 = add nsw i32 %106, 1
%108 = sext i32 %107 to i64
%109 = getelementptr inbounds [6 x double], [6 x double]* %10, i64 0, i64 %108
store double %104, double* %109
br label %110
110: ; preds = %18
%111 = load i32, i32* %12
%112 = add nsw i32 %111, 1
store i32 %112, i32* %12
br label %15
113: ; preds = %15
%114 = getelementptr inbounds [36 x double], [36 x double]* %9, i64 0, i64 0
%115 = getelementptr inbounds [6 x double], [6 x double]* %10, i64 0, i64 0
%116 = getelementptr inbounds [6 x double], [6 x double]* %11, i64 0, i64 0
%117 = getelementptr inbounds [360 x i8], [360 x i8]* %8, i64 0, i64 0
%118 = call i64 @imatrix_solve_n_m(double* %114, double* %115, double* %116, i32 6, i32 1, i8* %117)
%119 = icmp ne i64 %118, 0
br i1 %119, label %120, label %121
120: ; preds = %113
store i32 -1, i32* %4
br label %144
121: ; preds = %113
store i32 0, i32* %12
br label %122
122: ; preds = %134, %121
%123 = load i32, i32* %12
%124 = icmp slt i32 %123, 6
br i1 %124, label %125, label %137
125: ; preds = %122
%126 = load i32, i32* %12
%127 = sext i32 %126 to i64
%128 = getelementptr inbounds [6 x double], [6 x double]* %11, i64 0, i64 %127
%129 = load double, double* %128
%130 = load double*, double** %5
%131 = load i32, i32* %12
%132 = sext i32 %131 to i64
%133 = getelementptr inbounds double, double* %130, i64 %132
store double %129, double* %133
br label %134
134: ; preds = %125
%135 = load i32, i32* %12
%136 = add nsw i32 %135, 1
store i32 %136, i32* %12
br label %122
137: ; preds = %122
%138 = load double*, double** %5
%139 = getelementptr inbounds double, double* %138, i64 6
store double 0.000000e+00, double* %139
%140 = load double*, double** %5
%141 = getelementptr inbounds double, double* %140, i64 7
store double 0.000000e+00, double* %141
%142 = load double*, double** %5
%143 = getelementptr inbounds double, double* %142, i64 8
store double 1.000000e+00, double* %143
store i32 0, i32* %4
br label %144
144: ; preds = %137, %120
%145 = load i32, i32* %4
ret i32 %145
}

LLVM IR (-O2):
define i32 @itransform_affine(double* nocapture writeonly %0, double* nocapture %1, double* nocapture %2) {
%4 = alloca [360 x i8]
%5 = alloca [36 x double]
%6 = alloca [6 x double]
%7 = alloca [6 x double]
%8 = bitcast [6 x double]* %7 to i8*
%9 = getelementptr inbounds [360 x i8], [360 x i8]* %4, i64 0, i64 0
%10 = bitcast [36 x double]* %5 to i8*
%11 = bitcast [6 x double]* %6 to i8*
%12 = getelementptr inbounds [36 x double], [36 x double]* %5, i64 0, i64 9
%13 = bitcast double* %1 to <2 x double>*
%14 = load <2 x double>, <2 x double>* %13
%15 = getelementptr inbounds [36 x double], [36 x double]* %5, i64 0, i64 0
%16 = bitcast double* %12 to <2 x double>*
store <2 x double> %14, <2 x double>* %16
%17 = bitcast [36 x double]* %5 to <2 x double>*
store <2 x double> %14, <2 x double>* %17
%18 = getelementptr inbounds [36 x double], [36 x double]* %5, i64 0, i64 11
store double 1.000000e+00, double* %18
%19 = getelementptr inbounds [36 x double], [36 x double]* %5, i64 0, i64 2
store double 1.000000e+00, double* %19
%20 = getelementptr inbounds [36 x double], [36 x double]* %5, i64 0, i64 3
%21 = bitcast double* %20 to i8*
%22 = getelementptr inbounds [6 x double], [6 x double]* %6, i64 0, i64 0
%23 = bitcast double* %2 to <2 x double>*
%24 = load <2 x double>, <2 x double>* %23
%25 = bitcast [6 x double]* %6 to <2 x double>*
store <2 x double> %24, <2 x double>* %25
%26 = getelementptr inbounds double, double* %1, i64 2
%27 = getelementptr inbounds [36 x double], [36 x double]* %5, i64 0, i64 21
%28 = bitcast double* %26 to <2 x double>*
%29 = load <2 x double>, <2 x double>* %28
%30 = getelementptr inbounds [36 x double], [36 x double]* %5, i64 0, i64 12
%31 = bitcast double* %27 to <2 x double>*
store <2 x double> %29, <2 x double>* %31
%32 = bitcast double* %30 to <2 x double>*
store <2 x double> %29, <2 x double>* %32
%33 = getelementptr inbounds [36 x double], [36 x double]* %5, i64 0, i64 23
store double 1.000000e+00, double* %33
%34 = getelementptr inbounds [36 x double], [36 x double]* %5, i64 0, i64 14
store double 1.000000e+00, double* %34
%35 = getelementptr inbounds [36 x double], [36 x double]* %5, i64 0, i64 15
%36 = getelementptr inbounds double, double* %2, i64 2
%37 = bitcast double* %35 to i8*
%38 = getelementptr inbounds [6 x double], [6 x double]* %6, i64 0, i64 2
%39 = bitcast double* %36 to <2 x double>*
%40 = load <2 x double>, <2 x double>* %39
%41 = bitcast double* %38 to <2 x double>*
store <2 x double> %40, <2 x double>* %41
%42 = getelementptr inbounds double, double* %1, i64 4
%43 = getelementptr inbounds [36 x double], [36 x double]* %5, i64 0, i64 33
%44 = bitcast double* %42 to <2 x double>*
%45 = load <2 x double>, <2 x double>* %44
%46 = getelementptr inbounds [36 x double], [36 x double]* %5, i64 0, i64 24
%47 = bitcast double* %43 to <2 x double>*
store <2 x double> %45, <2 x double>* %47
%48 = bitcast double* %46 to <2 x double>*
store <2 x double> %45, <2 x double>* %48
%49 = getelementptr inbounds [36 x double], [36 x double]* %5, i64 0, i64 35
store double 1.000000e+00, double* %49
%50 = getelementptr inbounds [36 x double], [36 x double]* %5, i64 0, i64 26
store double 1.000000e+00, double* %50
%51 = getelementptr inbounds [36 x double], [36 x double]* %5, i64 0, i64 27
%52 = getelementptr inbounds double, double* %2, i64 4
%53 = bitcast double* %51 to i8*
%54 = getelementptr inbounds [6 x double], [6 x double]* %6, i64 0, i64 4
%55 = bitcast double* %52 to <2 x double>*
%56 = load <2 x double>, <2 x double>* %55
%57 = bitcast double* %54 to <2 x double>*
store <2 x double> %56, <2 x double>* %57
%58 = getelementptr inbounds [6 x double], [6 x double]* %7, i64 0, i64 0
%59 = call i64 @imatrix_solve_n_m(double* %15, double* %22, double* %58, i32 6, i32 1, i8* %9)
%60 = icmp eq i64 %59, 0
br i1 %60, label %61, label %66
61: ; preds = %3
%62 = bitcast double* %0 to i8*
%63 = getelementptr inbounds double, double* %0, i64 6
%64 = getelementptr inbounds double, double* %0, i64 8
%65 = bitcast double* %63 to i8*
store double 1.000000e+00, double* %64
br label %66
66: ; preds = %3, %61
%67 = phi i32 [ 0, %61 ], [ -1, %3 ]
ret i32 %67
}