; LLVM IR from cruppstahl/upscaledb :: src/2compressor/compressor_factory.ll (ZN9upscaledb17CompressorFactory6createEi)

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

@.str = external hidden unnamed_addr constant [92 x i8], align 1
@__FUNCTION__._ZN9upscaledb17CompressorFactory6createEi = external hidden unnamed_addr constant [7 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [57 x i8], align 1
@_ZTIN9upscaledb9ExceptionE = external dso_local constant { ptr, ptr }, align 8
@.str.2 = external hidden unnamed_addr constant [59 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [27 x i8], align 1

; Function Attrs: mustprogress uwtable
define dso_local noundef ptr @_ZN9upscaledb17CompressorFactory6createEi(i32 noundef %0) #0 align 2 personality ptr @__gxx_personality_v0 {
  %2 = alloca i32, align 4
  %3 = alloca ptr, align 8
  %4 = alloca i32, align 4
  store i32 %0, ptr %2, align 4, !tbaa !5
  %5 = load i32, ptr %2, align 4, !tbaa !5
  switch i32 %5, label %31 [
    i32 1, label %6
    i32 2, label %15
    i32 3, label %24
  ]

6:                                                ; preds = %1
  br label %7

7:                                                ; preds = %6
  call void @_ZN9upscaledb11dbg_prepareEiPKciS1_S1_(i32 noundef 1, ptr noundef @.str, i32 noundef 77, ptr noundef @__FUNCTION__._ZN9upscaledb17CompressorFactory6createEi, ptr noundef null)
  call void (ptr, ...) @_ZN9upscaledb7dbg_logEPKcz(ptr noundef @.str.1)
  br label %8

8:                                                ; preds = %7
  %9 = call ptr @__cxa_allocate_exception(i64 4) #7
  invoke void @_ZN9upscaledb9ExceptionC2Ei(ptr noundef nonnull align 4 dereferenceable(4) %9, i32 noundef -8)
          to label %10 unwind label %11

10:                                               ; preds = %8
  call void @__cxa_throw(ptr %9, ptr @_ZTIN9upscaledb9ExceptionE, ptr null) #8
  unreachable

11:                                               ; preds = %8
  %12 = landingpad { ptr, i32 }
          cleanup
  %13 = extractvalue { ptr, i32 } %12, 0
  store ptr %13, ptr %3, align 8
  %14 = extractvalue { ptr, i32 } %12, 1
  store i32 %14, ptr %4, align 4
  call void @__cxa_free_exception(ptr %9) #7
  br label %41

15:                                               ; preds = %1
  br label %16

16:                                               ; preds = %15
  call void @_ZN9upscaledb11dbg_prepareEiPKciS1_S1_(i32 noundef 1, ptr noundef @.str, i32 noundef 84, ptr noundef @__FUNCTION__._ZN9upscaledb17CompressorFactory6createEi, ptr noundef null)
  call void (ptr, ...) @_ZN9upscaledb7dbg_logEPKcz(ptr noundef @.str.2)
  br label %17

17:                                               ; preds = %16
  %18 = call ptr @__cxa_allocate_exception(i64 4) #7
  invoke void @_ZN9upscaledb9ExceptionC2Ei(ptr noundef nonnull align 4 dereferenceable(4) %18, i32 noundef -8)
          to label %19 unwind label %20

19:                                               ; preds = %17
  call void @__cxa_throw(ptr %18, ptr @_ZTIN9upscaledb9ExceptionE, ptr null) #8
  unreachable

20:                                               ; preds = %17
  %21 = landingpad { ptr, i32 }
          cleanup
  %22 = extractvalue { ptr, i32 } %21, 0
  store ptr %22, ptr %3, align 8
  %23 = extractvalue { ptr, i32 } %21, 1
  store i32 %23, ptr %4, align 4
  call void @__cxa_free_exception(ptr %18) #7
  br label %41

24:                                               ; preds = %1
  %25 = call noalias noundef nonnull ptr @_Znwm(i64 noundef 40) #9
  call void @llvm.memset.p0.i64(ptr align 16 %25, i8 0, i64 40, i1 false)
  invoke void @_ZN9upscaledb14CompressorImplINS_13LzfCompressorEEC2Ev(ptr noundef nonnull align 8 dereferenceable(37) %25)
          to label %26 unwind label %27

26:                                               ; preds = %24
  ret ptr %25

27:                                               ; preds = %24
  %28 = landingpad { ptr, i32 }
          cleanup
  %29 = extractvalue { ptr, i32 } %28, 0
  store ptr %29, ptr %3, align 8
  %30 = extractvalue { ptr, i32 } %28, 1
  store i32 %30, ptr %4, align 4
  call void @_ZdlPvm(ptr noundef %25, i64 noundef 40) #10
  br label %41

31:                                               ; preds = %1
  br label %32

32:                                               ; preds = %31
  call void @_ZN9upscaledb11dbg_prepareEiPKciS1_S1_(i32 noundef 1, ptr noundef @.str, i32 noundef 91, ptr noundef @__FUNCTION__._ZN9upscaledb17CompressorFactory6createEi, ptr noundef null)
  %33 = load i32, ptr %2, align 4, !tbaa !5
  call void (ptr, ...) @_ZN9upscaledb7dbg_logEPKcz(ptr noundef @.str.3, i32 noundef %33)
  br label %34

34:                                               ; preds = %32
  %35 = call ptr @__cxa_allocate_exception(i64 4) #7
  invoke void @_ZN9upscaledb9ExceptionC2Ei(ptr noundef nonnull align 4 dereferenceable(4) %35, i32 noundef -8)
          to label %36 unwind label %37

36:                                               ; preds = %34
  call void @__cxa_throw(ptr %35, ptr @_ZTIN9upscaledb9ExceptionE, ptr null) #8
  unreachable

37:                                               ; preds = %34
  %38 = landingpad { ptr, i32 }
          cleanup
  %39 = extractvalue { ptr, i32 } %38, 0
  store ptr %39, ptr %3, align 8
  %40 = extractvalue { ptr, i32 } %38, 1
  store i32 %40, ptr %4, align 4
  call void @__cxa_free_exception(ptr %35) #7
  br label %41

41:                                               ; preds = %37, %27, %20, %11
  %42 = load ptr, ptr %3, align 8
  %43 = load i32, ptr %4, align 4
  %44 = insertvalue { ptr, i32 } poison, ptr %42, 0
  %45 = insertvalue { ptr, i32 } %44, i32 %43, 1
  resume { ptr, i32 } %45
}

declare void @_ZN9upscaledb11dbg_prepareEiPKciS1_S1_(i32 noundef, ptr noundef, i32 noundef, ptr noundef, ptr noundef) #1

declare void @_ZN9upscaledb7dbg_logEPKcz(ptr noundef, ...) #1

declare ptr @__cxa_allocate_exception(i64)

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZN9upscaledb9ExceptionC2Ei(ptr noundef nonnull align 4 dereferenceable(4), i32 noundef) unnamed_addr #2 align 2

declare i32 @__gxx_personality_v0(...)

declare void @__cxa_free_exception(ptr)

declare void @__cxa_throw(ptr, ptr, ptr)

; Function Attrs: nobuiltin allocsize(0)
declare noundef nonnull ptr @_Znwm(i64 noundef) #3

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

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local void @_ZN9upscaledb14CompressorImplINS_13LzfCompressorEEC2Ev(ptr noundef nonnull align 8 dereferenceable(37)) unnamed_addr #5 align 2

; Function Attrs: nobuiltin nounwind
declare void @_ZdlPvm(ptr noundef, i64 noundef) #6

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 = { "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 = { 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 = { nobuiltin allocsize(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 = { nocallback nofree nounwind willreturn memory(argmem: write) }
attributes #5 = { 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 #6 = { nobuiltin nounwind "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 #7 = { nounwind }
attributes #8 = { noreturn }
attributes #9 = { builtin allocsize(0) }
attributes #10 = { builtin 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"

@.str = external hidden unnamed_addr constant [92 x i8], align 1
@__FUNCTION__._ZN9upscaledb17CompressorFactory6createEi = external hidden unnamed_addr constant [7 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [57 x i8], align 1
@_ZTIN9upscaledb9ExceptionE = external dso_local constant { ptr, ptr }, align 8
@.str.2 = external hidden unnamed_addr constant [59 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [27 x i8], align 1

; Function Attrs: mustprogress uwtable
define dso_local noundef nonnull ptr @_ZN9upscaledb17CompressorFactory6createEi(i32 noundef %0) local_unnamed_addr #0 align 2 personality ptr @__gxx_personality_v0 {
  switch i32 %0, label %11 [
    i32 1, label %2
    i32 2, label %4
    i32 3, label %6
  ]

2:                                                ; preds = %1
  tail call void @_ZN9upscaledb11dbg_prepareEiPKciS1_S1_(i32 noundef 1, ptr noundef nonnull @.str, i32 noundef 77, ptr noundef nonnull @__FUNCTION__._ZN9upscaledb17CompressorFactory6createEi, ptr noundef null)
  tail call void (ptr, ...) @_ZN9upscaledb7dbg_logEPKcz(ptr noundef nonnull @.str.1)
  %3 = tail call ptr @__cxa_allocate_exception(i64 4) #7
  tail call void @_ZN9upscaledb9ExceptionC2Ei(ptr noundef nonnull align 4 dereferenceable(4) %3, i32 noundef -8)
  tail call void @__cxa_throw(ptr nonnull %3, ptr nonnull @_ZTIN9upscaledb9ExceptionE, ptr null) #8
  unreachable

4:                                                ; preds = %1
  tail call void @_ZN9upscaledb11dbg_prepareEiPKciS1_S1_(i32 noundef 1, ptr noundef nonnull @.str, i32 noundef 84, ptr noundef nonnull @__FUNCTION__._ZN9upscaledb17CompressorFactory6createEi, ptr noundef null)
  tail call void (ptr, ...) @_ZN9upscaledb7dbg_logEPKcz(ptr noundef nonnull @.str.2)
  %5 = tail call ptr @__cxa_allocate_exception(i64 4) #7
  tail call void @_ZN9upscaledb9ExceptionC2Ei(ptr noundef nonnull align 4 dereferenceable(4) %5, i32 noundef -8)
  tail call void @__cxa_throw(ptr nonnull %5, ptr nonnull @_ZTIN9upscaledb9ExceptionE, ptr null) #8
  unreachable

6:                                                ; preds = %1
  %7 = tail call noalias noundef nonnull dereferenceable(40) ptr @_Znwm(i64 noundef 40) #9
  tail call void @llvm.memset.p0.i64(ptr noundef nonnull align 16 dereferenceable(40) %7, i8 0, i64 40, i1 false)
  invoke void @_ZN9upscaledb14CompressorImplINS_13LzfCompressorEEC2Ev(ptr noundef nonnull align 8 dereferenceable(37) %7)
          to label %8 unwind label %9

8:                                                ; preds = %6
  ret ptr %7

9:                                                ; preds = %6
  %10 = landingpad { ptr, i32 }
          cleanup
  tail call void @_ZdlPvm(ptr noundef nonnull %7, i64 noundef 40) #10
  resume { ptr, i32 } %10

11:                                               ; preds = %1
  tail call void @_ZN9upscaledb11dbg_prepareEiPKciS1_S1_(i32 noundef 1, ptr noundef nonnull @.str, i32 noundef 91, ptr noundef nonnull @__FUNCTION__._ZN9upscaledb17CompressorFactory6createEi, ptr noundef null)
  tail call void (ptr, ...) @_ZN9upscaledb7dbg_logEPKcz(ptr noundef nonnull @.str.3, i32 noundef %0)
  %12 = tail call ptr @__cxa_allocate_exception(i64 4) #7
  tail call void @_ZN9upscaledb9ExceptionC2Ei(ptr noundef nonnull align 4 dereferenceable(4) %12, i32 noundef -8)
  tail call void @__cxa_throw(ptr nonnull %12, ptr nonnull @_ZTIN9upscaledb9ExceptionE, ptr null) #8
  unreachable
}

declare void @_ZN9upscaledb11dbg_prepareEiPKciS1_S1_(i32 noundef, ptr noundef, i32 noundef, ptr noundef, ptr noundef) local_unnamed_addr #1

declare void @_ZN9upscaledb7dbg_logEPKcz(ptr noundef, ...) local_unnamed_addr #1

declare ptr @__cxa_allocate_exception(i64) local_unnamed_addr

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZN9upscaledb9ExceptionC2Ei(ptr noundef nonnull align 4 dereferenceable(4), i32 noundef) unnamed_addr #2 align 2

declare i32 @__gxx_personality_v0(...)

declare void @__cxa_throw(ptr, ptr, ptr) local_unnamed_addr

; Function Attrs: nobuiltin allocsize(0)
declare noundef nonnull ptr @_Znwm(i64 noundef) local_unnamed_addr #3

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

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local void @_ZN9upscaledb14CompressorImplINS_13LzfCompressorEEC2Ev(ptr noundef nonnull align 8 dereferenceable(37)) unnamed_addr #5 align 2

; Function Attrs: nobuiltin nounwind
declare void @_ZdlPvm(ptr noundef, i64 noundef) local_unnamed_addr #6

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 = { "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 = { 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 = { nobuiltin allocsize(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 nocallback nofree nounwind willreturn memory(argmem: write) }
attributes #5 = { 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 #6 = { nobuiltin nounwind "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 #7 = { nounwind }
attributes #8 = { noreturn }
attributes #9 = { builtin allocsize(0) }
attributes #10 = { builtin 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)"}


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