#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 */
int /*<<< orphan*/ cross(int *, int *, int *);
int /*<<< orphan*/ normalize(int *, int *);
int /*<<< orphan*/ orthoNormalize(int *);
int /*<<< orphan*/ vectorAdd(int *, int *, int *);
void updateMatrix(int *accel, int *gyro, int *matrix) {
  int i;
  int normaccel[3];
  int wAccel[3];
  int orient[3];
  int output[9];
  normalize(accel, normaccel);
  cross(&matrix[6], normaccel, wAccel);
  for (i = 0; i < 3; i++) {
    orient[i] = ((gyro[i] * 5) + (wAccel[i] * 1)) / (6);
  }
  for (i = 0; i < 3; i++) {
    cross(&matrix[3 * i], orient, &output[i * 3]);
    vectorAdd(&matrix[3 * i], &output[i * 3], &matrix[3 * i]);
  }
  orthoNormalize(matrix);
}


x86 assembly (clang, -O0):
<updateMatrix>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    -0x8(%rbp),%rdi
lea    -0x28(%rbp),%rsi
call   1040 <normalize@plt>
mov    -0x18(%rbp),%rdi
add    $0x18,%rdi
lea    -0x28(%rbp),%rsi
lea    -0x34(%rbp),%rdx
call   1060 <cross@plt>
movl   $0x0,-0x1c(%rbp)
cmpl   $0x3,-0x1c(%rbp)
jge    11c0 <updateMatrix+0x80>
mov    -0x10(%rbp),%rax
movslq -0x1c(%rbp),%rcx
imul   $0x5,(%rax,%rcx,4),%eax
movslq -0x1c(%rbp),%rcx
mov    -0x34(%rbp,%rcx,4),%ecx
shl    $0x0,%ecx
add    %ecx,%eax
mov    $0x6,%ecx
cltd
idiv   %ecx
mov    %eax,%ecx
movslq -0x1c(%rbp),%rax
mov    %ecx,-0x40(%rbp,%rax,4)
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    117d <updateMatrix+0x3d>
movl   $0x0,-0x1c(%rbp)
cmpl   $0x3,-0x1c(%rbp)
jge    1242 <updateMatrix+0x102>
mov    -0x18(%rbp),%rdi
imul   $0x3,-0x1c(%rbp),%eax
cltq
shl    $0x2,%rax
add    %rax,%rdi
lea    -0x40(%rbp),%rsi
imul   $0x3,-0x1c(%rbp),%eax
cltq
lea    -0x70(%rbp),%rdx
shl    $0x2,%rax
add    %rax,%rdx
call   1060 <cross@plt>
mov    -0x18(%rbp),%rdi
imul   $0x3,-0x1c(%rbp),%eax
cltq
shl    $0x2,%rax
add    %rax,%rdi
imul   $0x3,-0x1c(%rbp),%eax
cltq
lea    -0x70(%rbp),%rsi
shl    $0x2,%rax
add    %rax,%rsi
mov    -0x18(%rbp),%rdx
imul   $0x3,-0x1c(%rbp),%eax
cltq
shl    $0x2,%rax
add    %rax,%rdx
call   1050 <vectorAdd@plt>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    11c7 <updateMatrix+0x87>
mov    -0x18(%rbp),%rdi
call   1030 <orthoNormalize@plt>
add    $0x70,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<updateMatrix>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x50,%rsp
mov    %rdx,%r15
mov    %rsi,%rbx
lea    0x44(%rsp),%r12
mov    %r12,%rsi
call   1040 <normalize@plt>
lea    0x18(%r15),%r14
lea    0x14(%rsp),%rdx
mov    %r14,%rdi
mov    %r12,%rsi
call   1060 <cross@plt>
mov    (%rbx),%eax
lea    (%rax,%rax,4),%eax
add    0x14(%rsp),%eax
cltq
imul   $0x2aaaaaab,%rax,%rax
mov    %rax,%rcx
shr    $0x3f,%rcx
shr    $0x20,%rax
add    %ecx,%eax
mov    %eax,0x8(%rsp)
mov    0x4(%rbx),%eax
lea    (%rax,%rax,4),%eax
add    0x18(%rsp),%eax
cltq
imul   $0x2aaaaaab,%rax,%rax
mov    %rax,%rcx
shr    $0x3f,%rcx
shr    $0x20,%rax
add    %ecx,%eax
mov    %eax,0xc(%rsp)
mov    0x8(%rbx),%eax
lea    (%rax,%rax,4),%eax
add    0x1c(%rsp),%eax
cltq
imul   $0x2aaaaaab,%rax,%rax
mov    %rax,%rcx
shr    $0x3f,%rcx
shr    $0x20,%rax
add    %ecx,%eax
mov    %eax,0x10(%rsp)
lea    0x8(%rsp),%r12
lea    0x20(%rsp),%rbx
mov    %r15,%rdi
mov    %r12,%rsi
mov    %rbx,%rdx
call   1060 <cross@plt>
mov    %r15,%rdi
mov    %rbx,%rsi
mov    %r15,%rdx
call   1050 <vectorAdd@plt>
lea    0xc(%r15),%rbx
lea    0x2c(%rsp),%r13
mov    %rbx,%rdi
mov    %r12,%rsi
mov    %r13,%rdx
call   1060 <cross@plt>
mov    %rbx,%rdi
mov    %r13,%rsi
mov    %rbx,%rdx
call   1050 <vectorAdd@plt>
lea    0x38(%rsp),%rbx
mov    %r14,%rdi
mov    %r12,%rsi
mov    %rbx,%rdx
call   1060 <cross@plt>
mov    %r14,%rdi
mov    %rbx,%rsi
mov    %r14,%rdx
call   1050 <vectorAdd@plt>
mov    %r15,%rdi
call   1030 <orthoNormalize@plt>
add    $0x50,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

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

LLVM IR (-O2):
define void @updateMatrix(i32* %0, i32* nocapture %1, i32* %2) {
%4 = alloca [3 x i32]
%5 = alloca [3 x i32]
%6 = alloca [3 x i32]
%7 = alloca [9 x i32]
%8 = bitcast [3 x i32]* %4 to i8*
%9 = bitcast [3 x i32]* %5 to i8*
%10 = bitcast [3 x i32]* %6 to i8*
%11 = bitcast [9 x i32]* %7 to i8*
%12 = getelementptr inbounds [3 x i32], [3 x i32]* %4, i64 0, i64 0
%13 = call i32 @normalize(i32* %0, i32* %12)
%14 = getelementptr inbounds i32, i32* %2, i64 6
%15 = getelementptr inbounds [3 x i32], [3 x i32]* %5, i64 0, i64 0
%16 = call i32 @cross(i32* %14, i32* %12, i32* %15)
%17 = load i32, i32* %1
%18 = mul nsw i32 %17, 5
%19 = load i32, i32* %15
%20 = add nsw i32 %18, %19
%21 = sdiv i32 %20, 6
%22 = getelementptr inbounds [3 x i32], [3 x i32]* %6, i64 0, i64 0
store i32 %21, i32* %22
%23 = getelementptr inbounds i32, i32* %1, i64 1
%24 = load i32, i32* %23
%25 = mul nsw i32 %24, 5
%26 = getelementptr inbounds [3 x i32], [3 x i32]* %5, i64 0, i64 1
%27 = load i32, i32* %26
%28 = add nsw i32 %25, %27
%29 = sdiv i32 %28, 6
%30 = getelementptr inbounds [3 x i32], [3 x i32]* %6, i64 0, i64 1
store i32 %29, i32* %30
%31 = getelementptr inbounds i32, i32* %1, i64 2
%32 = load i32, i32* %31
%33 = mul nsw i32 %32, 5
%34 = getelementptr inbounds [3 x i32], [3 x i32]* %5, i64 0, i64 2
%35 = load i32, i32* %34
%36 = add nsw i32 %33, %35
%37 = sdiv i32 %36, 6
%38 = getelementptr inbounds [3 x i32], [3 x i32]* %6, i64 0, i64 2
store i32 %37, i32* %38
%39 = getelementptr inbounds [9 x i32], [9 x i32]* %7, i64 0, i64 0
%40 = call i32 @cross(i32* %2, i32* %22, i32* %39)
%41 = call i32 @vectorAdd(i32* %2, i32* %39, i32* %2)
%42 = getelementptr inbounds i32, i32* %2, i64 3
%43 = getelementptr inbounds [9 x i32], [9 x i32]* %7, i64 0, i64 3
%44 = call i32 @cross(i32* %42, i32* %22, i32* %43)
%45 = call i32 @vectorAdd(i32* %42, i32* %43, i32* %42)
%46 = getelementptr inbounds [9 x i32], [9 x i32]* %7, i64 0, i64 6
%47 = call i32 @cross(i32* %14, i32* %22, i32* %46)
%48 = call i32 @vectorAdd(i32* %14, i32* %46, i32* %14)
%49 = call i32 @orthoNormalize(i32* %2)
ret void
}