; LLVM IR from Dovyski/opengl-demos :: libs/glm-0.9.9.3/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.42" = type { %union.anon.43 }
%union.anon.43 = type { %struct.anon.44 }
%struct.anon.44 = type { float, float }
%"struct.glm::vec.47" = type { %union.anon.48 }
%union.anon.48 = type { <2 x double> }

@.str = external hidden unnamed_addr constant [7 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [95 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_9qualifierE3EEET0_RKNS_3vecIXT_ES2_XT1_EEE(ptr noundef nonnull align 8 dereferenceable(8)) #2

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local noundef double @_ZN3glm6lengthILi2EdLNS_9qualifierE3EEET0_RKNS_3vecIXT_ES2_XT1_EEE(ptr noundef nonnull align 16 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.42", align 8
  %6 = alloca %"struct.glm::vec.47", align 16
  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 = %28, %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 %31

11:                                               ; preds = %7
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #5
  %12 = call <2 x float> @_ZN3glm8diskRandIfEENS_3vecILi2ET_LNS_9qualifierE3EEES2_(float noundef 2.000000e+00)
  %13 = getelementptr inbounds %"struct.glm::vec.42", ptr %5, i32 0, i32 0
  %14 = getelementptr inbounds %union.anon.43, ptr %13, i32 0, i32 0
  store <2 x float> %12, ptr %14, align 8
  %15 = call noundef float @_ZN3glm6lengthILi2EfLNS_9qualifierE3EEET0_RKNS_3vecIXT_ES2_XT1_EEE(ptr noundef nonnull align 8 dereferenceable(8) %5)
  %16 = load float, ptr %2, align 4, !tbaa !9
  %17 = fadd float %16, %15
  store float %17, 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
  %18 = call { double, double } @_ZN3glm8diskRandIdEENS_3vecILi2ET_LNS_9qualifierE3EEES2_(double noundef 2.000000e+00)
  %19 = getelementptr inbounds %"struct.glm::vec.47", ptr %6, i32 0, i32 0
  %20 = getelementptr inbounds %union.anon.48, ptr %19, i32 0, i32 0
  %21 = getelementptr inbounds { double, double }, ptr %20, i32 0, i32 0
  %22 = extractvalue { double, double } %18, 0
  store double %22, ptr %21, align 16
  %23 = getelementptr inbounds { double, double }, ptr %20, i32 0, i32 1
  %24 = extractvalue { double, double } %18, 1
  store double %24, ptr %23, align 8
  %25 = call noundef double @_ZN3glm6lengthILi2EdLNS_9qualifierE3EEET0_RKNS_3vecIXT_ES2_XT1_EEE(ptr noundef nonnull align 16 dereferenceable(16) %6)
  %26 = load double, ptr %3, align 8, !tbaa !11
  %27 = fadd double %26, %25
  store double %27, ptr %3, align 8, !tbaa !11
  call void @llvm.lifetime.end.p0(i64 16, ptr %6) #5
  br label %28

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

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

47:                                               ; preds = %31
  br label %50

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

49:                                               ; No predecessors!
  br label %50

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

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

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local { double, double } @_ZN3glm8diskRandIdEENS_3vecILi2ET_LNS_9qualifierE3EEES2_(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.42" = type { %union.anon.43 }
%union.anon.43 = type { %struct.anon.44 }
%struct.anon.44 = type { float, float }
%"struct.glm::vec.47" = type { %union.anon.48 }
%union.anon.48 = type { <2 x double> }

@.str = external hidden unnamed_addr constant [7 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [95 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_9qualifierE3EEET0_RKNS_3vecIXT_ES2_XT1_EEE(ptr noundef nonnull align 8 dereferenceable(8)) local_unnamed_addr #2

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local noundef double @_ZN3glm6lengthILi2EdLNS_9qualifierE3EEET0_RKNS_3vecIXT_ES2_XT1_EEE(ptr noundef nonnull align 16 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.42", align 8
  %2 = alloca %"struct.glm::vec.47", align 16
  %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_9qualifierE3EEES2_(float noundef 2.000000e+00)
  store <2 x float> %8, ptr %1, align 8
  %9 = call noundef float @_ZN3glm6lengthILi2EfLNS_9qualifierE3EEET0_RKNS_3vecIXT_ES2_XT1_EEE(ptr noundef nonnull align 8 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_9qualifierE3EEES2_(double noundef 2.000000e+00)
  %12 = extractvalue { double, double } %11, 0
  store double %12, ptr %2, align 16
  %13 = extractvalue { double, double } %11, 1
  store double %13, ptr %3, align 8
  %14 = call noundef double @_ZN3glm6lengthILi2EdLNS_9qualifierE3EEET0_RKNS_3vecIXT_ES2_XT1_EEE(ptr noundef nonnull align 16 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_9qualifierE3EEES2_(float noundef) local_unnamed_addr #4

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local { double, double } @_ZN3glm8diskRandIdEENS_3vecILi2ET_LNS_9qualifierE3EEES2_(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,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,LCSSAPass,LICMPass,LoopRotatePass,LoopUnrollPass,SROAPass,SimplifyCFGPass