; LLVM IR from Overload-Technologies/Overload :: Dependencies/soloud/src/audiosource/vizsn/soloud_vizsn.ll (ZN6SoLoud5Vizsn7setTextEPc)

; 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.SoLoud::Vizsn" = type { %"class.SoLoud::AudioSource", ptr }
%"class.SoLoud::AudioSource" = type { ptr, i32, float, float, i32, i32, float, float, float, i32, float, [8 x ptr], ptr, ptr, ptr, i32, double }

@_ZL4keyz = external hidden constant [28 x i8], align 16

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

declare void @_ZN6SoLoud11AudioSource4stopEv(ptr noundef nonnull align 8 dereferenceable(152)) #2

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN6SoLoud5Vizsn7setTextEPc(ptr noundef nonnull align 8 dereferenceable(160) %0, ptr noundef %1) #3 align 2 {
  %3 = alloca ptr, align 8
  %4 = alloca ptr, align 8
  %5 = alloca i32, align 4
  %6 = alloca i32, align 4
  %7 = alloca i32, align 4
  store ptr %0, ptr %3, align 8, !tbaa !5
  store ptr %1, ptr %4, align 8, !tbaa !5
  %8 = load ptr, ptr %3, align 8
  %9 = load ptr, ptr %4, align 8, !tbaa !5
  %10 = icmp ne ptr %9, null
  br i1 %10, label %12, label %11

11:                                               ; preds = %2
  br label %97

12:                                               ; preds = %2
  call void @_ZN6SoLoud11AudioSource4stopEv(ptr noundef nonnull align 8 dereferenceable(152) %8)
  %13 = getelementptr inbounds %"class.SoLoud::Vizsn", ptr %8, i32 0, i32 1
  %14 = load ptr, ptr %13, align 8, !tbaa !9
  %15 = icmp eq ptr %14, null
  br i1 %15, label %17, label %16

16:                                               ; preds = %12
  call void @_ZdaPv(ptr noundef %14) #7
  br label %17

17:                                               ; preds = %16, %12
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #8
  %18 = load ptr, ptr %4, align 8, !tbaa !5
  %19 = call i64 @strlen(ptr noundef %18) #9
  %20 = trunc i64 %19 to i32
  store i32 %20, ptr %5, align 4, !tbaa !15
  %21 = load i32, ptr %5, align 4, !tbaa !15
  %22 = add nsw i32 %21, 3
  %23 = sext i32 %22 to i64
  %24 = call noalias noundef nonnull ptr @_Znam(i64 noundef %23) #10
  %25 = getelementptr inbounds %"class.SoLoud::Vizsn", ptr %8, i32 0, i32 1
  store ptr %24, ptr %25, align 8, !tbaa !9
  %26 = getelementptr inbounds %"class.SoLoud::Vizsn", ptr %8, i32 0, i32 1
  %27 = load ptr, ptr %26, align 8, !tbaa !9
  %28 = getelementptr inbounds i8, ptr %27, i64 1
  %29 = load ptr, ptr %4, align 8, !tbaa !5
  %30 = load i32, ptr %5, align 4, !tbaa !15
  %31 = sext i32 %30 to i64
  call void @llvm.memcpy.p0.p0.i64(ptr align 1 %28, ptr align 1 %29, i64 %31, i1 false)
  %32 = getelementptr inbounds %"class.SoLoud::Vizsn", ptr %8, i32 0, i32 1
  %33 = load ptr, ptr %32, align 8, !tbaa !9
  %34 = getelementptr inbounds i8, ptr %33, i64 0
  store i8 -2, ptr %34, align 1, !tbaa !16
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #8
  store i32 0, ptr %6, align 4, !tbaa !15
  br label %35

35:                                               ; preds = %81, %17
  %36 = load i32, ptr %6, align 4, !tbaa !15
  %37 = load i32, ptr %5, align 4, !tbaa !15
  %38 = icmp slt i32 %36, %37
  br i1 %38, label %39, label %84

39:                                               ; preds = %35
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #8
  %40 = getelementptr inbounds %"class.SoLoud::Vizsn", ptr %8, i32 0, i32 1
  %41 = load ptr, ptr %40, align 8, !tbaa !9
  %42 = load i32, ptr %6, align 4, !tbaa !15
  %43 = add nsw i32 %42, 1
  %44 = sext i32 %43 to i64
  %45 = getelementptr inbounds i8, ptr %41, i64 %44
  %46 = load i8, ptr %45, align 1, !tbaa !16
  %47 = sext i8 %46 to i32
  store i32 %47, ptr %7, align 4, !tbaa !15
  %48 = load i32, ptr %7, align 4, !tbaa !15
  %49 = icmp eq i32 %48, -124
  br i1 %49, label %50, label %51

50:                                               ; preds = %39
  store i32 123, ptr %7, align 4, !tbaa !15
  br label %51

51:                                               ; preds = %50, %39
  %52 = load i32, ptr %7, align 4, !tbaa !15
  %53 = icmp eq i32 %52, -108
  br i1 %53, label %54, label %55

54:                                               ; preds = %51
  store i32 124, ptr %7, align 4, !tbaa !15
  br label %55

55:                                               ; preds = %54, %51
  %56 = load i32, ptr %7, align 4, !tbaa !15
  %57 = icmp sge i32 %56, 97
  br i1 %57, label %58, label %73

58:                                               ; preds = %55
  %59 = load i32, ptr %7, align 4, !tbaa !15
  %60 = icmp sle i32 %59, 124
  br i1 %60, label %61, label %73

61:                                               ; preds = %58
  %62 = load i32, ptr %7, align 4, !tbaa !15
  %63 = sub nsw i32 %62, 97
  %64 = sext i32 %63 to i64
  %65 = getelementptr inbounds [28 x i8], ptr @_ZL4keyz, i64 0, i64 %64
  %66 = load i8, ptr %65, align 1, !tbaa !16
  %67 = getelementptr inbounds %"class.SoLoud::Vizsn", ptr %8, i32 0, i32 1
  %68 = load ptr, ptr %67, align 8, !tbaa !9
  %69 = load i32, ptr %6, align 4, !tbaa !15
  %70 = add nsw i32 %69, 1
  %71 = sext i32 %70 to i64
  %72 = getelementptr inbounds i8, ptr %68, i64 %71
  store i8 %66, ptr %72, align 1, !tbaa !16
  br label %80

73:                                               ; preds = %58, %55
  %74 = getelementptr inbounds %"class.SoLoud::Vizsn", ptr %8, i32 0, i32 1
  %75 = load ptr, ptr %74, align 8, !tbaa !9
  %76 = load i32, ptr %6, align 4, !tbaa !15
  %77 = add nsw i32 %76, 1
  %78 = sext i32 %77 to i64
  %79 = getelementptr inbounds i8, ptr %75, i64 %78
  store i8 -2, ptr %79, align 1, !tbaa !16
  br label %80

80:                                               ; preds = %73, %61
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #8
  br label %81

81:                                               ; preds = %80
  %82 = load i32, ptr %6, align 4, !tbaa !15
  %83 = add nsw i32 %82, 1
  store i32 %83, ptr %6, align 4, !tbaa !15
  br label %35, !llvm.loop !17

84:                                               ; preds = %35
  %85 = getelementptr inbounds %"class.SoLoud::Vizsn", ptr %8, i32 0, i32 1
  %86 = load ptr, ptr %85, align 8, !tbaa !9
  %87 = load i32, ptr %5, align 4, !tbaa !15
  %88 = add nsw i32 %87, 1
  %89 = sext i32 %88 to i64
  %90 = getelementptr inbounds i8, ptr %86, i64 %89
  store i8 -1, ptr %90, align 1, !tbaa !16
  %91 = getelementptr inbounds %"class.SoLoud::Vizsn", ptr %8, i32 0, i32 1
  %92 = load ptr, ptr %91, align 8, !tbaa !9
  %93 = load i32, ptr %5, align 4, !tbaa !15
  %94 = add nsw i32 %93, 2
  %95 = sext i32 %94 to i64
  %96 = getelementptr inbounds i8, ptr %92, i64 %95
  store i8 0, ptr %96, align 1, !tbaa !16
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #8
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #8
  br label %97

97:                                               ; preds = %84, %11
  ret void
}

; Function Attrs: nobuiltin nounwind
declare void @_ZdaPv(ptr noundef) #4

; Function Attrs: nounwind willreturn memory(read)
declare i64 @strlen(ptr noundef) #5

; Function Attrs: nobuiltin allocsize(0)
declare noundef nonnull ptr @_Znam(i64 noundef) #6

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
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 = { 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 #4 = { nobuiltin 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 #5 = { nounwind willreturn memory(read) "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 #6 = { nobuiltin allocsize(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 #7 = { builtin nounwind }
attributes #8 = { nounwind }
attributes #9 = { nounwind willreturn memory(read) }
attributes #10 = { builtin allocsize(0) }

!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, !6, i64 152}
!10 = !{!"_ZTSN6SoLoud5VizsnE", !11, i64 0, !6, i64 152}
!11 = !{!"_ZTSN6SoLoud11AudioSourceE", !12, i64 8, !13, i64 12, !13, i64 16, !12, i64 20, !12, i64 24, !13, i64 28, !13, i64 32, !13, i64 36, !12, i64 40, !13, i64 44, !7, i64 48, !6, i64 112, !6, i64 120, !6, i64 128, !12, i64 136, !14, i64 144}
!12 = !{!"int", !7, i64 0}
!13 = !{!"float", !7, i64 0}
!14 = !{!"double", !7, i64 0}
!15 = !{!12, !12, i64 0}
!16 = !{!7, !7, i64 0}
!17 = distinct !{!17, !18}
!18 = !{!"llvm.loop.mustprogress"}


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

@_ZL4keyz = external hidden local_unnamed_addr constant [28 x i8], align 16

; Function Attrs: mustprogress 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) #0

declare void @_ZN6SoLoud11AudioSource4stopEv(ptr noundef nonnull align 8 dereferenceable(152)) local_unnamed_addr #1

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN6SoLoud5Vizsn7setTextEPc(ptr noundef nonnull align 8 dereferenceable(160) %0, ptr noundef readonly %1) local_unnamed_addr #2 align 2 {
  %.not = icmp eq ptr %1, null
  br i1 %.not, label %35, label %3

3:                                                ; preds = %2
  tail call void @_ZN6SoLoud11AudioSource4stopEv(ptr noundef nonnull align 8 dereferenceable(152) %0)
  %4 = getelementptr inbounds i8, ptr %0, i64 152
  %5 = load ptr, ptr %4, align 8, !tbaa !5
  %6 = icmp eq ptr %5, null
  br i1 %6, label %8, label %7

7:                                                ; preds = %3
  tail call void @_ZdaPv(ptr noundef nonnull %5) #6
  br label %8

8:                                                ; preds = %7, %3
  %9 = tail call i64 @strlen(ptr noundef nonnull dereferenceable(1) %1) #7
  %10 = trunc i64 %9 to i32
  %11 = shl i64 %9, 32
  %sext = add i64 %11, 12884901888
  %12 = ashr exact i64 %sext, 32
  %13 = tail call noalias noundef nonnull ptr @_Znam(i64 noundef %12) #8
  store ptr %13, ptr %4, align 8, !tbaa !5
  %14 = getelementptr inbounds i8, ptr %13, i64 1
  %15 = ashr exact i64 %11, 32
  tail call void @llvm.memcpy.p0.p0.i64(ptr nonnull align 1 %14, ptr nonnull align 1 %1, i64 %15, i1 false)
  store i8 -2, ptr %13, align 1, !tbaa !14
  %16 = icmp sgt i32 %10, 0
  br i1 %16, label %.lr.ph.preheader, label %._crit_edge

.lr.ph.preheader:                                 ; preds = %8
  %wide.trip.count = and i64 %9, 2147483647
  br label %.lr.ph

.lr.ph:                                           ; preds = %.lr.ph.preheader, %28
  %indvars.iv = phi i64 [ 0, %.lr.ph.preheader ], [ %indvars.iv.next, %28 ]
  %17 = load ptr, ptr %4, align 8, !tbaa !5
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %18 = getelementptr inbounds i8, ptr %17, i64 %indvars.iv.next
  %19 = load i8, ptr %18, align 1, !tbaa !14
  %20 = icmp eq i8 %19, -124
  %narrow = select i1 %20, i8 123, i8 %19
  %21 = icmp eq i8 %narrow, -108
  %narrow26 = select i1 %21, i8 124, i8 %narrow
  %22 = add i8 %narrow26, -97
  %or.cond = icmp ult i8 %22, 28
  br i1 %or.cond, label %23, label %28

23:                                               ; preds = %.lr.ph
  %spec.store.select2 = zext nneg i8 %narrow26 to i64
  %24 = add nuw nsw i64 %spec.store.select2, 4294967199
  %25 = and i64 %24, 4294967295
  %26 = getelementptr inbounds [28 x i8], ptr @_ZL4keyz, i64 0, i64 %25
  %27 = load i8, ptr %26, align 1, !tbaa !14
  br label %28

28:                                               ; preds = %.lr.ph, %23
  %storemerge = phi i8 [ %27, %23 ], [ -2, %.lr.ph ]
  store i8 %storemerge, ptr %18, align 1, !tbaa !14
  %exitcond.not = icmp eq i64 %indvars.iv.next, %wide.trip.count
  br i1 %exitcond.not, label %._crit_edge.loopexit, label %.lr.ph, !llvm.loop !15

._crit_edge.loopexit:                             ; preds = %28
  %.pre = load ptr, ptr %4, align 8, !tbaa !5
  br label %._crit_edge

._crit_edge:                                      ; preds = %._crit_edge.loopexit, %8
  %29 = phi ptr [ %.pre, %._crit_edge.loopexit ], [ %13, %8 ]
  %sext24 = add i64 %11, 4294967296
  %30 = ashr exact i64 %sext24, 32
  %31 = getelementptr inbounds i8, ptr %29, i64 %30
  store i8 -1, ptr %31, align 1, !tbaa !14
  %32 = load ptr, ptr %4, align 8, !tbaa !5
  %sext25 = add i64 %11, 8589934592
  %33 = ashr exact i64 %sext25, 32
  %34 = getelementptr inbounds i8, ptr %32, i64 %33
  store i8 0, ptr %34, align 1, !tbaa !14
  br label %35

35:                                               ; preds = %2, %._crit_edge
  ret void
}

; Function Attrs: nobuiltin nounwind
declare void @_ZdaPv(ptr noundef) local_unnamed_addr #3

; Function Attrs: mustprogress nofree nounwind willreturn memory(argmem: read)
declare i64 @strlen(ptr nocapture noundef) local_unnamed_addr #4

; Function Attrs: nobuiltin allocsize(0)
declare noundef nonnull ptr @_Znam(i64 noundef) local_unnamed_addr #5

attributes #0 = { mustprogress nocallback nofree 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 = { 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 = { nobuiltin 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 #4 = { mustprogress nofree nounwind willreturn memory(argmem: read) "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 #5 = { nobuiltin allocsize(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 #6 = { builtin nounwind }
attributes #7 = { nounwind willreturn memory(read) }
attributes #8 = { builtin allocsize(0) }

!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, !12, i64 152}
!6 = !{!"_ZTSN6SoLoud5VizsnE", !7, i64 0, !12, i64 152}
!7 = !{!"_ZTSN6SoLoud11AudioSourceE", !8, i64 8, !11, i64 12, !11, i64 16, !8, i64 20, !8, i64 24, !11, i64 28, !11, i64 32, !11, i64 36, !8, i64 40, !11, i64 44, !9, i64 48, !12, i64 112, !12, i64 120, !12, i64 128, !8, i64 136, !13, i64 144}
!8 = !{!"int", !9, i64 0}
!9 = !{!"omnipotent char", !10, i64 0}
!10 = !{!"Simple C++ TBAA"}
!11 = !{!"float", !9, i64 0}
!12 = !{!"any pointer", !9, i64 0}
!13 = !{!"double", !9, i64 0}
!14 = !{!9, !9, i64 0}
!15 = distinct !{!15, !16}
!16 = !{!"llvm.loop.mustprogress"}


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