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

; 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.48" = type { %union.anon.49 }
%union.anon.49 = type { %struct.anon.50 }
%struct.anon.50 = type { float, float, float }
%"struct.glm::vec" = type { %union.anon.5 }
%union.anon.5 = type { %struct.anon }
%struct.anon = type { float, float, float, float }
%"struct.glm::vec.53" = type { %union.anon.54 }
%union.anon.54 = type { %struct.anon.55 }
%struct.anon.55 = type { i8, i8, i8 }

; 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: inlinehint mustprogress nounwind uwtable
declare dso_local void @_ZN3glm3vecILi3EfLNS_9qualifierE0EEC2Ef(ptr noundef nonnull align 4 dereferenceable(12), float noundef) unnamed_addr #1 align 2

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

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local noundef zeroext i1 @_ZN3glm3allILi3ELNS_9qualifierE0EEEbRKNS_3vecIXT_EbXT0_EEE(ptr noundef nonnull align 1 dereferenceable(3)) #3

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

; Function Attrs: mustprogress uwtable
define dso_local noundef i32 @_Z9test_RGBMv() #4 {
  %1 = alloca i32, align 4
  %2 = alloca i64, align 8
  %3 = alloca %"struct.glm::vec.48", align 4
  %4 = alloca %"struct.glm::vec", align 4
  %5 = alloca %"struct.glm::vec.48", align 4
  %6 = alloca { <2 x float>, float }, align 8
  %7 = alloca %"struct.glm::vec.53", align 1
  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 8, ptr %2) #6
  store i64 0, ptr %2, align 8, !tbaa !9
  br label %8

8:                                                ; preds = %33, %0
  %9 = load i64, ptr %2, align 8, !tbaa !9
  %10 = icmp ult i64 %9, 1024
  br i1 %10, label %12, label %11

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

12:                                               ; preds = %8
  call void @llvm.lifetime.start.p0(i64 12, ptr %3) #6
  %13 = load i64, ptr %2, align 8, !tbaa !9
  %14 = uitofp i64 %13 to float
  call void @_ZN3glm3vecILi3EfLNS_9qualifierE0EEC2Ef(ptr noundef nonnull align 4 dereferenceable(12) %3, float noundef %14)
  call void @llvm.lifetime.start.p0(i64 16, ptr %4) #6
  %15 = call { <2 x float>, <2 x float> } @_ZN3glm8packRGBMIfLNS_9qualifierE0EEENS_3vecILi4ET_XT0_EEERKNS2_ILi3ES3_XT0_EEE(ptr noundef nonnull align 4 dereferenceable(12) %3)
  %16 = getelementptr inbounds %"struct.glm::vec", ptr %4, i32 0, i32 0
  %17 = getelementptr inbounds %union.anon.5, ptr %16, i32 0, i32 0
  %18 = getelementptr inbounds { <2 x float>, <2 x float> }, ptr %17, i32 0, i32 0
  %19 = extractvalue { <2 x float>, <2 x float> } %15, 0
  store <2 x float> %19, ptr %18, align 4
  %20 = getelementptr inbounds { <2 x float>, <2 x float> }, ptr %17, i32 0, i32 1
  %21 = extractvalue { <2 x float>, <2 x float> } %15, 1
  store <2 x float> %21, ptr %20, align 4
  call void @llvm.lifetime.start.p0(i64 12, ptr %5) #6
  %22 = call { <2 x float>, float } @_ZN3glm10unpackRGBMIfLNS_9qualifierE0EEENS_3vecILi3ET_XT0_EEERKNS2_ILi4ES3_XT0_EEE(ptr noundef nonnull align 4 dereferenceable(16) %4)
  %23 = getelementptr inbounds %"struct.glm::vec.48", ptr %5, i32 0, i32 0
  %24 = getelementptr inbounds %union.anon.49, ptr %23, i32 0, i32 0
  store { <2 x float>, float } %22, ptr %6, align 8
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %24, ptr align 8 %6, i64 12, i1 false)
  call void @llvm.lifetime.start.p0(i64 3, ptr %7) #6
  %25 = call i24 @_ZN3glm5equalILi3EfLNS_9qualifierE0EEENS_3vecIXT_EbXT1_EEERKNS2_IXT_ET0_XT1_EEES7_S4_(ptr noundef nonnull align 4 dereferenceable(12) %3, ptr noundef nonnull align 4 dereferenceable(12) %5, float noundef 0x3F847AE140000000)
  %26 = getelementptr inbounds %"struct.glm::vec.53", ptr %7, i32 0, i32 0
  %27 = getelementptr inbounds %union.anon.54, ptr %26, i32 0, i32 0
  store i24 %25, ptr %27, align 1
  %28 = call noundef zeroext i1 @_ZN3glm3allILi3ELNS_9qualifierE0EEEbRKNS_3vecIXT_EbXT0_EEE(ptr noundef nonnull align 1 dereferenceable(3) %7)
  %29 = zext i1 %28 to i64
  %30 = select i1 %28, i32 0, i32 1
  %31 = load i32, ptr %1, align 4, !tbaa !5
  %32 = add nsw i32 %31, %30
  store i32 %32, ptr %1, align 4, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 3, ptr %7) #6
  call void @llvm.lifetime.end.p0(i64 12, ptr %5) #6
  call void @llvm.lifetime.end.p0(i64 16, ptr %4) #6
  call void @llvm.lifetime.end.p0(i64 12, ptr %3) #6
  br label %33

33:                                               ; preds = %12
  %34 = load i64, ptr %2, align 8, !tbaa !9
  %35 = add i64 %34, 1
  store i64 %35, ptr %2, align 8, !tbaa !9
  br label %8, !llvm.loop !11

36:                                               ; preds = %11
  %37 = load i32, ptr %1, align 4, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 4, ptr %1) #6
  ret i32 %37
}

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local { <2 x float>, <2 x float> } @_ZN3glm8packRGBMIfLNS_9qualifierE0EEENS_3vecILi4ET_XT0_EEERKNS2_ILi3ES3_XT0_EEE(ptr noundef nonnull align 4 dereferenceable(12)) #5

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local { <2 x float>, float } @_ZN3glm10unpackRGBMIfLNS_9qualifierE0EEENS_3vecILi3ET_XT0_EEERKNS2_ILi4ES3_XT0_EEE(ptr noundef nonnull align 4 dereferenceable(16)) #5

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { inlinehint mustprogress 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 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
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 }

!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 = distinct !{!11, !12}
!12 = !{!"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.48" = type { %union.anon.49 }
%union.anon.49 = type { %struct.anon.50 }
%struct.anon.50 = type { float, float, float }
%"struct.glm::vec" = type { %union.anon.5 }
%union.anon.5 = type { %struct.anon }
%struct.anon = type { float, float, float, float }
%"struct.glm::vec.53" = type { %union.anon.54 }
%union.anon.54 = type { %struct.anon.55 }
%struct.anon.55 = type { i8, i8, i8 }

; 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: inlinehint mustprogress nounwind uwtable
declare dso_local void @_ZN3glm3vecILi3EfLNS_9qualifierE0EEC2Ef(ptr noundef nonnull align 4 dereferenceable(12), float noundef) unnamed_addr #1 align 2

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local noundef zeroext i1 @_ZN3glm3allILi3ELNS_9qualifierE0EEEbRKNS_3vecIXT_EbXT0_EEE(ptr noundef nonnull align 1 dereferenceable(3)) local_unnamed_addr #2

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local i24 @_ZN3glm5equalILi3EfLNS_9qualifierE0EEENS_3vecIXT_EbXT1_EEERKNS2_IXT_ET0_XT1_EEES7_S4_(ptr noundef nonnull align 4 dereferenceable(12), ptr noundef nonnull align 4 dereferenceable(12), float noundef) local_unnamed_addr #2

; Function Attrs: mustprogress uwtable
define dso_local noundef i32 @_Z9test_RGBMv() local_unnamed_addr #3 {
  %1 = alloca %"struct.glm::vec.48", align 4
  %2 = alloca %"struct.glm::vec", align 8
  %3 = alloca %"struct.glm::vec.48", align 8
  %4 = alloca %"struct.glm::vec.53", align 4
  %5 = getelementptr inbounds i8, ptr %2, i64 8
  %.sroa.2.0..sroa_idx = getelementptr inbounds i8, ptr %3, i64 8
  br label %7

6:                                                ; preds = %7
  ret i32 %16

7:                                                ; preds = %0, %7
  %.07 = phi i32 [ 0, %0 ], [ %16, %7 ]
  %.056 = phi i64 [ 0, %0 ], [ %17, %7 ]
  call void @llvm.lifetime.start.p0(i64 12, ptr nonnull %1) #5
  %8 = uitofp nneg i64 %.056 to float
  call void @_ZN3glm3vecILi3EfLNS_9qualifierE0EEC2Ef(ptr noundef nonnull align 4 dereferenceable(12) %1, float noundef %8)
  call void @llvm.lifetime.start.p0(i64 16, ptr nonnull %2) #5
  %9 = call { <2 x float>, <2 x float> } @_ZN3glm8packRGBMIfLNS_9qualifierE0EEENS_3vecILi4ET_XT0_EEERKNS2_ILi3ES3_XT0_EEE(ptr noundef nonnull align 4 dereferenceable(12) %1)
  %10 = extractvalue { <2 x float>, <2 x float> } %9, 0
  store <2 x float> %10, ptr %2, align 8
  %11 = extractvalue { <2 x float>, <2 x float> } %9, 1
  store <2 x float> %11, ptr %5, align 8
  call void @llvm.lifetime.start.p0(i64 12, ptr nonnull %3) #5
  %12 = call { <2 x float>, float } @_ZN3glm10unpackRGBMIfLNS_9qualifierE0EEENS_3vecILi3ET_XT0_EEERKNS2_ILi4ES3_XT0_EEE(ptr noundef nonnull align 4 dereferenceable(16) %2)
  %.fca.0.extract = extractvalue { <2 x float>, float } %12, 0
  %.fca.1.extract = extractvalue { <2 x float>, float } %12, 1
  store <2 x float> %.fca.0.extract, ptr %3, align 8
  store float %.fca.1.extract, ptr %.sroa.2.0..sroa_idx, align 8
  call void @llvm.lifetime.start.p0(i64 3, ptr nonnull %4) #5
  %13 = call i24 @_ZN3glm5equalILi3EfLNS_9qualifierE0EEENS_3vecIXT_EbXT1_EEERKNS2_IXT_ET0_XT1_EEES7_S4_(ptr noundef nonnull align 4 dereferenceable(12) %1, ptr noundef nonnull align 4 dereferenceable(12) %3, float noundef 0x3F847AE140000000)
  store i24 %13, ptr %4, align 4
  %14 = call noundef zeroext i1 @_ZN3glm3allILi3ELNS_9qualifierE0EEEbRKNS_3vecIXT_EbXT0_EEE(ptr noundef nonnull align 1 dereferenceable(3) %4)
  %not. = xor i1 %14, true
  %15 = zext i1 %not. to i32
  %16 = add nuw nsw i32 %.07, %15
  call void @llvm.lifetime.end.p0(i64 3, ptr nonnull %4) #5
  call void @llvm.lifetime.end.p0(i64 12, ptr nonnull %3) #5
  call void @llvm.lifetime.end.p0(i64 16, ptr nonnull %2) #5
  call void @llvm.lifetime.end.p0(i64 12, ptr nonnull %1) #5
  %17 = add nuw nsw i64 %.056, 1
  %exitcond.not = icmp eq i64 %17, 1024
  br i1 %exitcond.not, label %6, label %7, !llvm.loop !5
}

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local { <2 x float>, <2 x float> } @_ZN3glm8packRGBMIfLNS_9qualifierE0EEENS_3vecILi4ET_XT0_EEERKNS2_ILi3ES3_XT0_EEE(ptr noundef nonnull align 4 dereferenceable(12)) local_unnamed_addr #4

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local { <2 x float>, float } @_ZN3glm10unpackRGBMIfLNS_9qualifierE0EEENS_3vecILi3ET_XT0_EEERKNS2_ILi4ES3_XT0_EEE(ptr noundef nonnull align 4 dereferenceable(16)) local_unnamed_addr #4

attributes #0 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { inlinehint mustprogress 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 = { 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 }

!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: EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,IndVarSimplifyPass,InferAlignmentPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,LCSSAPass,LICMPass,LoopRotatePass,LoopUnrollPass,ReassociatePass,SROAPass,SimplifyCFGPass