; LLVM IR from unitreerobotics/kinect_teleoperate :: src/extern/glfw/src/examples (wave)

; Unoptimized IR (clang -disable-llvm-passes):
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128"
target triple = "x86_64-unknown-linux-gnu"

@p = external dso_local global [50 x [50 x double]], align 16
@vx = external dso_local global [50 x [50 x double]], align 16
@vy = external dso_local global [50 x [50 x double]], align 16

; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture) #0

; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #0

; Function Attrs: nounwind uwtable
define dso_local void @init_grid() #1 {
  %1 = alloca i32, align 4
  %2 = alloca i32, align 4
  %3 = alloca double, align 8
  %4 = alloca double, align 8
  %5 = alloca double, align 8
  call void @llvm.lifetime.start.p0(i64 4, ptr %1) #4
  call void @llvm.lifetime.start.p0(i64 4, ptr %2) #4
  call void @llvm.lifetime.start.p0(i64 8, ptr %3) #4
  call void @llvm.lifetime.start.p0(i64 8, ptr %4) #4
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #4
  store i32 0, ptr %2, align 4, !tbaa !5
  br label %6

6:                                                ; preds = %67, %0
  %7 = load i32, ptr %2, align 4, !tbaa !5
  %8 = icmp slt i32 %7, 50
  br i1 %8, label %9, label %70

9:                                                ; preds = %6
  store i32 0, ptr %1, align 4, !tbaa !5
  br label %10

10:                                               ; preds = %63, %9
  %11 = load i32, ptr %1, align 4, !tbaa !5
  %12 = icmp slt i32 %11, 50
  br i1 %12, label %13, label %66

13:                                               ; preds = %10
  %14 = load i32, ptr %1, align 4, !tbaa !5
  %15 = sub nsw i32 %14, 25
  %16 = sitofp i32 %15 to double
  store double %16, ptr %3, align 8, !tbaa !9
  %17 = load i32, ptr %2, align 4, !tbaa !5
  %18 = sub nsw i32 %17, 25
  %19 = sitofp i32 %18 to double
  store double %19, ptr %4, align 8, !tbaa !9
  %20 = load double, ptr %3, align 8, !tbaa !9
  %21 = load double, ptr %3, align 8, !tbaa !9
  %22 = load double, ptr %4, align 8, !tbaa !9
  %23 = load double, ptr %4, align 8, !tbaa !9
  %24 = fmul double %22, %23
  %25 = call double @llvm.fmuladd.f64(double %20, double %21, double %24)
  %26 = call double @sqrt(double noundef %25) #4
  store double %26, ptr %5, align 8, !tbaa !9
  %27 = load double, ptr %5, align 8, !tbaa !9
  %28 = fcmp olt double %27, 2.500000e+00
  br i1 %28, label %29, label %43

29:                                               ; preds = %13
  %30 = load double, ptr %5, align 8, !tbaa !9
  %31 = fmul double %30, 1.000000e+01
  store double %31, ptr %5, align 8, !tbaa !9
  %32 = load double, ptr %5, align 8, !tbaa !9
  %33 = fmul double %32, 0x3F9015BF9217271A
  %34 = call double @cos(double noundef %33) #4
  %35 = fneg double %34
  %36 = fmul double %35, 1.000000e+02
  %37 = load i32, ptr %1, align 4, !tbaa !5
  %38 = sext i32 %37 to i64
  %39 = getelementptr inbounds [50 x [50 x double]], ptr @p, i64 0, i64 %38
  %40 = load i32, ptr %2, align 4, !tbaa !5
  %41 = sext i32 %40 to i64
  %42 = getelementptr inbounds [50 x double], ptr %39, i64 0, i64 %41
  store double %36, ptr %42, align 8, !tbaa !9
  br label %50

43:                                               ; preds = %13
  %44 = load i32, ptr %1, align 4, !tbaa !5
  %45 = sext i32 %44 to i64
  %46 = getelementptr inbounds [50 x [50 x double]], ptr @p, i64 0, i64 %45
  %47 = load i32, ptr %2, align 4, !tbaa !5
  %48 = sext i32 %47 to i64
  %49 = getelementptr inbounds [50 x double], ptr %46, i64 0, i64 %48
  store double 0.000000e+00, ptr %49, align 8, !tbaa !9
  br label %50

50:                                               ; preds = %43, %29
  %51 = load i32, ptr %1, align 4, !tbaa !5
  %52 = sext i32 %51 to i64
  %53 = getelementptr inbounds [50 x [50 x double]], ptr @vx, i64 0, i64 %52
  %54 = load i32, ptr %2, align 4, !tbaa !5
  %55 = sext i32 %54 to i64
  %56 = getelementptr inbounds [50 x double], ptr %53, i64 0, i64 %55
  store double 0.000000e+00, ptr %56, align 8, !tbaa !9
  %57 = load i32, ptr %1, align 4, !tbaa !5
  %58 = sext i32 %57 to i64
  %59 = getelementptr inbounds [50 x [50 x double]], ptr @vy, i64 0, i64 %58
  %60 = load i32, ptr %2, align 4, !tbaa !5
  %61 = sext i32 %60 to i64
  %62 = getelementptr inbounds [50 x double], ptr %59, i64 0, i64 %61
  store double 0.000000e+00, ptr %62, align 8, !tbaa !9
  br label %63

63:                                               ; preds = %50
  %64 = load i32, ptr %1, align 4, !tbaa !5
  %65 = add nsw i32 %64, 1
  store i32 %65, ptr %1, align 4, !tbaa !5
  br label %10, !llvm.loop !11

66:                                               ; preds = %10
  br label %67

67:                                               ; preds = %66
  %68 = load i32, ptr %2, align 4, !tbaa !5
  %69 = add nsw i32 %68, 1
  store i32 %69, ptr %2, align 4, !tbaa !5
  br label %6, !llvm.loop !13

70:                                               ; preds = %6
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %4) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %3) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %2) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %1) #4
  ret void
}

; Function Attrs: nounwind
declare double @sqrt(double noundef) #2

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare double @llvm.fmuladd.f64(double, double, double) #3

; Function Attrs: nounwind
declare double @cos(double noundef) #2

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { nounwind uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #2 = { nounwind "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #3 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #4 = { nounwind }

!llvm.module.flags = !{!0, !1, !2, !3}
!llvm.ident = !{!4}

!0 = !{i32 1, !"wchar_size", i32 4}
!1 = !{i32 8, !"PIC Level", i32 2}
!2 = !{i32 7, !"PIE Level", i32 2}
!3 = !{i32 7, !"uwtable", i32 2}
!4 = !{!"clang version 19.1.0 (git@github.com:llvm/llvm-project.git a4bf6cd7cfb1a1421ba92bca9d017b49936c55e4)"}
!5 = !{!6, !6, i64 0}
!6 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"double", !7, i64 0}
!11 = distinct !{!11, !12}
!12 = !{!"llvm.loop.mustprogress"}
!13 = distinct !{!13, !12}


; Optimized IR (opt -passes='default<O3>'):
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128"
target triple = "x86_64-unknown-linux-gnu"

@p = external dso_local local_unnamed_addr global [50 x [50 x double]], align 16
@vx = external dso_local local_unnamed_addr global [50 x [50 x double]], align 16
@vy = external dso_local local_unnamed_addr global [50 x [50 x double]], align 16

; Function Attrs: nofree nounwind memory(write) uwtable
define dso_local void @init_grid() local_unnamed_addr #0 {
  br label %.preheader

.preheader:                                       ; preds = %0, %20
  %indvars.iv25 = phi i64 [ 0, %0 ], [ %indvars.iv.next26, %20 ]
  %1 = trunc i64 %indvars.iv25 to i32
  %2 = add i32 %1, -25
  %3 = sitofp i32 %2 to double
  %4 = fmul double %3, %3
  br label %5

5:                                                ; preds = %.preheader, %16
  %indvars.iv = phi i64 [ 0, %.preheader ], [ %indvars.iv.next, %16 ]
  %6 = trunc i64 %indvars.iv to i32
  %7 = add i32 %6, -25
  %8 = sitofp i32 %7 to double
  %9 = tail call double @llvm.fmuladd.f64(double %8, double %8, double %4)
  %sqrt = tail call double @llvm.sqrt.f64(double %9)
  %10 = fcmp olt double %sqrt, 2.500000e+00
  br i1 %10, label %11, label %16

11:                                               ; preds = %5
  %12 = fmul double %sqrt, 1.000000e+01
  %13 = fmul double %12, 0x3F9015BF9217271A
  %14 = tail call double @cos(double noundef %13) #4
  %15 = fmul double %14, -1.000000e+02
  br label %16

16:                                               ; preds = %5, %11
  %.sink = phi double [ %15, %11 ], [ 0.000000e+00, %5 ]
  %17 = getelementptr inbounds [50 x [50 x double]], ptr @p, i64 0, i64 %indvars.iv, i64 %indvars.iv25
  store double %.sink, ptr %17, align 8
  %18 = getelementptr inbounds [50 x [50 x double]], ptr @vx, i64 0, i64 %indvars.iv, i64 %indvars.iv25
  store double 0.000000e+00, ptr %18, align 8, !tbaa !5
  %19 = getelementptr inbounds [50 x [50 x double]], ptr @vy, i64 0, i64 %indvars.iv, i64 %indvars.iv25
  store double 0.000000e+00, ptr %19, align 8, !tbaa !5
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %exitcond.not = icmp eq i64 %indvars.iv.next, 50
  br i1 %exitcond.not, label %20, label %5, !llvm.loop !9

20:                                               ; preds = %16
  %indvars.iv.next26 = add nuw nsw i64 %indvars.iv25, 1
  %exitcond28.not = icmp eq i64 %indvars.iv.next26, 50
  br i1 %exitcond28.not, label %21, label %.preheader, !llvm.loop !11

21:                                               ; preds = %20
  ret void
}

; Function Attrs: mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare double @llvm.fmuladd.f64(double, double, double) #1

; Function Attrs: mustprogress nofree nounwind willreturn memory(write)
declare double @cos(double noundef) local_unnamed_addr #2

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare double @llvm.sqrt.f64(double) #3

attributes #0 = { nofree nounwind memory(write) uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #1 = { mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #2 = { mustprogress nofree nounwind willreturn memory(write) "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #3 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #4 = { nounwind }

!llvm.module.flags = !{!0, !1, !2, !3}
!llvm.ident = !{!4}

!0 = !{i32 1, !"wchar_size", i32 4}
!1 = !{i32 8, !"PIC Level", i32 2}
!2 = !{i32 7, !"PIE Level", i32 2}
!3 = !{i32 7, !"uwtable", i32 2}
!4 = !{!"clang version 19.1.0 (git@github.com:llvm/llvm-project.git a4bf6cd7cfb1a1421ba92bca9d017b49936c55e4)"}
!5 = !{!6, !6, i64 0}
!6 = !{!"double", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = distinct !{!9, !10}
!10 = !{!"llvm.loop.mustprogress"}
!11 = distinct !{!11, !10}


; Effective O3 passes: AggressiveInstCombinePass,EarlyCSEPass,GlobalOptPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,LICMPass,LoopRotatePass,LoopSimplifyPass,MergedLoadStoreMotionPass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass,TailCallElimPass