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


x86 assembly (clang, -O0):
<rescale>:
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
je     112d <rescale+0x2d>
movsbl -0x11(%rbp),%eax
cmp    $0x61,%eax
jne    1177 <rescale+0x77>
movsd  -0x20(%rbp),%xmm0
mov    -0x10(%rbp),%rax
mulsd  (%rax),%xmm0
movsd  %xmm0,(%rax)
movsd  -0x20(%rbp),%xmm0
mov    -0x10(%rbp),%rax
mulsd  0x20(%rax),%xmm0
movsd  %xmm0,0x20(%rax)
movsd  -0x20(%rbp),%xmm0
mov    -0x10(%rbp),%rax
mulsd  0x40(%rax),%xmm0
movsd  %xmm0,0x40(%rax)
movsd  -0x20(%rbp),%xmm0
mov    -0x10(%rbp),%rax
mulsd  0x60(%rax),%xmm0
movsd  %xmm0,0x60(%rax)
movsbl -0x11(%rbp),%eax
cmp    $0x79,%eax
je     1191 <rescale+0x91>
movsbl -0x11(%rbp),%eax
cmp    $0x61,%eax
jne    11dd <rescale+0xdd>
movsd  -0x20(%rbp),%xmm0
mov    -0x10(%rbp),%rax
mulsd  0x8(%rax),%xmm0
movsd  %xmm0,0x8(%rax)
movsd  -0x20(%rbp),%xmm0
mov    -0x10(%rbp),%rax
mulsd  0x28(%rax),%xmm0
movsd  %xmm0,0x28(%rax)
movsd  -0x20(%rbp),%xmm0
mov    -0x10(%rbp),%rax
mulsd  0x48(%rax),%xmm0
movsd  %xmm0,0x48(%rax)
movsd  -0x20(%rbp),%xmm0
mov    -0x10(%rbp),%rax
mulsd  0x68(%rax),%xmm0
movsd  %xmm0,0x68(%rax)
movsbl -0x11(%rbp),%eax
cmp    $0x7a,%eax
je     11f7 <rescale+0xf7>
movsbl -0x11(%rbp),%eax
cmp    $0x61,%eax
jne    1243 <rescale+0x143>
movsd  -0x20(%rbp),%xmm0
mov    -0x10(%rbp),%rax
mulsd  0x10(%rax),%xmm0
movsd  %xmm0,0x10(%rax)
movsd  -0x20(%rbp),%xmm0
mov    -0x10(%rbp),%rax
mulsd  0x30(%rax),%xmm0
movsd  %xmm0,0x30(%rax)
movsd  -0x20(%rbp),%xmm0
mov    -0x10(%rbp),%rax
mulsd  0x50(%rax),%xmm0
movsd  %xmm0,0x50(%rax)
movsd  -0x20(%rbp),%xmm0
mov    -0x10(%rbp),%rax
mulsd  0x70(%rax),%xmm0
movsd  %xmm0,0x70(%rax)
mov    -0x4(%rbp),%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<rescale>:
shl    $0x18,%esi
cmp    $0x78ffffff,%esi
jg     119f <rescale+0x9f>
cmp    $0x61000000,%esi
je     1123 <rescale+0x23>
cmp    $0x78000000,%esi
jne    11f5 <rescale+0xf5>
movsd  (%rdi),%xmm1
mulsd  %xmm0,%xmm1
movsd  %xmm1,(%rdi)
movsd  0x20(%rdi),%xmm1
mulsd  %xmm0,%xmm1
movsd  %xmm1,0x20(%rdi)
movsd  0x40(%rdi),%xmm1
mulsd  %xmm0,%xmm1
movsd  %xmm1,0x40(%rdi)
movsd  0x60(%rdi),%xmm1
mulsd  %xmm0,%xmm1
movsd  %xmm1,0x60(%rdi)
cmp    $0x61000000,%esi
jne    11f5 <rescale+0xf5>
movsd  0x8(%rdi),%xmm1
mulsd  %xmm0,%xmm1
movsd  %xmm1,0x8(%rdi)
movsd  0x28(%rdi),%xmm1
mulsd  %xmm0,%xmm1
movsd  %xmm1,0x28(%rdi)
movsd  0x48(%rdi),%xmm1
mulsd  %xmm0,%xmm1
movsd  %xmm1,0x48(%rdi)
movsd  0x68(%rdi),%xmm1
mulsd  %xmm0,%xmm1
movsd  %xmm1,0x68(%rdi)
jmp    11af <rescale+0xaf>
cmp    $0x79000000,%esi
je     11b6 <rescale+0xb6>
cmp    $0x7a000000,%esi
jne    11f5 <rescale+0xf5>
mov    $0x2,%eax
jmp    11bb <rescale+0xbb>
mov    $0x1,%eax
movsd  (%rdi,%rax,8),%xmm1
mulsd  %xmm0,%xmm1
movsd  %xmm1,(%rdi,%rax,8)
movsd  0x20(%rdi,%rax,8),%xmm1
mulsd  %xmm0,%xmm1
movsd  %xmm1,0x20(%rdi,%rax,8)
movsd  0x40(%rdi,%rax,8),%xmm1
mulsd  %xmm0,%xmm1
movsd  %xmm1,0x40(%rdi,%rax,8)
mulsd  0x60(%rdi,%rax,8),%xmm0
movsd  %xmm0,0x60(%rdi,%rax,8)
ret

LLVM IR (-O0):
define i32 @rescale([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 %16, label %12
12: ; preds = %3
%13 = load i8, i8* %6
%14 = sext i8 %13 to i32
%15 = icmp eq i32 %14, 97
br i1 %15, label %16, label %41
16: ; preds = %12, %3
%17 = load double, double* %7
%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 = fmul double %21, %17
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 0
%27 = load double, double* %26
%28 = fmul double %27, %23
store double %28, double* %26
%29 = load double, double* %7
%30 = load [4 x double]*, [4 x double]** %5
%31 = getelementptr inbounds [4 x double], [4 x double]* %30, i64 2
%32 = getelementptr inbounds [4 x double], [4 x double]* %31, i64 0, i64 0
%33 = load double, double* %32
%34 = fmul double %33, %29
store double %34, double* %32
%35 = load double, double* %7
%36 = load [4 x double]*, [4 x double]** %5
%37 = getelementptr inbounds [4 x double], [4 x double]* %36, i64 3
%38 = getelementptr inbounds [4 x double], [4 x double]* %37, i64 0, i64 0
%39 = load double, double* %38
%40 = fmul double %39, %35
store double %40, double* %38
br label %41
41: ; preds = %16, %12
%42 = load i8, i8* %6
%43 = sext i8 %42 to i32
%44 = icmp eq i32 %43, 121
br i1 %44, label %49, label %45
45: ; preds = %41
%46 = load i8, i8* %6
%47 = sext i8 %46 to i32
%48 = icmp eq i32 %47, 97
br i1 %48, label %49, label %74
49: ; preds = %45, %41
%50 = load double, double* %7
%51 = load [4 x double]*, [4 x double]** %5
%52 = getelementptr inbounds [4 x double], [4 x double]* %51, i64 0
%53 = getelementptr inbounds [4 x double], [4 x double]* %52, i64 0, i64 1
%54 = load double, double* %53
%55 = fmul double %54, %50
store double %55, double* %53
%56 = load double, double* %7
%57 = load [4 x double]*, [4 x double]** %5
%58 = getelementptr inbounds [4 x double], [4 x double]* %57, i64 1
%59 = getelementptr inbounds [4 x double], [4 x double]* %58, i64 0, i64 1
%60 = load double, double* %59
%61 = fmul double %60, %56
store double %61, double* %59
%62 = load double, double* %7
%63 = load [4 x double]*, [4 x double]** %5
%64 = getelementptr inbounds [4 x double], [4 x double]* %63, i64 2
%65 = getelementptr inbounds [4 x double], [4 x double]* %64, i64 0, i64 1
%66 = load double, double* %65
%67 = fmul double %66, %62
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 3
%71 = getelementptr inbounds [4 x double], [4 x double]* %70, i64 0, i64 1
%72 = load double, double* %71
%73 = fmul double %72, %68
store double %73, double* %71
br label %74
74: ; preds = %49, %45
%75 = load i8, i8* %6
%76 = sext i8 %75 to i32
%77 = icmp eq i32 %76, 122
br i1 %77, label %82, label %78
78: ; preds = %74
%79 = load i8, i8* %6
%80 = sext i8 %79 to i32
%81 = icmp eq i32 %80, 97
br i1 %81, label %82, label %107
82: ; preds = %78, %74
%83 = load double, double* %7
%84 = load [4 x double]*, [4 x double]** %5
%85 = getelementptr inbounds [4 x double], [4 x double]* %84, i64 0
%86 = getelementptr inbounds [4 x double], [4 x double]* %85, i64 0, i64 2
%87 = load double, double* %86
%88 = fmul double %87, %83
store double %88, double* %86
%89 = load double, double* %7
%90 = load [4 x double]*, [4 x double]** %5
%91 = getelementptr inbounds [4 x double], [4 x double]* %90, i64 1
%92 = getelementptr inbounds [4 x double], [4 x double]* %91, i64 0, i64 2
%93 = load double, double* %92
%94 = fmul double %93, %89
store double %94, double* %92
%95 = load double, double* %7
%96 = load [4 x double]*, [4 x double]** %5
%97 = getelementptr inbounds [4 x double], [4 x double]* %96, i64 2
%98 = getelementptr inbounds [4 x double], [4 x double]* %97, i64 0, i64 2
%99 = load double, double* %98
%100 = fmul double %99, %95
store double %100, double* %98
%101 = load double, double* %7
%102 = load [4 x double]*, [4 x double]** %5
%103 = getelementptr inbounds [4 x double], [4 x double]* %102, i64 3
%104 = getelementptr inbounds [4 x double], [4 x double]* %103, i64 0, i64 2
%105 = load double, double* %104
%106 = fmul double %105, %101
store double %106, double* %104
br label %107
107: ; preds = %82, %78
%108 = load i32, i32* %4
ret i32 %108
}

LLVM IR (-O2):
define i32 @rescale([4 x double]* nocapture %0, i32 %1, double %2) {
%4 = shl i32 %1, 24
switch i32 %4, label %47 [
i32 2013265920, label %5
i32 1627389952, label %5
i32 2030043136, label %33
i32 2046820352, label %32
]
5: ; preds = %3, %3
%6 = getelementptr inbounds [4 x double], [4 x double]* %0, i64 0, i64 0
%7 = load double, double* %6
%8 = fmul double %7, %2
store double %8, double* %6
%9 = getelementptr inbounds [4 x double], [4 x double]* %0, i64 1, i64 0
%10 = load double, double* %9
%11 = fmul double %10, %2
store double %11, double* %9
%12 = getelementptr inbounds [4 x double], [4 x double]* %0, i64 2, i64 0
%13 = load double, double* %12
%14 = fmul double %13, %2
store double %14, double* %12
%15 = getelementptr inbounds [4 x double], [4 x double]* %0, i64 3, i64 0
%16 = load double, double* %15
%17 = fmul double %16, %2
store double %17, double* %15
%18 = icmp eq i32 %4, 1627389952
br i1 %18, label %19, label %47
19: ; preds = %5
%20 = getelementptr inbounds [4 x double], [4 x double]* %0, i64 0, i64 1
%21 = load double, double* %20
%22 = fmul double %21, %2
store double %22, double* %20
%23 = getelementptr inbounds [4 x double], [4 x double]* %0, i64 1, i64 1
%24 = load double, double* %23
%25 = fmul double %24, %2
store double %25, double* %23
%26 = getelementptr inbounds [4 x double], [4 x double]* %0, i64 2, i64 1
%27 = load double, double* %26
%28 = fmul double %27, %2
store double %28, double* %26
%29 = getelementptr inbounds [4 x double], [4 x double]* %0, i64 3, i64 1
%30 = load double, double* %29
%31 = fmul double %30, %2
store double %31, double* %29
br label %32
32: ; preds = %19, %3
br label %33
33: ; preds = %3, %32
%34 = phi i64 [ 2, %32 ], [ 1, %3 ]
%35 = getelementptr inbounds [4 x double], [4 x double]* %0, i64 0, i64 %34
%36 = load double, double* %35
%37 = fmul double %36, %2
store double %37, double* %35
%38 = getelementptr inbounds [4 x double], [4 x double]* %0, i64 1, i64 %34
%39 = load double, double* %38
%40 = fmul double %39, %2
store double %40, double* %38
%41 = getelementptr inbounds [4 x double], [4 x double]* %0, i64 2, i64 %34
%42 = load double, double* %41
%43 = fmul double %42, %2
store double %43, double* %41
%44 = getelementptr inbounds [4 x double], [4 x double]* %0, i64 3, i64 %34
%45 = load double, double* %44
%46 = fmul double %45, %2
store double %46, double* %44
br label %47
47: ; preds = %33, %5, %3
ret i32 undef
}