; LLVM IR from ermig1979/Simd :: src/Simd/SimdBaseImageLoad.ll (ZN4Simd4Base17CreateImageLoaderERKNS_16ImageLoaderParamE)

; 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.Simd::ImageLoaderParam" = type { ptr, i64, i32, i32 }

declare i32 @__gxx_personality_v0(...)

; Function Attrs: mustprogress uwtable
define dso_local noundef ptr @_ZN4Simd4Base17CreateImageLoaderERKNS_16ImageLoaderParamE(ptr noundef nonnull align 8 dereferenceable(24) %0) #0 personality ptr @__gxx_personality_v0 {
  %2 = alloca ptr, align 8
  %3 = alloca ptr, align 8
  %4 = alloca ptr, align 8
  %5 = alloca i32, align 4
  store ptr %0, ptr %3, align 8, !tbaa !5
  %6 = load ptr, ptr %3, align 8, !tbaa !5
  %7 = getelementptr inbounds %"struct.Simd::ImageLoaderParam", ptr %6, i32 0, i32 2
  %8 = load i32, ptr %7, align 8, !tbaa !9
  switch i32 %8, label %65 [
    i32 1, label %9
    i32 2, label %17
    i32 3, label %25
    i32 4, label %33
    i32 5, label %41
    i32 6, label %49
    i32 7, label %57
  ]

9:                                                ; preds = %1
  %10 = call noalias noundef nonnull ptr @_Znwm(i64 noundef 168) #4
  %11 = load ptr, ptr %3, align 8, !tbaa !5
  invoke void @_ZN4Simd4Base17ImagePgmTxtLoaderC1ERKNS_16ImageLoaderParamE(ptr noundef nonnull align 8 dereferenceable(168) %10, ptr noundef nonnull align 8 dereferenceable(24) %11)
          to label %12 unwind label %13

12:                                               ; preds = %9
  store ptr %10, ptr %2, align 8
  br label %66

13:                                               ; preds = %9
  %14 = landingpad { ptr, i32 }
          cleanup
  %15 = extractvalue { ptr, i32 } %14, 0
  store ptr %15, ptr %4, align 8
  %16 = extractvalue { ptr, i32 } %14, 1
  store i32 %16, ptr %5, align 4
  call void @_ZdlPvm(ptr noundef %10, i64 noundef 168) #5
  br label %68

17:                                               ; preds = %1
  %18 = call noalias noundef nonnull ptr @_Znwm(i64 noundef 168) #4
  %19 = load ptr, ptr %3, align 8, !tbaa !5
  invoke void @_ZN4Simd4Base17ImagePgmBinLoaderC1ERKNS_16ImageLoaderParamE(ptr noundef nonnull align 8 dereferenceable(168) %18, ptr noundef nonnull align 8 dereferenceable(24) %19)
          to label %20 unwind label %21

20:                                               ; preds = %17
  store ptr %18, ptr %2, align 8
  br label %66

21:                                               ; preds = %17
  %22 = landingpad { ptr, i32 }
          cleanup
  %23 = extractvalue { ptr, i32 } %22, 0
  store ptr %23, ptr %4, align 8
  %24 = extractvalue { ptr, i32 } %22, 1
  store i32 %24, ptr %5, align 4
  call void @_ZdlPvm(ptr noundef %18, i64 noundef 168) #5
  br label %68

25:                                               ; preds = %1
  %26 = call noalias noundef nonnull ptr @_Znwm(i64 noundef 168) #4
  %27 = load ptr, ptr %3, align 8, !tbaa !5
  invoke void @_ZN4Simd4Base17ImagePpmTxtLoaderC1ERKNS_16ImageLoaderParamE(ptr noundef nonnull align 8 dereferenceable(168) %26, ptr noundef nonnull align 8 dereferenceable(24) %27)
          to label %28 unwind label %29

28:                                               ; preds = %25
  store ptr %26, ptr %2, align 8
  br label %66

29:                                               ; preds = %25
  %30 = landingpad { ptr, i32 }
          cleanup
  %31 = extractvalue { ptr, i32 } %30, 0
  store ptr %31, ptr %4, align 8
  %32 = extractvalue { ptr, i32 } %30, 1
  store i32 %32, ptr %5, align 4
  call void @_ZdlPvm(ptr noundef %26, i64 noundef 168) #5
  br label %68

33:                                               ; preds = %1
  %34 = call noalias noundef nonnull ptr @_Znwm(i64 noundef 168) #4
  %35 = load ptr, ptr %3, align 8, !tbaa !5
  invoke void @_ZN4Simd4Base17ImagePpmBinLoaderC1ERKNS_16ImageLoaderParamE(ptr noundef nonnull align 8 dereferenceable(168) %34, ptr noundef nonnull align 8 dereferenceable(24) %35)
          to label %36 unwind label %37

36:                                               ; preds = %33
  store ptr %34, ptr %2, align 8
  br label %66

37:                                               ; preds = %33
  %38 = landingpad { ptr, i32 }
          cleanup
  %39 = extractvalue { ptr, i32 } %38, 0
  store ptr %39, ptr %4, align 8
  %40 = extractvalue { ptr, i32 } %38, 1
  store i32 %40, ptr %5, align 4
  call void @_ZdlPvm(ptr noundef %34, i64 noundef 168) #5
  br label %68

41:                                               ; preds = %1
  %42 = call noalias noundef nonnull ptr @_Znwm(i64 noundef 304) #4
  %43 = load ptr, ptr %3, align 8, !tbaa !5
  invoke void @_ZN4Simd4Base14ImagePngLoaderC1ERKNS_16ImageLoaderParamE(ptr noundef nonnull align 8 dereferenceable(304) %42, ptr noundef nonnull align 8 dereferenceable(24) %43)
          to label %44 unwind label %45

44:                                               ; preds = %41
  store ptr %42, ptr %2, align 8
  br label %66

45:                                               ; preds = %41
  %46 = landingpad { ptr, i32 }
          cleanup
  %47 = extractvalue { ptr, i32 } %46, 0
  store ptr %47, ptr %4, align 8
  %48 = extractvalue { ptr, i32 } %46, 1
  store i32 %48, ptr %5, align 4
  call void @_ZdlPvm(ptr noundef %42, i64 noundef 304) #5
  br label %68

49:                                               ; preds = %1
  %50 = call noalias noundef nonnull ptr @_Znwm(i64 noundef 128) #4
  %51 = load ptr, ptr %3, align 8, !tbaa !5
  invoke void @_ZN4Simd4Base15ImageJpegLoaderC1ERKNS_16ImageLoaderParamE(ptr noundef nonnull align 8 dereferenceable(128) %50, ptr noundef nonnull align 8 dereferenceable(24) %51)
          to label %52 unwind label %53

52:                                               ; preds = %49
  store ptr %50, ptr %2, align 8
  br label %66

53:                                               ; preds = %49
  %54 = landingpad { ptr, i32 }
          cleanup
  %55 = extractvalue { ptr, i32 } %54, 0
  store ptr %55, ptr %4, align 8
  %56 = extractvalue { ptr, i32 } %54, 1
  store i32 %56, ptr %5, align 4
  call void @_ZdlPvm(ptr noundef %50, i64 noundef 128) #5
  br label %68

57:                                               ; preds = %1
  %58 = call noalias noundef nonnull ptr @_Znwm(i64 noundef 176) #4
  %59 = load ptr, ptr %3, align 8, !tbaa !5
  invoke void @_ZN4Simd4Base14ImageBmpLoaderC1ERKNS_16ImageLoaderParamE(ptr noundef nonnull align 8 dereferenceable(172) %58, ptr noundef nonnull align 8 dereferenceable(24) %59)
          to label %60 unwind label %61

60:                                               ; preds = %57
  store ptr %58, ptr %2, align 8
  br label %66

61:                                               ; preds = %57
  %62 = landingpad { ptr, i32 }
          cleanup
  %63 = extractvalue { ptr, i32 } %62, 0
  store ptr %63, ptr %4, align 8
  %64 = extractvalue { ptr, i32 } %62, 1
  store i32 %64, ptr %5, align 4
  call void @_ZdlPvm(ptr noundef %58, i64 noundef 176) #5
  br label %68

65:                                               ; preds = %1
  store ptr null, ptr %2, align 8
  br label %66

66:                                               ; preds = %65, %60, %52, %44, %36, %28, %20, %12
  %67 = load ptr, ptr %2, align 8
  ret ptr %67

68:                                               ; preds = %61, %53, %45, %37, %29, %21, %13
  %69 = load ptr, ptr %4, align 8
  %70 = load i32, ptr %5, align 4
  %71 = insertvalue { ptr, i32 } poison, ptr %69, 0
  %72 = insertvalue { ptr, i32 } %71, i32 %70, 1
  resume { ptr, i32 } %72
}

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

declare void @_ZN4Simd4Base17ImagePgmTxtLoaderC1ERKNS_16ImageLoaderParamE(ptr noundef nonnull align 8 dereferenceable(168), ptr noundef nonnull align 8 dereferenceable(24)) unnamed_addr #2

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

declare void @_ZN4Simd4Base17ImagePgmBinLoaderC1ERKNS_16ImageLoaderParamE(ptr noundef nonnull align 8 dereferenceable(168), ptr noundef nonnull align 8 dereferenceable(24)) unnamed_addr #2

declare void @_ZN4Simd4Base17ImagePpmTxtLoaderC1ERKNS_16ImageLoaderParamE(ptr noundef nonnull align 8 dereferenceable(168), ptr noundef nonnull align 8 dereferenceable(24)) unnamed_addr #2

declare void @_ZN4Simd4Base17ImagePpmBinLoaderC1ERKNS_16ImageLoaderParamE(ptr noundef nonnull align 8 dereferenceable(168), ptr noundef nonnull align 8 dereferenceable(24)) unnamed_addr #2

declare void @_ZN4Simd4Base14ImagePngLoaderC1ERKNS_16ImageLoaderParamE(ptr noundef nonnull align 8 dereferenceable(304), ptr noundef nonnull align 8 dereferenceable(24)) unnamed_addr #2

declare void @_ZN4Simd4Base15ImageJpegLoaderC1ERKNS_16ImageLoaderParamE(ptr noundef nonnull align 8 dereferenceable(128), ptr noundef nonnull align 8 dereferenceable(24)) unnamed_addr #2

declare void @_ZN4Simd4Base14ImageBmpLoaderC1ERKNS_16ImageLoaderParamE(ptr noundef nonnull align 8 dereferenceable(172), ptr noundef nonnull align 8 dereferenceable(24)) unnamed_addr #2

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 = { 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 #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 = { 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 #4 = { builtin allocsize(0) }
attributes #5 = { 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 = !{!"any pointer", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{!10, !12, i64 16}
!10 = !{!"_ZTSN4Simd16ImageLoaderParamE", !6, i64 0, !11, i64 8, !12, i64 16, !13, i64 20}
!11 = !{!"long", !7, i64 0}
!12 = !{!"_ZTS17SimdImageFileType", !7, i64 0}
!13 = !{!"_ZTS19SimdPixelFormatType", !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"

declare i32 @__gxx_personality_v0(...)

; Function Attrs: mustprogress uwtable
define dso_local noundef ptr @_ZN4Simd4Base17CreateImageLoaderERKNS_16ImageLoaderParamE(ptr noundef nonnull align 8 dereferenceable(24) %0) local_unnamed_addr #0 personality ptr @__gxx_personality_v0 {
  %2 = getelementptr inbounds i8, ptr %0, i64 16
  %3 = load i32, ptr %2, align 8, !tbaa !5
  switch i32 %3, label %32 [
    i32 1, label %4
    i32 2, label %8
    i32 3, label %12
    i32 4, label %16
    i32 5, label %20
    i32 6, label %24
    i32 7, label %28
  ]

4:                                                ; preds = %1
  %5 = tail call noalias noundef nonnull dereferenceable(168) ptr @_Znwm(i64 noundef 168) #4
  invoke void @_ZN4Simd4Base17ImagePgmTxtLoaderC1ERKNS_16ImageLoaderParamE(ptr noundef nonnull align 8 dereferenceable(168) %5, ptr noundef nonnull align 8 dereferenceable(24) %0)
          to label %32 unwind label %6

6:                                                ; preds = %4
  %7 = landingpad { ptr, i32 }
          cleanup
  tail call void @_ZdlPvm(ptr noundef nonnull %5, i64 noundef 168) #5
  br label %33

8:                                                ; preds = %1
  %9 = tail call noalias noundef nonnull dereferenceable(168) ptr @_Znwm(i64 noundef 168) #4
  invoke void @_ZN4Simd4Base17ImagePgmBinLoaderC1ERKNS_16ImageLoaderParamE(ptr noundef nonnull align 8 dereferenceable(168) %9, ptr noundef nonnull align 8 dereferenceable(24) %0)
          to label %32 unwind label %10

10:                                               ; preds = %8
  %11 = landingpad { ptr, i32 }
          cleanup
  tail call void @_ZdlPvm(ptr noundef nonnull %9, i64 noundef 168) #5
  br label %33

12:                                               ; preds = %1
  %13 = tail call noalias noundef nonnull dereferenceable(168) ptr @_Znwm(i64 noundef 168) #4
  invoke void @_ZN4Simd4Base17ImagePpmTxtLoaderC1ERKNS_16ImageLoaderParamE(ptr noundef nonnull align 8 dereferenceable(168) %13, ptr noundef nonnull align 8 dereferenceable(24) %0)
          to label %32 unwind label %14

14:                                               ; preds = %12
  %15 = landingpad { ptr, i32 }
          cleanup
  tail call void @_ZdlPvm(ptr noundef nonnull %13, i64 noundef 168) #5
  br label %33

16:                                               ; preds = %1
  %17 = tail call noalias noundef nonnull dereferenceable(168) ptr @_Znwm(i64 noundef 168) #4
  invoke void @_ZN4Simd4Base17ImagePpmBinLoaderC1ERKNS_16ImageLoaderParamE(ptr noundef nonnull align 8 dereferenceable(168) %17, ptr noundef nonnull align 8 dereferenceable(24) %0)
          to label %32 unwind label %18

18:                                               ; preds = %16
  %19 = landingpad { ptr, i32 }
          cleanup
  tail call void @_ZdlPvm(ptr noundef nonnull %17, i64 noundef 168) #5
  br label %33

20:                                               ; preds = %1
  %21 = tail call noalias noundef nonnull dereferenceable(304) ptr @_Znwm(i64 noundef 304) #4
  invoke void @_ZN4Simd4Base14ImagePngLoaderC1ERKNS_16ImageLoaderParamE(ptr noundef nonnull align 8 dereferenceable(304) %21, ptr noundef nonnull align 8 dereferenceable(24) %0)
          to label %32 unwind label %22

22:                                               ; preds = %20
  %23 = landingpad { ptr, i32 }
          cleanup
  tail call void @_ZdlPvm(ptr noundef nonnull %21, i64 noundef 304) #5
  br label %33

24:                                               ; preds = %1
  %25 = tail call noalias noundef nonnull dereferenceable(128) ptr @_Znwm(i64 noundef 128) #4
  invoke void @_ZN4Simd4Base15ImageJpegLoaderC1ERKNS_16ImageLoaderParamE(ptr noundef nonnull align 8 dereferenceable(128) %25, ptr noundef nonnull align 8 dereferenceable(24) %0)
          to label %32 unwind label %26

26:                                               ; preds = %24
  %27 = landingpad { ptr, i32 }
          cleanup
  tail call void @_ZdlPvm(ptr noundef nonnull %25, i64 noundef 128) #5
  br label %33

28:                                               ; preds = %1
  %29 = tail call noalias noundef nonnull dereferenceable(176) ptr @_Znwm(i64 noundef 176) #4
  invoke void @_ZN4Simd4Base14ImageBmpLoaderC1ERKNS_16ImageLoaderParamE(ptr noundef nonnull align 8 dereferenceable(172) %29, ptr noundef nonnull align 8 dereferenceable(24) %0)
          to label %32 unwind label %30

30:                                               ; preds = %28
  %31 = landingpad { ptr, i32 }
          cleanup
  tail call void @_ZdlPvm(ptr noundef nonnull %29, i64 noundef 176) #5
  br label %33

32:                                               ; preds = %1, %28, %24, %20, %16, %12, %8, %4
  %.011 = phi ptr [ %5, %4 ], [ %9, %8 ], [ %13, %12 ], [ %17, %16 ], [ %21, %20 ], [ %25, %24 ], [ %29, %28 ], [ null, %1 ]
  ret ptr %.011

33:                                               ; preds = %30, %26, %22, %18, %14, %10, %6
  %.pn = phi { ptr, i32 } [ %31, %30 ], [ %27, %26 ], [ %23, %22 ], [ %19, %18 ], [ %15, %14 ], [ %11, %10 ], [ %7, %6 ]
  resume { ptr, i32 } %.pn
}

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

declare void @_ZN4Simd4Base17ImagePgmTxtLoaderC1ERKNS_16ImageLoaderParamE(ptr noundef nonnull align 8 dereferenceable(168), ptr noundef nonnull align 8 dereferenceable(24)) unnamed_addr #2

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

declare void @_ZN4Simd4Base17ImagePgmBinLoaderC1ERKNS_16ImageLoaderParamE(ptr noundef nonnull align 8 dereferenceable(168), ptr noundef nonnull align 8 dereferenceable(24)) unnamed_addr #2

declare void @_ZN4Simd4Base17ImagePpmTxtLoaderC1ERKNS_16ImageLoaderParamE(ptr noundef nonnull align 8 dereferenceable(168), ptr noundef nonnull align 8 dereferenceable(24)) unnamed_addr #2

declare void @_ZN4Simd4Base17ImagePpmBinLoaderC1ERKNS_16ImageLoaderParamE(ptr noundef nonnull align 8 dereferenceable(168), ptr noundef nonnull align 8 dereferenceable(24)) unnamed_addr #2

declare void @_ZN4Simd4Base14ImagePngLoaderC1ERKNS_16ImageLoaderParamE(ptr noundef nonnull align 8 dereferenceable(304), ptr noundef nonnull align 8 dereferenceable(24)) unnamed_addr #2

declare void @_ZN4Simd4Base15ImageJpegLoaderC1ERKNS_16ImageLoaderParamE(ptr noundef nonnull align 8 dereferenceable(128), ptr noundef nonnull align 8 dereferenceable(24)) unnamed_addr #2

declare void @_ZN4Simd4Base14ImageBmpLoaderC1ERKNS_16ImageLoaderParamE(ptr noundef nonnull align 8 dereferenceable(172), ptr noundef nonnull align 8 dereferenceable(24)) unnamed_addr #2

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 = { 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 #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 = { 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 #4 = { builtin allocsize(0) }
attributes #5 = { 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, !11, i64 16}
!6 = !{!"_ZTSN4Simd16ImageLoaderParamE", !7, i64 0, !10, i64 8, !11, i64 16, !12, i64 20}
!7 = !{!"any pointer", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C++ TBAA"}
!10 = !{!"long", !8, i64 0}
!11 = !{!"_ZTS17SimdImageFileType", !8, i64 0}
!12 = !{!"_ZTS19SimdPixelFormatType", !8, i64 0}


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