; LLVM IR from Dovyski/opengl-demos :: libs/glm-0.9.9.3/test/core/core_type_mat2x2.ll (Z9test_sizev)

; 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::mat" = type { [2 x %"struct.glm::vec"] }
%"struct.glm::vec" = type { %union.anon }
%union.anon = type { %struct.anon }
%struct.anon = type { float, float }
%"struct.glm::mat.18" = type { [2 x %"struct.glm::vec.19"] }
%"struct.glm::vec.19" = type { %union.anon.20 }
%union.anon.20 = type { %struct.anon.21 }
%struct.anon.21 = type { double, double }

; 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: mustprogress uwtable
define dso_local noundef i32 @_Z9test_sizev() #1 {
  %1 = alloca i32, align 4
  %2 = alloca %"struct.glm::mat", align 4
  %3 = alloca %"struct.glm::mat.18", align 8
  call void @llvm.lifetime.start.p0(i64 4, ptr %1) #4
  store i32 0, ptr %1, align 4, !tbaa !5
  %4 = load i32, ptr %1, align 4, !tbaa !5
  %5 = add nsw i32 %4, 0
  store i32 %5, ptr %1, align 4, !tbaa !5
  %6 = load i32, ptr %1, align 4, !tbaa !5
  %7 = add nsw i32 %6, 0
  store i32 %7, ptr %1, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 16, ptr %2) #4
  call void @llvm.memset.p0.i64(ptr align 4 %2, i8 0, i64 16, i1 false)
  %8 = call noundef i32 @_ZN3glm3matILi2ELi2EfLNS_9qualifierE0EE6lengthEv()
  %9 = icmp eq i32 %8, 2
  %10 = zext i1 %9 to i64
  %11 = select i1 %9, i32 0, i32 1
  %12 = load i32, ptr %1, align 4, !tbaa !5
  %13 = add nsw i32 %12, %11
  store i32 %13, ptr %1, align 4, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 16, ptr %2) #4
  call void @llvm.lifetime.start.p0(i64 32, ptr %3) #4
  call void @llvm.memset.p0.i64(ptr align 8 %3, i8 0, i64 32, i1 false)
  %14 = call noundef i32 @_ZN3glm3matILi2ELi2EdLNS_9qualifierE0EE6lengthEv()
  %15 = icmp eq i32 %14, 2
  %16 = zext i1 %15 to i64
  %17 = select i1 %15, i32 0, i32 1
  %18 = load i32, ptr %1, align 4, !tbaa !5
  %19 = add nsw i32 %18, %17
  store i32 %19, ptr %1, align 4, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 32, ptr %3) #4
  %20 = call noundef i32 @_ZN3glm3matILi2ELi2EfLNS_9qualifierE0EE6lengthEv()
  %21 = icmp eq i32 %20, 2
  %22 = zext i1 %21 to i64
  %23 = select i1 %21, i32 0, i32 1
  %24 = load i32, ptr %1, align 4, !tbaa !5
  %25 = add nsw i32 %24, %23
  store i32 %25, ptr %1, align 4, !tbaa !5
  %26 = call noundef i32 @_ZN3glm3matILi2ELi2EdLNS_9qualifierE0EE6lengthEv()
  %27 = icmp eq i32 %26, 2
  %28 = zext i1 %27 to i64
  %29 = select i1 %27, i32 0, i32 1
  %30 = load i32, ptr %1, align 4, !tbaa !5
  %31 = add nsw i32 %30, %29
  store i32 %31, ptr %1, align 4, !tbaa !5
  %32 = load i32, ptr %1, align 4, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 4, ptr %1) #4
  ret i32 %32
}

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef i32 @_ZN3glm3matILi2ELi2EfLNS_9qualifierE0EE6lengthEv() #3 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef i32 @_ZN3glm3matILi2ELi2EdLNS_9qualifierE0EE6lengthEv() #3 align 2

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { 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 #2 = { nocallback nofree nounwind willreturn memory(argmem: write) }
attributes #3 = { 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 #4 = { 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"}


; 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"

; Function Attrs: mustprogress nounwind uwtable
define dso_local noundef range(i32 0, 5) i32 @_Z9test_sizev() local_unnamed_addr #0 {
  %1 = tail call noundef i32 @_ZN3glm3matILi2ELi2EfLNS_9qualifierE0EE6lengthEv()
  %2 = icmp ne i32 %1, 2
  %3 = zext i1 %2 to i32
  %4 = tail call noundef i32 @_ZN3glm3matILi2ELi2EdLNS_9qualifierE0EE6lengthEv()
  %5 = icmp ne i32 %4, 2
  %6 = zext i1 %5 to i32
  %7 = add nuw nsw i32 %6, %3
  %8 = tail call noundef i32 @_ZN3glm3matILi2ELi2EfLNS_9qualifierE0EE6lengthEv()
  %9 = icmp ne i32 %8, 2
  %10 = zext i1 %9 to i32
  %11 = add nuw nsw i32 %7, %10
  %12 = tail call noundef i32 @_ZN3glm3matILi2ELi2EdLNS_9qualifierE0EE6lengthEv()
  %13 = icmp ne i32 %12, 2
  %14 = zext i1 %13 to i32
  %15 = add nuw nsw i32 %11, %14
  ret i32 %15
}

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef i32 @_ZN3glm3matILi2ELi2EfLNS_9qualifierE0EE6lengthEv() local_unnamed_addr #0 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef i32 @_ZN3glm3matILi2ELi2EdLNS_9qualifierE0EE6lengthEv() local_unnamed_addr #0 align 2

attributes #0 = { 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" }

!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)"}


; Effective O3 passes: EarlyCSEPass,GlobalOptPass,IPSCCPPass,InferFunctionAttrsPass,InstCombinePass,PostOrderFunctionAttrsPass,ReassociatePass,SROAPass,TailCallElimPass