; LLVM IR from txus/libtreadmill :: tests (darray_tests)

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

@array = external hidden global ptr, align 8
@stderr = external global ptr, align 8
@.str.1 = external hidden unnamed_addr constant [72 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [5 x i8], align 1
@.str.28 = external hidden unnamed_addr constant [44 x i8], align 1
@.str.29 = external hidden unnamed_addr constant [16 x i8], align 1
@.str.30 = external hidden unnamed_addr constant [50 x i8], align 1
@.str.31 = external hidden unnamed_addr constant [22 x i8], align 1
@.str.32 = external hidden unnamed_addr constant [41 x i8], align 1
@.str.33 = external hidden unnamed_addr constant [13 x i8], align 1

; Function Attrs: nounwind
declare i32 @fprintf(ptr noundef, ptr noundef, ...) #0

; Function Attrs: nounwind willreturn memory(none)
declare ptr @__errno_location() #1

; Function Attrs: nounwind
declare ptr @strerror(i32 noundef) #0

; Function Attrs: inlinehint nounwind uwtable
declare hidden ptr @Tm_DArray_new(ptr noundef) #2

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

; Function Attrs: nounwind
declare void @free(ptr noundef) #0

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

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

6:                                                ; preds = %18, %0
  %7 = load i32, ptr %2, align 4, !tbaa !5
  %8 = icmp slt i32 %7, 1000
  br i1 %8, label %9, label %21

9:                                                ; preds = %6
  call void @llvm.lifetime.start.p0(i64 8, ptr %3) #6
  %10 = load ptr, ptr @array, align 8, !tbaa !9
  %11 = call ptr @Tm_DArray_new(ptr noundef %10)
  store ptr %11, ptr %3, align 8, !tbaa !9
  %12 = load i32, ptr %2, align 4, !tbaa !5
  %13 = mul nsw i32 %12, 333
  %14 = load ptr, ptr %3, align 8, !tbaa !9
  store i32 %13, ptr %14, align 4, !tbaa !5
  %15 = load ptr, ptr @array, align 8, !tbaa !9
  %16 = load ptr, ptr %3, align 8, !tbaa !9
  %17 = call i32 @Tm_DArray_push(ptr noundef %15, ptr noundef %16)
  call void @llvm.lifetime.end.p0(i64 8, ptr %3) #6
  br label %18

18:                                               ; preds = %9
  %19 = load i32, ptr %2, align 4, !tbaa !5
  %20 = add nsw i32 %19, 1
  store i32 %20, ptr %2, align 4, !tbaa !5
  br label %6, !llvm.loop !11

21:                                               ; preds = %6
  %22 = load ptr, ptr @array, align 8, !tbaa !9
  %23 = getelementptr inbounds %struct.tm_darray_s, ptr %22, i32 0, i32 1
  %24 = load i32, ptr %23, align 4, !tbaa !13
  %25 = icmp eq i32 %24, 1201
  br i1 %25, label %39, label %26

26:                                               ; preds = %21
  %27 = load ptr, ptr @stderr, align 8, !tbaa !9
  %28 = call ptr @__errno_location() #7
  %29 = load i32, ptr %28, align 4, !tbaa !5
  %30 = icmp eq i32 %29, 0
  br i1 %30, label %31, label %32

31:                                               ; preds = %26
  br label %36

32:                                               ; preds = %26
  %33 = call ptr @__errno_location() #7
  %34 = load i32, ptr %33, align 4, !tbaa !5
  %35 = call ptr @strerror(i32 noundef %34) #6
  br label %36

36:                                               ; preds = %32, %31
  %37 = phi ptr [ @.str.2, %31 ], [ %35, %32 ]
  %38 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %27, ptr noundef @.str.28, ptr noundef @.str.1, i32 noundef 95, ptr noundef %37) #6
  store ptr @.str.29, ptr %1, align 8
  store i32 1, ptr %4, align 4
  br label %89

39:                                               ; preds = %21
  store i32 999, ptr %2, align 4, !tbaa !5
  br label %40

40:                                               ; preds = %85, %39
  %41 = load i32, ptr %2, align 4, !tbaa !5
  %42 = icmp sge i32 %41, 0
  br i1 %42, label %43, label %88

43:                                               ; preds = %40
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #6
  %44 = load ptr, ptr @array, align 8, !tbaa !9
  %45 = call ptr @Tm_DArray_pop(ptr noundef %44)
  store ptr %45, ptr %5, align 8, !tbaa !9
  %46 = load ptr, ptr %5, align 8, !tbaa !9
  %47 = icmp ne ptr %46, null
  br i1 %47, label %61, label %48

48:                                               ; preds = %43
  %49 = load ptr, ptr @stderr, align 8, !tbaa !9
  %50 = call ptr @__errno_location() #7
  %51 = load i32, ptr %50, align 4, !tbaa !5
  %52 = icmp eq i32 %51, 0
  br i1 %52, label %53, label %54

53:                                               ; preds = %48
  br label %58

54:                                               ; preds = %48
  %55 = call ptr @__errno_location() #7
  %56 = load i32, ptr %55, align 4, !tbaa !5
  %57 = call ptr @strerror(i32 noundef %56) #6
  br label %58

58:                                               ; preds = %54, %53
  %59 = phi ptr [ @.str.2, %53 ], [ %57, %54 ]
  %60 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %49, ptr noundef @.str.30, ptr noundef @.str.1, i32 noundef 99, ptr noundef %59) #6
  store ptr @.str.31, ptr %1, align 8
  store i32 1, ptr %4, align 4
  br label %82

61:                                               ; preds = %43
  %62 = load ptr, ptr %5, align 8, !tbaa !9
  %63 = load i32, ptr %62, align 4, !tbaa !5
  %64 = load i32, ptr %2, align 4, !tbaa !5
  %65 = mul nsw i32 %64, 333
  %66 = icmp eq i32 %63, %65
  br i1 %66, label %80, label %67

67:                                               ; preds = %61
  %68 = load ptr, ptr @stderr, align 8, !tbaa !9
  %69 = call ptr @__errno_location() #7
  %70 = load i32, ptr %69, align 4, !tbaa !5
  %71 = icmp eq i32 %70, 0
  br i1 %71, label %72, label %73

72:                                               ; preds = %67
  br label %77

73:                                               ; preds = %67
  %74 = call ptr @__errno_location() #7
  %75 = load i32, ptr %74, align 4, !tbaa !5
  %76 = call ptr @strerror(i32 noundef %75) #6
  br label %77

77:                                               ; preds = %73, %72
  %78 = phi ptr [ @.str.2, %72 ], [ %76, %73 ]
  %79 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %68, ptr noundef @.str.32, ptr noundef @.str.1, i32 noundef 100, ptr noundef %78) #6
  store ptr @.str.33, ptr %1, align 8
  store i32 1, ptr %4, align 4
  br label %82

80:                                               ; preds = %61
  %81 = load ptr, ptr %5, align 8, !tbaa !9
  call void @free(ptr noundef %81) #6
  store i32 0, ptr %4, align 4
  br label %82

82:                                               ; preds = %80, %77, %58
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #6
  %83 = load i32, ptr %4, align 4
  switch i32 %83, label %89 [
    i32 0, label %84
  ]

84:                                               ; preds = %82
  br label %85

85:                                               ; preds = %84
  %86 = load i32, ptr %2, align 4, !tbaa !5
  %87 = add nsw i32 %86, -1
  store i32 %87, ptr %2, align 4, !tbaa !5
  br label %40, !llvm.loop !16

88:                                               ; preds = %40
  store ptr null, ptr %1, align 8
  store i32 1, ptr %4, align 4
  br label %89

89:                                               ; preds = %88, %82, %36
  call void @llvm.lifetime.end.p0(i64 4, ptr %2) #6
  %90 = load ptr, ptr %1, align 8
  ret ptr %90
}

declare i32 @Tm_DArray_push(ptr noundef, ptr noundef) #5

declare ptr @Tm_DArray_pop(ptr noundef) #5

attributes #0 = { 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 #1 = { nounwind willreturn memory(none) "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 = { inlinehint 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 #3 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #4 = { 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 #5 = { "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(none) }

!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"}
!13 = !{!14, !6, i64 4}
!14 = !{!"tm_darray_s", !6, i64 0, !6, i64 4, !15, i64 8, !15, i64 16, !10, i64 24}
!15 = !{!"long", !7, i64 0}
!16 = distinct !{!16, !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"

@array = external hidden local_unnamed_addr global ptr, align 8
@stderr = external local_unnamed_addr global ptr, align 8
@.str.1 = external hidden unnamed_addr constant [72 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [5 x i8], align 1
@.str.28 = external hidden unnamed_addr constant [44 x i8], align 1
@.str.29 = external hidden unnamed_addr constant [16 x i8], align 1
@.str.30 = external hidden unnamed_addr constant [50 x i8], align 1
@.str.31 = external hidden unnamed_addr constant [22 x i8], align 1
@.str.32 = external hidden unnamed_addr constant [41 x i8], align 1
@.str.33 = external hidden unnamed_addr constant [13 x i8], align 1

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

; Function Attrs: mustprogress nofree nosync nounwind willreturn memory(none)
declare ptr @__errno_location() local_unnamed_addr #1

; Function Attrs: nounwind
declare ptr @strerror(i32 noundef) local_unnamed_addr #2

; Function Attrs: inlinehint nounwind uwtable
declare hidden ptr @Tm_DArray_new(ptr noundef) local_unnamed_addr #3

; Function Attrs: mustprogress nounwind willreturn allockind("free") memory(argmem: readwrite, inaccessiblemem: readwrite)
declare void @free(ptr allocptr nocapture noundef) local_unnamed_addr #4

; Function Attrs: nounwind uwtable
define dso_local noundef ptr @test_push_pop() local_unnamed_addr #5 {
  br label %1

1:                                                ; preds = %0, %1
  %.01321 = phi i32 [ 0, %0 ], [ %7, %1 ]
  %2 = load ptr, ptr @array, align 8, !tbaa !5
  %3 = tail call ptr @Tm_DArray_new(ptr noundef %2)
  %4 = mul nuw nsw i32 %.01321, 333
  store i32 %4, ptr %3, align 4, !tbaa !9
  %5 = load ptr, ptr @array, align 8, !tbaa !5
  %6 = tail call i32 @Tm_DArray_push(ptr noundef %5, ptr noundef nonnull %3) #7
  %7 = add nuw nsw i32 %.01321, 1
  %exitcond.not = icmp eq i32 %7, 1000
  br i1 %exitcond.not, label %8, label %1, !llvm.loop !11

8:                                                ; preds = %1
  %9 = load ptr, ptr @array, align 8, !tbaa !5
  %10 = getelementptr inbounds i8, ptr %9, i64 4
  %11 = load i32, ptr %10, align 4, !tbaa !13
  %12 = icmp eq i32 %11, 1201
  br i1 %12, label %.preheader, label %13

13:                                               ; preds = %8
  %14 = load ptr, ptr @stderr, align 8, !tbaa !5
  %15 = tail call ptr @__errno_location() #8
  %16 = load i32, ptr %15, align 4, !tbaa !9
  %17 = icmp eq i32 %16, 0
  br i1 %17, label %20, label %18

18:                                               ; preds = %13
  %19 = tail call ptr @strerror(i32 noundef %16) #7
  br label %20

20:                                               ; preds = %13, %18
  %21 = phi ptr [ %19, %18 ], [ @.str.2, %13 ]
  %22 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %14, ptr noundef nonnull @.str.28, ptr noundef nonnull @.str.1, i32 noundef 95, ptr noundef %21) #9
  br label %.thread

.preheader:                                       ; preds = %8, %49
  %.11422 = phi i32 [ %50, %49 ], [ 999, %8 ]
  %23 = load ptr, ptr @array, align 8, !tbaa !5
  %24 = tail call ptr @Tm_DArray_pop(ptr noundef %23) #7
  %.not = icmp eq ptr %24, null
  br i1 %.not, label %25, label %35

25:                                               ; preds = %.preheader
  %26 = load ptr, ptr @stderr, align 8, !tbaa !5
  %27 = tail call ptr @__errno_location() #8
  %28 = load i32, ptr %27, align 4, !tbaa !9
  %29 = icmp eq i32 %28, 0
  br i1 %29, label %32, label %30

30:                                               ; preds = %25
  %31 = tail call ptr @strerror(i32 noundef %28) #7
  br label %32

32:                                               ; preds = %25, %30
  %33 = phi ptr [ %31, %30 ], [ @.str.2, %25 ]
  %34 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %26, ptr noundef nonnull @.str.30, ptr noundef nonnull @.str.1, i32 noundef 99, ptr noundef %33) #9
  br label %.thread

35:                                               ; preds = %.preheader
  %36 = load i32, ptr %24, align 4, !tbaa !9
  %37 = mul nuw nsw i32 %.11422, 333
  %38 = icmp eq i32 %36, %37
  br i1 %38, label %49, label %39

39:                                               ; preds = %35
  %40 = load ptr, ptr @stderr, align 8, !tbaa !5
  %41 = tail call ptr @__errno_location() #8
  %42 = load i32, ptr %41, align 4, !tbaa !9
  %43 = icmp eq i32 %42, 0
  br i1 %43, label %46, label %44

44:                                               ; preds = %39
  %45 = tail call ptr @strerror(i32 noundef %42) #7
  br label %46

46:                                               ; preds = %39, %44
  %47 = phi ptr [ %45, %44 ], [ @.str.2, %39 ]
  %48 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %40, ptr noundef nonnull @.str.32, ptr noundef nonnull @.str.1, i32 noundef 100, ptr noundef %47) #9
  br label %.thread

49:                                               ; preds = %35
  tail call void @free(ptr noundef nonnull %24) #7
  %50 = add nsw i32 %.11422, -1
  %.not23 = icmp eq i32 %.11422, 0
  br i1 %.not23, label %.thread, label %.preheader, !llvm.loop !16

.thread:                                          ; preds = %49, %32, %46, %20
  %.2 = phi ptr [ @.str.29, %20 ], [ @.str.31, %32 ], [ @.str.33, %46 ], [ null, %49 ]
  ret ptr %.2
}

declare i32 @Tm_DArray_push(ptr noundef, ptr noundef) local_unnamed_addr #6

declare ptr @Tm_DArray_pop(ptr noundef) local_unnamed_addr #6

attributes #0 = { 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 #1 = { mustprogress nofree nosync nounwind willreturn memory(none) "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 = { 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 = { inlinehint 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 nounwind willreturn allockind("free") 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 #5 = { 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 #6 = { "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 = { nounwind }
attributes #8 = { nounwind willreturn memory(none) }
attributes #9 = { cold 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 = !{!14, !10, i64 4}
!14 = !{!"tm_darray_s", !10, i64 0, !10, i64 4, !15, i64 8, !15, i64 16, !6, i64 24}
!15 = !{!"long", !7, i64 0}
!16 = distinct !{!16, !12}


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