; LLVM IR from Dovyski/opengl-demos :: libs/glm-0.9.9.3/test/gtc/gtc_random.ll (Z17test_circularRandv)

; 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__._Z17test_circularRandv = external hidden unnamed_addr constant [24 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 zeroext i1 @_ZN3glm12epsilonEqualIfEEbRKT_S3_S3_(ptr noundef nonnull align 4 dereferenceable(4), ptr noundef nonnull align 4 dereferenceable(4), ptr noundef nonnull align 4 dereferenceable(4)) #2

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local noundef zeroext i1 @_ZN3glm12epsilonEqualIdEEbRKT_S3_S3_(ptr noundef nonnull align 8 dereferenceable(8), ptr noundef nonnull align 8 dereferenceable(8), ptr noundef nonnull align 8 dereferenceable(8)) #2

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

13:                                               ; preds = %36, %0
  %14 = load i64, ptr %6, align 8, !tbaa !9
  %15 = load i64, ptr %2, align 8, !tbaa !9
  %16 = icmp ult i64 %14, %15
  br i1 %16, label %18, label %17

17:                                               ; preds = %13
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #5
  br label %39

18:                                               ; preds = %13
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #5
  %19 = call <2 x float> @_ZN3glm12circularRandIfEENS_3vecILi2ET_LNS_9qualifierE3EEES2_(float noundef 1.000000e+00)
  %20 = getelementptr inbounds %"struct.glm::vec.42", ptr %7, i32 0, i32 0
  %21 = getelementptr inbounds %union.anon.43, ptr %20, i32 0, i32 0
  store <2 x float> %19, ptr %21, align 8
  %22 = call noundef float @_ZN3glm6lengthILi2EfLNS_9qualifierE3EEET0_RKNS_3vecIXT_ES2_XT1_EEE(ptr noundef nonnull align 8 dereferenceable(8) %7)
  %23 = load float, ptr %3, align 4, !tbaa !11
  %24 = fadd float %23, %22
  store float %24, ptr %3, align 4, !tbaa !11
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #5
  call void @llvm.lifetime.start.p0(i64 16, ptr %8) #5
  %25 = load double, ptr %5, align 8, !tbaa !13
  %26 = call { double, double } @_ZN3glm12circularRandIdEENS_3vecILi2ET_LNS_9qualifierE3EEES2_(double noundef %25)
  %27 = getelementptr inbounds %"struct.glm::vec.47", ptr %8, i32 0, i32 0
  %28 = getelementptr inbounds %union.anon.48, ptr %27, i32 0, i32 0
  %29 = getelementptr inbounds { double, double }, ptr %28, i32 0, i32 0
  %30 = extractvalue { double, double } %26, 0
  store double %30, ptr %29, align 16
  %31 = getelementptr inbounds { double, double }, ptr %28, i32 0, i32 1
  %32 = extractvalue { double, double } %26, 1
  store double %32, ptr %31, align 8
  %33 = call noundef double @_ZN3glm6lengthILi2EdLNS_9qualifierE3EEET0_RKNS_3vecIXT_ES2_XT1_EEE(ptr noundef nonnull align 16 dereferenceable(16) %8)
  %34 = load double, ptr %4, align 8, !tbaa !13
  %35 = fadd double %34, %33
  store double %35, ptr %4, align 8, !tbaa !13
  call void @llvm.lifetime.end.p0(i64 16, ptr %8) #5
  br label %36

36:                                               ; preds = %18
  %37 = load i64, ptr %6, align 8, !tbaa !9
  %38 = add i64 %37, 1
  store i64 %38, ptr %6, align 8, !tbaa !9
  br label %13, !llvm.loop !15

39:                                               ; preds = %17
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #5
  %40 = load i64, ptr %2, align 8, !tbaa !9
  %41 = uitofp i64 %40 to float
  store float %41, ptr %9, align 4, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #5
  store float 0x3F847AE140000000, ptr %10, align 4, !tbaa !11
  %42 = call noundef zeroext i1 @_ZN3glm12epsilonEqualIfEEbRKT_S3_S3_(ptr noundef nonnull align 4 dereferenceable(4) %3, ptr noundef nonnull align 4 dereferenceable(4) %9, ptr noundef nonnull align 4 dereferenceable(4) %10)
  %43 = zext i1 %42 to i64
  %44 = select i1 %42, i32 0, i32 1
  %45 = load i32, ptr %1, align 4, !tbaa !5
  %46 = add nsw i32 %45, %44
  store i32 %46, ptr %1, align 4, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #5
  call void @llvm.lifetime.start.p0(i64 8, ptr %11) #5
  %47 = load i64, ptr %2, align 8, !tbaa !9
  %48 = uitofp i64 %47 to double
  %49 = load double, ptr %5, align 8, !tbaa !13
  %50 = fmul double %48, %49
  store double %50, ptr %11, align 8, !tbaa !13
  call void @llvm.lifetime.start.p0(i64 8, ptr %12) #5
  store double 1.000000e-02, ptr %12, align 8, !tbaa !13
  %51 = call noundef zeroext i1 @_ZN3glm12epsilonEqualIdEEbRKT_S3_S3_(ptr noundef nonnull align 8 dereferenceable(8) %4, ptr noundef nonnull align 8 dereferenceable(8) %11, ptr noundef nonnull align 8 dereferenceable(8) %12)
  %52 = zext i1 %51 to i64
  %53 = select i1 %51, i32 0, i32 1
  %54 = load i32, ptr %1, align 4, !tbaa !5
  %55 = add nsw i32 %54, %53
  store i32 %55, ptr %1, align 4, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 8, ptr %12) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #5
  %56 = load i32, ptr %1, align 4, !tbaa !5
  %57 = icmp ne i32 %56, 0
  %58 = xor i1 %57, true
  br i1 %58, label %59, label %60

59:                                               ; preds = %39
  br label %62

60:                                               ; preds = %39
  call void @__assert_fail(ptr noundef @.str, ptr noundef @.str.1, i32 noundef 241, ptr noundef @__PRETTY_FUNCTION__._Z17test_circularRandv) #6
  unreachable

61:                                               ; No predecessors!
  br label %62

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

; 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 <2 x float> @_ZN3glm12circularRandIfEENS_3vecILi2ET_LNS_9qualifierE3EEES2_(float noundef) #4

; 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: inlinehint mustprogress uwtable
declare dso_local { double, double } @_ZN3glm12circularRandIdEENS_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 = !{!"long", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"float", !7, i64 0}
!13 = !{!14, !14, i64 0}
!14 = !{!"double", !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__._Z17test_circularRandv = external hidden unnamed_addr constant [24 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 zeroext i1 @_ZN3glm12epsilonEqualIfEEbRKT_S3_S3_(ptr noundef nonnull align 4 dereferenceable(4), ptr noundef nonnull align 4 dereferenceable(4), ptr noundef nonnull align 4 dereferenceable(4)) local_unnamed_addr #2

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local noundef zeroext i1 @_ZN3glm12epsilonEqualIdEEbRKT_S3_S3_(ptr noundef nonnull align 8 dereferenceable(8), ptr noundef nonnull align 8 dereferenceable(8), ptr noundef nonnull align 8 dereferenceable(8)) local_unnamed_addr #2

; Function Attrs: mustprogress uwtable
define dso_local noundef range(i32 0, 3) i32 @_Z17test_circularRandv() local_unnamed_addr #3 {
  %1 = alloca float, align 4
  %2 = alloca double, align 8
  %3 = alloca %"struct.glm::vec.42", align 8
  %4 = alloca %"struct.glm::vec.47", align 16
  %5 = alloca float, align 4
  %6 = alloca float, align 4
  %7 = alloca double, align 8
  %8 = alloca double, align 8
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %1) #5
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %2) #5
  %9 = getelementptr inbounds i8, ptr %4, i64 8
  br label %13

10:                                               ; preds = %13
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %5) #5
  store float 1.000000e+04, ptr %5, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %6) #5
  store float 0x3F847AE140000000, ptr %6, align 4, !tbaa !5
  %11 = call noundef zeroext i1 @_ZN3glm12epsilonEqualIfEEbRKT_S3_S3_(ptr noundef nonnull align 4 dereferenceable(4) %1, ptr noundef nonnull align 4 dereferenceable(4) %5, ptr noundef nonnull align 4 dereferenceable(4) %6)
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %6) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %5) #5
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %7) #5
  store double 2.000000e+04, ptr %7, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %8) #5
  store double 1.000000e-02, ptr %8, align 8, !tbaa !9
  %12 = call noundef zeroext i1 @_ZN3glm12epsilonEqualIdEEbRKT_S3_S3_(ptr noundef nonnull align 8 dereferenceable(8) %2, ptr noundef nonnull align 8 dereferenceable(8) %7, ptr noundef nonnull align 8 dereferenceable(8) %8)
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %8) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %7) #5
  %.demorgan = and i1 %11, %12
  br i1 %.demorgan, label %26, label %25

13:                                               ; preds = %0, %13
  %14 = phi double [ 0.000000e+00, %0 ], [ %23, %13 ]
  %15 = phi float [ 0.000000e+00, %0 ], [ %18, %13 ]
  %.011 = phi i64 [ 0, %0 ], [ %24, %13 ]
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %3) #5
  %16 = call <2 x float> @_ZN3glm12circularRandIfEENS_3vecILi2ET_LNS_9qualifierE3EEES2_(float noundef 1.000000e+00)
  store <2 x float> %16, ptr %3, align 8
  %17 = call noundef float @_ZN3glm6lengthILi2EfLNS_9qualifierE3EEET0_RKNS_3vecIXT_ES2_XT1_EEE(ptr noundef nonnull align 8 dereferenceable(8) %3)
  %18 = fadd float %17, %15
  store float %18, ptr %1, align 4, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %3) #5
  call void @llvm.lifetime.start.p0(i64 16, ptr nonnull %4) #5
  %19 = call { double, double } @_ZN3glm12circularRandIdEENS_3vecILi2ET_LNS_9qualifierE3EEES2_(double noundef 2.000000e+00)
  %20 = extractvalue { double, double } %19, 0
  store double %20, ptr %4, align 16
  %21 = extractvalue { double, double } %19, 1
  store double %21, ptr %9, align 8
  %22 = call noundef double @_ZN3glm6lengthILi2EdLNS_9qualifierE3EEET0_RKNS_3vecIXT_ES2_XT1_EEE(ptr noundef nonnull align 16 dereferenceable(16) %4)
  %23 = fadd double %22, %14
  store double %23, ptr %2, align 8, !tbaa !9
  call void @llvm.lifetime.end.p0(i64 16, ptr nonnull %4) #5
  %24 = add nuw nsw i64 %.011, 1
  %exitcond.not = icmp eq i64 %24, 10000
  br i1 %exitcond.not, label %10, label %13, !llvm.loop !11

25:                                               ; preds = %10
  call void @__assert_fail(ptr noundef nonnull @.str, ptr noundef nonnull @.str.1, i32 noundef 241, ptr noundef nonnull @__PRETTY_FUNCTION__._Z17test_circularRandv) #6
  unreachable

26:                                               ; preds = %10
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %2) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %1) #5
  ret i32 0
}

; 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 <2 x float> @_ZN3glm12circularRandIfEENS_3vecILi2ET_LNS_9qualifierE3EEES2_(float noundef) local_unnamed_addr #4

; 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: inlinehint mustprogress uwtable
declare dso_local { double, double } @_ZN3glm12circularRandIdEENS_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 = !{!6, !6, i64 0}
!6 = !{!"float", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"double", !7, i64 0}
!11 = distinct !{!11, !12}
!12 = !{!"llvm.loop.mustprogress"}


; Effective O3 passes: CorrelatedValuePropagationPass,DSEPass,EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,LICMPass,LoopRotatePass,ReassociatePass,SROAPass,SimplifyCFGPass