; LLVM IR from ronan-kerviche/glip-lib :: GLIP-Lib/src/Core (HdlTextureTools)

; 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.Glip::CoreGL::HdlTextureFormatDescriptor" = type { i32, i32, i32, i32, i32, [4 x i32], [4 x i32], [4 x i32], 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: mustprogress uwtable
declare dso_local noundef i32 @_ZN4Glip6CoreGL26HdlTextureFormatDescriptor17getTypeSizeInBitsEj(i32 noundef) #1 align 2

; 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 @_ZNK4Glip6CoreGL26HdlTextureFormatDescriptor18getPixelSizeInBitsEj(ptr noundef nonnull align 4 dereferenceable(72) %0, i32 noundef %1) #1 align 2 {
  %3 = alloca ptr, align 8
  %4 = alloca i32, align 4
  %5 = alloca i32, align 4
  %6 = alloca i32, align 4
  store ptr %0, ptr %3, align 8, !tbaa !5
  store i32 %1, ptr %4, align 4, !tbaa !9
  %7 = load ptr, ptr %3, align 8
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #2
  %8 = load i32, ptr %4, align 4, !tbaa !9
  %9 = call noundef i32 @_ZN4Glip6CoreGL26HdlTextureFormatDescriptor17getTypeSizeInBitsEj(i32 noundef %8)
  store i32 %9, ptr %5, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #2
  store i32 0, ptr %6, align 4, !tbaa !9
  %10 = getelementptr inbounds %"struct.Glip::CoreGL::HdlTextureFormatDescriptor", ptr %7, i32 0, i32 6
  %11 = getelementptr inbounds [4 x i32], ptr %10, i64 0, i64 0
  %12 = load i32, ptr %11, align 4, !tbaa !9
  %13 = icmp slt i32 %12, 0
  br i1 %13, label %14, label %16

14:                                               ; preds = %2
  %15 = load i32, ptr %5, align 4, !tbaa !9
  br label %20

16:                                               ; preds = %2
  %17 = getelementptr inbounds %"struct.Glip::CoreGL::HdlTextureFormatDescriptor", ptr %7, i32 0, i32 6
  %18 = getelementptr inbounds [4 x i32], ptr %17, i64 0, i64 0
  %19 = load i32, ptr %18, align 4, !tbaa !9
  br label %20

20:                                               ; preds = %16, %14
  %21 = phi i32 [ %15, %14 ], [ %19, %16 ]
  %22 = load i32, ptr %6, align 4, !tbaa !9
  %23 = add nsw i32 %22, %21
  store i32 %23, ptr %6, align 4, !tbaa !9
  %24 = getelementptr inbounds %"struct.Glip::CoreGL::HdlTextureFormatDescriptor", ptr %7, i32 0, i32 6
  %25 = getelementptr inbounds [4 x i32], ptr %24, i64 0, i64 1
  %26 = load i32, ptr %25, align 4, !tbaa !9
  %27 = icmp slt i32 %26, 0
  br i1 %27, label %28, label %30

28:                                               ; preds = %20
  %29 = load i32, ptr %5, align 4, !tbaa !9
  br label %34

30:                                               ; preds = %20
  %31 = getelementptr inbounds %"struct.Glip::CoreGL::HdlTextureFormatDescriptor", ptr %7, i32 0, i32 6
  %32 = getelementptr inbounds [4 x i32], ptr %31, i64 0, i64 1
  %33 = load i32, ptr %32, align 4, !tbaa !9
  br label %34

34:                                               ; preds = %30, %28
  %35 = phi i32 [ %29, %28 ], [ %33, %30 ]
  %36 = load i32, ptr %6, align 4, !tbaa !9
  %37 = add nsw i32 %36, %35
  store i32 %37, ptr %6, align 4, !tbaa !9
  %38 = getelementptr inbounds %"struct.Glip::CoreGL::HdlTextureFormatDescriptor", ptr %7, i32 0, i32 6
  %39 = getelementptr inbounds [4 x i32], ptr %38, i64 0, i64 2
  %40 = load i32, ptr %39, align 4, !tbaa !9
  %41 = icmp slt i32 %40, 0
  br i1 %41, label %42, label %44

42:                                               ; preds = %34
  %43 = load i32, ptr %5, align 4, !tbaa !9
  br label %48

44:                                               ; preds = %34
  %45 = getelementptr inbounds %"struct.Glip::CoreGL::HdlTextureFormatDescriptor", ptr %7, i32 0, i32 6
  %46 = getelementptr inbounds [4 x i32], ptr %45, i64 0, i64 2
  %47 = load i32, ptr %46, align 4, !tbaa !9
  br label %48

48:                                               ; preds = %44, %42
  %49 = phi i32 [ %43, %42 ], [ %47, %44 ]
  %50 = load i32, ptr %6, align 4, !tbaa !9
  %51 = add nsw i32 %50, %49
  store i32 %51, ptr %6, align 4, !tbaa !9
  %52 = getelementptr inbounds %"struct.Glip::CoreGL::HdlTextureFormatDescriptor", ptr %7, i32 0, i32 6
  %53 = getelementptr inbounds [4 x i32], ptr %52, i64 0, i64 3
  %54 = load i32, ptr %53, align 4, !tbaa !9
  %55 = icmp slt i32 %54, 0
  br i1 %55, label %56, label %58

56:                                               ; preds = %48
  %57 = load i32, ptr %5, align 4, !tbaa !9
  br label %62

58:                                               ; preds = %48
  %59 = getelementptr inbounds %"struct.Glip::CoreGL::HdlTextureFormatDescriptor", ptr %7, i32 0, i32 6
  %60 = getelementptr inbounds [4 x i32], ptr %59, i64 0, i64 3
  %61 = load i32, ptr %60, align 4, !tbaa !9
  br label %62

62:                                               ; preds = %58, %56
  %63 = phi i32 [ %57, %56 ], [ %61, %58 ]
  %64 = load i32, ptr %6, align 4, !tbaa !9
  %65 = add nsw i32 %64, %63
  store i32 %65, ptr %6, align 4, !tbaa !9
  %66 = load i32, ptr %6, align 4, !tbaa !9
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #2
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #2
  ret i32 %66
}

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 = { 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 = !{!"any pointer", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"int", !7, i64 0}


; 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 uwtable
declare dso_local noundef i32 @_ZN4Glip6CoreGL26HdlTextureFormatDescriptor17getTypeSizeInBitsEj(i32 noundef) local_unnamed_addr #0 align 2

; Function Attrs: mustprogress uwtable
define dso_local noundef i32 @_ZNK4Glip6CoreGL26HdlTextureFormatDescriptor18getPixelSizeInBitsEj(ptr nocapture noundef nonnull readonly align 4 dereferenceable(72) %0, i32 noundef %1) local_unnamed_addr #0 align 2 {
  %3 = tail call noundef i32 @_ZN4Glip6CoreGL26HdlTextureFormatDescriptor17getTypeSizeInBitsEj(i32 noundef %1)
  %4 = getelementptr inbounds i8, ptr %0, i64 36
  %5 = load <4 x i32>, ptr %4, align 4, !tbaa !5
  %6 = icmp slt <4 x i32> %5, zeroinitializer
  %7 = insertelement <4 x i32> poison, i32 %3, i64 0
  %8 = shufflevector <4 x i32> %7, <4 x i32> poison, <4 x i32> zeroinitializer
  %9 = select <4 x i1> %6, <4 x i32> %8, <4 x i32> %5
  %10 = tail call i32 @llvm.vector.reduce.add.v4i32(<4 x i32> %9)
  ret i32 %10
}

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare i32 @llvm.vector.reduce.add.v4i32(<4 x i32>) #1

attributes #0 = { 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 #1 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }

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


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