; LLVM IR from ybj366533/YY-Camera :: yy_soundtouch/src/main/jni/sonic (sonic)

; 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.sonicStreamStruct = type { ptr, ptr, ptr, ptr, float, float, float, float, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, float }

; 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: nounwind uwtable
define dso_local i32 @sonicFlushStream(ptr noundef %0) #1 {
  %2 = alloca i32, align 4
  %3 = alloca ptr, align 8
  %4 = alloca i32, align 4
  %5 = alloca i32, align 4
  %6 = alloca float, align 4
  %7 = alloca float, align 4
  %8 = alloca i32, align 4
  %9 = alloca i32, align 4
  store ptr %0, ptr %3, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #3
  %10 = load ptr, ptr %3, align 8, !tbaa !5
  %11 = getelementptr inbounds %struct.sonicStreamStruct, ptr %10, i32 0, i32 21
  %12 = load i32, ptr %11, align 4, !tbaa !9
  store i32 %12, ptr %4, align 4, !tbaa !13
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #3
  %13 = load ptr, ptr %3, align 8, !tbaa !5
  %14 = getelementptr inbounds %struct.sonicStreamStruct, ptr %13, i32 0, i32 16
  %15 = load i32, ptr %14, align 8, !tbaa !14
  store i32 %15, ptr %5, align 4, !tbaa !13
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #3
  %16 = load ptr, ptr %3, align 8, !tbaa !5
  %17 = getelementptr inbounds %struct.sonicStreamStruct, ptr %16, i32 0, i32 4
  %18 = load float, ptr %17, align 8, !tbaa !15
  %19 = load ptr, ptr %3, align 8, !tbaa !5
  %20 = getelementptr inbounds %struct.sonicStreamStruct, ptr %19, i32 0, i32 6
  %21 = load float, ptr %20, align 8, !tbaa !16
  %22 = fdiv float %18, %21
  store float %22, ptr %6, align 4, !tbaa !17
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #3
  %23 = load ptr, ptr %3, align 8, !tbaa !5
  %24 = getelementptr inbounds %struct.sonicStreamStruct, ptr %23, i32 0, i32 7
  %25 = load float, ptr %24, align 4, !tbaa !18
  %26 = load ptr, ptr %3, align 8, !tbaa !5
  %27 = getelementptr inbounds %struct.sonicStreamStruct, ptr %26, i32 0, i32 6
  %28 = load float, ptr %27, align 8, !tbaa !16
  %29 = fmul float %25, %28
  store float %29, ptr %7, align 4, !tbaa !17
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #3
  %30 = load ptr, ptr %3, align 8, !tbaa !5
  %31 = getelementptr inbounds %struct.sonicStreamStruct, ptr %30, i32 0, i32 17
  %32 = load i32, ptr %31, align 4, !tbaa !19
  %33 = load i32, ptr %5, align 4, !tbaa !13
  %34 = sitofp i32 %33 to float
  %35 = load float, ptr %6, align 4, !tbaa !17
  %36 = fdiv float %34, %35
  %37 = load ptr, ptr %3, align 8, !tbaa !5
  %38 = getelementptr inbounds %struct.sonicStreamStruct, ptr %37, i32 0, i32 18
  %39 = load i32, ptr %38, align 8, !tbaa !20
  %40 = sitofp i32 %39 to float
  %41 = fadd float %36, %40
  %42 = load float, ptr %7, align 4, !tbaa !17
  %43 = fdiv float %41, %42
  %44 = fadd float %43, 5.000000e-01
  %45 = fptosi float %44 to i32
  %46 = add nsw i32 %32, %45
  store i32 %46, ptr %8, align 4, !tbaa !13
  %47 = load ptr, ptr %3, align 8, !tbaa !5
  %48 = load i32, ptr %5, align 4, !tbaa !13
  %49 = load i32, ptr %4, align 4, !tbaa !13
  %50 = mul nsw i32 2, %49
  %51 = add nsw i32 %48, %50
  %52 = call i32 @enlargeInputBufferIfNeeded(ptr noundef %47, i32 noundef %51)
  %53 = icmp ne i32 %52, 0
  br i1 %53, label %55, label %54

54:                                               ; preds = %1
  store i32 0, ptr %2, align 4
  store i32 1, ptr %9, align 4
  br label %102

55:                                               ; preds = %1
  %56 = load ptr, ptr %3, align 8, !tbaa !5
  %57 = getelementptr inbounds %struct.sonicStreamStruct, ptr %56, i32 0, i32 0
  %58 = load ptr, ptr %57, align 8, !tbaa !21
  %59 = load i32, ptr %5, align 4, !tbaa !13
  %60 = load ptr, ptr %3, align 8, !tbaa !5
  %61 = getelementptr inbounds %struct.sonicStreamStruct, ptr %60, i32 0, i32 12
  %62 = load i32, ptr %61, align 8, !tbaa !22
  %63 = mul nsw i32 %59, %62
  %64 = sext i32 %63 to i64
  %65 = getelementptr inbounds i16, ptr %58, i64 %64
  %66 = load i32, ptr %4, align 4, !tbaa !13
  %67 = mul nsw i32 2, %66
  %68 = sext i32 %67 to i64
  %69 = mul i64 %68, 2
  %70 = load ptr, ptr %3, align 8, !tbaa !5
  %71 = getelementptr inbounds %struct.sonicStreamStruct, ptr %70, i32 0, i32 12
  %72 = load i32, ptr %71, align 8, !tbaa !22
  %73 = sext i32 %72 to i64
  %74 = mul i64 %69, %73
  call void @llvm.memset.p0.i64(ptr align 2 %65, i8 0, i64 %74, i1 false)
  %75 = load i32, ptr %4, align 4, !tbaa !13
  %76 = mul nsw i32 2, %75
  %77 = load ptr, ptr %3, align 8, !tbaa !5
  %78 = getelementptr inbounds %struct.sonicStreamStruct, ptr %77, i32 0, i32 16
  %79 = load i32, ptr %78, align 8, !tbaa !14
  %80 = add nsw i32 %79, %76
  store i32 %80, ptr %78, align 8, !tbaa !14
  %81 = load ptr, ptr %3, align 8, !tbaa !5
  %82 = call i32 @sonicWriteShortToStream(ptr noundef %81, ptr noundef null, i32 noundef 0)
  %83 = icmp ne i32 %82, 0
  br i1 %83, label %85, label %84

84:                                               ; preds = %55
  store i32 0, ptr %2, align 4
  store i32 1, ptr %9, align 4
  br label %102

85:                                               ; preds = %55
  %86 = load ptr, ptr %3, align 8, !tbaa !5
  %87 = getelementptr inbounds %struct.sonicStreamStruct, ptr %86, i32 0, i32 17
  %88 = load i32, ptr %87, align 4, !tbaa !19
  %89 = load i32, ptr %8, align 4, !tbaa !13
  %90 = icmp sgt i32 %88, %89
  br i1 %90, label %91, label %95

91:                                               ; preds = %85
  %92 = load i32, ptr %8, align 4, !tbaa !13
  %93 = load ptr, ptr %3, align 8, !tbaa !5
  %94 = getelementptr inbounds %struct.sonicStreamStruct, ptr %93, i32 0, i32 17
  store i32 %92, ptr %94, align 4, !tbaa !19
  br label %95

95:                                               ; preds = %91, %85
  %96 = load ptr, ptr %3, align 8, !tbaa !5
  %97 = getelementptr inbounds %struct.sonicStreamStruct, ptr %96, i32 0, i32 16
  store i32 0, ptr %97, align 8, !tbaa !14
  %98 = load ptr, ptr %3, align 8, !tbaa !5
  %99 = getelementptr inbounds %struct.sonicStreamStruct, ptr %98, i32 0, i32 22
  store i32 0, ptr %99, align 8, !tbaa !23
  %100 = load ptr, ptr %3, align 8, !tbaa !5
  %101 = getelementptr inbounds %struct.sonicStreamStruct, ptr %100, i32 0, i32 18
  store i32 0, ptr %101, align 8, !tbaa !20
  store i32 1, ptr %2, align 4
  store i32 1, ptr %9, align 4
  br label %102

102:                                              ; preds = %95, %84, %54
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #3
  %103 = load i32, ptr %2, align 4
  ret i32 %103
}

; Function Attrs: nounwind uwtable
declare hidden i32 @enlargeInputBufferIfNeeded(ptr noundef, i32 noundef) #1

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #2

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

attributes #0 = { 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 = { nocallback nofree nounwind willreturn memory(argmem: write) }
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 = !{!10, !12, i64 100}
!10 = !{!"sonicStreamStruct", !6, i64 0, !6, i64 8, !6, i64 16, !6, i64 24, !11, i64 32, !11, i64 36, !11, i64 40, !11, i64 44, !12, i64 48, !12, i64 52, !12, i64 56, !12, i64 60, !12, i64 64, !12, i64 68, !12, i64 72, !12, i64 76, !12, i64 80, !12, i64 84, !12, i64 88, !12, i64 92, !12, i64 96, !12, i64 100, !12, i64 104, !12, i64 108, !12, i64 112, !12, i64 116, !11, i64 120}
!11 = !{!"float", !7, i64 0}
!12 = !{!"int", !7, i64 0}
!13 = !{!12, !12, i64 0}
!14 = !{!10, !12, i64 80}
!15 = !{!10, !11, i64 32}
!16 = !{!10, !11, i64 40}
!17 = !{!11, !11, i64 0}
!18 = !{!10, !11, i64 44}
!19 = !{!10, !12, i64 84}
!20 = !{!10, !12, i64 88}
!21 = !{!10, !6, i64 0}
!22 = !{!10, !12, i64 64}
!23 = !{!10, !12, i64 104}


; 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: nounwind uwtable
define dso_local range(i32 0, 2) i32 @sonicFlushStream(ptr noundef %0) local_unnamed_addr #0 {
  %2 = getelementptr inbounds i8, ptr %0, i64 100
  %3 = load i32, ptr %2, align 4, !tbaa !5
  %4 = getelementptr inbounds i8, ptr %0, i64 80
  %5 = load i32, ptr %4, align 8, !tbaa !12
  %6 = getelementptr inbounds i8, ptr %0, i64 32
  %7 = load float, ptr %6, align 8, !tbaa !13
  %8 = getelementptr inbounds i8, ptr %0, i64 40
  %9 = load float, ptr %8, align 8, !tbaa !14
  %10 = fdiv float %7, %9
  %11 = getelementptr inbounds i8, ptr %0, i64 44
  %12 = load float, ptr %11, align 4, !tbaa !15
  %13 = fmul float %9, %12
  %14 = getelementptr inbounds i8, ptr %0, i64 84
  %15 = load i32, ptr %14, align 4, !tbaa !16
  %16 = sitofp i32 %5 to float
  %17 = fdiv float %16, %10
  %18 = getelementptr inbounds i8, ptr %0, i64 88
  %19 = load i32, ptr %18, align 8, !tbaa !17
  %20 = sitofp i32 %19 to float
  %21 = fadd float %17, %20
  %22 = fdiv float %21, %13
  %23 = fadd float %22, 5.000000e-01
  %24 = fptosi float %23 to i32
  %25 = add nsw i32 %15, %24
  %26 = shl nsw i32 %3, 1
  %27 = add nsw i32 %5, %26
  %28 = tail call i32 @enlargeInputBufferIfNeeded(ptr noundef %0, i32 noundef %27)
  %.not = icmp eq i32 %28, 0
  br i1 %.not, label %49, label %29

29:                                               ; preds = %1
  %30 = load ptr, ptr %0, align 8, !tbaa !18
  %31 = getelementptr inbounds i8, ptr %0, i64 64
  %32 = load i32, ptr %31, align 8, !tbaa !19
  %33 = mul nsw i32 %32, %5
  %34 = sext i32 %33 to i64
  %35 = getelementptr inbounds i16, ptr %30, i64 %34
  %36 = sext i32 %26 to i64
  %37 = shl nsw i64 %36, 1
  %38 = sext i32 %32 to i64
  %39 = mul i64 %37, %38
  tail call void @llvm.memset.p0.i64(ptr align 2 %35, i8 0, i64 %39, i1 false)
  %40 = load i32, ptr %4, align 8, !tbaa !12
  %41 = add nsw i32 %40, %26
  store i32 %41, ptr %4, align 8, !tbaa !12
  %42 = tail call i32 @sonicWriteShortToStream(ptr noundef nonnull %0, ptr noundef null, i32 noundef 0)
  %.not30 = icmp eq i32 %42, 0
  br i1 %.not30, label %49, label %43

43:                                               ; preds = %29
  %44 = load i32, ptr %14, align 4, !tbaa !16
  %45 = icmp sgt i32 %44, %25
  br i1 %45, label %46, label %47

46:                                               ; preds = %43
  store i32 %25, ptr %14, align 4, !tbaa !16
  br label %47

47:                                               ; preds = %46, %43
  store i32 0, ptr %4, align 8, !tbaa !12
  %48 = getelementptr inbounds i8, ptr %0, i64 104
  store i32 0, ptr %48, align 8, !tbaa !20
  store i32 0, ptr %18, align 8, !tbaa !17
  br label %49

49:                                               ; preds = %29, %1, %47
  %.0 = phi i32 [ 1, %47 ], [ 0, %1 ], [ 0, %29 ]
  ret i32 %.0
}

; Function Attrs: nounwind uwtable
declare hidden i32 @enlargeInputBufferIfNeeded(ptr noundef, i32 noundef) local_unnamed_addr #0

; Function Attrs: mustprogress nocallback nofree nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #1

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

attributes #0 = { 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 #1 = { mustprogress nocallback nofree nounwind willreturn memory(argmem: write) }

!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 100}
!6 = !{!"sonicStreamStruct", !7, i64 0, !7, i64 8, !7, i64 16, !7, i64 24, !10, i64 32, !10, i64 36, !10, i64 40, !10, i64 44, !11, i64 48, !11, i64 52, !11, i64 56, !11, i64 60, !11, i64 64, !11, i64 68, !11, i64 72, !11, i64 76, !11, i64 80, !11, i64 84, !11, i64 88, !11, i64 92, !11, i64 96, !11, i64 100, !11, i64 104, !11, i64 108, !11, i64 112, !11, i64 116, !10, i64 120}
!7 = !{!"any pointer", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"float", !8, i64 0}
!11 = !{!"int", !8, i64 0}
!12 = !{!6, !11, i64 80}
!13 = !{!6, !10, i64 32}
!14 = !{!6, !10, i64 40}
!15 = !{!6, !10, i64 44}
!16 = !{!6, !11, i64 84}
!17 = !{!6, !11, i64 88}
!18 = !{!6, !7, i64 0}
!19 = !{!6, !11, i64 64}
!20 = !{!6, !11, i64 104}


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