; LLVM IR from ronan-kerviche/glip-lib :: GLIP-Lib/src/Core/HdlTexture.ll (ZN4Glip6CoreGL10HdlTexture12getSizeOnGPUEi)

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

; 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
declare dso_local noundef zeroext i1 @_ZNK4Glip6CoreGL24HdlAbstractTextureFormat12isCompressedEv(ptr noundef nonnull align 8 dereferenceable(52)) #1 align 2

declare void @glGetTexLevelParameteriv(i32 noundef, i32 noundef, i32 noundef, ptr noundef) #2

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN4Glip6CoreGL10HdlTexture4bindEj(ptr noundef nonnull align 8 dereferenceable(57), i32 noundef) #1 align 2

; Function Attrs: mustprogress uwtable
define dso_local noundef i32 @_ZN4Glip6CoreGL10HdlTexture12getSizeOnGPUEi(ptr noundef nonnull align 8 dereferenceable(57) %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
  %7 = alloca i32, align 4
  %8 = alloca i32, align 4
  %9 = alloca i32, align 4
  %10 = alloca i32, align 4
  %11 = alloca i32, align 4
  %12 = alloca i32, align 4
  %13 = alloca i32, align 4
  %14 = alloca i32, align 4
  %15 = alloca i32, align 4
  store ptr %0, ptr %3, align 8, !tbaa !5
  store i32 %1, ptr %4, align 4, !tbaa !9
  %16 = load ptr, ptr %3, align 8
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #3
  call void @_ZN4Glip6CoreGL10HdlTexture4bindEj(ptr noundef nonnull align 8 dereferenceable(57) %16, i32 noundef 33984)
  %17 = call noundef zeroext i1 @_ZNK4Glip6CoreGL24HdlAbstractTextureFormat12isCompressedEv(ptr noundef nonnull align 8 dereferenceable(52) %16)
  br i1 %17, label %18, label %20

18:                                               ; preds = %2
  %19 = load i32, ptr %4, align 4, !tbaa !9
  call void @glGetTexLevelParameteriv(i32 noundef 3553, i32 noundef %19, i32 noundef 34464, ptr noundef %5)
  br label %49

20:                                               ; preds = %2
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #3
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #3
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #3
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #3
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #3
  call void @llvm.lifetime.start.p0(i64 4, ptr %11) #3
  call void @llvm.lifetime.start.p0(i64 4, ptr %12) #3
  call void @llvm.lifetime.start.p0(i64 4, ptr %13) #3
  call void @llvm.lifetime.start.p0(i64 4, ptr %14) #3
  call void @llvm.lifetime.start.p0(i64 4, ptr %15) #3
  %21 = load i32, ptr %4, align 4, !tbaa !9
  call void @glGetTexLevelParameteriv(i32 noundef 3553, i32 noundef %21, i32 noundef 4096, ptr noundef %13)
  %22 = load i32, ptr %4, align 4, !tbaa !9
  call void @glGetTexLevelParameteriv(i32 noundef 3553, i32 noundef %22, i32 noundef 4097, ptr noundef %14)
  %23 = load i32, ptr %4, align 4, !tbaa !9
  call void @glGetTexLevelParameteriv(i32 noundef 3553, i32 noundef %23, i32 noundef 32860, ptr noundef %6)
  %24 = load i32, ptr %4, align 4, !tbaa !9
  call void @glGetTexLevelParameteriv(i32 noundef 3553, i32 noundef %24, i32 noundef 32861, ptr noundef %7)
  %25 = load i32, ptr %4, align 4, !tbaa !9
  call void @glGetTexLevelParameteriv(i32 noundef 3553, i32 noundef %25, i32 noundef 32862, ptr noundef %8)
  %26 = load i32, ptr %4, align 4, !tbaa !9
  call void @glGetTexLevelParameteriv(i32 noundef 3553, i32 noundef %26, i32 noundef 32863, ptr noundef %9)
  %27 = load i32, ptr %4, align 4, !tbaa !9
  call void @glGetTexLevelParameteriv(i32 noundef 3553, i32 noundef %27, i32 noundef 32864, ptr noundef %10)
  %28 = load i32, ptr %4, align 4, !tbaa !9
  call void @glGetTexLevelParameteriv(i32 noundef 3553, i32 noundef %28, i32 noundef 32865, ptr noundef %11)
  %29 = load i32, ptr %4, align 4, !tbaa !9
  call void @glGetTexLevelParameteriv(i32 noundef 3553, i32 noundef %29, i32 noundef 34890, ptr noundef %12)
  %30 = load i32, ptr %6, align 4, !tbaa !9
  %31 = load i32, ptr %7, align 4, !tbaa !9
  %32 = add nsw i32 %30, %31
  %33 = load i32, ptr %8, align 4, !tbaa !9
  %34 = add nsw i32 %32, %33
  %35 = load i32, ptr %9, align 4, !tbaa !9
  %36 = add nsw i32 %34, %35
  %37 = load i32, ptr %10, align 4, !tbaa !9
  %38 = add nsw i32 %36, %37
  %39 = load i32, ptr %11, align 4, !tbaa !9
  %40 = add nsw i32 %38, %39
  %41 = load i32, ptr %12, align 4, !tbaa !9
  %42 = add nsw i32 %40, %41
  %43 = sdiv i32 %42, 8
  store i32 %43, ptr %15, align 4, !tbaa !9
  %44 = load i32, ptr %13, align 4, !tbaa !9
  %45 = load i32, ptr %14, align 4, !tbaa !9
  %46 = mul nsw i32 %44, %45
  %47 = load i32, ptr %15, align 4, !tbaa !9
  %48 = mul nsw i32 %46, %47
  store i32 %48, ptr %5, align 4, !tbaa !9
  call void @llvm.lifetime.end.p0(i64 4, ptr %15) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %14) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %13) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %12) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #3
  br label %49

49:                                               ; preds = %20, %18
  %50 = load i32, ptr %5, align 4, !tbaa !9
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #3
  ret i32 %50
}

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 = { "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 = { 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 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: mustprogress uwtable
declare dso_local noundef zeroext i1 @_ZNK4Glip6CoreGL24HdlAbstractTextureFormat12isCompressedEv(ptr noundef nonnull align 8 dereferenceable(52)) local_unnamed_addr #1 align 2

declare void @glGetTexLevelParameteriv(i32 noundef, i32 noundef, i32 noundef, ptr noundef) local_unnamed_addr #2

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN4Glip6CoreGL10HdlTexture4bindEj(ptr noundef nonnull align 8 dereferenceable(57), i32 noundef) local_unnamed_addr #1 align 2

; Function Attrs: mustprogress uwtable
define dso_local noundef i32 @_ZN4Glip6CoreGL10HdlTexture12getSizeOnGPUEi(ptr noundef nonnull align 8 dereferenceable(57) %0, i32 noundef %1) local_unnamed_addr #1 align 2 {
  %3 = alloca i32, align 4
  %4 = alloca i32, align 4
  %5 = alloca i32, align 4
  %6 = alloca i32, align 4
  %7 = alloca i32, align 4
  %8 = alloca i32, align 4
  %9 = alloca i32, align 4
  %10 = alloca i32, align 4
  %11 = alloca i32, align 4
  %12 = alloca i32, align 4
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %3) #3
  tail call void @_ZN4Glip6CoreGL10HdlTexture4bindEj(ptr noundef nonnull align 8 dereferenceable(57) %0, i32 noundef 33984)
  %13 = tail call noundef zeroext i1 @_ZNK4Glip6CoreGL24HdlAbstractTextureFormat12isCompressedEv(ptr noundef nonnull align 8 dereferenceable(52) %0)
  br i1 %13, label %14, label %15

14:                                               ; preds = %2
  call void @glGetTexLevelParameteriv(i32 noundef 3553, i32 noundef %1, i32 noundef 34464, ptr noundef nonnull %3)
  %.pre = load i32, ptr %3, align 4, !tbaa !5
  br label %34

15:                                               ; preds = %2
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %4) #3
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %5) #3
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %6) #3
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %7) #3
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %8) #3
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %9) #3
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %10) #3
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %11) #3
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %12) #3
  call void @glGetTexLevelParameteriv(i32 noundef 3553, i32 noundef %1, i32 noundef 4096, ptr noundef nonnull %11)
  call void @glGetTexLevelParameteriv(i32 noundef 3553, i32 noundef %1, i32 noundef 4097, ptr noundef nonnull %12)
  call void @glGetTexLevelParameteriv(i32 noundef 3553, i32 noundef %1, i32 noundef 32860, ptr noundef nonnull %4)
  call void @glGetTexLevelParameteriv(i32 noundef 3553, i32 noundef %1, i32 noundef 32861, ptr noundef nonnull %5)
  call void @glGetTexLevelParameteriv(i32 noundef 3553, i32 noundef %1, i32 noundef 32862, ptr noundef nonnull %6)
  call void @glGetTexLevelParameteriv(i32 noundef 3553, i32 noundef %1, i32 noundef 32863, ptr noundef nonnull %7)
  call void @glGetTexLevelParameteriv(i32 noundef 3553, i32 noundef %1, i32 noundef 32864, ptr noundef nonnull %8)
  call void @glGetTexLevelParameteriv(i32 noundef 3553, i32 noundef %1, i32 noundef 32865, ptr noundef nonnull %9)
  call void @glGetTexLevelParameteriv(i32 noundef 3553, i32 noundef %1, i32 noundef 34890, ptr noundef nonnull %10)
  %16 = load i32, ptr %4, align 4, !tbaa !5
  %17 = load i32, ptr %5, align 4, !tbaa !5
  %18 = add nsw i32 %17, %16
  %19 = load i32, ptr %6, align 4, !tbaa !5
  %20 = add nsw i32 %18, %19
  %21 = load i32, ptr %7, align 4, !tbaa !5
  %22 = add nsw i32 %20, %21
  %23 = load i32, ptr %8, align 4, !tbaa !5
  %24 = add nsw i32 %22, %23
  %25 = load i32, ptr %9, align 4, !tbaa !5
  %26 = add nsw i32 %24, %25
  %27 = load i32, ptr %10, align 4, !tbaa !5
  %28 = add nsw i32 %26, %27
  %29 = sdiv i32 %28, 8
  %30 = load i32, ptr %11, align 4, !tbaa !5
  %31 = load i32, ptr %12, align 4, !tbaa !5
  %32 = mul nsw i32 %31, %30
  %33 = mul nsw i32 %32, %29
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %12) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %11) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %10) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %9) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %8) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %7) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %6) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %5) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %4) #3
  br label %34

34:                                               ; preds = %15, %14
  %35 = phi i32 [ %33, %15 ], [ %.pre, %14 ]
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %3) #3
  ret i32 %35
}

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


; Effective O3 passes: DSEPass,GVNPass,GlobalOptPass,InferFunctionAttrsPass,InstCombinePass,ReassociatePass,SROAPass,TailCallElimPass