#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*/ NormalizeAngles(float *);
void InterpolateAngles(float *start, float *end, float *output, float frac) {
  int i;
  float ang1, ang2;
  float d;
  NormalizeAngles(start);
  NormalizeAngles(end);
  for (i = 0; i < 3; i++) {
    ang1 = start[i];
    ang2 = end[i];
    d = ang2 - ang1;
    if (d > 180) {
      d -= 360;
    } else if (d < -180) {
      d += 360;
    }
    output[i] = ang1 + d * frac;
  }
  NormalizeAngles(output);
}


x86 assembly (clang, -O0):
<InterpolateAngles>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
movss  %xmm0,-0x1c(%rbp)
mov    -0x8(%rbp),%rdi
call   1030 <NormalizeAngles@plt>
mov    -0x10(%rbp),%rdi
call   1030 <NormalizeAngles@plt>
movl   $0x0,-0x20(%rbp)
cmpl   $0x3,-0x20(%rbp)
jge    120b <InterpolateAngles+0xfb>
mov    -0x8(%rbp),%rax
movslq -0x20(%rbp),%rcx
movss  (%rax,%rcx,4),%xmm0
movss  %xmm0,-0x24(%rbp)
mov    -0x10(%rbp),%rax
movslq -0x20(%rbp),%rcx
movss  (%rax,%rcx,4),%xmm0
movss  %xmm0,-0x28(%rbp)
movss  -0x28(%rbp),%xmm0
subss  -0x24(%rbp),%xmm0
movss  %xmm0,-0x2c(%rbp)
movss  -0x2c(%rbp),%xmm0
movss  0xe74(%rip),%xmm1
ucomiss %xmm1,%xmm0
jbe    11b0 <InterpolateAngles+0xa0>
movss  -0x2c(%rbp),%xmm0
movss  0xe66(%rip),%xmm1
subss  %xmm1,%xmm0
movss  %xmm0,-0x2c(%rbp)
jmp    11d9 <InterpolateAngles+0xc9>
movss  0xe4c(%rip),%xmm0
ucomiss -0x2c(%rbp),%xmm0
jbe    11d4 <InterpolateAngles+0xc4>
movss  0xe3e(%rip),%xmm0
addss  -0x2c(%rbp),%xmm0
movss  %xmm0,-0x2c(%rbp)
jmp    11d9 <InterpolateAngles+0xc9>
movss  -0x24(%rbp),%xmm1
movss  -0x2c(%rbp),%xmm0
movss  -0x1c(%rbp),%xmm2
mulss  %xmm2,%xmm0
addss  %xmm1,%xmm0
mov    -0x18(%rbp),%rax
movslq -0x20(%rbp),%rcx
movss  %xmm0,(%rax,%rcx,4)
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    1142 <InterpolateAngles+0x32>
mov    -0x18(%rbp),%rdi
call   1030 <NormalizeAngles@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<InterpolateAngles>:
push   %r15
push   %r14
push   %rbx
sub    $0x10,%rsp
movss  %xmm0,0xc(%rsp)
mov    %rdx,%r14
mov    %rsi,%r15
mov    %rdi,%rbx
call   1030 <NormalizeAngles@plt>
mov    %r15,%rdi
call   1030 <NormalizeAngles@plt>
movss  (%rbx),%xmm0
movss  (%r15),%xmm1
subss  %xmm0,%xmm1
ucomiss 0xeb7(%rip),%xmm1
jbe    1155 <InterpolateAngles+0x45>
addss  0xeb9(%rip),%xmm1
jmp    116a <InterpolateAngles+0x5a>
movss  0xea7(%rip),%xmm2
ucomiss %xmm1,%xmm2
jbe    116a <InterpolateAngles+0x5a>
addss  0xe9e(%rip),%xmm1
movss  0xc(%rsp),%xmm3
mulss  %xmm3,%xmm1
addss  %xmm0,%xmm1
movss  %xmm1,(%r14)
movss  0x4(%rbx),%xmm0
movss  0x4(%r15),%xmm1
subss  %xmm0,%xmm1
ucomiss 0xe6d(%rip),%xmm1
jbe    119f <InterpolateAngles+0x8f>
addss  0xe6f(%rip),%xmm1
jmp    11b4 <InterpolateAngles+0xa4>
movss  0xe5d(%rip),%xmm2
ucomiss %xmm1,%xmm2
jbe    11b4 <InterpolateAngles+0xa4>
addss  0xe54(%rip),%xmm1
mulss  %xmm3,%xmm1
addss  %xmm0,%xmm1
movss  %xmm1,0x4(%r14)
movss  0x8(%rbx),%xmm0
movss  0x8(%r15),%xmm1
subss  %xmm0,%xmm1
ucomiss 0xe28(%rip),%xmm1
jbe    11e4 <InterpolateAngles+0xd4>
addss  0xe2a(%rip),%xmm1
jmp    11f9 <InterpolateAngles+0xe9>
movss  0xe18(%rip),%xmm2
ucomiss %xmm1,%xmm2
jbe    11f9 <InterpolateAngles+0xe9>
addss  0xe0f(%rip),%xmm1
mulss  %xmm3,%xmm1
addss  %xmm0,%xmm1
movss  %xmm1,0x8(%r14)
mov    %r14,%rdi
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %r15
jmp    1030 <NormalizeAngles@plt>

LLVM IR (-O0):
define void @InterpolateAngles(float* %0, float* %1, float* %2, float %3) {
%5 = alloca float*
%6 = alloca float*
%7 = alloca float*
%8 = alloca float
%9 = alloca i32
%10 = alloca float
%11 = alloca float
%12 = alloca float
store float* %0, float** %5
store float* %1, float** %6
store float* %2, float** %7
store float %3, float* %8
%13 = load float*, float** %5
%14 = call i32 @NormalizeAngles(float* %13)
%15 = load float*, float** %6
%16 = call i32 @NormalizeAngles(float* %15)
store i32 0, i32* %9
br label %17
17: ; preds = %55, %4
%18 = load i32, i32* %9
%19 = icmp slt i32 %18, 3
br i1 %19, label %20, label %58
20: ; preds = %17
%21 = load float*, float** %5
%22 = load i32, i32* %9
%23 = sext i32 %22 to i64
%24 = getelementptr inbounds float, float* %21, i64 %23
%25 = load float, float* %24
store float %25, float* %10
%26 = load float*, float** %6
%27 = load i32, i32* %9
%28 = sext i32 %27 to i64
%29 = getelementptr inbounds float, float* %26, i64 %28
%30 = load float, float* %29
store float %30, float* %11
%31 = load float, float* %11
%32 = load float, float* %10
%33 = fsub float %31, %32
store float %33, float* %12
%34 = load float, float* %12
%35 = fcmp ogt float %34, 1.800000e+02
br i1 %35, label %36, label %39
36: ; preds = %20
%37 = load float, float* %12
%38 = fsub float %37, 3.600000e+02
store float %38, float* %12
br label %46
39: ; preds = %20
%40 = load float, float* %12
%41 = fcmp olt float %40, -1.800000e+02
br i1 %41, label %42, label %45
42: ; preds = %39
%43 = load float, float* %12
%44 = fadd float %43, 3.600000e+02
store float %44, float* %12
br label %45
45: ; preds = %42, %39
br label %46
46: ; preds = %45, %36
%47 = load float, float* %10
%48 = load float, float* %12
%49 = load float, float* %8
%50 = call float @llvm.fmuladd.f32(float %48, float %49, float %47)
%51 = load float*, float** %7
%52 = load i32, i32* %9
%53 = sext i32 %52 to i64
%54 = getelementptr inbounds float, float* %51, i64 %53
store float %50, float* %54
br label %55
55: ; preds = %46
%56 = load i32, i32* %9
%57 = add nsw i32 %56, 1
store i32 %57, i32* %9
br label %17
58: ; preds = %17
%59 = load float*, float** %7
%60 = call i32 @NormalizeAngles(float* %59)
ret void
}

LLVM IR (-O2):
define void @InterpolateAngles(float* %0, float* %1, float* %2, float %3) {
%5 = tail call i32 @NormalizeAngles(float* %0)
%6 = tail call i32 @NormalizeAngles(float* %1)
%7 = load float, float* %0
%8 = load float, float* %1
%9 = fsub float %8, %7
%10 = fcmp ogt float %9, 1.800000e+02
br i1 %10, label %11, label %13
11: ; preds = %4
%12 = fadd float %9, -3.600000e+02
br label %17
13: ; preds = %4
%14 = fcmp olt float %9, -1.800000e+02
br i1 %14, label %15, label %17
15: ; preds = %13
%16 = fadd float %9, 3.600000e+02
br label %17
17: ; preds = %13, %15, %11
%18 = phi float [ %12, %11 ], [ %16, %15 ], [ %9, %13 ]
%19 = tail call float @llvm.fmuladd.f32(float %18, float %3, float %7)
store float %19, float* %2
%20 = getelementptr inbounds float, float* %0, i64 1
%21 = load float, float* %20
%22 = getelementptr inbounds float, float* %1, i64 1
%23 = load float, float* %22
%24 = fsub float %23, %21
%25 = fcmp ogt float %24, 1.800000e+02
br i1 %25, label %30, label %26
26: ; preds = %17
%27 = fcmp olt float %24, -1.800000e+02
br i1 %27, label %28, label %32
28: ; preds = %26
%29 = fadd float %24, 3.600000e+02
br label %32
30: ; preds = %17
%31 = fadd float %24, -3.600000e+02
br label %32
32: ; preds = %30, %28, %26
%33 = phi float [ %31, %30 ], [ %29, %28 ], [ %24, %26 ]
%34 = tail call float @llvm.fmuladd.f32(float %33, float %3, float %21)
%35 = getelementptr inbounds float, float* %2, i64 1
store float %34, float* %35
%36 = getelementptr inbounds float, float* %0, i64 2
%37 = load float, float* %36
%38 = getelementptr inbounds float, float* %1, i64 2
%39 = load float, float* %38
%40 = fsub float %39, %37
%41 = fcmp ogt float %40, 1.800000e+02
br i1 %41, label %46, label %42
42: ; preds = %32
%43 = fcmp olt float %40, -1.800000e+02
br i1 %43, label %44, label %48
44: ; preds = %42
%45 = fadd float %40, 3.600000e+02
br label %48
46: ; preds = %32
%47 = fadd float %40, -3.600000e+02
br label %48
48: ; preds = %46, %44, %42
%49 = phi float [ %47, %46 ], [ %45, %44 ], [ %40, %42 ]
%50 = tail call float @llvm.fmuladd.f32(float %49, float %3, float %37)
%51 = getelementptr inbounds float, float* %2, i64 2
store float %50, float* %51
%52 = tail call i32 @NormalizeAngles(float* %2)
ret void
}