; LLVM IR from jgaeddert/liquid-dsp :: src/matrix/tests (smatrixi_autotest)

; 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 [91 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [3 x i8], align 1
@__const.autotest_smatrixi_mul.c_test = external hidden unnamed_addr constant [12 x i16], align 16
@.str.10 = external hidden unnamed_addr constant [20 x i8], align 1
@.str.11 = external hidden unnamed_addr constant [24 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

declare ptr @smatrixi_create(i32 noundef, i32 noundef) #1

declare i32 @smatrixi_set(ptr noundef, i32 noundef, i32 noundef, i16 noundef signext) #1

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: readwrite)
declare void @llvm.memcpy.p0.p0.i64(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i64, i1 immarg) #2

declare void @liquid_autotest_failed_expr(ptr noundef, i32 noundef, ptr noundef, double noundef, ptr noundef, ptr noundef, double noundef) #1

declare void @liquid_autotest_passed(...) #1

declare i32 @smatrixi_destroy(ptr noundef) #1

; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #0

; Function Attrs: nounwind uwtable
define dso_local void @autotest_smatrixi_mul() #3 {
  %1 = alloca ptr, align 8
  %2 = alloca ptr, align 8
  %3 = alloca ptr, align 8
  %4 = alloca [12 x i16], align 16
  %5 = alloca i32, align 4
  %6 = alloca i32, align 4
  call void @llvm.lifetime.start.p0(i64 8, ptr %1) #4
  %7 = call ptr @smatrixi_create(i32 noundef 4, i32 noundef 5)
  store ptr %7, ptr %1, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %2) #4
  %8 = call ptr @smatrixi_create(i32 noundef 5, i32 noundef 3)
  store ptr %8, ptr %2, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %3) #4
  %9 = call ptr @smatrixi_create(i32 noundef 4, i32 noundef 3)
  store ptr %9, ptr %3, align 8, !tbaa !5
  %10 = load ptr, ptr %1, align 8, !tbaa !5
  %11 = call i32 @smatrixi_set(ptr noundef %10, i32 noundef 0, i32 noundef 4, i16 noundef signext 4)
  %12 = load ptr, ptr %1, align 8, !tbaa !5
  %13 = call i32 @smatrixi_set(ptr noundef %12, i32 noundef 2, i32 noundef 3, i16 noundef signext 3)
  %14 = load ptr, ptr %1, align 8, !tbaa !5
  %15 = call i32 @smatrixi_set(ptr noundef %14, i32 noundef 3, i32 noundef 0, i16 noundef signext 2)
  %16 = load ptr, ptr %1, align 8, !tbaa !5
  %17 = call i32 @smatrixi_set(ptr noundef %16, i32 noundef 3, i32 noundef 4, i16 noundef signext 0)
  %18 = load ptr, ptr %1, align 8, !tbaa !5
  %19 = call i32 @smatrixi_set(ptr noundef %18, i32 noundef 3, i32 noundef 4, i16 noundef signext 1)
  %20 = load ptr, ptr %2, align 8, !tbaa !5
  %21 = call i32 @smatrixi_set(ptr noundef %20, i32 noundef 0, i32 noundef 0, i16 noundef signext 7)
  %22 = load ptr, ptr %2, align 8, !tbaa !5
  %23 = call i32 @smatrixi_set(ptr noundef %22, i32 noundef 0, i32 noundef 1, i16 noundef signext 6)
  %24 = load ptr, ptr %2, align 8, !tbaa !5
  %25 = call i32 @smatrixi_set(ptr noundef %24, i32 noundef 3, i32 noundef 1, i16 noundef signext 5)
  %26 = load ptr, ptr %2, align 8, !tbaa !5
  %27 = call i32 @smatrixi_set(ptr noundef %26, i32 noundef 4, i32 noundef 0, i16 noundef signext 2)
  %28 = load ptr, ptr %1, align 8, !tbaa !5
  %29 = load ptr, ptr %2, align 8, !tbaa !5
  %30 = load ptr, ptr %3, align 8, !tbaa !5
  %31 = call i32 @smatrixi_mul(ptr noundef %28, ptr noundef %29, ptr noundef %30)
  call void @llvm.lifetime.start.p0(i64 24, ptr %4) #4
  call void @llvm.memcpy.p0.p0.i64(ptr align 16 %4, ptr align 16 @__const.autotest_smatrixi_mul.c_test, i64 24, i1 false)
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #4
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #4
  store i32 0, ptr %5, align 4, !tbaa !9
  br label %32

32:                                               ; preds = %74, %0
  %33 = load i32, ptr %5, align 4, !tbaa !9
  %34 = icmp ult i32 %33, 4
  br i1 %34, label %35, label %77

35:                                               ; preds = %32
  store i32 0, ptr %6, align 4, !tbaa !9
  br label %36

36:                                               ; preds = %70, %35
  %37 = load i32, ptr %6, align 4, !tbaa !9
  %38 = icmp ult i32 %37, 3
  br i1 %38, label %39, label %73

39:                                               ; preds = %36
  %40 = load ptr, ptr %3, align 8, !tbaa !5
  %41 = load i32, ptr %5, align 4, !tbaa !9
  %42 = load i32, ptr %6, align 4, !tbaa !9
  %43 = call signext i16 @smatrixi_get(ptr noundef %40, i32 noundef %41, i32 noundef %42)
  %44 = sext i16 %43 to i32
  %45 = load i32, ptr %5, align 4, !tbaa !9
  %46 = mul i32 %45, 3
  %47 = load i32, ptr %6, align 4, !tbaa !9
  %48 = add i32 %46, %47
  %49 = zext i32 %48 to i64
  %50 = getelementptr inbounds [12 x i16], ptr %4, i64 0, i64 %49
  %51 = load i16, ptr %50, align 2, !tbaa !11
  %52 = sext i16 %51 to i32
  %53 = icmp ne i32 %44, %52
  br i1 %53, label %54, label %68

54:                                               ; preds = %39
  %55 = load ptr, ptr %3, align 8, !tbaa !5
  %56 = load i32, ptr %5, align 4, !tbaa !9
  %57 = load i32, ptr %6, align 4, !tbaa !9
  %58 = call signext i16 @smatrixi_get(ptr noundef %55, i32 noundef %56, i32 noundef %57)
  %59 = sitofp i16 %58 to double
  %60 = load i32, ptr %5, align 4, !tbaa !9
  %61 = mul i32 %60, 3
  %62 = load i32, ptr %6, align 4, !tbaa !9
  %63 = add i32 %61, %62
  %64 = zext i32 %63 to i64
  %65 = getelementptr inbounds [12 x i16], ptr %4, i64 0, i64 %64
  %66 = load i16, ptr %65, align 2, !tbaa !11
  %67 = sitofp i16 %66 to double
  call void @liquid_autotest_failed_expr(ptr noundef @.str, i32 noundef 116, ptr noundef @.str.10, double noundef %59, ptr noundef @.str.2, ptr noundef @.str.11, double noundef %67)
  br label %69

68:                                               ; preds = %39
  call void (...) @liquid_autotest_passed()
  br label %69

69:                                               ; preds = %68, %54
  br label %70

70:                                               ; preds = %69
  %71 = load i32, ptr %6, align 4, !tbaa !9
  %72 = add i32 %71, 1
  store i32 %72, ptr %6, align 4, !tbaa !9
  br label %36, !llvm.loop !13

73:                                               ; preds = %36
  br label %74

74:                                               ; preds = %73
  %75 = load i32, ptr %5, align 4, !tbaa !9
  %76 = add i32 %75, 1
  store i32 %76, ptr %5, align 4, !tbaa !9
  br label %32, !llvm.loop !15

77:                                               ; preds = %32
  %78 = load ptr, ptr %1, align 8, !tbaa !5
  %79 = call i32 @smatrixi_destroy(ptr noundef %78)
  %80 = load ptr, ptr %2, align 8, !tbaa !5
  %81 = call i32 @smatrixi_destroy(ptr noundef %80)
  %82 = load ptr, ptr %3, align 8, !tbaa !5
  %83 = call i32 @smatrixi_destroy(ptr noundef %82)
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #4
  call void @llvm.lifetime.end.p0(i64 24, ptr %4) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %3) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %2) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %1) #4
  ret void
}

declare i32 @smatrixi_mul(ptr noundef, ptr noundef, ptr noundef) #1

declare signext i16 @smatrixi_get(ptr noundef, i32 noundef, i32 noundef) #1

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #3 = { 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 #4 = { 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/C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"int", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"short", !7, i64 0}
!13 = distinct !{!13, !14}
!14 = !{!"llvm.loop.mustprogress"}
!15 = distinct !{!15, !14}


; 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 [91 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [3 x i8], align 1
@__const.autotest_smatrixi_mul.c_test = external hidden unnamed_addr constant [12 x i16], align 16
@.str.10 = external hidden unnamed_addr constant [20 x i8], align 1
@.str.11 = external hidden unnamed_addr constant [24 x i8], align 1

declare ptr @smatrixi_create(i32 noundef, i32 noundef) local_unnamed_addr #0

declare i32 @smatrixi_set(ptr noundef, i32 noundef, i32 noundef, i16 noundef signext) local_unnamed_addr #0

declare void @liquid_autotest_failed_expr(ptr noundef, i32 noundef, ptr noundef, double noundef, ptr noundef, ptr noundef, double noundef) local_unnamed_addr #0

declare void @liquid_autotest_passed(...) local_unnamed_addr #0

declare i32 @smatrixi_destroy(ptr noundef) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
define dso_local void @autotest_smatrixi_mul() local_unnamed_addr #1 {
  %1 = tail call ptr @smatrixi_create(i32 noundef 4, i32 noundef 5) #2
  %2 = tail call ptr @smatrixi_create(i32 noundef 5, i32 noundef 3) #2
  %3 = tail call ptr @smatrixi_create(i32 noundef 4, i32 noundef 3) #2
  %4 = tail call i32 @smatrixi_set(ptr noundef %1, i32 noundef 0, i32 noundef 4, i16 noundef signext 4) #2
  %5 = tail call i32 @smatrixi_set(ptr noundef %1, i32 noundef 2, i32 noundef 3, i16 noundef signext 3) #2
  %6 = tail call i32 @smatrixi_set(ptr noundef %1, i32 noundef 3, i32 noundef 0, i16 noundef signext 2) #2
  %7 = tail call i32 @smatrixi_set(ptr noundef %1, i32 noundef 3, i32 noundef 4, i16 noundef signext 0) #2
  %8 = tail call i32 @smatrixi_set(ptr noundef %1, i32 noundef 3, i32 noundef 4, i16 noundef signext 1) #2
  %9 = tail call i32 @smatrixi_set(ptr noundef %2, i32 noundef 0, i32 noundef 0, i16 noundef signext 7) #2
  %10 = tail call i32 @smatrixi_set(ptr noundef %2, i32 noundef 0, i32 noundef 1, i16 noundef signext 6) #2
  %11 = tail call i32 @smatrixi_set(ptr noundef %2, i32 noundef 3, i32 noundef 1, i16 noundef signext 5) #2
  %12 = tail call i32 @smatrixi_set(ptr noundef %2, i32 noundef 4, i32 noundef 0, i16 noundef signext 2) #2
  %13 = tail call i32 @smatrixi_mul(ptr noundef %1, ptr noundef %2, ptr noundef %3) #2
  br label %.preheader

.preheader:                                       ; preds = %0, %44
  %indvars.iv = phi i64 [ 0, %0 ], [ %indvars.iv.next, %44 ]
  %14 = mul nuw nsw i64 %indvars.iv, 3
  %15 = trunc nuw nsw i64 %indvars.iv to i32
  %16 = tail call signext i16 @smatrixi_get(ptr noundef %3, i32 noundef %15, i32 noundef 0) #2
  %17 = getelementptr inbounds [12 x i16], ptr @__const.autotest_smatrixi_mul.c_test, i64 0, i64 %14
  %18 = load i16, ptr %17, align 2, !tbaa !5
  %.not = icmp eq i16 %16, %18
  br i1 %.not, label %23, label %19

19:                                               ; preds = %.preheader
  %20 = tail call signext i16 @smatrixi_get(ptr noundef %3, i32 noundef %15, i32 noundef 0) #2
  %21 = sitofp i16 %20 to double
  %22 = sitofp i16 %18 to double
  tail call void @liquid_autotest_failed_expr(ptr noundef nonnull @.str, i32 noundef 116, ptr noundef nonnull @.str.10, double noundef %21, ptr noundef nonnull @.str.2, ptr noundef nonnull @.str.11, double noundef %22) #2
  br label %24

23:                                               ; preds = %.preheader
  tail call void (...) @liquid_autotest_passed() #2
  br label %24

24:                                               ; preds = %19, %23
  %25 = tail call signext i16 @smatrixi_get(ptr noundef %3, i32 noundef %15, i32 noundef 1) #2
  %26 = add nuw nsw i64 %14, 1
  %27 = getelementptr inbounds [12 x i16], ptr @__const.autotest_smatrixi_mul.c_test, i64 0, i64 %26
  %28 = load i16, ptr %27, align 2, !tbaa !5
  %.not.1 = icmp eq i16 %25, %28
  br i1 %.not.1, label %33, label %29

29:                                               ; preds = %24
  %30 = tail call signext i16 @smatrixi_get(ptr noundef %3, i32 noundef %15, i32 noundef 1) #2
  %31 = sitofp i16 %30 to double
  %32 = sitofp i16 %28 to double
  tail call void @liquid_autotest_failed_expr(ptr noundef nonnull @.str, i32 noundef 116, ptr noundef nonnull @.str.10, double noundef %31, ptr noundef nonnull @.str.2, ptr noundef nonnull @.str.11, double noundef %32) #2
  br label %34

33:                                               ; preds = %24
  tail call void (...) @liquid_autotest_passed() #2
  br label %34

34:                                               ; preds = %33, %29
  %35 = tail call signext i16 @smatrixi_get(ptr noundef %3, i32 noundef %15, i32 noundef 2) #2
  %36 = add nuw nsw i64 %14, 2
  %37 = getelementptr inbounds [12 x i16], ptr @__const.autotest_smatrixi_mul.c_test, i64 0, i64 %36
  %38 = load i16, ptr %37, align 2, !tbaa !5
  %.not.2 = icmp eq i16 %35, %38
  br i1 %.not.2, label %43, label %39

39:                                               ; preds = %34
  %40 = tail call signext i16 @smatrixi_get(ptr noundef %3, i32 noundef %15, i32 noundef 2) #2
  %41 = sitofp i16 %40 to double
  %42 = sitofp i16 %38 to double
  tail call void @liquid_autotest_failed_expr(ptr noundef nonnull @.str, i32 noundef 116, ptr noundef nonnull @.str.10, double noundef %41, ptr noundef nonnull @.str.2, ptr noundef nonnull @.str.11, double noundef %42) #2
  br label %44

43:                                               ; preds = %34
  tail call void (...) @liquid_autotest_passed() #2
  br label %44

44:                                               ; preds = %43, %39
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %exitcond.not = icmp eq i64 %indvars.iv.next, 4
  br i1 %exitcond.not, label %45, label %.preheader, !llvm.loop !9

45:                                               ; preds = %44
  %46 = tail call i32 @smatrixi_destroy(ptr noundef %1) #2
  %47 = tail call i32 @smatrixi_destroy(ptr noundef %2) #2
  %48 = tail call i32 @smatrixi_destroy(ptr noundef %3) #2
  ret void
}

declare i32 @smatrixi_mul(ptr noundef, ptr noundef, ptr noundef) local_unnamed_addr #0

declare signext i16 @smatrixi_get(ptr noundef, i32 noundef, i32 noundef) local_unnamed_addr #0

attributes #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 = { 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 #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 = !{!"short", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = distinct !{!9, !10}
!10 = !{!"llvm.loop.mustprogress"}


; Effective O3 passes: EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,LICMPass,LoopRotatePass,LoopSimplifyPass,ReassociatePass,SROAPass,SimplifyCFGPass,TailCallElimPass