; LLVM IR from ermig1979/Simd :: src/Simd/SimdBaseSynetScale.ll (ZN4Simd4Base12SynetScale8i7ForwardEPKhPh)

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

%"class.Simd::Base::SynetScale8i" = type { %"struct.Simd::Deletable", %"struct.Simd::CvtParam", %"struct.Simd::CvtParam", %"struct.Simd::Array.0", %"struct.Simd::Array.0", %"struct.Simd::Base::Scale8iParam" }
%"struct.Simd::Deletable" = type { ptr }
%"struct.Simd::CvtParam" = type <{ %"struct.Simd::Array", %"struct.Simd::Array.0", %"struct.Simd::Array.0", %"struct.Simd::Array.0", %"struct.Simd::Array.0", i8, [3 x i8], i32, i32, i32, i32, [4 x i8] }>
%"struct.Simd::Array" = type { ptr, i64 }
%"struct.Simd::Array.0" = type { ptr, i64 }
%"struct.Simd::Base::Scale8iParam" = type { i64, i64, i64, i32, i32, i32, i32 }

@.str = external hidden unnamed_addr constant [2 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [80 x i8], align 1
@__PRETTY_FUNCTION__._ZN4Simd4Base12SynetScale8i7ForwardEPKhPh = external hidden unnamed_addr constant [67 x i8], align 1

; 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: noreturn nounwind
declare void @__assert_fail(ptr noundef, ptr noundef, i32 noundef, ptr noundef) #1

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN4Simd4Base12SynetScale8i7ForwardEPKhPh(ptr noundef nonnull align 8 dereferenceable(288) %0, ptr noundef %1, ptr noundef %2) #2 align 2 {
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca ptr, align 8
  store ptr %0, ptr %4, align 8, !tbaa !5
  store ptr %1, ptr %5, align 8, !tbaa !5
  store ptr %2, ptr %6, align 8, !tbaa !5
  %8 = load ptr, ptr %4, align 8
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #3
  %9 = getelementptr inbounds %"class.Simd::Base::SynetScale8i", ptr %8, i32 0, i32 5
  store ptr %9, ptr %7, align 8, !tbaa !5
  %10 = load ptr, ptr %7, align 8, !tbaa !5
  %11 = getelementptr inbounds %"struct.Simd::Base::Scale8iParam", ptr %10, i32 0, i32 3
  %12 = load i32, ptr %11, align 8, !tbaa !9
  %13 = icmp eq i32 %12, 3
  br i1 %13, label %14, label %25

14:                                               ; preds = %3
  %15 = load ptr, ptr %7, align 8, !tbaa !5
  %16 = getelementptr inbounds %"struct.Simd::Base::Scale8iParam", ptr %15, i32 0, i32 4
  %17 = load i32, ptr %16, align 4, !tbaa !15
  %18 = icmp eq i32 %17, 3
  br i1 %18, label %19, label %25

19:                                               ; preds = %14
  %20 = load ptr, ptr %5, align 8, !tbaa !5
  %21 = load ptr, ptr %6, align 8, !tbaa !5
  %22 = load ptr, ptr %8, align 8, !tbaa !16
  %23 = getelementptr inbounds ptr, ptr %22, i64 2
  %24 = load ptr, ptr %23, align 8
  call void %24(ptr noundef nonnull align 8 dereferenceable(288) %8, ptr noundef %20, ptr noundef %21)
  br label %77

25:                                               ; preds = %14, %3
  %26 = load ptr, ptr %7, align 8, !tbaa !5
  %27 = getelementptr inbounds %"struct.Simd::Base::Scale8iParam", ptr %26, i32 0, i32 3
  %28 = load i32, ptr %27, align 8, !tbaa !9
  %29 = icmp eq i32 %28, 0
  br i1 %29, label %30, label %41

30:                                               ; preds = %25
  %31 = load ptr, ptr %7, align 8, !tbaa !5
  %32 = getelementptr inbounds %"struct.Simd::Base::Scale8iParam", ptr %31, i32 0, i32 4
  %33 = load i32, ptr %32, align 4, !tbaa !15
  %34 = icmp eq i32 %33, 3
  br i1 %34, label %35, label %41

35:                                               ; preds = %30
  %36 = load ptr, ptr %5, align 8, !tbaa !5
  %37 = load ptr, ptr %6, align 8, !tbaa !5
  %38 = load ptr, ptr %8, align 8, !tbaa !16
  %39 = getelementptr inbounds ptr, ptr %38, i64 4
  %40 = load ptr, ptr %39, align 8
  call void %40(ptr noundef nonnull align 8 dereferenceable(288) %8, ptr noundef %36, ptr noundef %37)
  br label %76

41:                                               ; preds = %30, %25
  %42 = load ptr, ptr %7, align 8, !tbaa !5
  %43 = getelementptr inbounds %"struct.Simd::Base::Scale8iParam", ptr %42, i32 0, i32 3
  %44 = load i32, ptr %43, align 8, !tbaa !9
  %45 = icmp eq i32 %44, 3
  br i1 %45, label %46, label %57

46:                                               ; preds = %41
  %47 = load ptr, ptr %7, align 8, !tbaa !5
  %48 = getelementptr inbounds %"struct.Simd::Base::Scale8iParam", ptr %47, i32 0, i32 4
  %49 = load i32, ptr %48, align 4, !tbaa !15
  %50 = icmp eq i32 %49, 0
  br i1 %50, label %51, label %57

51:                                               ; preds = %46
  %52 = load ptr, ptr %5, align 8, !tbaa !5
  %53 = load ptr, ptr %6, align 8, !tbaa !5
  %54 = load ptr, ptr %8, align 8, !tbaa !16
  %55 = getelementptr inbounds ptr, ptr %54, i64 3
  %56 = load ptr, ptr %55, align 8
  call void %56(ptr noundef nonnull align 8 dereferenceable(288) %8, ptr noundef %52, ptr noundef %53)
  br label %75

57:                                               ; preds = %46, %41
  %58 = load ptr, ptr %7, align 8, !tbaa !5
  %59 = getelementptr inbounds %"struct.Simd::Base::Scale8iParam", ptr %58, i32 0, i32 3
  %60 = load i32, ptr %59, align 8, !tbaa !9
  %61 = icmp eq i32 %60, 0
  br i1 %61, label %62, label %73

62:                                               ; preds = %57
  %63 = load ptr, ptr %7, align 8, !tbaa !5
  %64 = getelementptr inbounds %"struct.Simd::Base::Scale8iParam", ptr %63, i32 0, i32 4
  %65 = load i32, ptr %64, align 4, !tbaa !15
  %66 = icmp eq i32 %65, 0
  br i1 %66, label %67, label %73

67:                                               ; preds = %62
  %68 = load ptr, ptr %5, align 8, !tbaa !5
  %69 = load ptr, ptr %6, align 8, !tbaa !5
  %70 = load ptr, ptr %8, align 8, !tbaa !16
  %71 = getelementptr inbounds ptr, ptr %70, i64 5
  %72 = load ptr, ptr %71, align 8
  call void %72(ptr noundef nonnull align 8 dereferenceable(288) %8, ptr noundef %68, ptr noundef %69)
  br label %74

73:                                               ; preds = %62, %57
  call void @__assert_fail(ptr noundef @.str, ptr noundef @.str.1, i32 noundef 207, ptr noundef @__PRETTY_FUNCTION__._ZN4Simd4Base12SynetScale8i7ForwardEPKhPh) #4
  unreachable

74:                                               ; preds = %67
  br label %75

75:                                               ; preds = %74, %51
  br label %76

76:                                               ; preds = %75, %35
  br label %77

77:                                               ; preds = %76, %19
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #3
  ret void
}

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { noreturn 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 #2 = { 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 #3 = { nounwind }
attributes #4 = { noreturn 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 24}
!10 = !{!"_ZTSN4Simd4Base12Scale8iParamE", !11, i64 0, !11, i64 8, !11, i64 16, !12, i64 24, !12, i64 28, !13, i64 32, !14, i64 36}
!11 = !{!"long", !7, i64 0}
!12 = !{!"_ZTS18SimdTensorDataType", !7, i64 0}
!13 = !{!"_ZTS20SimdTensorFormatType", !7, i64 0}
!14 = !{!"_ZTS26SimdSynetCompatibilityType", !7, i64 0}
!15 = !{!10, !12, i64 28}
!16 = !{!17, !17, i64 0}
!17 = !{!"vtable pointer", !8, 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"

@.str = external hidden unnamed_addr constant [2 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [80 x i8], align 1
@__PRETTY_FUNCTION__._ZN4Simd4Base12SynetScale8i7ForwardEPKhPh = external hidden unnamed_addr constant [67 x i8], align 1

; Function Attrs: noreturn nounwind
declare void @__assert_fail(ptr noundef, ptr noundef, i32 noundef, ptr noundef) local_unnamed_addr #0

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN4Simd4Base12SynetScale8i7ForwardEPKhPh(ptr noundef nonnull align 8 dereferenceable(288) %0, ptr noundef %1, ptr noundef %2) local_unnamed_addr #1 align 2 {
  %4 = getelementptr inbounds i8, ptr %0, i64 272
  %5 = load i32, ptr %4, align 8, !tbaa !5
  %6 = icmp eq i32 %5, 3
  %7 = getelementptr inbounds i8, ptr %0, i64 276
  %8 = load i32, ptr %7, align 4
  %9 = icmp eq i32 %8, 3
  %or.cond = select i1 %6, i1 %9, i1 false
  br i1 %or.cond, label %16, label %10

10:                                               ; preds = %3
  %11 = icmp eq i32 %5, 0
  %or.cond21 = select i1 %11, i1 %9, i1 false
  br i1 %or.cond21, label %16, label %12

12:                                               ; preds = %10
  %13 = icmp eq i32 %8, 0
  %or.cond24 = select i1 %6, i1 %13, i1 false
  br i1 %or.cond24, label %16, label %14

14:                                               ; preds = %12
  %or.cond27 = select i1 %11, i1 %13, i1 false
  br i1 %or.cond27, label %16, label %15

15:                                               ; preds = %14
  tail call void @__assert_fail(ptr noundef nonnull @.str, ptr noundef nonnull @.str.1, i32 noundef 207, ptr noundef nonnull @__PRETTY_FUNCTION__._ZN4Simd4Base12SynetScale8i7ForwardEPKhPh) #2
  unreachable

16:                                               ; preds = %14, %12, %10, %3
  %.sink29 = phi i64 [ 16, %3 ], [ 32, %10 ], [ 24, %12 ], [ 40, %14 ]
  %17 = load ptr, ptr %0, align 8, !tbaa !13
  %18 = getelementptr inbounds i8, ptr %17, i64 %.sink29
  %19 = load ptr, ptr %18, align 8
  tail call void %19(ptr noundef nonnull align 8 dereferenceable(288) %0, ptr noundef %1, ptr noundef %2)
  ret void
}

attributes #0 = { noreturn 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 #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 = { noreturn 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, !10, i64 24}
!6 = !{!"_ZTSN4Simd4Base12Scale8iParamE", !7, i64 0, !7, i64 8, !7, i64 16, !10, i64 24, !10, i64 28, !11, i64 32, !12, i64 36}
!7 = !{!"long", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C++ TBAA"}
!10 = !{!"_ZTS18SimdTensorDataType", !8, i64 0}
!11 = !{!"_ZTS20SimdTensorFormatType", !8, i64 0}
!12 = !{!"_ZTS26SimdSynetCompatibilityType", !8, i64 0}
!13 = !{!14, !14, i64 0}
!14 = !{!"vtable pointer", !9, i64 0}


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