translate(a, dir, val) double a[4][4], val;
char dir;
{
  if (dir == 'x') {
    a[0][0] += val * a[0][3];
    a[1][0] += val * a[1][3];
    a[2][0] += val * a[2][3];
    a[3][0] += val * a[3][3];
  } else if (dir == 'y') {
    a[0][1] += val * a[0][3];
    a[1][1] += val * a[1][3];
    a[2][1] += val * a[2][3];
    a[3][1] += val * a[3][3];
  } else {
    a[0][2] += val * a[0][3];
    a[1][2] += val * a[1][3];
    a[2][2] += val * a[2][3];
    a[3][2] += val * a[3][3];
  }
}


x86 assembly (clang, -O0):
<translate>:
push   %rbp
mov    %rsp,%rbp
mov    %sil,%al
mov    %rdi,-0x10(%rbp)
mov    %al,-0x11(%rbp)
movsd  %xmm0,-0x20(%rbp)
movsbl -0x11(%rbp),%eax
cmp    $0x78,%eax
jne    11b3 <translate+0xb3>
movsd  -0x20(%rbp),%xmm0
mov    -0x10(%rbp),%rax
movsd  0x18(%rax),%xmm2
mov    -0x10(%rbp),%rax
movsd  (%rax),%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,(%rax)
movsd  -0x20(%rbp),%xmm0
mov    -0x10(%rbp),%rax
movsd  0x38(%rax),%xmm2
mov    -0x10(%rbp),%rax
movsd  0x20(%rax),%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,0x20(%rax)
movsd  -0x20(%rbp),%xmm0
mov    -0x10(%rbp),%rax
movsd  0x58(%rax),%xmm2
mov    -0x10(%rbp),%rax
movsd  0x40(%rax),%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,0x40(%rax)
movsd  -0x20(%rbp),%xmm0
mov    -0x10(%rbp),%rax
movsd  0x78(%rax),%xmm2
mov    -0x10(%rbp),%rax
movsd  0x60(%rax),%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,0x60(%rax)
jmp    12ea <translate+0x1ea>
movsbl -0x11(%rbp),%eax
cmp    $0x79,%eax
jne    1255 <translate+0x155>
movsd  -0x20(%rbp),%xmm0
mov    -0x10(%rbp),%rax
movsd  0x18(%rax),%xmm2
mov    -0x10(%rbp),%rax
movsd  0x8(%rax),%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,0x8(%rax)
movsd  -0x20(%rbp),%xmm0
mov    -0x10(%rbp),%rax
movsd  0x38(%rax),%xmm2
mov    -0x10(%rbp),%rax
movsd  0x28(%rax),%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,0x28(%rax)
movsd  -0x20(%rbp),%xmm0
mov    -0x10(%rbp),%rax
movsd  0x58(%rax),%xmm2
mov    -0x10(%rbp),%rax
movsd  0x48(%rax),%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,0x48(%rax)
movsd  -0x20(%rbp),%xmm0
mov    -0x10(%rbp),%rax
movsd  0x78(%rax),%xmm2
mov    -0x10(%rbp),%rax
movsd  0x68(%rax),%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,0x68(%rax)
jmp    12e5 <translate+0x1e5>
movsd  -0x20(%rbp),%xmm0
mov    -0x10(%rbp),%rax
movsd  0x18(%rax),%xmm2
mov    -0x10(%rbp),%rax
movsd  0x10(%rax),%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,0x10(%rax)
movsd  -0x20(%rbp),%xmm0
mov    -0x10(%rbp),%rax
movsd  0x38(%rax),%xmm2
mov    -0x10(%rbp),%rax
movsd  0x30(%rax),%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,0x30(%rax)
movsd  -0x20(%rbp),%xmm0
mov    -0x10(%rbp),%rax
movsd  0x58(%rax),%xmm2
mov    -0x10(%rbp),%rax
movsd  0x50(%rax),%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,0x50(%rax)
movsd  -0x20(%rbp),%xmm0
mov    -0x10(%rbp),%rax
movsd  0x78(%rax),%xmm2
mov    -0x10(%rbp),%rax
movsd  0x70(%rax),%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,0x70(%rax)
jmp    12ea <translate+0x1ea>
mov    -0x4(%rbp),%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<translate>:
shl    $0x18,%esi
xor    %eax,%eax
cmp    $0x79000000,%esi
sete   %al
mov    $0x2,%ecx
sub    %rax,%rcx
xor    %eax,%eax
cmp    $0x78000000,%esi
cmovne %rcx,%rax
movsd  0x18(%rdi),%xmm1
mulsd  %xmm0,%xmm1
addsd  (%rdi,%rax,8),%xmm1
movsd  %xmm1,(%rdi,%rax,8)
movsd  0x38(%rdi),%xmm1
mulsd  %xmm0,%xmm1
addsd  0x20(%rdi,%rax,8),%xmm1
movsd  %xmm1,0x20(%rdi,%rax,8)
movsd  0x58(%rdi),%xmm1
mulsd  %xmm0,%xmm1
addsd  0x40(%rdi,%rax,8),%xmm1
movsd  %xmm1,0x40(%rdi,%rax,8)
mulsd  0x78(%rdi),%xmm0
addsd  0x60(%rdi,%rax,8),%xmm0
movsd  %xmm0,0x60(%rdi,%rax,8)
ret

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

LLVM IR (-O2):
define i32 @translate([4 x double]* %0, i32 %1, double %2) {
%4 = shl i32 %1, 24
%5 = icmp eq i32 %4, 2030043136
%6 = select i1 %5, i64 1, i64 2
%7 = icmp eq i32 %4, 2013265920
%8 = select i1 %7, i64 0, i64 %6
%9 = getelementptr inbounds [4 x double], [4 x double]* %0, i64 0, i64 3
%10 = load double, double* %9
%11 = getelementptr inbounds [4 x double], [4 x double]* %0, i64 0, i64 %8
%12 = load double, double* %11
%13 = tail call double @llvm.fmuladd.f64(double %2, double %10, double %12)
store double %13, double* %11
%14 = getelementptr inbounds [4 x double], [4 x double]* %0, i64 1, i64 3
%15 = load double, double* %14
%16 = getelementptr inbounds [4 x double], [4 x double]* %0, i64 1, i64 %8
%17 = load double, double* %16
%18 = tail call double @llvm.fmuladd.f64(double %2, double %15, double %17)
store double %18, double* %16
%19 = getelementptr inbounds [4 x double], [4 x double]* %0, i64 2, i64 3
%20 = load double, double* %19
%21 = getelementptr inbounds [4 x double], [4 x double]* %0, i64 2, i64 %8
%22 = load double, double* %21
%23 = tail call double @llvm.fmuladd.f64(double %2, double %20, double %22)
store double %23, double* %21
%24 = getelementptr inbounds [4 x double], [4 x double]* %0, i64 3, i64 3
%25 = load double, double* %24
%26 = getelementptr inbounds [4 x double], [4 x double]* %0, i64 3, i64 %8
%27 = load double, double* %26
%28 = tail call double @llvm.fmuladd.f64(double %2, double %25, double %27)
store double %28, double* %26
ret i32 undef
}