; LLVM IR from NVIDIA/tensorflow :: tensorflow/lite/experimental/micro/examples/micro_speech/micro_features/pcan_g_6c750051 (Z19WideDynamicFunctionjPKs)

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

; Function Attrs: mustprogress uwtable
define dso_local noundef signext i16 @_Z19WideDynamicFunctionjPKs(i32 noundef %0, ptr noundef %1) #0 {
  %3 = alloca i16, align 2
  %4 = alloca i32, align 4
  %5 = alloca ptr, align 8
  %6 = alloca i16, align 2
  %7 = alloca i16, align 2
  %8 = alloca i32, align 4
  store i32 %0, ptr %4, align 4, !tbaa !5
  store ptr %1, ptr %5, align 8, !tbaa !9
  %9 = load i32, ptr %4, align 4, !tbaa !5
  %10 = icmp ule i32 %9, 2
  br i1 %10, label %11, label %17

11:                                               ; preds = %2
  %12 = load ptr, ptr %5, align 8, !tbaa !9
  %13 = load i32, ptr %4, align 4, !tbaa !5
  %14 = zext i32 %13 to i64
  %15 = getelementptr inbounds i16, ptr %12, i64 %14
  %16 = load i16, ptr %15, align 2, !tbaa !11
  store i16 %16, ptr %3, align 2
  br label %77

17:                                               ; preds = %2
  call void @llvm.lifetime.start.p0(i64 2, ptr %6) #3
  %18 = load i32, ptr %4, align 4, !tbaa !5
  %19 = call noundef i32 @_ZL20MostSignificantBit32j(i32 noundef %18)
  %20 = trunc i32 %19 to i16
  store i16 %20, ptr %6, align 2, !tbaa !11
  %21 = load i16, ptr %6, align 2, !tbaa !11
  %22 = sext i16 %21 to i32
  %23 = mul nsw i32 4, %22
  %24 = sub nsw i32 %23, 6
  %25 = load ptr, ptr %5, align 8, !tbaa !9
  %26 = sext i32 %24 to i64
  %27 = getelementptr inbounds i16, ptr %25, i64 %26
  store ptr %27, ptr %5, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 2, ptr %7) #3
  %28 = load i16, ptr %6, align 2, !tbaa !11
  %29 = sext i16 %28 to i32
  %30 = icmp slt i32 %29, 11
  br i1 %30, label %31, label %37

31:                                               ; preds = %17
  %32 = load i32, ptr %4, align 4, !tbaa !5
  %33 = load i16, ptr %6, align 2, !tbaa !11
  %34 = sext i16 %33 to i32
  %35 = sub nsw i32 11, %34
  %36 = shl i32 %32, %35
  br label %43

37:                                               ; preds = %17
  %38 = load i32, ptr %4, align 4, !tbaa !5
  %39 = load i16, ptr %6, align 2, !tbaa !11
  %40 = sext i16 %39 to i32
  %41 = sub nsw i32 %40, 11
  %42 = lshr i32 %38, %41
  br label %43

43:                                               ; preds = %37, %31
  %44 = phi i32 [ %36, %31 ], [ %42, %37 ]
  %45 = and i32 %44, 1023
  %46 = trunc i32 %45 to i16
  store i16 %46, ptr %7, align 2, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #3
  %47 = load ptr, ptr %5, align 8, !tbaa !9
  %48 = getelementptr inbounds i16, ptr %47, i64 2
  %49 = load i16, ptr %48, align 2, !tbaa !11
  %50 = sext i16 %49 to i32
  %51 = load i16, ptr %7, align 2, !tbaa !11
  %52 = sext i16 %51 to i32
  %53 = mul nsw i32 %50, %52
  %54 = ashr i32 %53, 5
  store i32 %54, ptr %8, align 4, !tbaa !5
  %55 = load ptr, ptr %5, align 8, !tbaa !9
  %56 = getelementptr inbounds i16, ptr %55, i64 1
  %57 = load i16, ptr %56, align 2, !tbaa !11
  %58 = sext i16 %57 to i32
  %59 = shl i32 %58, 5
  %60 = load i32, ptr %8, align 4, !tbaa !5
  %61 = add nsw i32 %60, %59
  store i32 %61, ptr %8, align 4, !tbaa !5
  %62 = load i16, ptr %7, align 2, !tbaa !11
  %63 = sext i16 %62 to i32
  %64 = load i32, ptr %8, align 4, !tbaa !5
  %65 = mul nsw i32 %64, %63
  store i32 %65, ptr %8, align 4, !tbaa !5
  %66 = load i32, ptr %8, align 4, !tbaa !5
  %67 = add nsw i32 %66, 16384
  %68 = ashr i32 %67, 15
  store i32 %68, ptr %8, align 4, !tbaa !5
  %69 = load ptr, ptr %5, align 8, !tbaa !9
  %70 = getelementptr inbounds i16, ptr %69, i64 0
  %71 = load i16, ptr %70, align 2, !tbaa !11
  %72 = sext i16 %71 to i32
  %73 = load i32, ptr %8, align 4, !tbaa !5
  %74 = add nsw i32 %73, %72
  store i32 %74, ptr %8, align 4, !tbaa !5
  %75 = load i32, ptr %8, align 4, !tbaa !5
  %76 = trunc i32 %75 to i16
  store i16 %76, ptr %3, align 2
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #3
  call void @llvm.lifetime.end.p0(i64 2, ptr %7) #3
  call void @llvm.lifetime.end.p0(i64 2, ptr %6) #3
  br label %77

77:                                               ; preds = %43, %11
  %78 = load i16, ptr %3, align 2
  ret i16 %78
}

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

; Function Attrs: inlinehint mustprogress uwtable
declare hidden noundef i32 @_ZL20MostSignificantBit32j(i32 noundef) #2

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

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 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { 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 #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 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"any pointer", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"short", !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"

; Function Attrs: mustprogress uwtable
define dso_local noundef signext i16 @_Z19WideDynamicFunctionjPKs(i32 noundef %0, ptr nocapture noundef readonly %1) local_unnamed_addr #0 {
  %3 = icmp ult i32 %0, 3
  br i1 %3, label %4, label %8

4:                                                ; preds = %2
  %5 = zext nneg i32 %0 to i64
  %6 = getelementptr inbounds i16, ptr %1, i64 %5
  %7 = load i16, ptr %6, align 2, !tbaa !5
  br label %38

8:                                                ; preds = %2
  %9 = tail call noundef i32 @_ZL20MostSignificantBit32j(i32 noundef %0)
  %sext = shl i32 %9, 16
  %10 = ashr exact i32 %sext, 16
  %11 = ashr exact i32 %sext, 14
  %12 = sext i32 %11 to i64
  %13 = getelementptr i16, ptr %1, i64 %12
  %14 = getelementptr i8, ptr %13, i64 -12
  %15 = icmp slt i32 %10, 11
  %16 = sub nsw i32 11, %10
  %17 = shl i32 %0, %16
  %18 = add nsw i32 %10, -11
  %19 = lshr i32 %0, %18
  %20 = select i1 %15, i32 %17, i32 %19
  %21 = and i32 %20, 1023
  %22 = getelementptr i8, ptr %13, i64 -8
  %23 = load i16, ptr %22, align 2, !tbaa !5
  %24 = sext i16 %23 to i32
  %25 = mul nsw i32 %21, %24
  %26 = ashr i32 %25, 5
  %27 = getelementptr i8, ptr %13, i64 -10
  %28 = load i16, ptr %27, align 2, !tbaa !5
  %29 = sext i16 %28 to i32
  %30 = shl nsw i32 %29, 5
  %31 = add nsw i32 %26, %30
  %32 = mul nsw i32 %31, %21
  %33 = add nsw i32 %32, 16384
  %34 = lshr i32 %33, 15
  %35 = load i16, ptr %14, align 2, !tbaa !5
  %36 = trunc i32 %34 to i16
  %37 = add i16 %35, %36
  br label %38

38:                                               ; preds = %8, %4
  %.0 = phi i16 [ %7, %4 ], [ %37, %8 ]
  ret i16 %.0
}

; Function Attrs: inlinehint mustprogress uwtable
declare hidden noundef i32 @_ZL20MostSignificantBit32j(i32 noundef) local_unnamed_addr #1

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 = { 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" }

!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++ TBAA"}


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