void NormalizeAngles(float *angles) {
  int i;
  for (i = 0; i < 3; i++) {
    if (angles[i] > 180.0) {
      angles[i] -= 360.0;
    } else if (angles[i] < -180.0) {
      angles[i] += 360.0;
    }
  }
}


x86 assembly (clang, -O0):
<NormalizeAngles>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
cmpl   $0x3,-0xc(%rbp)
jge    11c8 <NormalizeAngles+0xc8>
mov    -0x8(%rbp),%rax
movslq -0xc(%rbp),%rcx
movss  (%rax,%rcx,4),%xmm0
cvtss2sd %xmm0,%xmm0
movsd  0xece(%rip),%xmm1
ucomisd %xmm1,%xmm0
jbe    1167 <NormalizeAngles+0x67>
mov    -0x8(%rbp),%rax
movslq -0xc(%rbp),%rcx
movss  (%rax,%rcx,4),%xmm0
cvtss2sd %xmm0,%xmm0
movsd  0xebb(%rip),%xmm1
subsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,(%rax,%rcx,4)
jmp    11b5 <NormalizeAngles+0xb5>
mov    -0x8(%rbp),%rax
movslq -0xc(%rbp),%rcx
movss  (%rax,%rcx,4),%xmm0
cvtss2sd %xmm0,%xmm1
movsd  0xe88(%rip),%xmm0
ucomisd %xmm1,%xmm0
jbe    11b0 <NormalizeAngles+0xb0>
mov    -0x8(%rbp),%rax
movslq -0xc(%rbp),%rcx
movss  (%rax,%rcx,4),%xmm0
cvtss2sd %xmm0,%xmm0
movsd  0xe6d(%rip),%xmm1
addsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,(%rax,%rcx,4)
jmp    11b5 <NormalizeAngles+0xb5>
jmp    11ba <NormalizeAngles+0xba>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    110f <NormalizeAngles+0xf>
pop    %rbp
ret

x86 assembly (clang, -O2):
<NormalizeAngles>:
movss  (%rdi),%xmm0
ucomiss 0xef9(%rip),%xmm0
jbe    1117 <NormalizeAngles+0x17>
movss  0xeeb(%rip),%xmm1
jmp    112c <NormalizeAngles+0x2c>
movss  0xeed(%rip),%xmm1
ucomiss %xmm0,%xmm1
jbe    1134 <NormalizeAngles+0x34>
movss  0xedc(%rip),%xmm1
addss  %xmm1,%xmm0
movss  %xmm0,(%rdi)
movss  0x4(%rdi),%xmm0
ucomiss 0xec4(%rip),%xmm0
jbe    114c <NormalizeAngles+0x4c>
movss  0xeb6(%rip),%xmm1
jmp    1161 <NormalizeAngles+0x61>
movss  0xeb8(%rip),%xmm1
ucomiss %xmm0,%xmm1
jbe    116a <NormalizeAngles+0x6a>
movss  0xea7(%rip),%xmm1
addss  %xmm1,%xmm0
movss  %xmm0,0x4(%rdi)
movss  0x8(%rdi),%xmm0
ucomiss 0xe8e(%rip),%xmm0
jbe    1182 <NormalizeAngles+0x82>
movss  0xe80(%rip),%xmm1
jmp    1197 <NormalizeAngles+0x97>
movss  0xe82(%rip),%xmm1
ucomiss %xmm0,%xmm1
jbe    11a0 <NormalizeAngles+0xa0>
movss  0xe71(%rip),%xmm1
addss  %xmm1,%xmm0
movss  %xmm0,0x8(%rdi)
ret

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

LLVM IR (-O2):
define void @NormalizeAngles(float* nocapture %0) {
%2 = load float, float* %0
%3 = fcmp ogt float %2, 1.800000e+02
br i1 %3, label %6, label %4
4: ; preds = %1
%5 = fcmp olt float %2, -1.800000e+02
br i1 %5, label %6, label %9
6: ; preds = %4, %1
%7 = phi float [ -3.600000e+02, %1 ], [ 3.600000e+02, %4 ]
%8 = fadd float %2, %7
store float %8, float* %0
br label %9
9: ; preds = %6, %4
%10 = getelementptr inbounds float, float* %0, i64 1
%11 = load float, float* %10
%12 = fcmp ogt float %11, 1.800000e+02
br i1 %12, label %15, label %13
13: ; preds = %9
%14 = fcmp olt float %11, -1.800000e+02
br i1 %14, label %15, label %18
15: ; preds = %9, %13
%16 = phi float [ 3.600000e+02, %13 ], [ -3.600000e+02, %9 ]
%17 = fadd float %11, %16
store float %17, float* %10
br label %18
18: ; preds = %15, %13
%19 = getelementptr inbounds float, float* %0, i64 2
%20 = load float, float* %19
%21 = fcmp ogt float %20, 1.800000e+02
br i1 %21, label %24, label %22
22: ; preds = %18
%23 = fcmp olt float %20, -1.800000e+02
br i1 %23, label %24, label %27
24: ; preds = %18, %22
%25 = phi float [ 3.600000e+02, %22 ], [ -3.600000e+02, %18 ]
%26 = fadd float %20, %25
store float %26, float* %19
br label %27
27: ; preds = %24, %22
ret void
}