void grid_check_lat_borders_rad(int n, double *ybounds) {
  if (ybounds[0] > ybounds[n - 1]) {
    if ((180. / 3.14159265358979323846) * ybounds[0] >
        (0.5 * 3.14159265358979323846))
      ybounds[0] = (0.5 * 3.14159265358979323846);
    if ((180. / 3.14159265358979323846) * ybounds[n - 1] <
        -(0.5 * 3.14159265358979323846))
      ybounds[n - 1] = -(0.5 * 3.14159265358979323846);
  } else {
    if ((180. / 3.14159265358979323846) * ybounds[0] <
        -(0.5 * 3.14159265358979323846))
      ybounds[0] = -(0.5 * 3.14159265358979323846);
    if ((180. / 3.14159265358979323846) * ybounds[n - 1] >
        (0.5 * 3.14159265358979323846))
      ybounds[n - 1] = (0.5 * 3.14159265358979323846);
  }
}


x86 assembly (clang, -O0):
<grid_check_lat_borders_rad>:
push   %rbp
mov    %rsp,%rbp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x10(%rbp),%rax
movsd  (%rax),%xmm0
mov    -0x10(%rbp),%rax
mov    -0x4(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
ucomisd (%rax,%rcx,8),%xmm0
jbe    11a8 <grid_check_lat_borders_rad+0xa8>
mov    -0x10(%rbp),%rax
movsd  0xed1(%rip),%xmm0
mulsd  (%rax),%xmm0
movsd  0xecd(%rip),%xmm1
ucomisd %xmm1,%xmm0
jbe    115d <grid_check_lat_borders_rad+0x5d>
mov    -0x10(%rbp),%rax
movsd  0xeb7(%rip),%xmm0
movsd  %xmm0,(%rax)
mov    -0x10(%rbp),%rax
mov    -0x4(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
movsd  0xe96(%rip),%xmm1
mulsd  (%rax,%rcx,8),%xmm1
movsd  0xe81(%rip),%xmm0
ucomisd %xmm1,%xmm0
jbe    11a3 <grid_check_lat_borders_rad+0xa3>
mov    -0x10(%rbp),%rax
mov    -0x4(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
movsd  0xe62(%rip),%xmm0
movsd  %xmm0,(%rax,%rcx,8)
jmp    1225 <grid_check_lat_borders_rad+0x125>
mov    -0x10(%rbp),%rax
movsd  0xe54(%rip),%xmm1
mulsd  (%rax),%xmm1
movsd  0xe40(%rip),%xmm0
ucomisd %xmm1,%xmm0
jbe    11da <grid_check_lat_borders_rad+0xda>
mov    -0x10(%rbp),%rax
movsd  0xe2a(%rip),%xmm0
movsd  %xmm0,(%rax)
mov    -0x10(%rbp),%rax
mov    -0x4(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
movsd  0xe19(%rip),%xmm0
mulsd  (%rax,%rcx,8),%xmm0
movsd  0xe14(%rip),%xmm1
ucomisd %xmm1,%xmm0
jbe    1220 <grid_check_lat_borders_rad+0x120>
mov    -0x10(%rbp),%rax
mov    -0x4(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
movsd  0xdf5(%rip),%xmm0
movsd  %xmm0,(%rax,%rcx,8)
jmp    1225 <grid_check_lat_borders_rad+0x125>
pop    %rbp
ret

x86 assembly (clang, -O2):
<grid_check_lat_borders_rad>:
movsd  (%rsi),%xmm1
movslq %edi,%rax
movsd  -0x8(%rsi,%rax,8),%xmm0
add    $0xffffffffffffffff,%rax
ucomisd %xmm0,%xmm1
mulsd  0xee3(%rip),%xmm1
jbe    1153 <grid_check_lat_borders_rad+0x53>
ucomisd 0xee9(%rip),%xmm1
jbe    113b <grid_check_lat_borders_rad+0x3b>
movabs $0x3ff921fb54442d18,%rcx
21 f9 3f
mov    %rcx,(%rsi)
movsd  (%rsi,%rax,8),%xmm0
mulsd  0xebd(%rip),%xmm0
movsd  0xebd(%rip),%xmm1
ucomisd %xmm0,%xmm1
ja     1189 <grid_check_lat_borders_rad+0x89>
jmp    118e <grid_check_lat_borders_rad+0x8e>
movsd  0xead(%rip),%xmm2
ucomisd %xmm1,%xmm2
jbe    1173 <grid_check_lat_borders_rad+0x73>
movabs $0xbff921fb54442d18,%rcx
21 f9 bf
mov    %rcx,(%rsi)
movsd  (%rsi,%rax,8),%xmm0
mulsd  0xe85(%rip),%xmm0
movsd  0xe8d(%rip),%xmm1
ucomisd %xmm1,%xmm0
jbe    118e <grid_check_lat_borders_rad+0x8e>
movsd  %xmm1,(%rsi,%rax,8)
ret

LLVM IR (-O0):
define void @grid_check_lat_borders_rad(i32 %0, double* %1) {
%3 = alloca i32
%4 = alloca double*
store i32 %0, i32* %3
store double* %1, double** %4
%5 = load double*, double** %4
%6 = getelementptr inbounds double, double* %5, i64 0
%7 = load double, double* %6
%8 = load double*, double** %4
%9 = load i32, i32* %3
%10 = sub nsw i32 %9, 1
%11 = sext i32 %10 to i64
%12 = getelementptr inbounds double, double* %8, i64 %11
%13 = load double, double* %12
%14 = fcmp ogt double %7, %13
br i1 %14, label %15, label %40
15: ; preds = %2
%16 = load double*, double** %4
%17 = getelementptr inbounds double, double* %16, i64 0
%18 = load double, double* %17
%19 = fmul double 0x404CA5DC1A63C1F8, %18
%20 = fcmp ogt double %19, 0x3FF921FB54442D18
br i1 %20, label %21, label %24
21: ; preds = %15
%22 = load double*, double** %4
%23 = getelementptr inbounds double, double* %22, i64 0
store double 0x3FF921FB54442D18, double* %23
br label %24
24: ; preds = %21, %15
%25 = load double*, double** %4
%26 = load i32, i32* %3
%27 = sub nsw i32 %26, 1
%28 = sext i32 %27 to i64
%29 = getelementptr inbounds double, double* %25, i64 %28
%30 = load double, double* %29
%31 = fmul double 0x404CA5DC1A63C1F8, %30
%32 = fcmp olt double %31, 0xBFF921FB54442D18
br i1 %32, label %33, label %39
33: ; preds = %24
%34 = load double*, double** %4
%35 = load i32, i32* %3
%36 = sub nsw i32 %35, 1
%37 = sext i32 %36 to i64
%38 = getelementptr inbounds double, double* %34, i64 %37
store double 0xBFF921FB54442D18, double* %38
br label %39
39: ; preds = %33, %24
br label %65
40: ; preds = %2
%41 = load double*, double** %4
%42 = getelementptr inbounds double, double* %41, i64 0
%43 = load double, double* %42
%44 = fmul double 0x404CA5DC1A63C1F8, %43
%45 = fcmp olt double %44, 0xBFF921FB54442D18
br i1 %45, label %46, label %49
46: ; preds = %40
%47 = load double*, double** %4
%48 = getelementptr inbounds double, double* %47, i64 0
store double 0xBFF921FB54442D18, double* %48
br label %49
49: ; preds = %46, %40
%50 = load double*, double** %4
%51 = load i32, i32* %3
%52 = sub nsw i32 %51, 1
%53 = sext i32 %52 to i64
%54 = getelementptr inbounds double, double* %50, i64 %53
%55 = load double, double* %54
%56 = fmul double 0x404CA5DC1A63C1F8, %55
%57 = fcmp ogt double %56, 0x3FF921FB54442D18
br i1 %57, label %58, label %64
58: ; preds = %49
%59 = load double*, double** %4
%60 = load i32, i32* %3
%61 = sub nsw i32 %60, 1
%62 = sext i32 %61 to i64
%63 = getelementptr inbounds double, double* %59, i64 %62
store double 0x3FF921FB54442D18, double* %63
br label %64
64: ; preds = %58, %49
br label %65
65: ; preds = %64, %39
ret void
}

LLVM IR (-O2):
define void @grid_check_lat_borders_rad(i32 %0, double* nocapture %1) {
%3 = load double, double* %1
%4 = add nsw i32 %0, -1
%5 = sext i32 %4 to i64
%6 = getelementptr inbounds double, double* %1, i64 %5
%7 = load double, double* %6
%8 = fcmp ogt double %3, %7
%9 = fmul double %3, 0x404CA5DC1A63C1F8
br i1 %8, label %10, label %18
10: ; preds = %2
%11 = fcmp ogt double %9, 0x3FF921FB54442D18
br i1 %11, label %12, label %14
12: ; preds = %10
store double 0x3FF921FB54442D18, double* %1
%13 = load double, double* %6
br label %14
14: ; preds = %12, %10
%15 = phi double [ %13, %12 ], [ %7, %10 ]
%16 = fmul double %15, 0x404CA5DC1A63C1F8
%17 = fcmp olt double %16, 0xBFF921FB54442D18
br i1 %17, label %26, label %28
18: ; preds = %2
%19 = fcmp olt double %9, 0xBFF921FB54442D18
br i1 %19, label %20, label %22
20: ; preds = %18
store double 0xBFF921FB54442D18, double* %1
%21 = load double, double* %6
br label %22
22: ; preds = %20, %18
%23 = phi double [ %21, %20 ], [ %7, %18 ]
%24 = fmul double %23, 0x404CA5DC1A63C1F8
%25 = fcmp ogt double %24, 0x3FF921FB54442D18
br i1 %25, label %26, label %28
26: ; preds = %22, %14
%27 = phi double [ 0xBFF921FB54442D18, %14 ], [ 0x3FF921FB54442D18, %22 ]
store double %27, double* %6
br label %28
28: ; preds = %26, %22, %14
ret void
}