; LLVM IR from jpvt/Computer_Graphics :: Assignment #3/third_party/glm/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.49" = type { %union.anon.50, %union.anon.51, %union.anon.52 }
%union.anon.50 = type { float }
%union.anon.51 = type { float }
%union.anon.52 = type { float }
%"struct.glm::vec" = type { %union.anon.5, %union.anon.6, %union.anon.7, %union.anon.8 }
%union.anon.5 = type { float }
%union.anon.6 = type { float }
%union.anon.7 = type { float }
%union.anon.8 = type { float }
%"struct.glm::vec.53" = type { %union.anon.54, %union.anon.55, %union.anon.56 }
%union.anon.54 = type { i8 }
%union.anon.55 = type { i8 }
%union.anon.56 = type { 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: 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: inlinehint mustprogress nounwind uwtable
declare dso_local void @_ZN3glm3vecILi3EfLNS_9qualifierE0EEC2Ef(ptr noundef nonnull align 4 dereferenceable(12), float noundef) unnamed_addr #2 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)) #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.49", align 4
  %4 = alloca %"struct.glm::vec", align 4
  %5 = alloca %"struct.glm::vec.49", 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 = %27, %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 %30

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 { <2 x float>, <2 x float> }, ptr %4, i32 0, i32 0
  %17 = extractvalue { <2 x float>, <2 x float> } %15, 0
  store <2 x float> %17, ptr %16, align 4
  %18 = getelementptr inbounds { <2 x float>, <2 x float> }, ptr %4, i32 0, i32 1
  %19 = extractvalue { <2 x float>, <2 x float> } %15, 1
  store <2 x float> %19, ptr %18, align 4
  call void @llvm.lifetime.start.p0(i64 12, ptr %5) #6
  %20 = call { <2 x float>, float } @_ZN3glm10unpackRGBMIfLNS_9qualifierE0EEENS_3vecILi3ET_XT0_EEERKNS2_ILi4ES3_XT0_EEE(ptr noundef nonnull align 4 dereferenceable(16) %4)
  store { <2 x float>, float } %20, ptr %6, align 8
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %5, ptr align 8 %6, i64 12, i1 false)
  call void @llvm.lifetime.start.p0(i64 3, ptr %7) #6
  %21 = 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)
  store i24 %21, ptr %7, align 1
  %22 = call noundef zeroext i1 @_ZN3glm3allILi3ELNS_9qualifierE0EEEbRKNS_3vecIXT_EbXT0_EEE(ptr noundef nonnull align 1 dereferenceable(3) %7)
  %23 = zext i1 %22 to i64
  %24 = select i1 %22, i32 0, i32 1
  %25 = load i32, ptr %1, align 4, !tbaa !5
  %26 = add nsw i32 %25, %24
  store i32 %26, 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 %27

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

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

; 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 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { 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 #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.49" = type { %union.anon.50, %union.anon.51, %union.anon.52 }
%union.anon.50 = type { float }
%union.anon.51 = type { float }
%union.anon.52 = type { float }
%"struct.glm::vec" = type { %union.anon.5, %union.anon.6, %union.anon.7, %union.anon.8 }
%union.anon.5 = type { float }
%union.anon.6 = type { float }
%union.anon.7 = type { float }
%union.anon.8 = type { float }
%"struct.glm::vec.53" = type { %union.anon.54, %union.anon.55, %union.anon.56 }
%union.anon.54 = type { i8 }
%union.anon.55 = type { i8 }
%union.anon.56 = type { 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.49", align 4
  %2 = alloca %"struct.glm::vec", align 8
  %3 = alloca %"struct.glm::vec.49", 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