; LLVM IR from mlcommons/tiny :: benchmark/reference_submissions/streaming_wakeword/sww_testing_l4r5zi/X-CUBE-AI_ (init)

; 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.ai_error_ = type { i32 }
%struct.ai_network_params_ = type { %union.anon.1 }
%union.anon.1 = type { %struct.anon.2 }
%struct.anon.2 = type { %struct.ai_buffer_, %struct.ai_buffer_ }
%struct.ai_buffer_ = type { i32, ptr, ptr, i32, i32, %struct.ai_buffer_shape_ }
%struct.ai_buffer_shape_ = type { i32, ptr }
%struct.anon.3 = type { i32, %struct.ai_buffer_array_, %struct.ai_buffer_array_ }
%struct.ai_buffer_array_ = type { i16, i16, ptr }

; 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 nounwind willreturn memory(argmem: readwrite)
declare void @llvm.memcpy.p0.p0.i64(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i64, i1 immarg) #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
declare dso_local i32 @ai_sww_model_get_error(ptr noundef) #2

; Function Attrs: nounwind uwtable
declare dso_local i32 @ai_sww_model_create(ptr noundef, ptr noundef) #2

; Function Attrs: nounwind uwtable
define dso_local i32 @ai_sww_model_create_and_init(ptr noundef %0, ptr noundef %1, ptr noundef %2) #2 {
  %4 = alloca %struct.ai_error_, align 4
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca ptr, align 8
  %8 = alloca %struct.ai_network_params_, align 8
  %9 = alloca %struct.ai_error_, align 4
  %10 = alloca i32, align 4
  %11 = alloca %struct.ai_error_, align 4
  %12 = alloca i16, align 2
  %13 = alloca i16, align 2
  %14 = alloca %struct.ai_error_, align 4
  store ptr %0, ptr %5, align 8, !tbaa !5
  store ptr %1, ptr %6, align 8, !tbaa !5
  store ptr %2, ptr %7, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 96, ptr %8) #4
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #4
  %15 = load ptr, ptr %5, align 8, !tbaa !5
  %16 = call i32 @ai_sww_model_create(ptr noundef %15, ptr noundef null)
  %17 = getelementptr inbounds %struct.ai_error_, ptr %9, i32 0, i32 0
  store i32 %16, ptr %17, align 4
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %4, ptr align 4 %9, i64 4, i1 false), !tbaa.struct !9
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #4
  %18 = load i32, ptr %4, align 4
  %19 = and i32 %18, 255
  %20 = icmp ne i32 %19, 0
  br i1 %20, label %21, label %22

21:                                               ; preds = %3
  store i32 1, ptr %10, align 4
  br label %103

22:                                               ; preds = %3
  %23 = call zeroext i1 @ai_sww_model_data_params_get(ptr noundef %8)
  %24 = zext i1 %23 to i32
  %25 = icmp ne i32 %24, 1
  br i1 %25, label %26, label %31

26:                                               ; preds = %22
  call void @llvm.lifetime.start.p0(i64 4, ptr %11) #4
  %27 = load ptr, ptr %5, align 8, !tbaa !5
  %28 = load ptr, ptr %27, align 8, !tbaa !5
  %29 = call i32 @ai_sww_model_get_error(ptr noundef %28)
  %30 = getelementptr inbounds %struct.ai_error_, ptr %11, i32 0, i32 0
  store i32 %29, ptr %30, align 4
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %4, ptr align 4 %11, i64 4, i1 false), !tbaa.struct !9
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #4
  store i32 1, ptr %10, align 4
  br label %103

31:                                               ; preds = %22
  call void @llvm.lifetime.start.p0(i64 2, ptr %12) #4
  store i16 0, ptr %12, align 2, !tbaa !11
  br label %32

32:                                               ; preds = %58, %31
  %33 = load ptr, ptr %6, align 8, !tbaa !5
  %34 = icmp ne ptr %33, null
  br i1 %34, label %35, label %44

35:                                               ; preds = %32
  %36 = load i16, ptr %12, align 2, !tbaa !11
  %37 = zext i16 %36 to i32
  %38 = getelementptr inbounds %struct.ai_network_params_, ptr %8, i32 0, i32 0
  %39 = getelementptr inbounds %struct.anon.3, ptr %38, i32 0, i32 2
  %40 = getelementptr inbounds %struct.ai_buffer_array_, ptr %39, i32 0, i32 1
  %41 = load i16, ptr %40, align 2, !tbaa !10
  %42 = zext i16 %41 to i32
  %43 = icmp slt i32 %37, %42
  br label %44

44:                                               ; preds = %35, %32
  %45 = phi i1 [ false, %32 ], [ %43, %35 ]
  br i1 %45, label %47, label %46

46:                                               ; preds = %44
  store i32 2, ptr %10, align 4
  call void @llvm.lifetime.end.p0(i64 2, ptr %12) #4
  br label %61

47:                                               ; preds = %44
  %48 = getelementptr inbounds %struct.ai_network_params_, ptr %8, i32 0, i32 0
  %49 = getelementptr inbounds %struct.anon.3, ptr %48, i32 0, i32 2
  %50 = load i16, ptr %12, align 2, !tbaa !11
  %51 = zext i16 %50 to i32
  %52 = load ptr, ptr %6, align 8, !tbaa !5
  %53 = load i16, ptr %12, align 2, !tbaa !11
  %54 = zext i16 %53 to i64
  %55 = getelementptr inbounds ptr, ptr %52, i64 %54
  %56 = load ptr, ptr %55, align 8, !tbaa !5
  %57 = call zeroext i1 @ai_buffer_array_item_set_address(ptr noundef %49, i32 noundef %51, ptr noundef %56)
  br label %58

58:                                               ; preds = %47
  %59 = load i16, ptr %12, align 2, !tbaa !11
  %60 = add i16 %59, 1
  store i16 %60, ptr %12, align 2, !tbaa !11
  br label %32, !llvm.loop !13

61:                                               ; preds = %46
  call void @llvm.lifetime.start.p0(i64 2, ptr %13) #4
  store i16 0, ptr %13, align 2, !tbaa !11
  br label %62

62:                                               ; preds = %88, %61
  %63 = load ptr, ptr %7, align 8, !tbaa !5
  %64 = icmp ne ptr %63, null
  br i1 %64, label %65, label %74

65:                                               ; preds = %62
  %66 = load i16, ptr %13, align 2, !tbaa !11
  %67 = zext i16 %66 to i32
  %68 = getelementptr inbounds %struct.ai_network_params_, ptr %8, i32 0, i32 0
  %69 = getelementptr inbounds %struct.anon.3, ptr %68, i32 0, i32 1
  %70 = getelementptr inbounds %struct.ai_buffer_array_, ptr %69, i32 0, i32 1
  %71 = load i16, ptr %70, align 2, !tbaa !10
  %72 = zext i16 %71 to i32
  %73 = icmp slt i32 %67, %72
  br label %74

74:                                               ; preds = %65, %62
  %75 = phi i1 [ false, %62 ], [ %73, %65 ]
  br i1 %75, label %77, label %76

76:                                               ; preds = %74
  store i32 5, ptr %10, align 4
  call void @llvm.lifetime.end.p0(i64 2, ptr %13) #4
  br label %91

77:                                               ; preds = %74
  %78 = getelementptr inbounds %struct.ai_network_params_, ptr %8, i32 0, i32 0
  %79 = getelementptr inbounds %struct.anon.3, ptr %78, i32 0, i32 1
  %80 = load i16, ptr %13, align 2, !tbaa !11
  %81 = zext i16 %80 to i32
  %82 = load ptr, ptr %7, align 8, !tbaa !5
  %83 = load i16, ptr %13, align 2, !tbaa !11
  %84 = zext i16 %83 to i64
  %85 = getelementptr inbounds ptr, ptr %82, i64 %84
  %86 = load ptr, ptr %85, align 8, !tbaa !5
  %87 = call zeroext i1 @ai_buffer_array_item_set_address(ptr noundef %79, i32 noundef %81, ptr noundef %86)
  br label %88

88:                                               ; preds = %77
  %89 = load i16, ptr %13, align 2, !tbaa !11
  %90 = add i16 %89, 1
  store i16 %90, ptr %13, align 2, !tbaa !11
  br label %62, !llvm.loop !15

91:                                               ; preds = %76
  %92 = load ptr, ptr %5, align 8, !tbaa !5
  %93 = load ptr, ptr %92, align 8, !tbaa !5
  %94 = call zeroext i1 @ai_sww_model_init(ptr noundef %93, ptr noundef %8)
  %95 = zext i1 %94 to i32
  %96 = icmp ne i32 %95, 1
  br i1 %96, label %97, label %102

97:                                               ; preds = %91
  call void @llvm.lifetime.start.p0(i64 4, ptr %14) #4
  %98 = load ptr, ptr %5, align 8, !tbaa !5
  %99 = load ptr, ptr %98, align 8, !tbaa !5
  %100 = call i32 @ai_sww_model_get_error(ptr noundef %99)
  %101 = getelementptr inbounds %struct.ai_error_, ptr %14, i32 0, i32 0
  store i32 %100, ptr %101, align 4
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %4, ptr align 4 %14, i64 4, i1 false), !tbaa.struct !9
  call void @llvm.lifetime.end.p0(i64 4, ptr %14) #4
  br label %102

102:                                              ; preds = %97, %91
  store i32 1, ptr %10, align 4
  br label %103

103:                                              ; preds = %102, %26, %21
  call void @llvm.lifetime.end.p0(i64 96, ptr %8) #4
  %104 = getelementptr inbounds %struct.ai_error_, ptr %4, i32 0, i32 0
  %105 = load i32, ptr %104, align 4
  ret i32 %105
}

declare zeroext i1 @ai_sww_model_data_params_get(ptr noundef) #3

declare zeroext i1 @ai_buffer_array_item_set_address(ptr noundef, i32 noundef, ptr noundef) #3

; Function Attrs: nounwind uwtable
declare dso_local zeroext i1 @ai_sww_model_init(ptr noundef, ptr noundef) #2

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { 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 = { "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 = !{i64 0, i64 4, !10}
!10 = !{!7, !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"

%struct.ai_network_params_ = type { %union.anon.1 }
%union.anon.1 = type { %struct.anon.2 }
%struct.anon.2 = type { %struct.ai_buffer_, %struct.ai_buffer_ }
%struct.ai_buffer_ = type { i32, ptr, ptr, i32, i32, %struct.ai_buffer_shape_ }
%struct.ai_buffer_shape_ = type { i32, ptr }

; 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: nounwind uwtable
declare dso_local i32 @ai_sww_model_get_error(ptr noundef) local_unnamed_addr #1

; Function Attrs: nounwind uwtable
declare dso_local i32 @ai_sww_model_create(ptr noundef, ptr noundef) local_unnamed_addr #1

; Function Attrs: nounwind uwtable
define dso_local i32 @ai_sww_model_create_and_init(ptr noundef %0, ptr noundef readonly %1, ptr noundef readonly %2) local_unnamed_addr #1 {
  %4 = alloca %struct.ai_network_params_, align 8
  call void @llvm.lifetime.start.p0(i64 96, ptr nonnull %4) #3
  %5 = tail call i32 @ai_sww_model_create(ptr noundef %0, ptr noundef null)
  %6 = and i32 %5, 255
  %.not = icmp eq i32 %6, 0
  br i1 %.not, label %7, label %41

7:                                                ; preds = %3
  %8 = call zeroext i1 @ai_sww_model_data_params_get(ptr noundef nonnull %4) #3
  br i1 %8, label %.preheader26, label %.sink.split

.preheader26:                                     ; preds = %7
  %9 = icmp ne ptr %1, null
  %10 = getelementptr inbounds i8, ptr %4, i64 26
  %11 = load i16, ptr %10, align 2
  %12 = icmp ne i16 %11, 0
  %13 = select i1 %9, i1 %12, i1 false
  br i1 %13, label %.lr.ph, label %.preheader

.lr.ph:                                           ; preds = %.preheader26
  %14 = getelementptr inbounds i8, ptr %4, i64 24
  br label %21

.preheader:                                       ; preds = %21, %.preheader26
  %15 = icmp ne ptr %2, null
  %16 = getelementptr inbounds i8, ptr %4, i64 10
  %17 = load i16, ptr %16, align 2
  %18 = icmp ne i16 %17, 0
  %19 = select i1 %15, i1 %18, i1 false
  br i1 %19, label %.lr.ph29, label %._crit_edge

.lr.ph29:                                         ; preds = %.preheader
  %20 = getelementptr inbounds i8, ptr %4, i64 8
  br label %31

21:                                               ; preds = %.lr.ph, %21
  %indvars.iv = phi i64 [ 0, %.lr.ph ], [ %indvars.iv.next, %21 ]
  %22 = trunc nuw i64 %indvars.iv to i32
  %23 = getelementptr inbounds ptr, ptr %1, i64 %indvars.iv
  %24 = load ptr, ptr %23, align 8, !tbaa !5
  %25 = call zeroext i1 @ai_buffer_array_item_set_address(ptr noundef nonnull %14, i32 noundef %22, ptr noundef %24) #3
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %26 = load i16, ptr %10, align 2
  %27 = zext i16 %26 to i64
  %28 = icmp ult i64 %indvars.iv.next, %27
  br i1 %28, label %21, label %.preheader, !llvm.loop !9

._crit_edge:                                      ; preds = %31, %.preheader
  %29 = load ptr, ptr %0, align 8, !tbaa !5
  %30 = call zeroext i1 @ai_sww_model_init(ptr noundef %29, ptr noundef nonnull %4)
  br i1 %30, label %41, label %.sink.split

31:                                               ; preds = %.lr.ph29, %31
  %indvars.iv31 = phi i64 [ 0, %.lr.ph29 ], [ %indvars.iv.next32, %31 ]
  %32 = trunc nuw i64 %indvars.iv31 to i32
  %33 = getelementptr inbounds ptr, ptr %2, i64 %indvars.iv31
  %34 = load ptr, ptr %33, align 8, !tbaa !5
  %35 = call zeroext i1 @ai_buffer_array_item_set_address(ptr noundef nonnull %20, i32 noundef %32, ptr noundef %34) #3
  %indvars.iv.next32 = add nuw nsw i64 %indvars.iv31, 1
  %36 = load i16, ptr %16, align 2
  %37 = zext i16 %36 to i64
  %38 = icmp ult i64 %indvars.iv.next32, %37
  br i1 %38, label %31, label %._crit_edge, !llvm.loop !11

.sink.split:                                      ; preds = %._crit_edge, %7
  %39 = load ptr, ptr %0, align 8, !tbaa !5
  %40 = call i32 @ai_sww_model_get_error(ptr noundef %39)
  br label %41

41:                                               ; preds = %.sink.split, %._crit_edge, %3
  %.sroa.017.1 = phi i32 [ %5, %3 ], [ %5, %._crit_edge ], [ %40, %.sink.split ]
  call void @llvm.lifetime.end.p0(i64 96, ptr nonnull %4) #3
  ret i32 %.sroa.017.1
}

declare zeroext i1 @ai_sww_model_data_params_get(ptr noundef) local_unnamed_addr #2

declare zeroext i1 @ai_buffer_array_item_set_address(ptr noundef, i32 noundef, ptr noundef) local_unnamed_addr #2

; Function Attrs: nounwind uwtable
declare dso_local zeroext i1 @ai_sww_model_init(ptr noundef, ptr noundef) local_unnamed_addr #1

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


; Effective O3 passes: CorrelatedValuePropagationPass,EarlyCSEPass,GlobalOptPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,LICMPass,LoopInstSimplifyPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass,TailCallElimPass