#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 mat4_getIndex(int, int);
int /*<<< orphan*/ mat4d_identity(double *);
void mat4d_scale_new(double result[16], double x, double y, double z) {
  mat4d_identity(result);
  result[mat4_getIndex(0, 0)] = x;
  result[mat4_getIndex(1, 1)] = y;
  result[mat4_getIndex(2, 2)] = z;
}


x86 assembly (clang, -O0):
<mat4d_scale_new>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %rdi,-0x8(%rbp)
movsd  %xmm0,-0x10(%rbp)
movsd  %xmm1,-0x18(%rbp)
movsd  %xmm2,-0x20(%rbp)
mov    -0x8(%rbp),%rdi
call   1030 <mat4d_identity@plt>
movsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x50(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x48(%rbp)
xor    %esi,%esi
mov    %esi,%edi
call   1040 <mat4_getIndex@plt>
movsd  -0x50(%rbp),%xmm0
mov    %rax,%rcx
mov    -0x48(%rbp),%rax
movsd  %xmm0,(%rax,%rcx,8)
movsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x40(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x38(%rbp)
mov    $0x1,%esi
mov    %esi,%edi
call   1040 <mat4_getIndex@plt>
movsd  -0x40(%rbp),%xmm0
mov    %rax,%rcx
mov    -0x38(%rbp),%rax
movsd  %xmm0,(%rax,%rcx,8)
movsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x30(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    $0x2,%esi
mov    %esi,%edi
call   1040 <mat4_getIndex@plt>
movsd  -0x30(%rbp),%xmm0
mov    %rax,%rcx
mov    -0x28(%rbp),%rax
movsd  %xmm0,(%rax,%rcx,8)
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<mat4d_scale_new>:
push   %rbx
sub    $0x20,%rsp
movsd  %xmm2,0x18(%rsp)
movsd  %xmm1,0x10(%rsp)
movsd  %xmm0,0x8(%rsp)
mov    %rdi,%rbx
call   1030 <mat4d_identity@plt>
xor    %edi,%edi
xor    %esi,%esi
call   1040 <mat4_getIndex@plt>
movsd  0x8(%rsp),%xmm0
movsd  %xmm0,(%rbx,%rax,8)
mov    $0x1,%edi
mov    $0x1,%esi
call   1040 <mat4_getIndex@plt>
movsd  0x10(%rsp),%xmm0
movsd  %xmm0,(%rbx,%rax,8)
mov    $0x2,%edi
mov    $0x2,%esi
call   1040 <mat4_getIndex@plt>
movsd  0x18(%rsp),%xmm0
movsd  %xmm0,(%rbx,%rax,8)
add    $0x20,%rsp
pop    %rbx
ret

LLVM IR (-O0):
define void @mat4d_scale_new(double* %0, double %1, double %2, double %3) {
%5 = alloca double*
%6 = alloca double
%7 = alloca double
%8 = alloca double
store double* %0, double** %5
store double %1, double* %6
store double %2, double* %7
store double %3, double* %8
%9 = load double*, double** %5
%10 = call i32 @mat4d_identity(double* %9)
%11 = load double, double* %6
%12 = load double*, double** %5
%13 = call i64 @mat4_getIndex(i32 0, i32 0)
%14 = getelementptr inbounds double, double* %12, i64 %13
store double %11, double* %14
%15 = load double, double* %7
%16 = load double*, double** %5
%17 = call i64 @mat4_getIndex(i32 1, i32 1)
%18 = getelementptr inbounds double, double* %16, i64 %17
store double %15, double* %18
%19 = load double, double* %8
%20 = load double*, double** %5
%21 = call i64 @mat4_getIndex(i32 2, i32 2)
%22 = getelementptr inbounds double, double* %20, i64 %21
store double %19, double* %22
ret void
}

LLVM IR (-O2):
define void @mat4d_scale_new(double* %0, double %1, double %2, double %3) {
%5 = tail call i32 @mat4d_identity(double* %0)
%6 = tail call i64 @mat4_getIndex(i32 0, i32 0)
%7 = getelementptr inbounds double, double* %0, i64 %6
store double %1, double* %7
%8 = tail call i64 @mat4_getIndex(i32 1, i32 1)
%9 = getelementptr inbounds double, double* %0, i64 %8
store double %2, double* %9
%10 = tail call i64 @mat4_getIndex(i32 2, i32 2)
%11 = getelementptr inbounds double, double* %0, i64 %10
store double %3, double* %11
ret void
}