#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 */
size_t ORDER(int, int, int, int);
void ap_inverse_affine_transformation(double *restrict B, double *restrict b,
                                      double *restrict physical_x,
                                      double *restrict physical_y, int length,
                                      double *restrict ref_x,
                                      double *restrict ref_y) {
  int i;
  double determinant = B[ORDER(0, 0, 2, 2)] * B[ORDER(1, 1, 2, 2)] -
                       B[ORDER(0, 1, 2, 2)] * B[ORDER(1, 0, 2, 2)];
  for (i = 0; i < length; i++) {
    ref_x[i] = (B[ORDER(1, 1, 2, 2)] * (physical_x[i] - b[0]) -
                B[ORDER(0, 1, 2, 2)] * (physical_y[i] - b[1])) /
               determinant;
    ref_y[i] = (-1.0 * B[ORDER(1, 0, 2, 2)] * (physical_x[i] - b[0]) +
                B[ORDER(0, 0, 2, 2)] * (physical_y[i] - b[1])) /
               determinant;
  }
}


x86 assembly (clang, -O0):
<ap_inverse_affine_transformation>:
push   %rbp
mov    %rsp,%rbp
sub    $0xc0,%rsp
mov    0x10(%rbp),%rax
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    %r8d,-0x24(%rbp)
mov    %r9,-0x30(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x78(%rbp)
xor    %esi,%esi
mov    $0x2,%ecx
mov    %esi,%edi
mov    %ecx,%edx
call   1030 <ORDER@plt>
mov    %rax,%rcx
mov    -0x78(%rbp),%rax
movsd  (%rax,%rcx,8),%xmm0
movsd  %xmm0,-0x58(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x70(%rbp)
mov    $0x1,%esi
mov    $0x2,%ecx
mov    %esi,%edi
mov    %ecx,%edx
call   1030 <ORDER@plt>
mov    %rax,%rcx
mov    -0x70(%rbp),%rax
movsd  (%rax,%rcx,8),%xmm0
movsd  %xmm0,-0x50(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x68(%rbp)
xor    %edi,%edi
mov    $0x1,%esi
mov    $0x2,%ecx
mov    %ecx,%edx
call   1030 <ORDER@plt>
mov    %rax,%rcx
mov    -0x68(%rbp),%rax
movsd  (%rax,%rcx,8),%xmm0
movsd  %xmm0,-0x60(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x48(%rbp)
mov    $0x1,%edi
xor    %esi,%esi
mov    $0x2,%ecx
mov    %ecx,%edx
call   1030 <ORDER@plt>
movsd  -0x60(%rbp),%xmm1
movsd  -0x58(%rbp),%xmm0
movsd  -0x50(%rbp),%xmm2
mov    %rax,%rcx
mov    -0x48(%rbp),%rax
mulsd  (%rax,%rcx,8),%xmm1
movq   %xmm1,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x40(%rbp)
movl   $0x0,-0x34(%rbp)
mov    -0x34(%rbp),%eax
cmp    -0x24(%rbp),%eax
jge    13cf <ap_inverse_affine_transformation+0x2bf>
mov    -0x8(%rbp),%rax
mov    %rax,-0xb8(%rbp)
mov    $0x1,%esi
mov    $0x2,%ecx
mov    %esi,%edi
mov    %ecx,%edx
call   1030 <ORDER@plt>
mov    %rax,%rcx
mov    -0xb8(%rbp),%rax
movsd  (%rax,%rcx,8),%xmm0
movsd  %xmm0,-0xb0(%rbp)
ff
mov    -0x18(%rbp),%rax
movslq -0x34(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
mov    -0x10(%rbp),%rax
subsd  (%rax),%xmm0
movsd  %xmm0,-0xa8(%rbp)
ff
mov    -0x8(%rbp),%rax
mov    %rax,-0xa0(%rbp)
xor    %edi,%edi
mov    $0x1,%esi
mov    $0x2,%ecx
mov    %ecx,%edx
call   1030 <ORDER@plt>
movsd  -0xb0(%rbp),%xmm0
ff
movsd  -0xa8(%rbp),%xmm2
ff
mov    %rax,%rcx
mov    -0xa0(%rbp),%rax
movsd  (%rax,%rcx,8),%xmm1
mov    -0x20(%rbp),%rax
movslq -0x34(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm3
mov    -0x10(%rbp),%rax
subsd  0x8(%rax),%xmm3
mulsd  %xmm3,%xmm1
movq   %xmm1,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
divsd  -0x40(%rbp),%xmm0
mov    -0x30(%rbp),%rax
movslq -0x34(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x8(%rbp),%rax
mov    %rax,-0x98(%rbp)
mov    $0x1,%edi
xor    %esi,%esi
mov    $0x2,%ecx
mov    %ecx,%edx
call   1030 <ORDER@plt>
mov    %rax,%rcx
mov    -0x98(%rbp),%rax
movsd  0xcd1(%rip),%xmm0
mulsd  (%rax,%rcx,8),%xmm0
movsd  %xmm0,-0x90(%rbp)
ff
mov    -0x18(%rbp),%rax
movslq -0x34(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
mov    -0x10(%rbp),%rax
subsd  (%rax),%xmm0
movsd  %xmm0,-0x88(%rbp)
ff
mov    -0x8(%rbp),%rax
mov    %rax,-0x80(%rbp)
xor    %esi,%esi
mov    $0x2,%ecx
mov    %esi,%edi
mov    %ecx,%edx
call   1030 <ORDER@plt>
movsd  -0x90(%rbp),%xmm0
ff
movsd  -0x88(%rbp),%xmm2
ff
mov    %rax,%rcx
mov    -0x80(%rbp),%rax
movsd  (%rax,%rcx,8),%xmm1
mov    -0x20(%rbp),%rax
movslq -0x34(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm3
mov    -0x10(%rbp),%rax
subsd  0x8(%rax),%xmm3
mulsd  %xmm3,%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
divsd  -0x40(%rbp),%xmm0
mov    0x10(%rbp),%rax
movslq -0x34(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x34(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x34(%rbp)
jmp    1219 <ap_inverse_affine_transformation+0x109>
add    $0xc0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ap_inverse_affine_transformation>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x28,%rsp
mov    %r9,0x10(%rsp)
mov    %r8d,%ebp
mov    %rcx,%r15
mov    %rdx,%r12
mov    %rsi,%r13
mov    %rdi,%rbx
xor    %edi,%edi
xor    %esi,%esi
mov    $0x2,%edx
mov    $0x2,%ecx
call   1030 <ORDER@plt>
movsd  (%rbx,%rax,8),%xmm0
movsd  %xmm0,(%rsp)
mov    $0x1,%edi
mov    $0x1,%esi
mov    $0x2,%edx
mov    $0x2,%ecx
call   1030 <ORDER@plt>
movsd  (%rsp),%xmm0
mulsd  (%rbx,%rax,8),%xmm0
movsd  %xmm0,(%rsp)
xor    %edi,%edi
mov    $0x1,%esi
mov    $0x2,%edx
mov    $0x2,%ecx
call   1030 <ORDER@plt>
movsd  (%rbx,%rax,8),%xmm0
movsd  %xmm0,0x8(%rsp)
mov    $0x1,%edi
xor    %esi,%esi
mov    $0x2,%edx
mov    $0x2,%ecx
call   1030 <ORDER@plt>
test   %ebp,%ebp
jle    12cd <ap_inverse_affine_transformation+0x1bd>
movsd  0x8(%rsp),%xmm1
mulsd  (%rbx,%rax,8),%xmm1
movsd  (%rsp),%xmm0
subsd  %xmm1,%xmm0
movsd  %xmm0,(%rsp)
mov    %ebp,%ebp
xor    %r14d,%r14d
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    $0x1,%edi
mov    $0x1,%esi
mov    $0x2,%edx
mov    $0x2,%ecx
call   1030 <ORDER@plt>
movsd  (%r12,%r14,8),%xmm0
subsd  0x0(%r13),%xmm0
movsd  %xmm0,0x8(%rsp)
movsd  (%rbx,%rax,8),%xmm1
mulsd  %xmm0,%xmm1
movsd  %xmm1,0x18(%rsp)
xor    %edi,%edi
mov    $0x1,%esi
mov    $0x2,%edx
mov    $0x2,%ecx
call   1030 <ORDER@plt>
movsd  (%r15,%r14,8),%xmm1
subsd  0x8(%r13),%xmm1
movsd  %xmm1,0x20(%rsp)
movsd  (%rbx,%rax,8),%xmm0
mulsd  %xmm1,%xmm0
movsd  0x18(%rsp),%xmm1
subsd  %xmm0,%xmm1
divsd  (%rsp),%xmm1
mov    0x10(%rsp),%rax
movsd  %xmm1,(%rax,%r14,8)
mov    $0x1,%edi
xor    %esi,%esi
mov    $0x2,%edx
mov    $0x2,%ecx
call   1030 <ORDER@plt>
movsd  0x8(%rsp),%xmm0
mulsd  (%rbx,%rax,8),%xmm0
movsd  %xmm0,0x8(%rsp)
xor    %edi,%edi
xor    %esi,%esi
mov    $0x2,%edx
mov    $0x2,%ecx
call   1030 <ORDER@plt>
movsd  0x20(%rsp),%xmm0
mulsd  (%rbx,%rax,8),%xmm0
subsd  0x8(%rsp),%xmm0
divsd  (%rsp),%xmm0
mov    0x60(%rsp),%rax
movsd  %xmm0,(%rax,%r14,8)
add    $0x1,%r14
cmp    %r14,%rbp
jne    11e0 <ap_inverse_affine_transformation+0xd0>
add    $0x28,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define void @ap_inverse_affine_transformation(double* noalias %0, double* noalias %1, double* noalias %2, double* noalias %3, i32 %4, double* noalias %5, double* noalias %6) {
%8 = alloca double*
%9 = alloca double*
%10 = alloca double*
%11 = alloca double*
%12 = alloca i32
%13 = alloca double*
%14 = alloca double*
%15 = alloca i32
%16 = alloca double
store double* %0, double** %8
store double* %1, double** %9
store double* %2, double** %10
store double* %3, double** %11
store i32 %4, i32* %12
store double* %5, double** %13
store double* %6, double** %14
%17 = load double*, double** %8
%18 = call i64 @ORDER(i32 0, i32 0, i32 2, i32 2)
%19 = getelementptr inbounds double, double* %17, i64 %18
%20 = load double, double* %19
%21 = load double*, double** %8
%22 = call i64 @ORDER(i32 1, i32 1, i32 2, i32 2)
%23 = getelementptr inbounds double, double* %21, i64 %22
%24 = load double, double* %23
%25 = load double*, double** %8
%26 = call i64 @ORDER(i32 0, i32 1, i32 2, i32 2)
%27 = getelementptr inbounds double, double* %25, i64 %26
%28 = load double, double* %27
%29 = load double*, double** %8
%30 = call i64 @ORDER(i32 1, i32 0, i32 2, i32 2)
%31 = getelementptr inbounds double, double* %29, i64 %30
%32 = load double, double* %31
%33 = fmul double %28, %32
%34 = fneg double %33
%35 = call double @llvm.fmuladd.f64(double %20, double %24, double %34)
store double %35, double* %16
store i32 0, i32* %15
br label %36
36: ; preds = %111, %7
%37 = load i32, i32* %15
%38 = load i32, i32* %12
%39 = icmp slt i32 %37, %38
br i1 %39, label %40, label %114
40: ; preds = %36
%41 = load double*, double** %8
%42 = call i64 @ORDER(i32 1, i32 1, i32 2, i32 2)
%43 = getelementptr inbounds double, double* %41, i64 %42
%44 = load double, double* %43
%45 = load double*, double** %10
%46 = load i32, i32* %15
%47 = sext i32 %46 to i64
%48 = getelementptr inbounds double, double* %45, i64 %47
%49 = load double, double* %48
%50 = load double*, double** %9
%51 = getelementptr inbounds double, double* %50, i64 0
%52 = load double, double* %51
%53 = fsub double %49, %52
%54 = load double*, double** %8
%55 = call i64 @ORDER(i32 0, i32 1, i32 2, i32 2)
%56 = getelementptr inbounds double, double* %54, i64 %55
%57 = load double, double* %56
%58 = load double*, double** %11
%59 = load i32, i32* %15
%60 = sext i32 %59 to i64
%61 = getelementptr inbounds double, double* %58, i64 %60
%62 = load double, double* %61
%63 = load double*, double** %9
%64 = getelementptr inbounds double, double* %63, i64 1
%65 = load double, double* %64
%66 = fsub double %62, %65
%67 = fmul double %57, %66
%68 = fneg double %67
%69 = call double @llvm.fmuladd.f64(double %44, double %53, double %68)
%70 = load double, double* %16
%71 = fdiv double %69, %70
%72 = load double*, double** %13
%73 = load i32, i32* %15
%74 = sext i32 %73 to i64
%75 = getelementptr inbounds double, double* %72, i64 %74
store double %71, double* %75
%76 = load double*, double** %8
%77 = call i64 @ORDER(i32 1, i32 0, i32 2, i32 2)
%78 = getelementptr inbounds double, double* %76, i64 %77
%79 = load double, double* %78
%80 = fmul double -1.000000e+00, %79
%81 = load double*, double** %10
%82 = load i32, i32* %15
%83 = sext i32 %82 to i64
%84 = getelementptr inbounds double, double* %81, i64 %83
%85 = load double, double* %84
%86 = load double*, double** %9
%87 = getelementptr inbounds double, double* %86, i64 0
%88 = load double, double* %87
%89 = fsub double %85, %88
%90 = load double*, double** %8
%91 = call i64 @ORDER(i32 0, i32 0, i32 2, i32 2)
%92 = getelementptr inbounds double, double* %90, i64 %91
%93 = load double, double* %92
%94 = load double*, double** %11
%95 = load i32, i32* %15
%96 = sext i32 %95 to i64
%97 = getelementptr inbounds double, double* %94, i64 %96
%98 = load double, double* %97
%99 = load double*, double** %9
%100 = getelementptr inbounds double, double* %99, i64 1
%101 = load double, double* %100
%102 = fsub double %98, %101
%103 = fmul double %93, %102
%104 = call double @llvm.fmuladd.f64(double %80, double %89, double %103)
%105 = load double, double* %16
%106 = fdiv double %104, %105
%107 = load double*, double** %14
%108 = load i32, i32* %15
%109 = sext i32 %108 to i64
%110 = getelementptr inbounds double, double* %107, i64 %109
store double %106, double* %110
br label %111
111: ; preds = %40
%112 = load i32, i32* %15
%113 = add nsw i32 %112, 1
store i32 %113, i32* %15
br label %36
114: ; preds = %36
ret void
}

LLVM IR (-O2):
define void @ap_inverse_affine_transformation(double* noalias nocapture %0, double* noalias nocapture %1, double* noalias nocapture %2, double* noalias nocapture %3, i32 %4, double* noalias nocapture writeonly %5, double* noalias nocapture writeonly %6) {
%8 = tail call i64 @ORDER(i32 0, i32 0, i32 2, i32 2)
%9 = getelementptr inbounds double, double* %0, i64 %8
%10 = load double, double* %9
%11 = tail call i64 @ORDER(i32 1, i32 1, i32 2, i32 2)
%12 = getelementptr inbounds double, double* %0, i64 %11
%13 = load double, double* %12
%14 = tail call i64 @ORDER(i32 0, i32 1, i32 2, i32 2)
%15 = getelementptr inbounds double, double* %0, i64 %14
%16 = load double, double* %15
%17 = tail call i64 @ORDER(i32 1, i32 0, i32 2, i32 2)
%18 = getelementptr inbounds double, double* %0, i64 %17
%19 = load double, double* %18
%20 = fneg double %16
%21 = fmul double %19, %20
%22 = tail call double @llvm.fmuladd.f64(double %10, double %13, double %21)
%23 = icmp sgt i32 %4, 0
br i1 %23, label %24, label %61
24: ; preds = %7
%25 = getelementptr inbounds double, double* %1, i64 1
%26 = zext i32 %4 to i64
br label %27
27: ; preds = %24, %27
%28 = phi i64 [ 0, %24 ], [ %59, %27 ]
%29 = tail call i64 @ORDER(i32 1, i32 1, i32 2, i32 2)
%30 = getelementptr inbounds double, double* %0, i64 %29
%31 = load double, double* %30
%32 = getelementptr inbounds double, double* %2, i64 %28
%33 = load double, double* %32
%34 = load double, double* %1
%35 = fsub double %33, %34
%36 = tail call i64 @ORDER(i32 0, i32 1, i32 2, i32 2)
%37 = getelementptr inbounds double, double* %0, i64 %36
%38 = load double, double* %37
%39 = getelementptr inbounds double, double* %3, i64 %28
%40 = load double, double* %39
%41 = load double, double* %25
%42 = fsub double %40, %41
%43 = fneg double %38
%44 = fmul double %42, %43
%45 = tail call double @llvm.fmuladd.f64(double %31, double %35, double %44)
%46 = fdiv double %45, %22
%47 = getelementptr inbounds double, double* %5, i64 %28
store double %46, double* %47
%48 = tail call i64 @ORDER(i32 1, i32 0, i32 2, i32 2)
%49 = getelementptr inbounds double, double* %0, i64 %48
%50 = load double, double* %49
%51 = fneg double %50
%52 = tail call i64 @ORDER(i32 0, i32 0, i32 2, i32 2)
%53 = getelementptr inbounds double, double* %0, i64 %52
%54 = load double, double* %53
%55 = fmul double %42, %54
%56 = tail call double @llvm.fmuladd.f64(double %51, double %35, double %55)
%57 = fdiv double %56, %22
%58 = getelementptr inbounds double, double* %6, i64 %28
store double %57, double* %58
%59 = add nuw nsw i64 %28, 1
%60 = icmp eq i64 %59, %26
br i1 %60, label %61, label %27
61: ; preds = %27, %7
ret void
}