void mat4_igrow(float m[4][4], float x, float y, float z) {
  float s[3];
  float v[3][4] = {{1, 0, 0, 0}, {0, 1, 0, 0}, {0, 0, 1, 0}};
  int i;
  for (i = 0; i < 3; i++) {
    mat4_mul_vec4(m, v[i], v[i]);
    s[i] = vec3_norm(v[i]);
  }
  s[0] = (2 * x + s[0]) / s[0];
  s[1] = (2 * y + s[1]) / s[1];
  s[2] = (2 * z + s[2]) / s[2];
  mat4_iscale(m, s[0], s[1], s[2]);
}


x86 assembly (clang, -O0):
<mat4_igrow>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
mov    %rdi,-0x8(%rbp)
movss  %xmm0,-0xc(%rbp)
movss  %xmm1,-0x10(%rbp)
movss  %xmm2,-0x14(%rbp)
lea    -0x50(%rbp),%rdi
xor    %esi,%esi
mov    $0x30,%edx
call   1040 <memset@plt>
movss  0xe8d(%rip),%xmm0
movss  %xmm0,-0x50(%rbp)
movss  0xe80(%rip),%xmm0
movss  %xmm0,-0x3c(%rbp)
movss  0xe73(%rip),%xmm0
movss  %xmm0,-0x28(%rbp)
movl   $0x0,-0x54(%rbp)
cmpl   $0x3,-0x54(%rbp)
jge    11fe <mat4_igrow+0xbe>
mov    -0x8(%rbp),%rdi
movslq -0x54(%rbp),%rax
lea    -0x50(%rbp),%rsi
shl    $0x4,%rax
add    %rax,%rsi
movslq -0x54(%rbp),%rax
lea    -0x50(%rbp),%rdx
shl    $0x4,%rax
add    %rax,%rdx
mov    $0x0,%al
call   1030 <mat4_mul_vec4@plt>
movslq -0x54(%rbp),%rax
lea    -0x50(%rbp),%rdi
shl    $0x4,%rax
add    %rax,%rdi
mov    $0x0,%al
call   1060 <vec3_norm@plt>
cvtsi2ss %eax,%xmm0
movslq -0x54(%rbp),%rax
movss  %xmm0,-0x20(%rbp,%rax,4)
mov    -0x54(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x54(%rbp)
jmp    1199 <mat4_igrow+0x59>
movss  -0xc(%rbp),%xmm0
movss  -0x20(%rbp),%xmm1
addss  %xmm0,%xmm0
addss  %xmm1,%xmm0
divss  -0x20(%rbp),%xmm0
movss  %xmm0,-0x20(%rbp)
movss  -0x10(%rbp),%xmm0
movss  -0x1c(%rbp),%xmm1
addss  %xmm0,%xmm0
addss  %xmm1,%xmm0
divss  -0x1c(%rbp),%xmm0
movss  %xmm0,-0x1c(%rbp)
movss  -0x14(%rbp),%xmm0
movss  -0x18(%rbp),%xmm1
addss  %xmm0,%xmm0
addss  %xmm1,%xmm0
divss  -0x18(%rbp),%xmm0
movss  %xmm0,-0x18(%rbp)
mov    -0x8(%rbp),%rdi
movss  -0x20(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
movss  -0x1c(%rbp),%xmm1
cvtss2sd %xmm1,%xmm1
movss  -0x18(%rbp),%xmm2
cvtss2sd %xmm2,%xmm2
mov    $0x3,%al
call   1050 <mat4_iscale@plt>
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<mat4_igrow>:
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x58,%rsp
movss  %xmm2,0x1c(%rsp)
movss  %xmm1,0x18(%rsp)
movss  %xmm0,0x14(%rsp)
mov    %rdi,%r12
xorps  %xmm0,%xmm0
movaps %xmm0,0x20(%rsp)
movaps %xmm0,0x30(%rsp)
movaps %xmm0,0x40(%rsp)
lea    0x40(%rsp),%r14
lea    0x30(%rsp),%r15
movl   $0x3f800000,0x20(%rsp)
3f
movl   $0x3f800000,0x34(%rsp)
3f
movl   $0x3f800000,0x48(%rsp)
3f
lea    0x20(%rsp),%rbx
mov    %rbx,%rsi
mov    %rbx,%rdx
xor    %eax,%eax
call   1030 <mat4_mul_vec4@plt>
mov    %rbx,%rdi
xor    %eax,%eax
call   1050 <vec3_norm@plt>
xorps  %xmm0,%xmm0
cvtsi2ss %eax,%xmm0
movss  %xmm0,0x10(%rsp)
mov    %r12,%rdi
mov    %r15,%rsi
mov    %r15,%rdx
xor    %eax,%eax
call   1030 <mat4_mul_vec4@plt>
mov    %r15,%rdi
xor    %eax,%eax
call   1050 <vec3_norm@plt>
xorps  %xmm0,%xmm0
cvtsi2ss %eax,%xmm0
movss  %xmm0,0xc(%rsp)
mov    %r12,%rdi
mov    %r14,%rsi
mov    %r14,%rdx
xor    %eax,%eax
call   1030 <mat4_mul_vec4@plt>
mov    %r14,%rdi
xor    %eax,%eax
call   1050 <vec3_norm@plt>
xorps  %xmm0,%xmm0
cvtsi2ss %eax,%xmm0
movss  0x14(%rsp),%xmm1
addss  %xmm1,%xmm1
movss  0x10(%rsp),%xmm2
addss  %xmm2,%xmm1
divss  %xmm2,%xmm1
movaps %xmm1,%xmm4
movss  0x18(%rsp),%xmm1
addss  %xmm1,%xmm1
movss  0xc(%rsp),%xmm2
addss  %xmm2,%xmm1
divss  %xmm2,%xmm1
movaps %xmm1,%xmm3
movss  0x1c(%rsp),%xmm1
addss  %xmm1,%xmm1
addss  %xmm0,%xmm1
divss  %xmm0,%xmm1
movaps %xmm1,%xmm2
xorps  %xmm0,%xmm0
cvtss2sd %xmm4,%xmm0
xorps  %xmm1,%xmm1
cvtss2sd %xmm3,%xmm1
cvtss2sd %xmm2,%xmm2
mov    %r12,%rdi
mov    $0x3,%al
call   1040 <mat4_iscale@plt>
add    $0x58,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define void @mat4_igrow([4 x float]* %0, float %1, float %2, float %3) {
%5 = alloca [4 x float]*
%6 = alloca float
%7 = alloca float
%8 = alloca float
%9 = alloca [3 x float]
%10 = alloca [3 x [4 x float]]
%11 = alloca i32
store [4 x float]* %0, [4 x float]** %5
store float %1, float* %6
store float %2, float* %7
store float %3, float* %8
%12 = bitcast [3 x [4 x float]]* %10 to i8*
%13 = bitcast i8* %12 to [3 x [4 x float]]*
%14 = getelementptr inbounds [3 x [4 x float]], [3 x [4 x float]]* %13, i32 0, i32 0
%15 = getelementptr inbounds [4 x float], [4 x float]* %14, i32 0, i32 0
store float 1.000000e+00, float* %15
%16 = getelementptr inbounds [3 x [4 x float]], [3 x [4 x float]]* %13, i32 0, i32 1
%17 = getelementptr inbounds [4 x float], [4 x float]* %16, i32 0, i32 1
store float 1.000000e+00, float* %17
%18 = getelementptr inbounds [3 x [4 x float]], [3 x [4 x float]]* %13, i32 0, i32 2
%19 = getelementptr inbounds [4 x float], [4 x float]* %18, i32 0, i32 2
store float 1.000000e+00, float* %19
store i32 0, i32* %11
br label %20
20: ; preds = %43, %4
%21 = load i32, i32* %11
%22 = icmp slt i32 %21, 3
br i1 %22, label %23, label %46
23: ; preds = %20
%24 = load [4 x float]*, [4 x float]** %5
%25 = load i32, i32* %11
%26 = sext i32 %25 to i64
%27 = getelementptr inbounds [3 x [4 x float]], [3 x [4 x float]]* %10, i64 0, i64 %26
%28 = getelementptr inbounds [4 x float], [4 x float]* %27, i64 0, i64 0
%29 = load i32, i32* %11
%30 = sext i32 %29 to i64
%31 = getelementptr inbounds [3 x [4 x float]], [3 x [4 x float]]* %10, i64 0, i64 %30
%32 = getelementptr inbounds [4 x float], [4 x float]* %31, i64 0, i64 0
%33 = call i32 ([4 x float]*, float*, float*, ...) bitcast (i32 (...)* @mat4_mul_vec4 to i32 ([4 x float]*, float*, float*, ...)*)([4 x float]* %24, float* %28, float* %32)
%34 = load i32, i32* %11
%35 = sext i32 %34 to i64
%36 = getelementptr inbounds [3 x [4 x float]], [3 x [4 x float]]* %10, i64 0, i64 %35
%37 = getelementptr inbounds [4 x float], [4 x float]* %36, i64 0, i64 0
%38 = call i32 (float*, ...) bitcast (i32 (...)* @vec3_norm to i32 (float*, ...)*)(float* %37)
%39 = sitofp i32 %38 to float
%40 = load i32, i32* %11
%41 = sext i32 %40 to i64
%42 = getelementptr inbounds [3 x float], [3 x float]* %9, i64 0, i64 %41
store float %39, float* %42
br label %43
43: ; preds = %23
%44 = load i32, i32* %11
%45 = add nsw i32 %44, 1
store i32 %45, i32* %11
br label %20
46: ; preds = %20
%47 = load float, float* %6
%48 = getelementptr inbounds [3 x float], [3 x float]* %9, i64 0, i64 0
%49 = load float, float* %48
%50 = call float @llvm.fmuladd.f32(float 2.000000e+00, float %47, float %49)
%51 = getelementptr inbounds [3 x float], [3 x float]* %9, i64 0, i64 0
%52 = load float, float* %51
%53 = fdiv float %50, %52
%54 = getelementptr inbounds [3 x float], [3 x float]* %9, i64 0, i64 0
store float %53, float* %54
%55 = load float, float* %7
%56 = getelementptr inbounds [3 x float], [3 x float]* %9, i64 0, i64 1
%57 = load float, float* %56
%58 = call float @llvm.fmuladd.f32(float 2.000000e+00, float %55, float %57)
%59 = getelementptr inbounds [3 x float], [3 x float]* %9, i64 0, i64 1
%60 = load float, float* %59
%61 = fdiv float %58, %60
%62 = getelementptr inbounds [3 x float], [3 x float]* %9, i64 0, i64 1
store float %61, float* %62
%63 = load float, float* %8
%64 = getelementptr inbounds [3 x float], [3 x float]* %9, i64 0, i64 2
%65 = load float, float* %64
%66 = call float @llvm.fmuladd.f32(float 2.000000e+00, float %63, float %65)
%67 = getelementptr inbounds [3 x float], [3 x float]* %9, i64 0, i64 2
%68 = load float, float* %67
%69 = fdiv float %66, %68
%70 = getelementptr inbounds [3 x float], [3 x float]* %9, i64 0, i64 2
store float %69, float* %70
%71 = load [4 x float]*, [4 x float]** %5
%72 = getelementptr inbounds [3 x float], [3 x float]* %9, i64 0, i64 0
%73 = load float, float* %72
%74 = fpext float %73 to double
%75 = getelementptr inbounds [3 x float], [3 x float]* %9, i64 0, i64 1
%76 = load float, float* %75
%77 = fpext float %76 to double
%78 = getelementptr inbounds [3 x float], [3 x float]* %9, i64 0, i64 2
%79 = load float, float* %78
%80 = fpext float %79 to double
%81 = call i32 ([4 x float]*, double, double, double, ...) bitcast (i32 (...)* @mat4_iscale to i32 ([4 x float]*, double, double, double, ...)*)([4 x float]* %71, double %74, double %77, double %80)
ret void
}

LLVM IR (-O2):
define void @mat4_igrow([4 x float]* %0, float %1, float %2, float %3) {
%5 = alloca [3 x [4 x float]]
%6 = bitcast [3 x [4 x float]]* %5 to i8*
%7 = getelementptr inbounds [3 x [4 x float]], [3 x [4 x float]]* %5, i64 0, i64 0, i64 0
store float 1.000000e+00, float* %7
%8 = getelementptr inbounds [3 x [4 x float]], [3 x [4 x float]]* %5, i64 0, i64 1, i64 1
store float 1.000000e+00, float* %8
%9 = getelementptr inbounds [3 x [4 x float]], [3 x [4 x float]]* %5, i64 0, i64 2, i64 2
store float 1.000000e+00, float* %9
%10 = call i32 ([4 x float]*, float*, float*, ...) bitcast (i32 (...)* @mat4_mul_vec4 to i32 ([4 x float]*, float*, float*, ...)*)([4 x float]* %0, float* %7, float* %7)
%11 = call i32 (float*, ...) bitcast (i32 (...)* @vec3_norm to i32 (float*, ...)*)(float* %7)
%12 = sitofp i32 %11 to float
%13 = getelementptr inbounds [3 x [4 x float]], [3 x [4 x float]]* %5, i64 0, i64 1, i64 0
%14 = call i32 ([4 x float]*, float*, float*, ...) bitcast (i32 (...)* @mat4_mul_vec4 to i32 ([4 x float]*, float*, float*, ...)*)([4 x float]* %0, float* %13, float* %13)
%15 = call i32 (float*, ...) bitcast (i32 (...)* @vec3_norm to i32 (float*, ...)*)(float* %13)
%16 = sitofp i32 %15 to float
%17 = getelementptr inbounds [3 x [4 x float]], [3 x [4 x float]]* %5, i64 0, i64 2, i64 0
%18 = call i32 ([4 x float]*, float*, float*, ...) bitcast (i32 (...)* @mat4_mul_vec4 to i32 ([4 x float]*, float*, float*, ...)*)([4 x float]* %0, float* %17, float* %17)
%19 = call i32 (float*, ...) bitcast (i32 (...)* @vec3_norm to i32 (float*, ...)*)(float* %17)
%20 = sitofp i32 %19 to float
%21 = call float @llvm.fmuladd.f32(float %1, float 2.000000e+00, float %12)
%22 = fdiv float %21, %12
%23 = call float @llvm.fmuladd.f32(float %2, float 2.000000e+00, float %16)
%24 = fdiv float %23, %16
%25 = call float @llvm.fmuladd.f32(float %3, float 2.000000e+00, float %20)
%26 = fdiv float %25, %20
%27 = fpext float %22 to double
%28 = fpext float %24 to double
%29 = fpext float %26 to double
%30 = call i32 ([4 x float]*, double, double, double, ...) bitcast (i32 (...)* @mat4_iscale to i32 ([4 x float]*, double, double, double, ...)*)([4 x float]* %0, double %27, double %28, double %29)
ret void
}