; LLVM IR from jpvt/Computer_Graphics :: Assignment #3/third_party/glm/test/gtc/gtc_random.ll (Z13test_diskRandv)

; 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.glm::vec.25" = type { %union.anon.26, %union.anon.27 }
%union.anon.26 = type { float }
%union.anon.27 = type { float }
%"struct.glm::vec.28" = type { %union.anon.29, %union.anon.30 }
%union.anon.29 = type { double }
%union.anon.30 = type { double }

@.str = external hidden unnamed_addr constant [7 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [110 x i8], align 1
@__PRETTY_FUNCTION__._Z13test_diskRandv = external hidden unnamed_addr constant [20 x i8], align 1

; 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: noreturn nounwind
declare void @__assert_fail(ptr noundef, ptr noundef, i32 noundef, ptr noundef) #1

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local noundef float @_ZN3glm6lengthILi2EfLNS_9qualifierE0EEET0_RKNS_3vecIXT_ES2_XT1_EEE(ptr noundef nonnull align 4 dereferenceable(8)) #2

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local noundef double @_ZN3glm6lengthILi2EdLNS_9qualifierE0EEET0_RKNS_3vecIXT_ES2_XT1_EEE(ptr noundef nonnull align 8 dereferenceable(16)) #2

; Function Attrs: mustprogress uwtable
define dso_local noundef i32 @_Z13test_diskRandv() #3 {
  %1 = alloca i32, align 4
  %2 = alloca float, align 4
  %3 = alloca double, align 8
  %4 = alloca i64, align 8
  %5 = alloca %"struct.glm::vec.25", align 4
  %6 = alloca %"struct.glm::vec.28", align 8
  call void @llvm.lifetime.start.p0(i64 4, ptr %1) #5
  store i32 0, ptr %1, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %2) #5
  store float 0.000000e+00, ptr %2, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %3) #5
  store double 0.000000e+00, ptr %3, align 8, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 8, ptr %4) #5
  store i64 0, ptr %4, align 8, !tbaa !13
  br label %7

7:                                                ; preds = %24, %0
  %8 = load i64, ptr %4, align 8, !tbaa !13
  %9 = icmp ult i64 %8, 10000
  br i1 %9, label %11, label %10

10:                                               ; preds = %7
  call void @llvm.lifetime.end.p0(i64 8, ptr %4) #5
  br label %27

11:                                               ; preds = %7
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #5
  %12 = call <2 x float> @_ZN3glm8diskRandIfEENS_3vecILi2ET_LNS_9qualifierE0EEES2_(float noundef 2.000000e+00)
  store <2 x float> %12, ptr %5, align 4
  %13 = call noundef float @_ZN3glm6lengthILi2EfLNS_9qualifierE0EEET0_RKNS_3vecIXT_ES2_XT1_EEE(ptr noundef nonnull align 4 dereferenceable(8) %5)
  %14 = load float, ptr %2, align 4, !tbaa !9
  %15 = fadd float %14, %13
  store float %15, ptr %2, align 4, !tbaa !9
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #5
  call void @llvm.lifetime.start.p0(i64 16, ptr %6) #5
  %16 = call { double, double } @_ZN3glm8diskRandIdEENS_3vecILi2ET_LNS_9qualifierE0EEES2_(double noundef 2.000000e+00)
  %17 = getelementptr inbounds { double, double }, ptr %6, i32 0, i32 0
  %18 = extractvalue { double, double } %16, 0
  store double %18, ptr %17, align 8
  %19 = getelementptr inbounds { double, double }, ptr %6, i32 0, i32 1
  %20 = extractvalue { double, double } %16, 1
  store double %20, ptr %19, align 8
  %21 = call noundef double @_ZN3glm6lengthILi2EdLNS_9qualifierE0EEET0_RKNS_3vecIXT_ES2_XT1_EEE(ptr noundef nonnull align 8 dereferenceable(16) %6)
  %22 = load double, ptr %3, align 8, !tbaa !11
  %23 = fadd double %22, %21
  store double %23, ptr %3, align 8, !tbaa !11
  call void @llvm.lifetime.end.p0(i64 16, ptr %6) #5
  br label %24

24:                                               ; preds = %11
  %25 = load i64, ptr %4, align 8, !tbaa !13
  %26 = add i64 %25, 1
  store i64 %26, ptr %4, align 8, !tbaa !13
  br label %7, !llvm.loop !15

27:                                               ; preds = %10
  %28 = load float, ptr %2, align 4, !tbaa !9
  %29 = fcmp olt float %28, 2.000000e+04
  %30 = zext i1 %29 to i64
  %31 = select i1 %29, i32 0, i32 1
  %32 = load i32, ptr %1, align 4, !tbaa !5
  %33 = add nsw i32 %32, %31
  store i32 %33, ptr %1, align 4, !tbaa !5
  %34 = load double, ptr %3, align 8, !tbaa !11
  %35 = fcmp olt double %34, 2.000000e+04
  %36 = zext i1 %35 to i64
  %37 = select i1 %35, i32 0, i32 1
  %38 = load i32, ptr %1, align 4, !tbaa !5
  %39 = add nsw i32 %38, %37
  store i32 %39, ptr %1, align 4, !tbaa !5
  %40 = load i32, ptr %1, align 4, !tbaa !5
  %41 = icmp ne i32 %40, 0
  %42 = xor i1 %41, true
  br i1 %42, label %43, label %44

43:                                               ; preds = %27
  br label %46

44:                                               ; preds = %27
  call void @__assert_fail(ptr noundef @.str, ptr noundef @.str.1, i32 noundef 298, ptr noundef @__PRETTY_FUNCTION__._Z13test_diskRandv) #6
  unreachable

45:                                               ; No predecessors!
  br label %46

46:                                               ; preds = %45, %43
  call void @llvm.lifetime.end.p0(i64 8, ptr %3) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %2) #5
  %47 = load i32, ptr %1, align 4, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 4, ptr %1) #5
  ret i32 %47
}

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local <2 x float> @_ZN3glm8diskRandIfEENS_3vecILi2ET_LNS_9qualifierE0EEES2_(float noundef) #4

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local { double, double } @_ZN3glm8diskRandIdEENS_3vecILi2ET_LNS_9qualifierE0EEES2_(double noundef) #2

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { noreturn 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 #2 = { inlinehint mustprogress 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 #3 = { mustprogress uwtable "min-legal-vector-width"="64" "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 #4 = { inlinehint mustprogress uwtable "min-legal-vector-width"="64" "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 #5 = { nounwind }
attributes #6 = { noreturn 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++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"float", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"double", !7, i64 0}
!13 = !{!14, !14, i64 0}
!14 = !{!"long", !7, i64 0}
!15 = distinct !{!15, !16}
!16 = !{!"llvm.loop.mustprogress"}


; 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.glm::vec.25" = type { %union.anon.26, %union.anon.27 }
%union.anon.26 = type { float }
%union.anon.27 = type { float }
%"struct.glm::vec.28" = type { %union.anon.29, %union.anon.30 }
%union.anon.29 = type { double }
%union.anon.30 = type { double }

@.str = external hidden unnamed_addr constant [7 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [110 x i8], align 1
@__PRETTY_FUNCTION__._Z13test_diskRandv = external hidden unnamed_addr constant [20 x i8], align 1

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

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

; Function Attrs: noreturn nounwind
declare void @__assert_fail(ptr noundef, ptr noundef, i32 noundef, ptr noundef) local_unnamed_addr #1

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local noundef float @_ZN3glm6lengthILi2EfLNS_9qualifierE0EEET0_RKNS_3vecIXT_ES2_XT1_EEE(ptr noundef nonnull align 4 dereferenceable(8)) local_unnamed_addr #2

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local noundef double @_ZN3glm6lengthILi2EdLNS_9qualifierE0EEET0_RKNS_3vecIXT_ES2_XT1_EEE(ptr noundef nonnull align 8 dereferenceable(16)) local_unnamed_addr #2

; Function Attrs: mustprogress uwtable
define dso_local noundef range(i32 0, 3) i32 @_Z13test_diskRandv() local_unnamed_addr #3 {
  %1 = alloca %"struct.glm::vec.25", align 8
  %2 = alloca %"struct.glm::vec.28", align 8
  %3 = getelementptr inbounds i8, ptr %2, i64 8
  br label %7

4:                                                ; preds = %7
  %5 = fcmp olt float %10, 2.000000e+04
  %6 = fcmp olt double %15, 2.000000e+04
  %.not13 = and i1 %5, %6
  br i1 %.not13, label %18, label %17

7:                                                ; preds = %0, %7
  %.016 = phi i64 [ 0, %0 ], [ %16, %7 ]
  %.0915 = phi double [ 0.000000e+00, %0 ], [ %15, %7 ]
  %.01014 = phi float [ 0.000000e+00, %0 ], [ %10, %7 ]
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %1) #5
  %8 = call <2 x float> @_ZN3glm8diskRandIfEENS_3vecILi2ET_LNS_9qualifierE0EEES2_(float noundef 2.000000e+00)
  store <2 x float> %8, ptr %1, align 8
  %9 = call noundef float @_ZN3glm6lengthILi2EfLNS_9qualifierE0EEET0_RKNS_3vecIXT_ES2_XT1_EEE(ptr noundef nonnull align 4 dereferenceable(8) %1)
  %10 = fadd float %.01014, %9
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %1) #5
  call void @llvm.lifetime.start.p0(i64 16, ptr nonnull %2) #5
  %11 = call { double, double } @_ZN3glm8diskRandIdEENS_3vecILi2ET_LNS_9qualifierE0EEES2_(double noundef 2.000000e+00)
  %12 = extractvalue { double, double } %11, 0
  store double %12, ptr %2, align 8
  %13 = extractvalue { double, double } %11, 1
  store double %13, ptr %3, align 8
  %14 = call noundef double @_ZN3glm6lengthILi2EdLNS_9qualifierE0EEET0_RKNS_3vecIXT_ES2_XT1_EEE(ptr noundef nonnull align 8 dereferenceable(16) %2)
  %15 = fadd double %.0915, %14
  call void @llvm.lifetime.end.p0(i64 16, ptr nonnull %2) #5
  %16 = add nuw nsw i64 %.016, 1
  %exitcond.not = icmp eq i64 %16, 10000
  br i1 %exitcond.not, label %4, label %7, !llvm.loop !5

17:                                               ; preds = %4
  call void @__assert_fail(ptr noundef nonnull @.str, ptr noundef nonnull @.str.1, i32 noundef 298, ptr noundef nonnull @__PRETTY_FUNCTION__._Z13test_diskRandv) #6
  unreachable

18:                                               ; preds = %4
  ret i32 0
}

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local <2 x float> @_ZN3glm8diskRandIfEENS_3vecILi2ET_LNS_9qualifierE0EEES2_(float noundef) local_unnamed_addr #4

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local { double, double } @_ZN3glm8diskRandIdEENS_3vecILi2ET_LNS_9qualifierE0EEES2_(double noundef) local_unnamed_addr #2

attributes #0 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { noreturn 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 #2 = { inlinehint mustprogress 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 #3 = { mustprogress uwtable "min-legal-vector-width"="64" "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 #4 = { inlinehint mustprogress uwtable "min-legal-vector-width"="64" "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 #5 = { nounwind }
attributes #6 = { noreturn 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 = distinct !{!5, !6}
!6 = !{!"llvm.loop.mustprogress"}


; Effective O3 passes: CorrelatedValuePropagationPass,EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,IndVarSimplifyPass,InferAlignmentPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,LCSSAPass,LICMPass,LoopRotatePass,LoopUnrollPass,SROAPass,SimplifyCFGPass