; LLVM IR from jgaeddert/liquid-dsp :: scripts (autoscript)

; 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.autoscript_s = type { [256 x i8], i8, i32, ptr }
%struct.package_s = type { [256 x i8], [256 x i8], ptr, i32 }

@stderr = external global ptr, align 8
@.str.42 = external hidden unnamed_addr constant [49 x i8], align 1
@.str.43 = external hidden unnamed_addr constant [6 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

; Function Attrs: nounwind
declare ptr @strncpy(ptr noundef, ptr noundef, i64 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
declare i32 @fprintf(ptr noundef, ptr noundef, ...) #1

; Function Attrs: noreturn nounwind
declare void @exit(i32 noundef) #2

; Function Attrs: nounwind uwtable
define dso_local void @autoscript_addpackage(ptr noundef %0, ptr noundef %1, ptr noundef %2) #3 {
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca i32, align 4
  store ptr %0, ptr %4, align 8, !tbaa !5
  store ptr %1, ptr %5, align 8, !tbaa !5
  store ptr %2, ptr %6, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #6
  store i32 0, ptr %7, align 4, !tbaa !9
  br label %8

8:                                                ; preds = %44, %3
  %9 = load i32, ptr %7, align 4, !tbaa !9
  %10 = load ptr, ptr %4, align 8, !tbaa !5
  %11 = getelementptr inbounds %struct.autoscript_s, ptr %10, i32 0, i32 2
  %12 = load i32, ptr %11, align 4, !tbaa !11
  %13 = icmp ult i32 %9, %12
  br i1 %13, label %14, label %47

14:                                               ; preds = %8
  %15 = load ptr, ptr %4, align 8, !tbaa !5
  %16 = getelementptr inbounds %struct.autoscript_s, ptr %15, i32 0, i32 3
  %17 = load ptr, ptr %16, align 8, !tbaa !13
  %18 = load i32, ptr %7, align 4, !tbaa !9
  %19 = zext i32 %18 to i64
  %20 = getelementptr inbounds %struct.package_s, ptr %17, i64 %19
  %21 = getelementptr inbounds %struct.package_s, ptr %20, i32 0, i32 0
  %22 = getelementptr inbounds [256 x i8], ptr %21, i64 0, i64 0
  %23 = load ptr, ptr %5, align 8, !tbaa !5
  %24 = call i32 @strcmp(ptr noundef %22, ptr noundef %23) #7
  %25 = icmp eq i32 %24, 0
  br i1 %25, label %26, label %43

26:                                               ; preds = %14
  %27 = load ptr, ptr @stderr, align 8, !tbaa !5
  %28 = load ptr, ptr %5, align 8, !tbaa !5
  %29 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %27, ptr noundef @.str.42, ptr noundef %28) #6
  %30 = load ptr, ptr @stderr, align 8, !tbaa !5
  %31 = load ptr, ptr %4, align 8, !tbaa !5
  %32 = getelementptr inbounds %struct.autoscript_s, ptr %31, i32 0, i32 3
  %33 = load ptr, ptr %32, align 8, !tbaa !13
  %34 = load i32, ptr %7, align 4, !tbaa !9
  %35 = zext i32 %34 to i64
  %36 = getelementptr inbounds %struct.package_s, ptr %33, i64 %35
  %37 = getelementptr inbounds %struct.package_s, ptr %36, i32 0, i32 1
  %38 = getelementptr inbounds [256 x i8], ptr %37, i64 0, i64 0
  %39 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %30, ptr noundef @.str.43, ptr noundef %38) #6
  %40 = load ptr, ptr @stderr, align 8, !tbaa !5
  %41 = load ptr, ptr %6, align 8, !tbaa !5
  %42 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %40, ptr noundef @.str.43, ptr noundef %41) #6
  call void @exit(i32 noundef 1) #8
  unreachable

43:                                               ; preds = %14
  br label %44

44:                                               ; preds = %43
  %45 = load i32, ptr %7, align 4, !tbaa !9
  %46 = add i32 %45, 1
  store i32 %46, ptr %7, align 4, !tbaa !9
  br label %8, !llvm.loop !14

47:                                               ; preds = %8
  %48 = load ptr, ptr %4, align 8, !tbaa !5
  %49 = getelementptr inbounds %struct.autoscript_s, ptr %48, i32 0, i32 2
  %50 = load i32, ptr %49, align 4, !tbaa !11
  %51 = add i32 %50, 1
  store i32 %51, ptr %49, align 4, !tbaa !11
  %52 = load ptr, ptr %4, align 8, !tbaa !5
  %53 = getelementptr inbounds %struct.autoscript_s, ptr %52, i32 0, i32 3
  %54 = load ptr, ptr %53, align 8, !tbaa !13
  %55 = load ptr, ptr %4, align 8, !tbaa !5
  %56 = getelementptr inbounds %struct.autoscript_s, ptr %55, i32 0, i32 2
  %57 = load i32, ptr %56, align 4, !tbaa !11
  %58 = zext i32 %57 to i64
  %59 = mul i64 %58, 528
  %60 = call ptr @realloc(ptr noundef %54, i64 noundef %59) #9
  %61 = load ptr, ptr %4, align 8, !tbaa !5
  %62 = getelementptr inbounds %struct.autoscript_s, ptr %61, i32 0, i32 3
  store ptr %60, ptr %62, align 8, !tbaa !13
  %63 = load ptr, ptr %4, align 8, !tbaa !5
  %64 = getelementptr inbounds %struct.autoscript_s, ptr %63, i32 0, i32 3
  %65 = load ptr, ptr %64, align 8, !tbaa !13
  %66 = load ptr, ptr %4, align 8, !tbaa !5
  %67 = getelementptr inbounds %struct.autoscript_s, ptr %66, i32 0, i32 2
  %68 = load i32, ptr %67, align 4, !tbaa !11
  %69 = sub i32 %68, 1
  %70 = zext i32 %69 to i64
  %71 = getelementptr inbounds %struct.package_s, ptr %65, i64 %70
  %72 = getelementptr inbounds %struct.package_s, ptr %71, i32 0, i32 0
  %73 = getelementptr inbounds [256 x i8], ptr %72, i64 0, i64 0
  %74 = load ptr, ptr %5, align 8, !tbaa !5
  %75 = call ptr @strncpy(ptr noundef %73, ptr noundef %74, i64 noundef 255) #6
  %76 = load ptr, ptr %4, align 8, !tbaa !5
  %77 = getelementptr inbounds %struct.autoscript_s, ptr %76, i32 0, i32 3
  %78 = load ptr, ptr %77, align 8, !tbaa !13
  %79 = load ptr, ptr %4, align 8, !tbaa !5
  %80 = getelementptr inbounds %struct.autoscript_s, ptr %79, i32 0, i32 2
  %81 = load i32, ptr %80, align 4, !tbaa !11
  %82 = sub i32 %81, 1
  %83 = zext i32 %82 to i64
  %84 = getelementptr inbounds %struct.package_s, ptr %78, i64 %83
  %85 = getelementptr inbounds %struct.package_s, ptr %84, i32 0, i32 0
  %86 = getelementptr inbounds [256 x i8], ptr %85, i64 0, i64 255
  store i8 0, ptr %86, align 1, !tbaa !16
  %87 = load ptr, ptr %4, align 8, !tbaa !5
  %88 = getelementptr inbounds %struct.autoscript_s, ptr %87, i32 0, i32 3
  %89 = load ptr, ptr %88, align 8, !tbaa !13
  %90 = load ptr, ptr %4, align 8, !tbaa !5
  %91 = getelementptr inbounds %struct.autoscript_s, ptr %90, i32 0, i32 2
  %92 = load i32, ptr %91, align 4, !tbaa !11
  %93 = sub i32 %92, 1
  %94 = zext i32 %93 to i64
  %95 = getelementptr inbounds %struct.package_s, ptr %89, i64 %94
  %96 = getelementptr inbounds %struct.package_s, ptr %95, i32 0, i32 1
  %97 = getelementptr inbounds [256 x i8], ptr %96, i64 0, i64 0
  %98 = load ptr, ptr %6, align 8, !tbaa !5
  %99 = call ptr @strncpy(ptr noundef %97, ptr noundef %98, i64 noundef 255) #6
  %100 = load ptr, ptr %4, align 8, !tbaa !5
  %101 = getelementptr inbounds %struct.autoscript_s, ptr %100, i32 0, i32 3
  %102 = load ptr, ptr %101, align 8, !tbaa !13
  %103 = load ptr, ptr %4, align 8, !tbaa !5
  %104 = getelementptr inbounds %struct.autoscript_s, ptr %103, i32 0, i32 2
  %105 = load i32, ptr %104, align 4, !tbaa !11
  %106 = sub i32 %105, 1
  %107 = zext i32 %106 to i64
  %108 = getelementptr inbounds %struct.package_s, ptr %102, i64 %107
  %109 = getelementptr inbounds %struct.package_s, ptr %108, i32 0, i32 1
  %110 = getelementptr inbounds [256 x i8], ptr %109, i64 0, i64 255
  store i8 0, ptr %110, align 1, !tbaa !16
  %111 = load ptr, ptr %4, align 8, !tbaa !5
  %112 = getelementptr inbounds %struct.autoscript_s, ptr %111, i32 0, i32 3
  %113 = load ptr, ptr %112, align 8, !tbaa !13
  %114 = load ptr, ptr %4, align 8, !tbaa !5
  %115 = getelementptr inbounds %struct.autoscript_s, ptr %114, i32 0, i32 2
  %116 = load i32, ptr %115, align 4, !tbaa !11
  %117 = sub i32 %116, 1
  %118 = zext i32 %117 to i64
  %119 = getelementptr inbounds %struct.package_s, ptr %113, i64 %118
  %120 = getelementptr inbounds %struct.package_s, ptr %119, i32 0, i32 3
  store i32 0, ptr %120, align 8, !tbaa !17
  %121 = load ptr, ptr %4, align 8, !tbaa !5
  %122 = getelementptr inbounds %struct.autoscript_s, ptr %121, i32 0, i32 3
  %123 = load ptr, ptr %122, align 8, !tbaa !13
  %124 = load ptr, ptr %4, align 8, !tbaa !5
  %125 = getelementptr inbounds %struct.autoscript_s, ptr %124, i32 0, i32 2
  %126 = load i32, ptr %125, align 4, !tbaa !11
  %127 = sub i32 %126, 1
  %128 = zext i32 %127 to i64
  %129 = getelementptr inbounds %struct.package_s, ptr %123, i64 %128
  %130 = getelementptr inbounds %struct.package_s, ptr %129, i32 0, i32 2
  store ptr null, ptr %130, align 8, !tbaa !19
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #6
  ret void
}

; Function Attrs: nounwind willreturn memory(read)
declare i32 @strcmp(ptr noundef, ptr noundef) #4

; Function Attrs: nounwind allocsize(1)
declare ptr @realloc(ptr noundef, i64 noundef) #5

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

!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, !10, i64 260}
!12 = !{!"autoscript_s", !7, i64 0, !7, i64 256, !10, i64 260, !6, i64 264}
!13 = !{!12, !6, i64 264}
!14 = distinct !{!14, !15}
!15 = !{!"llvm.loop.mustprogress"}
!16 = !{!7, !7, i64 0}
!17 = !{!18, !10, i64 520}
!18 = !{!"package_s", !7, i64 0, !7, i64 256, !6, i64 512, !10, i64 520}
!19 = !{!18, !6, i64 512}


; 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.package_s = type { [256 x i8], [256 x i8], ptr, i32 }

@stderr = external local_unnamed_addr global ptr, align 8
@.str.42 = external hidden unnamed_addr constant [49 x i8], align 1
@.str.43 = external hidden unnamed_addr constant [6 x i8], align 1

; Function Attrs: mustprogress nofree nounwind willreturn memory(argmem: readwrite)
declare ptr @strncpy(ptr noalias noundef returned writeonly, ptr noalias nocapture noundef readonly, i64 noundef) local_unnamed_addr #0

; Function Attrs: nofree nounwind
declare noundef i32 @fprintf(ptr nocapture noundef, ptr nocapture noundef readonly, ...) local_unnamed_addr #1

; Function Attrs: noreturn nounwind
declare void @exit(i32 noundef) local_unnamed_addr #2

; Function Attrs: nounwind uwtable
define dso_local void @autoscript_addpackage(ptr nocapture noundef %0, ptr noundef %1, ptr noundef %2) local_unnamed_addr #3 {
  %4 = getelementptr inbounds i8, ptr %0, i64 260
  %5 = load i32, ptr %4, align 4, !tbaa !5
  %.not = icmp eq i32 %5, 0
  %.phi.trans.insert = getelementptr inbounds i8, ptr %0, i64 264
  %.pre = load ptr, ptr %.phi.trans.insert, align 8, !tbaa !11
  br i1 %.not, label %._crit_edge, label %.lr.ph

.lr.ph:                                           ; preds = %3
  %wide.trip.count = zext i32 %5 to i64
  br label %7

6:                                                ; preds = %7
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %exitcond.not = icmp eq i64 %indvars.iv.next, %wide.trip.count
  br i1 %exitcond.not, label %._crit_edge, label %7, !llvm.loop !12

7:                                                ; preds = %.lr.ph, %6
  %indvars.iv = phi i64 [ 0, %.lr.ph ], [ %indvars.iv.next, %6 ]
  %8 = getelementptr inbounds %struct.package_s, ptr %.pre, i64 %indvars.iv
  %9 = tail call i32 @strcmp(ptr noundef nonnull dereferenceable(1) %8, ptr noundef nonnull dereferenceable(1) %1) #6
  %10 = icmp eq i32 %9, 0
  br i1 %10, label %11, label %6

11:                                               ; preds = %7
  %12 = load ptr, ptr @stderr, align 8, !tbaa !14
  %13 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %12, ptr noundef nonnull @.str.42, ptr noundef %1) #7
  %14 = load ptr, ptr @stderr, align 8, !tbaa !14
  %15 = load ptr, ptr %.phi.trans.insert, align 8, !tbaa !11
  %16 = getelementptr inbounds %struct.package_s, ptr %15, i64 %indvars.iv, i32 1
  %17 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %14, ptr noundef nonnull @.str.43, ptr noundef nonnull %16) #7
  %18 = load ptr, ptr @stderr, align 8, !tbaa !14
  %19 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %18, ptr noundef nonnull @.str.43, ptr noundef %2) #7
  tail call void @exit(i32 noundef 1) #8
  unreachable

._crit_edge:                                      ; preds = %6, %3
  %20 = add i32 %5, 1
  store i32 %20, ptr %4, align 4, !tbaa !5
  %21 = getelementptr inbounds i8, ptr %0, i64 264
  %22 = zext i32 %20 to i64
  %23 = mul nuw nsw i64 %22, 528
  %24 = tail call ptr @realloc(ptr noundef %.pre, i64 noundef %23) #9
  store ptr %24, ptr %21, align 8, !tbaa !11
  %25 = load i32, ptr %4, align 4, !tbaa !5
  %26 = add i32 %25, -1
  %27 = zext i32 %26 to i64
  %28 = getelementptr inbounds %struct.package_s, ptr %24, i64 %27
  %29 = tail call ptr @strncpy(ptr noundef nonnull dereferenceable(1) %28, ptr noundef nonnull dereferenceable(1) %1, i64 noundef 255) #10
  %30 = getelementptr inbounds %struct.package_s, ptr %24, i64 %27, i32 0, i64 255
  store i8 0, ptr %30, align 1, !tbaa !15
  %31 = getelementptr inbounds %struct.package_s, ptr %24, i64 %27, i32 1
  %32 = tail call ptr @strncpy(ptr noundef nonnull dereferenceable(1) %31, ptr noundef nonnull dereferenceable(1) %2, i64 noundef 255) #10
  %33 = getelementptr inbounds %struct.package_s, ptr %24, i64 %27, i32 1, i64 255
  store i8 0, ptr %33, align 1, !tbaa !15
  %34 = getelementptr inbounds %struct.package_s, ptr %24, i64 %27, i32 3
  store i32 0, ptr %34, align 8, !tbaa !16
  %35 = getelementptr inbounds %struct.package_s, ptr %24, i64 %27, i32 2
  store ptr null, ptr %35, align 8, !tbaa !18
  ret void
}

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

; Function Attrs: mustprogress nounwind willreturn allockind("realloc") allocsize(1) memory(argmem: readwrite, inaccessiblemem: readwrite)
declare noalias noundef ptr @realloc(ptr allocptr nocapture noundef, i64 noundef) local_unnamed_addr #5

attributes #0 = { mustprogress nofree nounwind willreturn memory(argmem: readwrite) "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 = { nofree 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 #2 = { noreturn 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 #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 = { 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 = { mustprogress nounwind willreturn allockind("realloc") allocsize(1) memory(argmem: readwrite, inaccessiblemem: readwrite) "alloc-family"="malloc" "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 = { nounwind willreturn memory(read) }
attributes #7 = { cold nounwind }
attributes #8 = { noreturn nounwind }
attributes #9 = { nounwind allocsize(1) }
attributes #10 = { 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, !9, i64 260}
!6 = !{!"autoscript_s", !7, i64 0, !7, i64 256, !9, i64 260, !10, i64 264}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!"int", !7, i64 0}
!10 = !{!"any pointer", !7, i64 0}
!11 = !{!6, !10, i64 264}
!12 = distinct !{!12, !13}
!13 = !{!"llvm.loop.mustprogress"}
!14 = !{!10, !10, i64 0}
!15 = !{!7, !7, i64 0}
!16 = !{!17, !9, i64 520}
!17 = !{!"package_s", !7, i64 0, !7, i64 256, !10, i64 512, !9, i64 520}
!18 = !{!17, !10, i64 512}


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