; LLVM IR from jgaeddert/liquid-dsp :: examples (bsequence_example)

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

@__const.main.v = external hidden unnamed_addr constant [4 x i8], align 1
@.str = external hidden unnamed_addr constant [14 x i8], align 1

; Function Attrs: nounwind uwtable
define dso_local i32 @main() #0 {
  %1 = alloca i32, align 4
  %2 = alloca i32, align 4
  %3 = alloca ptr, align 8
  %4 = alloca [4 x i8], align 1
  %5 = alloca i32, align 4
  %6 = alloca i32, align 4
  store i32 0, ptr %1, align 4
  call void @llvm.lifetime.start.p0(i64 4, ptr %2) #4
  store i32 16, ptr %2, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %3) #4
  %7 = load i32, ptr %2, align 4, !tbaa !5
  %8 = call ptr @bsequence_create(i32 noundef %7)
  store ptr %8, ptr %3, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #4
  call void @llvm.memcpy.p0.p0.i64(ptr align 1 %4, ptr align 1 @__const.main.v, i64 4, i1 false)
  %9 = load ptr, ptr %3, align 8, !tbaa !9
  %10 = getelementptr inbounds [4 x i8], ptr %4, i64 0, i64 0
  %11 = call i32 @bsequence_init(ptr noundef %9, ptr noundef %10)
  %12 = load ptr, ptr %3, align 8, !tbaa !9
  %13 = call i32 @bsequence_push(ptr noundef %12, i32 noundef 1)
  %14 = load ptr, ptr %3, align 8, !tbaa !9
  %15 = call i32 @bsequence_push(ptr noundef %14, i32 noundef 1)
  %16 = load ptr, ptr %3, align 8, !tbaa !9
  %17 = call i32 @bsequence_push(ptr noundef %16, i32 noundef 1)
  %18 = load ptr, ptr %3, align 8, !tbaa !9
  %19 = call i32 @bsequence_push(ptr noundef %18, i32 noundef 1)
  %20 = load ptr, ptr %3, align 8, !tbaa !9
  %21 = call i32 @bsequence_push(ptr noundef %20, i32 noundef 0)
  %22 = load ptr, ptr %3, align 8, !tbaa !9
  %23 = call i32 @bsequence_push(ptr noundef %22, i32 noundef 1)
  %24 = load ptr, ptr %3, align 8, !tbaa !9
  %25 = call i32 @bsequence_print(ptr noundef %24)
  %26 = load ptr, ptr %3, align 8, !tbaa !9
  %27 = call i32 @bsequence_circshift(ptr noundef %26)
  %28 = load ptr, ptr %3, align 8, !tbaa !9
  %29 = call i32 @bsequence_print(ptr noundef %28)
  %30 = load ptr, ptr %3, align 8, !tbaa !9
  %31 = call i32 @bsequence_circshift(ptr noundef %30)
  %32 = load ptr, ptr %3, align 8, !tbaa !9
  %33 = call i32 @bsequence_print(ptr noundef %32)
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #4
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #4
  store i32 0, ptr %6, align 4, !tbaa !5
  br label %34

34:                                               ; preds = %45, %0
  %35 = load i32, ptr %6, align 4, !tbaa !5
  %36 = load i32, ptr %2, align 4, !tbaa !5
  %37 = icmp ult i32 %35, %36
  br i1 %37, label %38, label %48

38:                                               ; preds = %34
  %39 = load ptr, ptr %3, align 8, !tbaa !9
  %40 = load i32, ptr %6, align 4, !tbaa !5
  %41 = call i32 @bsequence_index(ptr noundef %39, i32 noundef %40)
  store i32 %41, ptr %5, align 4, !tbaa !5
  %42 = load i32, ptr %6, align 4, !tbaa !5
  %43 = load i32, ptr %5, align 4, !tbaa !5
  %44 = call i32 (ptr, ...) @printf(ptr noundef @.str, i32 noundef %42, i32 noundef %43)
  br label %45

45:                                               ; preds = %38
  %46 = load i32, ptr %6, align 4, !tbaa !5
  %47 = add i32 %46, 1
  store i32 %47, ptr %6, align 4, !tbaa !5
  br label %34, !llvm.loop !11

48:                                               ; preds = %34
  %49 = load ptr, ptr %3, align 8, !tbaa !9
  %50 = call i32 @bsequence_destroy(ptr noundef %49)
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %3) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %2) #4
  ret i32 0
}

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

declare ptr @bsequence_create(i32 noundef) #2

; 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) #3

declare i32 @bsequence_init(ptr noundef, ptr noundef) #2

declare i32 @bsequence_push(ptr noundef, i32 noundef) #2

declare i32 @bsequence_print(ptr noundef) #2

declare i32 @bsequence_circshift(ptr noundef) #2

declare i32 @bsequence_index(ptr noundef, i32 noundef) #2

declare i32 @printf(ptr noundef, ...) #2

declare i32 @bsequence_destroy(ptr 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 = { 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 = { nocallback nofree nosync 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 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
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 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"any pointer", !7, i64 0}
!11 = distinct !{!11, !12}
!12 = !{!"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"

@__const.main.v = external hidden unnamed_addr constant [4 x i8], align 1
@.str = external hidden unnamed_addr constant [14 x i8], align 1

; Function Attrs: nounwind uwtable
define dso_local noundef i32 @main() local_unnamed_addr #0 {
  %1 = alloca [4 x i8], align 4
  %2 = tail call ptr @bsequence_create(i32 noundef 16) #4
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %1) #4
  %3 = load i32, ptr @__const.main.v, align 1
  store i32 %3, ptr %1, align 4
  %4 = call i32 @bsequence_init(ptr noundef %2, ptr noundef nonnull %1) #4
  %5 = call i32 @bsequence_push(ptr noundef %2, i32 noundef 1) #4
  %6 = call i32 @bsequence_push(ptr noundef %2, i32 noundef 1) #4
  %7 = call i32 @bsequence_push(ptr noundef %2, i32 noundef 1) #4
  %8 = call i32 @bsequence_push(ptr noundef %2, i32 noundef 1) #4
  %9 = call i32 @bsequence_push(ptr noundef %2, i32 noundef 0) #4
  %10 = call i32 @bsequence_push(ptr noundef %2, i32 noundef 1) #4
  %11 = call i32 @bsequence_print(ptr noundef %2) #4
  %12 = call i32 @bsequence_circshift(ptr noundef %2) #4
  %13 = call i32 @bsequence_print(ptr noundef %2) #4
  %14 = call i32 @bsequence_circshift(ptr noundef %2) #4
  %15 = call i32 @bsequence_print(ptr noundef %2) #4
  %16 = call i32 @bsequence_index(ptr noundef %2, i32 noundef 0) #4
  %17 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str, i32 noundef 0, i32 noundef %16)
  %18 = call i32 @bsequence_index(ptr noundef %2, i32 noundef 1) #4
  %19 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str, i32 noundef 1, i32 noundef %18)
  %20 = call i32 @bsequence_index(ptr noundef %2, i32 noundef 2) #4
  %21 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str, i32 noundef 2, i32 noundef %20)
  %22 = call i32 @bsequence_index(ptr noundef %2, i32 noundef 3) #4
  %23 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str, i32 noundef 3, i32 noundef %22)
  %24 = call i32 @bsequence_index(ptr noundef %2, i32 noundef 4) #4
  %25 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str, i32 noundef 4, i32 noundef %24)
  %26 = call i32 @bsequence_index(ptr noundef %2, i32 noundef 5) #4
  %27 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str, i32 noundef 5, i32 noundef %26)
  %28 = call i32 @bsequence_index(ptr noundef %2, i32 noundef 6) #4
  %29 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str, i32 noundef 6, i32 noundef %28)
  %30 = call i32 @bsequence_index(ptr noundef %2, i32 noundef 7) #4
  %31 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str, i32 noundef 7, i32 noundef %30)
  %32 = call i32 @bsequence_index(ptr noundef %2, i32 noundef 8) #4
  %33 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str, i32 noundef 8, i32 noundef %32)
  %34 = call i32 @bsequence_index(ptr noundef %2, i32 noundef 9) #4
  %35 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str, i32 noundef 9, i32 noundef %34)
  %36 = call i32 @bsequence_index(ptr noundef %2, i32 noundef 10) #4
  %37 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str, i32 noundef 10, i32 noundef %36)
  %38 = call i32 @bsequence_index(ptr noundef %2, i32 noundef 11) #4
  %39 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str, i32 noundef 11, i32 noundef %38)
  %40 = call i32 @bsequence_index(ptr noundef %2, i32 noundef 12) #4
  %41 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str, i32 noundef 12, i32 noundef %40)
  %42 = call i32 @bsequence_index(ptr noundef %2, i32 noundef 13) #4
  %43 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str, i32 noundef 13, i32 noundef %42)
  %44 = call i32 @bsequence_index(ptr noundef %2, i32 noundef 14) #4
  %45 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str, i32 noundef 14, i32 noundef %44)
  %46 = call i32 @bsequence_index(ptr noundef %2, i32 noundef 15) #4
  %47 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str, i32 noundef 15, i32 noundef %46)
  %48 = call i32 @bsequence_destroy(ptr noundef %2) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %1) #4
  ret i32 0
}

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

declare ptr @bsequence_create(i32 noundef) local_unnamed_addr #2

declare i32 @bsequence_init(ptr noundef, ptr noundef) local_unnamed_addr #2

declare i32 @bsequence_push(ptr noundef, i32 noundef) local_unnamed_addr #2

declare i32 @bsequence_print(ptr noundef) local_unnamed_addr #2

declare i32 @bsequence_circshift(ptr noundef) local_unnamed_addr #2

declare i32 @bsequence_index(ptr noundef, i32 noundef) local_unnamed_addr #2

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

declare i32 @bsequence_destroy(ptr noundef) local_unnamed_addr #2

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

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


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