; 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"

%struct.Vertex = type { float, float, float, float, float, float }

@vertex = external dso_local global [2500 x %struct.Vertex], align 16
@p = 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 @adjust_grid() #1 {
  %1 = alloca i32, align 4
  %2 = alloca i32, align 4
  %3 = alloca i32, align 4
  call void @llvm.lifetime.start.p0(i64 4, ptr %1) #2
  call void @llvm.lifetime.start.p0(i64 4, ptr %2) #2
  call void @llvm.lifetime.start.p0(i64 4, ptr %3) #2
  store i32 0, ptr %3, align 4, !tbaa !5
  br label %4

4:                                                ; preds = %33, %0
  %5 = load i32, ptr %3, align 4, !tbaa !5
  %6 = icmp slt i32 %5, 50
  br i1 %6, label %7, label %36

7:                                                ; preds = %4
  store i32 0, ptr %2, align 4, !tbaa !5
  br label %8

8:                                                ; preds = %29, %7
  %9 = load i32, ptr %2, align 4, !tbaa !5
  %10 = icmp slt i32 %9, 50
  br i1 %10, label %11, label %32

11:                                               ; preds = %8
  %12 = load i32, ptr %3, align 4, !tbaa !5
  %13 = mul nsw i32 %12, 50
  %14 = load i32, ptr %2, align 4, !tbaa !5
  %15 = add nsw i32 %13, %14
  store i32 %15, ptr %1, align 4, !tbaa !5
  %16 = load i32, ptr %2, align 4, !tbaa !5
  %17 = sext i32 %16 to i64
  %18 = getelementptr inbounds [50 x [50 x double]], ptr @p, i64 0, i64 %17
  %19 = load i32, ptr %3, align 4, !tbaa !5
  %20 = sext i32 %19 to i64
  %21 = getelementptr inbounds [50 x double], ptr %18, i64 0, i64 %20
  %22 = load double, ptr %21, align 8, !tbaa !9
  %23 = fmul double %22, 2.000000e-02
  %24 = fptrunc double %23 to float
  %25 = load i32, ptr %1, align 4, !tbaa !5
  %26 = sext i32 %25 to i64
  %27 = getelementptr inbounds [2500 x %struct.Vertex], ptr @vertex, i64 0, i64 %26
  %28 = getelementptr inbounds %struct.Vertex, ptr %27, i32 0, i32 2
  store float %24, ptr %28, align 8, !tbaa !11
  br label %29

29:                                               ; preds = %11
  %30 = load i32, ptr %2, align 4, !tbaa !5
  %31 = add nsw i32 %30, 1
  store i32 %31, ptr %2, align 4, !tbaa !5
  br label %8, !llvm.loop !14

32:                                               ; preds = %8
  br label %33

33:                                               ; preds = %32
  %34 = load i32, ptr %3, align 4, !tbaa !5
  %35 = add nsw i32 %34, 1
  store i32 %35, ptr %3, align 4, !tbaa !5
  br label %4, !llvm.loop !16

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

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 }

!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 = !{!12, !13, i64 8}
!12 = !{!"Vertex", !13, i64 0, !13, i64 4, !13, i64 8, !13, i64 12, !13, i64 16, !13, i64 20}
!13 = !{!"float", !7, i64 0}
!14 = distinct !{!14, !15}
!15 = !{!"llvm.loop.mustprogress"}
!16 = distinct !{!16, !15}


; 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"

%struct.Vertex = type { float, float, float, float, float, float }

@vertex = external dso_local local_unnamed_addr global [2500 x %struct.Vertex], align 16
@p = external dso_local local_unnamed_addr global [50 x [50 x double]], align 16

; Function Attrs: nofree norecurse nosync nounwind memory(readwrite, argmem: none, inaccessiblemem: none) uwtable
define dso_local void @adjust_grid() local_unnamed_addr #0 {
  br label %.preheader

.preheader:                                       ; preds = %0, %15
  %indvars.iv13 = phi i64 [ 0, %0 ], [ %indvars.iv.next14, %15 ]
  %1 = mul nuw nsw i64 %indvars.iv13, 50
  br label %2

2:                                                ; preds = %2, %.preheader
  %indvars.iv = phi i64 [ 0, %.preheader ], [ %indvars.iv.next.1, %2 ]
  %3 = add nuw nsw i64 %indvars.iv, %1
  %4 = getelementptr inbounds [50 x [50 x double]], ptr @p, i64 0, i64 %indvars.iv, i64 %indvars.iv13
  %5 = load double, ptr %4, align 8, !tbaa !5
  %6 = fmul double %5, 2.000000e-02
  %7 = fptrunc double %6 to float
  %8 = getelementptr inbounds [2500 x %struct.Vertex], ptr @vertex, i64 0, i64 %3, i32 2
  store float %7, ptr %8, align 8, !tbaa !9
  %indvars.iv.next = or disjoint i64 %indvars.iv, 1
  %9 = add nuw nsw i64 %indvars.iv.next, %1
  %10 = getelementptr inbounds [50 x [50 x double]], ptr @p, i64 0, i64 %indvars.iv.next, i64 %indvars.iv13
  %11 = load double, ptr %10, align 8, !tbaa !5
  %12 = fmul double %11, 2.000000e-02
  %13 = fptrunc double %12 to float
  %14 = getelementptr inbounds [2500 x %struct.Vertex], ptr @vertex, i64 0, i64 %9, i32 2
  store float %13, ptr %14, align 16, !tbaa !9
  %indvars.iv.next.1 = add nuw nsw i64 %indvars.iv, 2
  %exitcond.not.1 = icmp eq i64 %indvars.iv.next.1, 50
  br i1 %exitcond.not.1, label %15, label %2, !llvm.loop !12

15:                                               ; preds = %2
  %indvars.iv.next14 = add nuw nsw i64 %indvars.iv13, 1
  %exitcond16.not = icmp eq i64 %indvars.iv.next14, 50
  br i1 %exitcond16.not, label %16, label %.preheader, !llvm.loop !14

16:                                               ; preds = %15
  ret void
}

attributes #0 = { nofree norecurse nosync nounwind memory(readwrite, argmem: none, inaccessiblemem: none) 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" }

!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 = !{!10, !11, i64 8}
!10 = !{!"Vertex", !11, i64 0, !11, i64 4, !11, i64 8, !11, i64 12, !11, i64 16, !11, i64 20}
!11 = !{!"float", !7, i64 0}
!12 = distinct !{!12, !13}
!13 = !{!"llvm.loop.mustprogress"}
!14 = distinct !{!14, !13}


; Effective O3 passes: GlobalOptPass,IndVarSimplifyPass,InferAlignmentPass,InferFunctionAttrsPass,InstCombinePass,LICMPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,PostOrderFunctionAttrsPass,ReassociatePass,SROAPass,SimplifyCFGPass