; LLVM IR from buzz-lang/Buzz :: src/testing (testbuzzstrman)

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

@.str = external hidden unnamed_addr constant [35 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [5 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [9 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [8 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [38 x i8], align 1
@.str.5 = external hidden unnamed_addr constant [13 x i8], align 1
@.str.6 = external hidden unnamed_addr constant [19 x i8], align 1
@.str.7 = external hidden unnamed_addr constant [16 x i8], align 1
@.str.8 = external hidden unnamed_addr constant [24 x i8], align 1
@.str.9 = external hidden unnamed_addr constant [35 x i8], align 1
@.str.10 = external hidden unnamed_addr constant [30 x i8], align 1
@.str.11 = external hidden unnamed_addr constant [19 x i8], align 1
@.str.12 = external hidden unnamed_addr constant [18 x i8], align 1
@.str.13 = external hidden unnamed_addr constant [16 x i8], align 1
@.str.14 = external hidden unnamed_addr constant [23 x i8], align 1

; Function Attrs: nounwind uwtable
define dso_local i32 @main() #0 {
  %1 = alloca i32, align 4
  %2 = alloca ptr, align 8
  %3 = alloca i32, align 4
  %4 = alloca i32, align 4
  store i32 0, ptr %1, align 4
  call void @llvm.lifetime.start.p0(i64 8, ptr %2) #3
  %5 = call ptr (...) @buzzstrman_new()
  store ptr %5, ptr %2, align 8, !tbaa !5
  %6 = call i32 (ptr, ...) @printf(ptr noundef @.str)
  %7 = load ptr, ptr %2, align 8, !tbaa !5
  %8 = call zeroext i16 @buzzstrman_register(ptr noundef %7, ptr noundef @.str.1, i32 noundef 1)
  %9 = load ptr, ptr %2, align 8, !tbaa !5
  %10 = call zeroext i16 @buzzstrman_register(ptr noundef %9, ptr noundef @.str.2, i32 noundef 1)
  %11 = load ptr, ptr %2, align 8, !tbaa !5
  %12 = call zeroext i16 @buzzstrman_register(ptr noundef %11, ptr noundef @.str.3, i32 noundef 1)
  %13 = load ptr, ptr %2, align 8, !tbaa !5
  call void @buzzstrman_print(ptr noundef %13)
  %14 = call i32 (ptr, ...) @printf(ptr noundef @.str.4)
  %15 = load ptr, ptr %2, align 8, !tbaa !5
  %16 = call zeroext i16 @buzzstrman_register(ptr noundef %15, ptr noundef @.str.5, i32 noundef 0)
  %17 = load ptr, ptr %2, align 8, !tbaa !5
  %18 = call zeroext i16 @buzzstrman_register(ptr noundef %17, ptr noundef @.str.6, i32 noundef 0)
  %19 = load ptr, ptr %2, align 8, !tbaa !5
  %20 = call zeroext i16 @buzzstrman_register(ptr noundef %19, ptr noundef @.str.7, i32 noundef 0)
  %21 = load ptr, ptr %2, align 8, !tbaa !5
  %22 = call zeroext i16 @buzzstrman_register(ptr noundef %21, ptr noundef @.str.8, i32 noundef 0)
  %23 = load ptr, ptr %2, align 8, !tbaa !5
  call void @buzzstrman_print(ptr noundef %23)
  %24 = call i32 (ptr, ...) @printf(ptr noundef @.str.9)
  %25 = load ptr, ptr %2, align 8, !tbaa !5
  %26 = call zeroext i16 @buzzstrman_register(ptr noundef %25, ptr noundef @.str.1, i32 noundef 1)
  %27 = load ptr, ptr %2, align 8, !tbaa !5
  %28 = call zeroext i16 @buzzstrman_register(ptr noundef %27, ptr noundef @.str.6, i32 noundef 0)
  %29 = load ptr, ptr %2, align 8, !tbaa !5
  call void @buzzstrman_print(ptr noundef %29)
  %30 = call i32 (ptr, ...) @printf(ptr noundef @.str.10)
  %31 = load ptr, ptr %2, align 8, !tbaa !5
  call void @buzzstrman_gc_clear(ptr noundef %31)
  %32 = load ptr, ptr %2, align 8, !tbaa !5
  %33 = load ptr, ptr %2, align 8, !tbaa !5
  %34 = call zeroext i16 @buzzstrman_register(ptr noundef %33, ptr noundef @.str.5, i32 noundef 0)
  call void @buzzstrman_gc_mark(ptr noundef %32, i16 noundef zeroext %34)
  %35 = load ptr, ptr %2, align 8, !tbaa !5
  %36 = load ptr, ptr %2, align 8, !tbaa !5
  %37 = call zeroext i16 @buzzstrman_register(ptr noundef %36, ptr noundef @.str.7, i32 noundef 0)
  call void @buzzstrman_gc_mark(ptr noundef %35, i16 noundef zeroext %37)
  %38 = load ptr, ptr %2, align 8, !tbaa !5
  call void @buzzstrman_gc_prune(ptr noundef %38)
  %39 = load ptr, ptr %2, align 8, !tbaa !5
  call void @buzzstrman_print(ptr noundef %39)
  %40 = call i32 (ptr, ...) @printf(ptr noundef @.str.11)
  call void @llvm.lifetime.start.p0(i64 4, ptr %3) #3
  store i32 0, ptr %3, align 4, !tbaa !9
  br label %41

41:                                               ; preds = %50, %0
  %42 = load i32, ptr %3, align 4, !tbaa !9
  %43 = icmp slt i32 %42, 60000
  br i1 %43, label %45, label %44

44:                                               ; preds = %41
  call void @llvm.lifetime.end.p0(i64 4, ptr %3) #3
  br label %53

45:                                               ; preds = %41
  %46 = load ptr, ptr %2, align 8, !tbaa !5
  %47 = call zeroext i16 @buzzstrman_register(ptr noundef %46, ptr noundef @.str.12, i32 noundef 0)
  %48 = load ptr, ptr %2, align 8, !tbaa !5
  call void @buzzstrman_gc_clear(ptr noundef %48)
  %49 = load ptr, ptr %2, align 8, !tbaa !5
  call void @buzzstrman_gc_prune(ptr noundef %49)
  br label %50

50:                                               ; preds = %45
  %51 = load i32, ptr %3, align 4, !tbaa !9
  %52 = add nsw i32 %51, 1
  store i32 %52, ptr %3, align 4, !tbaa !9
  br label %41, !llvm.loop !11

53:                                               ; preds = %44
  %54 = load ptr, ptr %2, align 8, !tbaa !5
  %55 = call zeroext i16 @buzzstrman_register(ptr noundef %54, ptr noundef @.str.13, i32 noundef 0)
  %56 = load ptr, ptr %2, align 8, !tbaa !5
  call void @buzzstrman_print(ptr noundef %56)
  %57 = call i32 (ptr, ...) @printf(ptr noundef @.str.14)
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #3
  store i32 0, ptr %4, align 4, !tbaa !9
  br label %58

58:                                               ; preds = %67, %53
  %59 = load i32, ptr %4, align 4, !tbaa !9
  %60 = icmp slt i32 %59, 6000
  br i1 %60, label %62, label %61

61:                                               ; preds = %58
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #3
  br label %70

62:                                               ; preds = %58
  %63 = load ptr, ptr %2, align 8, !tbaa !5
  %64 = call zeroext i16 @buzzstrman_register(ptr noundef %63, ptr noundef @.str.12, i32 noundef 0)
  %65 = load ptr, ptr %2, align 8, !tbaa !5
  call void @buzzstrman_gc_clear(ptr noundef %65)
  %66 = load ptr, ptr %2, align 8, !tbaa !5
  call void @buzzstrman_gc_prune(ptr noundef %66)
  br label %67

67:                                               ; preds = %62
  %68 = load i32, ptr %4, align 4, !tbaa !9
  %69 = add nsw i32 %68, 1
  store i32 %69, ptr %4, align 4, !tbaa !9
  br label %58, !llvm.loop !13

70:                                               ; preds = %61
  %71 = load ptr, ptr %2, align 8, !tbaa !5
  %72 = call zeroext i16 @buzzstrman_register(ptr noundef %71, ptr noundef @.str.13, i32 noundef 0)
  %73 = load ptr, ptr %2, align 8, !tbaa !5
  call void @buzzstrman_print(ptr noundef %73)
  call void @buzzstrman_destroy(ptr noundef %2)
  call void @llvm.lifetime.end.p0(i64 8, ptr %2) #3
  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 @buzzstrman_new(...) #2

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

declare zeroext i16 @buzzstrman_register(ptr noundef, ptr noundef, i32 noundef) #2

declare void @buzzstrman_print(ptr noundef) #2

declare void @buzzstrman_gc_clear(ptr noundef) #2

declare void @buzzstrman_gc_mark(ptr noundef, i16 noundef zeroext) #2

declare void @buzzstrman_gc_prune(ptr noundef) #2

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

declare void @buzzstrman_destroy(ptr noundef) #2

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 = { 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, !10, i64 0}
!10 = !{!"int", !7, i64 0}
!11 = distinct !{!11, !12}
!12 = !{!"llvm.loop.mustprogress"}
!13 = distinct !{!13, !12}


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

@.str = external hidden unnamed_addr constant [35 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [5 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [9 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [8 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [38 x i8], align 1
@.str.5 = external hidden unnamed_addr constant [13 x i8], align 1
@.str.6 = external hidden unnamed_addr constant [19 x i8], align 1
@.str.7 = external hidden unnamed_addr constant [16 x i8], align 1
@.str.8 = external hidden unnamed_addr constant [24 x i8], align 1
@.str.9 = external hidden unnamed_addr constant [35 x i8], align 1
@.str.10 = external hidden unnamed_addr constant [30 x i8], align 1
@.str.11 = external hidden unnamed_addr constant [19 x i8], align 1
@.str.12 = external hidden unnamed_addr constant [18 x i8], align 1
@.str.13 = external hidden unnamed_addr constant [16 x i8], align 1
@.str.14 = external hidden unnamed_addr constant [23 x i8], align 1

; Function Attrs: nounwind uwtable
define dso_local noundef i32 @main() local_unnamed_addr #0 {
  %1 = alloca ptr, align 8
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %1) #4
  %2 = tail call ptr (...) @buzzstrman_new() #4
  store ptr %2, ptr %1, align 8, !tbaa !5
  %3 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str)
  %4 = tail call zeroext i16 @buzzstrman_register(ptr noundef %2, ptr noundef nonnull @.str.1, i32 noundef 1) #4
  %5 = tail call zeroext i16 @buzzstrman_register(ptr noundef %2, ptr noundef nonnull @.str.2, i32 noundef 1) #4
  %6 = tail call zeroext i16 @buzzstrman_register(ptr noundef %2, ptr noundef nonnull @.str.3, i32 noundef 1) #4
  tail call void @buzzstrman_print(ptr noundef %2) #4
  %7 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.4)
  %8 = tail call zeroext i16 @buzzstrman_register(ptr noundef %2, ptr noundef nonnull @.str.5, i32 noundef 0) #4
  %9 = tail call zeroext i16 @buzzstrman_register(ptr noundef %2, ptr noundef nonnull @.str.6, i32 noundef 0) #4
  %10 = tail call zeroext i16 @buzzstrman_register(ptr noundef %2, ptr noundef nonnull @.str.7, i32 noundef 0) #4
  %11 = tail call zeroext i16 @buzzstrman_register(ptr noundef %2, ptr noundef nonnull @.str.8, i32 noundef 0) #4
  tail call void @buzzstrman_print(ptr noundef %2) #4
  %12 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.9)
  %13 = tail call zeroext i16 @buzzstrman_register(ptr noundef %2, ptr noundef nonnull @.str.1, i32 noundef 1) #4
  %14 = tail call zeroext i16 @buzzstrman_register(ptr noundef %2, ptr noundef nonnull @.str.6, i32 noundef 0) #4
  tail call void @buzzstrman_print(ptr noundef %2) #4
  %15 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.10)
  tail call void @buzzstrman_gc_clear(ptr noundef %2) #4
  %16 = tail call zeroext i16 @buzzstrman_register(ptr noundef %2, ptr noundef nonnull @.str.5, i32 noundef 0) #4
  tail call void @buzzstrman_gc_mark(ptr noundef %2, i16 noundef zeroext %16) #4
  %17 = tail call zeroext i16 @buzzstrman_register(ptr noundef %2, ptr noundef nonnull @.str.7, i32 noundef 0) #4
  tail call void @buzzstrman_gc_mark(ptr noundef %2, i16 noundef zeroext %17) #4
  tail call void @buzzstrman_gc_prune(ptr noundef %2) #4
  tail call void @buzzstrman_print(ptr noundef %2) #4
  %18 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.11)
  br label %22

19:                                               ; preds = %22
  %20 = tail call zeroext i16 @buzzstrman_register(ptr noundef %2, ptr noundef nonnull @.str.13, i32 noundef 0) #4
  tail call void @buzzstrman_print(ptr noundef %2) #4
  %21 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.14)
  br label %27

22:                                               ; preds = %0, %22
  %.045 = phi i32 [ 0, %0 ], [ %24, %22 ]
  %23 = tail call zeroext i16 @buzzstrman_register(ptr noundef %2, ptr noundef nonnull @.str.12, i32 noundef 0) #4
  tail call void @buzzstrman_gc_clear(ptr noundef %2) #4
  tail call void @buzzstrman_gc_prune(ptr noundef %2) #4
  %24 = add nuw nsw i32 %.045, 1
  %exitcond.not = icmp eq i32 %24, 60000
  br i1 %exitcond.not, label %19, label %22, !llvm.loop !9

25:                                               ; preds = %27
  %26 = tail call zeroext i16 @buzzstrman_register(ptr noundef %2, ptr noundef nonnull @.str.13, i32 noundef 0) #4
  tail call void @buzzstrman_print(ptr noundef %2) #4
  call void @buzzstrman_destroy(ptr noundef nonnull %1) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %1) #4
  ret i32 0

27:                                               ; preds = %19, %27
  %.06 = phi i32 [ 0, %19 ], [ %29, %27 ]
  %28 = tail call zeroext i16 @buzzstrman_register(ptr noundef %2, ptr noundef nonnull @.str.12, i32 noundef 0) #4
  tail call void @buzzstrman_gc_clear(ptr noundef %2) #4
  tail call void @buzzstrman_gc_prune(ptr noundef %2) #4
  %29 = add nuw nsw i32 %.06, 1
  %exitcond7.not = icmp eq i32 %29, 6000
  br i1 %exitcond7.not, label %25, label %27, !llvm.loop !11
}

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

declare ptr @buzzstrman_new(...) local_unnamed_addr #2

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

declare zeroext i16 @buzzstrman_register(ptr noundef, ptr noundef, i32 noundef) local_unnamed_addr #2

declare void @buzzstrman_print(ptr noundef) local_unnamed_addr #2

declare void @buzzstrman_gc_clear(ptr noundef) local_unnamed_addr #2

declare void @buzzstrman_gc_mark(ptr noundef, i16 noundef zeroext) local_unnamed_addr #2

declare void @buzzstrman_gc_prune(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

declare void @buzzstrman_destroy(ptr noundef) local_unnamed_addr #2

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)"}
!5 = !{!6, !6, i64 0}
!6 = !{!"any pointer", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = distinct !{!9, !10}
!10 = !{!"llvm.loop.mustprogress"}
!11 = distinct !{!11, !10}


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