int scg_affine(int nV, double *Vertex, double *matrix) {
  int i;
  double v1, v2, v3;
  for (i = 0; i < nV; i++) {
    v1 = Vertex[i * 3];
    v2 = Vertex[i * 3 + 1];
    v3 = Vertex[i * 3 + 2];
    Vertex[i * 3] = matrix[0] * v1 + matrix[1] * v2 + matrix[2] * v3;
    Vertex[i * 3 + 1] = matrix[3] * v1 + matrix[4] * v2 + matrix[5] * v3;
    Vertex[i * 3 + 2] = matrix[6] * v1 + matrix[7] * v2 + matrix[8] * v3;
  }
  return 0;
}


x86 assembly (clang, -O0):
<scg_affine>:
push   %rbp
mov    %rsp,%rbp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0x4(%rbp),%eax
jge    1258 <scg_affine+0x158>
mov    -0x10(%rbp),%rax
imul   $0x3,-0x1c(%rbp),%ecx
movslq %ecx,%rcx
movsd  (%rax,%rcx,8),%xmm0
movsd  %xmm0,-0x28(%rbp)
mov    -0x10(%rbp),%rax
imul   $0x3,-0x1c(%rbp),%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
movsd  (%rax,%rcx,8),%xmm0
movsd  %xmm0,-0x30(%rbp)
mov    -0x10(%rbp),%rax
imul   $0x3,-0x1c(%rbp),%ecx
add    $0x2,%ecx
movslq %ecx,%rcx
movsd  (%rax,%rcx,8),%xmm0
movsd  %xmm0,-0x38(%rbp)
mov    -0x18(%rbp),%rax
movsd  (%rax),%xmm1
movsd  -0x28(%rbp),%xmm2
mov    -0x18(%rbp),%rax
movsd  0x8(%rax),%xmm0
mulsd  -0x30(%rbp),%xmm0
mulsd  %xmm2,%xmm1
addsd  %xmm0,%xmm1
mov    -0x18(%rbp),%rax
movsd  0x10(%rax),%xmm0
movsd  -0x38(%rbp),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
mov    -0x10(%rbp),%rax
imul   $0x3,-0x1c(%rbp),%ecx
movslq %ecx,%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x18(%rbp),%rax
movsd  0x18(%rax),%xmm1
movsd  -0x28(%rbp),%xmm2
mov    -0x18(%rbp),%rax
movsd  0x20(%rax),%xmm0
mulsd  -0x30(%rbp),%xmm0
mulsd  %xmm2,%xmm1
addsd  %xmm0,%xmm1
mov    -0x18(%rbp),%rax
movsd  0x28(%rax),%xmm0
movsd  -0x38(%rbp),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
mov    -0x10(%rbp),%rax
imul   $0x3,-0x1c(%rbp),%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x18(%rbp),%rax
movsd  0x30(%rax),%xmm1
movsd  -0x28(%rbp),%xmm2
mov    -0x18(%rbp),%rax
movsd  0x38(%rax),%xmm0
mulsd  -0x30(%rbp),%xmm0
mulsd  %xmm2,%xmm1
addsd  %xmm0,%xmm1
mov    -0x18(%rbp),%rax
movsd  0x40(%rax),%xmm0
movsd  -0x38(%rbp),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
mov    -0x10(%rbp),%rax
imul   $0x3,-0x1c(%rbp),%ecx
add    $0x2,%ecx
movslq %ecx,%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    1116 <scg_affine+0x16>
xor    %eax,%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<scg_affine>:
test   %edi,%edi
jle    11c6 <scg_affine+0xc6>
mov    %edi,%eax
cmp    $0x1,%edi
je     112d <scg_affine+0x2d>
lea    0x48(%rdx),%rcx
cmp    %rsi,%rcx
jbe    11c9 <scg_affine+0xc9>
lea    (%rax,%rax,2),%rcx
lea    (%rsi,%rcx,8),%rcx
cmp    %rdx,%rcx
jbe    11c9 <scg_affine+0xc9>
xor    %r8d,%r8d
lea    (%r8,%r8,2),%rcx
lea    (%rsi,%rcx,8),%rcx
add    $0x10,%rcx
sub    %r8,%rax
nop
movsd  -0x10(%rcx),%xmm0
movsd  -0x8(%rcx),%xmm2
movsd  (%rcx),%xmm1
movsd  0x8(%rdx),%xmm3
mulsd  %xmm2,%xmm3
movsd  (%rdx),%xmm4
mulsd  %xmm0,%xmm4
addsd  %xmm3,%xmm4
movsd  0x10(%rdx),%xmm3
mulsd  %xmm1,%xmm3
addsd  %xmm4,%xmm3
movsd  %xmm3,-0x10(%rcx)
movsd  0x20(%rdx),%xmm3
mulsd  %xmm2,%xmm3
movsd  0x18(%rdx),%xmm4
mulsd  %xmm0,%xmm4
addsd  %xmm3,%xmm4
movsd  0x28(%rdx),%xmm3
mulsd  %xmm1,%xmm3
addsd  %xmm4,%xmm3
movsd  %xmm3,-0x8(%rcx)
mulsd  0x38(%rdx),%xmm2
mulsd  0x30(%rdx),%xmm0
addsd  %xmm2,%xmm0
mulsd  0x40(%rdx),%xmm1
addsd  %xmm0,%xmm1
movsd  %xmm1,(%rcx)
add    $0x18,%rcx
add    $0xffffffffffffffff,%rax
jne    1140 <scg_affine+0x40>
xor    %eax,%eax
ret
mov    %eax,%r8d
and    $0xfffffffe,%r8d
mov    %r8,%rdi
mov    %rsi,%rcx
cs nopw 0x0(%rax,%rax,1)
movupd (%rcx),%xmm2
movupd 0x10(%rcx),%xmm1
movupd 0x20(%rcx),%xmm0
movapd %xmm1,%xmm3
movsd  %xmm2,%xmm3
shufpd $0x1,%xmm0,%xmm2
movsd  %xmm1,%xmm0
movsd  (%rdx),%xmm5
movsd  0x8(%rdx),%xmm6
movsd  0x10(%rdx),%xmm1
movsd  0x18(%rdx),%xmm4
unpcklpd %xmm5,%xmm5
unpcklpd %xmm6,%xmm6
mulpd  %xmm2,%xmm6
mulpd  %xmm3,%xmm5
addpd  %xmm6,%xmm5
unpcklpd %xmm1,%xmm1
mulpd  %xmm0,%xmm1
addpd  %xmm5,%xmm1
unpcklpd %xmm4,%xmm4
movsd  0x20(%rdx),%xmm5
unpcklpd %xmm5,%xmm5
mulpd  %xmm2,%xmm5
mulpd  %xmm3,%xmm4
addpd  %xmm5,%xmm4
movsd  0x28(%rdx),%xmm5
unpcklpd %xmm5,%xmm5
mulpd  %xmm0,%xmm5
addpd  %xmm4,%xmm5
movsd  0x30(%rdx),%xmm4
unpcklpd %xmm4,%xmm4
movsd  0x38(%rdx),%xmm6
unpcklpd %xmm6,%xmm6
mulpd  %xmm2,%xmm6
mulpd  %xmm3,%xmm4
addpd  %xmm6,%xmm4
movsd  0x40(%rdx),%xmm2
unpcklpd %xmm2,%xmm2
mulpd  %xmm0,%xmm2
addpd  %xmm4,%xmm2
movapd %xmm5,%xmm0
unpckhpd %xmm2,%xmm0
shufpd $0x2,%xmm1,%xmm2
unpcklpd %xmm5,%xmm1
movupd %xmm1,(%rcx)
movupd %xmm2,0x10(%rcx)
movupd %xmm0,0x20(%rcx)
add    $0x30,%rcx
add    $0xfffffffffffffffe,%rdi
jne    11e0 <scg_affine+0xe0>
cmp    %rax,%r8
je     11c6 <scg_affine+0xc6>
jmp    1130 <scg_affine+0x30>

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

LLVM IR (-O2):
define i32 @scg_affine(i32 %0, double* nocapture %1, double* nocapture %2) {
%4 = icmp sgt i32 %0, 0
br i1 %4, label %5, label %112
5: ; preds = %3
%6 = getelementptr inbounds double, double* %2, i64 1
%7 = getelementptr inbounds double, double* %2, i64 2
%8 = getelementptr inbounds double, double* %2, i64 3
%9 = getelementptr inbounds double, double* %2, i64 4
%10 = getelementptr inbounds double, double* %2, i64 5
%11 = getelementptr inbounds double, double* %2, i64 6
%12 = getelementptr inbounds double, double* %2, i64 7
%13 = getelementptr inbounds double, double* %2, i64 8
%14 = zext i32 %0 to i64
%15 = icmp eq i32 %0, 1
br i1 %15, label %79, label %16
16: ; preds = %5
%17 = mul nuw nsw i64 %14, 3
%18 = getelementptr double, double* %1, i64 %17
%19 = getelementptr double, double* %2, i64 9
%20 = icmp ugt double* %19, %1
%21 = icmp ugt double* %18, %2
%22 = and i1 %20, %21
br i1 %22, label %79, label %23
23: ; preds = %16
%24 = and i64 %14, 4294967294
br label %25
25: ; preds = %25, %23
%26 = phi i64 [ 0, %23 ], [ %75, %25 ]
%27 = mul nuw nsw i64 %26, 3
%28 = getelementptr inbounds double, double* %1, i64 %27
%29 = bitcast double* %28 to <6 x double>*
%30 = load <6 x double>, <6 x double>* %29
%31 = shufflevector <6 x double> %30, <6 x double> poison, <2 x i32> <i32 0, i32 3>
%32 = shufflevector <6 x double> %30, <6 x double> poison, <2 x i32> <i32 1, i32 4>
%33 = shufflevector <6 x double> %30, <6 x double> poison, <2 x i32> <i32 2, i32 5>
%34 = load double, double* %2
%35 = insertelement <2 x double> poison, double %34, i64 0
%36 = shufflevector <2 x double> %35, <2 x double> poison, <2 x i32> zeroinitializer
%37 = load double, double* %6
%38 = insertelement <2 x double> poison, double %37, i64 0
%39 = shufflevector <2 x double> %38, <2 x double> poison, <2 x i32> zeroinitializer
%40 = fmul <2 x double> %32, %39
%41 = call <2 x double> @llvm.fmuladd.v2f64(<2 x double> %36, <2 x double> %31, <2 x double> %40)
%42 = load double, double* %7
%43 = insertelement <2 x double> poison, double %42, i64 0
%44 = shufflevector <2 x double> %43, <2 x double> poison, <2 x i32> zeroinitializer
%45 = call <2 x double> @llvm.fmuladd.v2f64(<2 x double> %44, <2 x double> %33, <2 x double> %41)
%46 = load double, double* %8
%47 = insertelement <2 x double> poison, double %46, i64 0
%48 = shufflevector <2 x double> %47, <2 x double> poison, <2 x i32> zeroinitializer
%49 = load double, double* %9
%50 = insertelement <2 x double> poison, double %49, i64 0
%51 = shufflevector <2 x double> %50, <2 x double> poison, <2 x i32> zeroinitializer
%52 = fmul <2 x double> %32, %51
%53 = call <2 x double> @llvm.fmuladd.v2f64(<2 x double> %48, <2 x double> %31, <2 x double> %52)
%54 = load double, double* %10
%55 = insertelement <2 x double> poison, double %54, i64 0
%56 = shufflevector <2 x double> %55, <2 x double> poison, <2 x i32> zeroinitializer
%57 = call <2 x double> @llvm.fmuladd.v2f64(<2 x double> %56, <2 x double> %33, <2 x double> %53)
%58 = load double, double* %11
%59 = insertelement <2 x double> poison, double %58, i64 0
%60 = shufflevector <2 x double> %59, <2 x double> poison, <2 x i32> zeroinitializer
%61 = load double, double* %12
%62 = insertelement <2 x double> poison, double %61, i64 0
%63 = shufflevector <2 x double> %62, <2 x double> poison, <2 x i32> zeroinitializer
%64 = fmul <2 x double> %32, %63
%65 = call <2 x double> @llvm.fmuladd.v2f64(<2 x double> %60, <2 x double> %31, <2 x double> %64)
%66 = load double, double* %13
%67 = insertelement <2 x double> poison, double %66, i64 0
%68 = shufflevector <2 x double> %67, <2 x double> poison, <2 x i32> zeroinitializer
%69 = call <2 x double> @llvm.fmuladd.v2f64(<2 x double> %68, <2 x double> %33, <2 x double> %65)
%70 = getelementptr inbounds double, double* %1, i64 %27
%71 = bitcast double* %70 to <6 x double>*
%72 = shufflevector <2 x double> %45, <2 x double> %57, <4 x i32> <i32 0, i32 1, i32 2, i32 3>
%73 = shufflevector <2 x double> %69, <2 x double> poison, <4 x i32> <i32 0, i32 1, i32 undef, i32 undef>
%74 = shufflevector <4 x double> %72, <4 x double> %73, <6 x i32> <i32 0, i32 2, i32 4, i32 1, i32 3, i32 5>
store <6 x double> %74, <6 x double>* %71
%75 = add nuw i64 %26, 2
%76 = icmp eq i64 %75, %24
br i1 %76, label %77, label %25
77: ; preds = %25
%78 = icmp eq i64 %24, %14
br i1 %78, label %112, label %79
79: ; preds = %16, %5, %77
%80 = phi i64 [ 0, %16 ], [ 0, %5 ], [ %24, %77 ]
br label %81
81: ; preds = %79, %81
%82 = phi i64 [ %110, %81 ], [ %80, %79 ]
%83 = mul nuw nsw i64 %82, 3
%84 = getelementptr inbounds double, double* %1, i64 %83
%85 = load double, double* %84
%86 = add nuw nsw i64 %83, 1
%87 = getelementptr inbounds double, double* %1, i64 %86
%88 = load double, double* %87
%89 = add nuw nsw i64 %83, 2
%90 = getelementptr inbounds double, double* %1, i64 %89
%91 = load double, double* %90
%92 = load double, double* %2
%93 = load double, double* %6
%94 = fmul double %88, %93
%95 = tail call double @llvm.fmuladd.f64(double %92, double %85, double %94)
%96 = load double, double* %7
%97 = tail call double @llvm.fmuladd.f64(double %96, double %91, double %95)
store double %97, double* %84
%98 = load double, double* %8
%99 = load double, double* %9
%100 = fmul double %88, %99
%101 = tail call double @llvm.fmuladd.f64(double %98, double %85, double %100)
%102 = load double, double* %10
%103 = tail call double @llvm.fmuladd.f64(double %102, double %91, double %101)
store double %103, double* %87
%104 = load double, double* %11
%105 = load double, double* %12
%106 = fmul double %88, %105
%107 = tail call double @llvm.fmuladd.f64(double %104, double %85, double %106)
%108 = load double, double* %13
%109 = tail call double @llvm.fmuladd.f64(double %108, double %91, double %107)
store double %109, double* %90
%110 = add nuw nsw i64 %82, 1
%111 = icmp eq i64 %110, %14
br i1 %111, label %112, label %81
112: ; preds = %81, %77, %3
ret i32 0
}