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

; 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.31" = type { %union.anon.32, %union.anon.33, %union.anon.34 }
%union.anon.32 = type { float }
%union.anon.33 = type { float }
%union.anon.34 = type { float }
%"struct.glm::vec.35" = type { %union.anon.36, %union.anon.37, %union.anon.38 }
%union.anon.36 = type { double }
%union.anon.37 = type { double }
%union.anon.38 = 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_ballRandv = 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 nounwind willreturn memory(argmem: readwrite)
declare void @llvm.memcpy.p0.p0.i64(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i64, i1 immarg) #1

; 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) #2

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local noundef float @_ZN3glm6lengthILi3EfLNS_9qualifierE0EEET0_RKNS_3vecIXT_ES2_XT1_EEE(ptr noundef nonnull align 4 dereferenceable(12)) #3

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local noundef double @_ZN3glm6lengthILi3EdLNS_9qualifierE0EEET0_RKNS_3vecIXT_ES2_XT1_EEE(ptr noundef nonnull align 8 dereferenceable(24)) #3

; Function Attrs: mustprogress uwtable
define dso_local noundef i32 @_Z13test_ballRandv() #4 {
  %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.31", align 4
  %6 = alloca { <2 x float>, float }, align 8
  %7 = alloca %"struct.glm::vec.35", align 8
  call void @llvm.lifetime.start.p0(i64 4, ptr %1) #6
  store i32 0, ptr %1, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %2) #6
  store float 0.000000e+00, ptr %2, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %3) #6
  store double 0.000000e+00, ptr %3, align 8, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 8, ptr %4) #6
  store i64 0, ptr %4, align 8, !tbaa !13
  br label %8

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

11:                                               ; preds = %8
  call void @llvm.lifetime.end.p0(i64 8, ptr %4) #6
  br label %23

12:                                               ; preds = %8
  call void @llvm.lifetime.start.p0(i64 12, ptr %5) #6
  %13 = call { <2 x float>, float } @_ZN3glm8ballRandIfEENS_3vecILi3ET_LNS_9qualifierE0EEES2_(float noundef 2.000000e+00)
  store { <2 x float>, float } %13, ptr %6, align 8
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %5, ptr align 8 %6, i64 12, i1 false)
  %14 = call noundef float @_ZN3glm6lengthILi3EfLNS_9qualifierE0EEET0_RKNS_3vecIXT_ES2_XT1_EEE(ptr noundef nonnull align 4 dereferenceable(12) %5)
  %15 = load float, ptr %2, align 4, !tbaa !9
  %16 = fadd float %15, %14
  store float %16, ptr %2, align 4, !tbaa !9
  call void @llvm.lifetime.end.p0(i64 12, ptr %5) #6
  call void @llvm.lifetime.start.p0(i64 24, ptr %7) #6
  call void @_ZN3glm8ballRandIdEENS_3vecILi3ET_LNS_9qualifierE0EEES2_(ptr dead_on_unwind writable sret(%"struct.glm::vec.35") align 8 %7, double noundef 2.000000e+00)
  %17 = call noundef double @_ZN3glm6lengthILi3EdLNS_9qualifierE0EEET0_RKNS_3vecIXT_ES2_XT1_EEE(ptr noundef nonnull align 8 dereferenceable(24) %7)
  %18 = load double, ptr %3, align 8, !tbaa !11
  %19 = fadd double %18, %17
  store double %19, ptr %3, align 8, !tbaa !11
  call void @llvm.lifetime.end.p0(i64 24, ptr %7) #6
  br label %20

20:                                               ; preds = %12
  %21 = load i64, ptr %4, align 8, !tbaa !13
  %22 = add i64 %21, 1
  store i64 %22, ptr %4, align 8, !tbaa !13
  br label %8, !llvm.loop !15

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

39:                                               ; preds = %23
  br label %42

40:                                               ; preds = %23
  call void @__assert_fail(ptr noundef @.str, ptr noundef @.str.1, i32 noundef 320, ptr noundef @__PRETTY_FUNCTION__._Z13test_ballRandv) #7
  unreachable

41:                                               ; No predecessors!
  br label %42

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

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local { <2 x float>, float } @_ZN3glm8ballRandIfEENS_3vecILi3ET_LNS_9qualifierE0EEES2_(float noundef) #5

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local void @_ZN3glm8ballRandIdEENS_3vecILi3ET_LNS_9qualifierE0EEES2_(ptr dead_on_unwind noalias writable sret(%"struct.glm::vec.35") align 8, double noundef) #3

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { 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 #3 = { 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 #4 = { 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 = { 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 #6 = { nounwind }
attributes #7 = { 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.31" = type { %union.anon.32, %union.anon.33, %union.anon.34 }
%union.anon.32 = type { float }
%union.anon.33 = type { float }
%union.anon.34 = type { float }
%"struct.glm::vec.35" = type { %union.anon.36, %union.anon.37, %union.anon.38 }
%union.anon.36 = type { double }
%union.anon.37 = type { double }
%union.anon.38 = 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_ballRandv = 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 @_ZN3glm6lengthILi3EfLNS_9qualifierE0EEET0_RKNS_3vecIXT_ES2_XT1_EEE(ptr noundef nonnull align 4 dereferenceable(12)) local_unnamed_addr #2

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

; Function Attrs: mustprogress uwtable
define dso_local noundef range(i32 0, 3) i32 @_Z13test_ballRandv() local_unnamed_addr #3 {
  %1 = alloca %"struct.glm::vec.31", align 8
  %2 = alloca %"struct.glm::vec.35", align 8
  %.sroa.2.0..sroa_idx = getelementptr inbounds i8, ptr %1, i64 8
  br label %6

3:                                                ; preds = %6
  %4 = fcmp olt float %9, 2.000000e+04
  %5 = fcmp olt double %11, 2.000000e+04
  %.not13 = and i1 %5, %4
  br i1 %.not13, label %14, label %13

6:                                                ; preds = %0, %6
  %.016 = phi float [ 0.000000e+00, %0 ], [ %9, %6 ]
  %.0915 = phi i64 [ 0, %0 ], [ %12, %6 ]
  %.01014 = phi double [ 0.000000e+00, %0 ], [ %11, %6 ]
  call void @llvm.lifetime.start.p0(i64 12, ptr nonnull %1) #5
  %7 = call { <2 x float>, float } @_ZN3glm8ballRandIfEENS_3vecILi3ET_LNS_9qualifierE0EEES2_(float noundef 2.000000e+00)
  %.fca.0.extract = extractvalue { <2 x float>, float } %7, 0
  %.fca.1.extract = extractvalue { <2 x float>, float } %7, 1
  store <2 x float> %.fca.0.extract, ptr %1, align 8
  store float %.fca.1.extract, ptr %.sroa.2.0..sroa_idx, align 8
  %8 = call noundef float @_ZN3glm6lengthILi3EfLNS_9qualifierE0EEET0_RKNS_3vecIXT_ES2_XT1_EEE(ptr noundef nonnull align 4 dereferenceable(12) %1)
  %9 = fadd float %.016, %8
  call void @llvm.lifetime.end.p0(i64 12, ptr nonnull %1) #5
  call void @llvm.lifetime.start.p0(i64 24, ptr nonnull %2) #5
  call void @_ZN3glm8ballRandIdEENS_3vecILi3ET_LNS_9qualifierE0EEES2_(ptr dead_on_unwind nonnull writable sret(%"struct.glm::vec.35") align 8 %2, double noundef 2.000000e+00)
  %10 = call noundef double @_ZN3glm6lengthILi3EdLNS_9qualifierE0EEET0_RKNS_3vecIXT_ES2_XT1_EEE(ptr noundef nonnull align 8 dereferenceable(24) %2)
  %11 = fadd double %.01014, %10
  call void @llvm.lifetime.end.p0(i64 24, ptr nonnull %2) #5
  %12 = add nuw nsw i64 %.0915, 1
  %exitcond.not = icmp eq i64 %12, 10000
  br i1 %exitcond.not, label %3, label %6, !llvm.loop !5

13:                                               ; preds = %3
  call void @__assert_fail(ptr noundef nonnull @.str, ptr noundef nonnull @.str.1, i32 noundef 320, ptr noundef nonnull @__PRETTY_FUNCTION__._Z13test_ballRandv) #6
  unreachable

14:                                               ; preds = %3
  ret i32 0
}

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

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local void @_ZN3glm8ballRandIdEENS_3vecILi3ET_LNS_9qualifierE0EEES2_(ptr dead_on_unwind noalias writable sret(%"struct.glm::vec.35") align 8, 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,ReassociatePass,SROAPass,SimplifyCFGPass