void grid_check_lat_borders(int n, double *ybounds) {
  if (ybounds[0] > ybounds[n - 1]) {
    if (ybounds[0] > 88)
      ybounds[0] = 90;
    if (ybounds[n - 1] < -88)
      ybounds[n - 1] = -90;
  } else {
    if (ybounds[0] < -88)
      ybounds[0] = -90;
    if (ybounds[n - 1] > 88)
      ybounds[n - 1] = 90;
  }
}


x86 assembly (clang, -O0):
<grid_check_lat_borders>:
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    1194 <grid_check_lat_borders+0x94>
mov    -0x10(%rbp),%rax
movsd  (%rax),%xmm0
movsd  0xed5(%rip),%xmm1
ucomisd %xmm1,%xmm0
jbe    1155 <grid_check_lat_borders+0x55>
mov    -0x10(%rbp),%rax
movsd  0xec7(%rip),%xmm0
movsd  %xmm0,(%rax)
mov    -0x10(%rbp),%rax
mov    -0x4(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
movsd  0xe96(%rip),%xmm0
ucomisd (%rax,%rcx,8),%xmm0
jbe    118f <grid_check_lat_borders+0x8f>
mov    -0x10(%rbp),%rax
mov    -0x4(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
movsd  0xe7e(%rip),%xmm0
movsd  %xmm0,(%rax,%rcx,8)
jmp    11fd <grid_check_lat_borders+0xfd>
mov    -0x10(%rbp),%rax
movsd  0xe60(%rip),%xmm0
ucomisd (%rax),%xmm0
jbe    11ba <grid_check_lat_borders+0xba>
mov    -0x10(%rbp),%rax
movsd  0xe52(%rip),%xmm0
movsd  %xmm0,(%rax)
mov    -0x10(%rbp),%rax
mov    -0x4(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
movsd  (%rax,%rcx,8),%xmm0
movsd  0xe3c(%rip),%xmm1
ucomisd %xmm1,%xmm0
jbe    11f8 <grid_check_lat_borders+0xf8>
mov    -0x10(%rbp),%rax
mov    -0x4(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
movsd  0xe25(%rip),%xmm0
movsd  %xmm0,(%rax,%rcx,8)
jmp    11fd <grid_check_lat_borders+0xfd>
pop    %rbp
ret

x86 assembly (clang, -O2):
<grid_check_lat_borders>:
movsd  (%rsi),%xmm1
movslq %edi,%rax
movsd  -0x8(%rsi,%rax,8),%xmm0
add    $0xffffffffffffffff,%rax
ucomisd %xmm0,%xmm1
jbe    114b <grid_check_lat_borders+0x4b>
ucomisd 0xef1(%rip),%xmm1
jbe    1133 <grid_check_lat_borders+0x33>
movabs $0x4056800000000000,%rcx
80 56 40
mov    %rcx,(%rsi)
movsd  (%rsi,%rax,8),%xmm0
movsd  0xec5(%rip),%xmm1
ucomisd %xmm0,%xmm1
jbe    1182 <grid_check_lat_borders+0x82>
movsd  0xecf(%rip),%xmm0
jmp    117d <grid_check_lat_borders+0x7d>
movsd  0xead(%rip),%xmm2
ucomisd %xmm1,%xmm2
jbe    116b <grid_check_lat_borders+0x6b>
movabs $0xc056800000000000,%rcx
80 56 c0
mov    %rcx,(%rsi)
movsd  (%rsi,%rax,8),%xmm0
ucomisd 0xe9d(%rip),%xmm0
jbe    1182 <grid_check_lat_borders+0x82>
movsd  0xe8b(%rip),%xmm0
movsd  %xmm0,(%rsi,%rax,8)
ret

LLVM IR (-O0):
define void @grid_check_lat_borders(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 %38
15: ; preds = %2
%16 = load double*, double** %4
%17 = getelementptr inbounds double, double* %16, i64 0
%18 = load double, double* %17
%19 = fcmp ogt double %18, 8.800000e+01
br i1 %19, label %20, label %23
20: ; preds = %15
%21 = load double*, double** %4
%22 = getelementptr inbounds double, double* %21, i64 0
store double 9.000000e+01, double* %22
br label %23
23: ; preds = %20, %15
%24 = load double*, double** %4
%25 = load i32, i32* %3
%26 = sub nsw i32 %25, 1
%27 = sext i32 %26 to i64
%28 = getelementptr inbounds double, double* %24, i64 %27
%29 = load double, double* %28
%30 = fcmp olt double %29, -8.800000e+01
br i1 %30, label %31, label %37
31: ; preds = %23
%32 = load double*, double** %4
%33 = load i32, i32* %3
%34 = sub nsw i32 %33, 1
%35 = sext i32 %34 to i64
%36 = getelementptr inbounds double, double* %32, i64 %35
store double -9.000000e+01, double* %36
br label %37
37: ; preds = %31, %23
br label %61
38: ; preds = %2
%39 = load double*, double** %4
%40 = getelementptr inbounds double, double* %39, i64 0
%41 = load double, double* %40
%42 = fcmp olt double %41, -8.800000e+01
br i1 %42, label %43, label %46
43: ; preds = %38
%44 = load double*, double** %4
%45 = getelementptr inbounds double, double* %44, i64 0
store double -9.000000e+01, double* %45
br label %46
46: ; preds = %43, %38
%47 = load double*, double** %4
%48 = load i32, i32* %3
%49 = sub nsw i32 %48, 1
%50 = sext i32 %49 to i64
%51 = getelementptr inbounds double, double* %47, i64 %50
%52 = load double, double* %51
%53 = fcmp ogt double %52, 8.800000e+01
br i1 %53, label %54, label %60
54: ; preds = %46
%55 = load double*, double** %4
%56 = load i32, i32* %3
%57 = sub nsw i32 %56, 1
%58 = sext i32 %57 to i64
%59 = getelementptr inbounds double, double* %55, i64 %58
store double 9.000000e+01, double* %59
br label %60
60: ; preds = %54, %46
br label %61
61: ; preds = %60, %37
ret void
}

LLVM IR (-O2):
define void @grid_check_lat_borders(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
br i1 %8, label %9, label %16
9: ; preds = %2
%10 = fcmp ogt double %3, 8.800000e+01
br i1 %10, label %11, label %13
11: ; preds = %9
store double 9.000000e+01, double* %1
%12 = load double, double* %6
br label %13
13: ; preds = %11, %9
%14 = phi double [ %12, %11 ], [ %7, %9 ]
%15 = fcmp olt double %14, -8.800000e+01
br i1 %15, label %23, label %25
16: ; preds = %2
%17 = fcmp olt double %3, -8.800000e+01
br i1 %17, label %18, label %20
18: ; preds = %16
store double -9.000000e+01, double* %1
%19 = load double, double* %6
br label %20
20: ; preds = %18, %16
%21 = phi double [ %19, %18 ], [ %7, %16 ]
%22 = fcmp ogt double %21, 8.800000e+01
br i1 %22, label %23, label %25
23: ; preds = %20, %13
%24 = phi double [ -9.000000e+01, %13 ], [ 9.000000e+01, %20 ]
store double %24, double* %6
br label %25
25: ; preds = %23, %20, %13
ret void
}