; LLVM IR from txus/libtreadmill :: src/treadmill (darray)

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

@stderr = external global ptr, align 8
@.str = external hidden unnamed_addr constant [43 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [74 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [5 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [61 x i8], align 1

; Function Attrs: nounwind uwtable
define dso_local ptr @Tm_DArray_create(i64 noundef %0, i64 noundef %1) #0 {
  %3 = alloca ptr, align 8
  %4 = alloca i64, align 8
  %5 = alloca i64, align 8
  %6 = alloca ptr, align 8
  %7 = alloca i32, align 4
  store i64 %0, ptr %4, align 8, !tbaa !5
  store i64 %1, ptr %5, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #6
  %8 = call noalias ptr @malloc(i64 noundef 32) #7
  store ptr %8, ptr %6, align 8, !tbaa !9
  %9 = load ptr, ptr %6, align 8, !tbaa !9
  %10 = icmp ne ptr %9, null
  br i1 %10, label %25, label %11

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

16:                                               ; preds = %11
  br label %21

17:                                               ; preds = %11
  %18 = call ptr @__errno_location() #8
  %19 = load i32, ptr %18, align 4, !tbaa !11
  %20 = call ptr @strerror(i32 noundef %19) #6
  br label %21

21:                                               ; preds = %17, %16
  %22 = phi ptr [ @.str.2, %16 ], [ %20, %17 ]
  %23 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %12, ptr noundef @.str, ptr noundef @.str.1, i32 noundef 7, ptr noundef %22) #6
  %24 = call ptr @__errno_location() #8
  store i32 0, ptr %24, align 4, !tbaa !11
  br label %80

25:                                               ; preds = %2
  %26 = load i64, ptr %5, align 8, !tbaa !5
  %27 = trunc i64 %26 to i32
  %28 = load ptr, ptr %6, align 8, !tbaa !9
  %29 = getelementptr inbounds %struct.tm_darray_s, ptr %28, i32 0, i32 1
  store i32 %27, ptr %29, align 4, !tbaa !13
  %30 = load ptr, ptr %6, align 8, !tbaa !9
  %31 = getelementptr inbounds %struct.tm_darray_s, ptr %30, i32 0, i32 1
  %32 = load i32, ptr %31, align 4, !tbaa !13
  %33 = icmp sgt i32 %32, 0
  br i1 %33, label %48, label %34

34:                                               ; preds = %25
  %35 = load ptr, ptr @stderr, align 8, !tbaa !9
  %36 = call ptr @__errno_location() #8
  %37 = load i32, ptr %36, align 4, !tbaa !11
  %38 = icmp eq i32 %37, 0
  br i1 %38, label %39, label %40

39:                                               ; preds = %34
  br label %44

40:                                               ; preds = %34
  %41 = call ptr @__errno_location() #8
  %42 = load i32, ptr %41, align 4, !tbaa !11
  %43 = call ptr @strerror(i32 noundef %42) #6
  br label %44

44:                                               ; preds = %40, %39
  %45 = phi ptr [ @.str.2, %39 ], [ %43, %40 ]
  %46 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %35, ptr noundef @.str.3, ptr noundef @.str.1, i32 noundef 9, ptr noundef %45) #6
  %47 = call ptr @__errno_location() #8
  store i32 0, ptr %47, align 4, !tbaa !11
  br label %80

48:                                               ; preds = %25
  %49 = load i64, ptr %5, align 8, !tbaa !5
  %50 = call noalias ptr @calloc(i64 noundef %49, i64 noundef 8) #9
  %51 = load ptr, ptr %6, align 8, !tbaa !9
  %52 = getelementptr inbounds %struct.tm_darray_s, ptr %51, i32 0, i32 4
  store ptr %50, ptr %52, align 8, !tbaa !15
  %53 = load ptr, ptr %6, align 8, !tbaa !9
  %54 = getelementptr inbounds %struct.tm_darray_s, ptr %53, i32 0, i32 4
  %55 = load ptr, ptr %54, align 8, !tbaa !15
  %56 = icmp ne ptr %55, null
  br i1 %56, label %71, label %57

57:                                               ; preds = %48
  %58 = load ptr, ptr @stderr, align 8, !tbaa !9
  %59 = call ptr @__errno_location() #8
  %60 = load i32, ptr %59, align 4, !tbaa !11
  %61 = icmp eq i32 %60, 0
  br i1 %61, label %62, label %63

62:                                               ; preds = %57
  br label %67

63:                                               ; preds = %57
  %64 = call ptr @__errno_location() #8
  %65 = load i32, ptr %64, align 4, !tbaa !11
  %66 = call ptr @strerror(i32 noundef %65) #6
  br label %67

67:                                               ; preds = %63, %62
  %68 = phi ptr [ @.str.2, %62 ], [ %66, %63 ]
  %69 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %58, ptr noundef @.str, ptr noundef @.str.1, i32 noundef 12, ptr noundef %68) #6
  %70 = call ptr @__errno_location() #8
  store i32 0, ptr %70, align 4, !tbaa !11
  br label %80

71:                                               ; preds = %48
  %72 = load ptr, ptr %6, align 8, !tbaa !9
  %73 = getelementptr inbounds %struct.tm_darray_s, ptr %72, i32 0, i32 0
  store i32 0, ptr %73, align 8, !tbaa !16
  %74 = load i64, ptr %4, align 8, !tbaa !5
  %75 = load ptr, ptr %6, align 8, !tbaa !9
  %76 = getelementptr inbounds %struct.tm_darray_s, ptr %75, i32 0, i32 2
  store i64 %74, ptr %76, align 8, !tbaa !17
  %77 = load ptr, ptr %6, align 8, !tbaa !9
  %78 = getelementptr inbounds %struct.tm_darray_s, ptr %77, i32 0, i32 3
  store i64 300, ptr %78, align 8, !tbaa !18
  %79 = load ptr, ptr %6, align 8, !tbaa !9
  store ptr %79, ptr %3, align 8
  store i32 1, ptr %7, align 4
  br label %86

80:                                               ; preds = %67, %44, %21
  %81 = load ptr, ptr %6, align 8, !tbaa !9
  %82 = icmp ne ptr %81, null
  br i1 %82, label %83, label %85

83:                                               ; preds = %80
  %84 = load ptr, ptr %6, align 8, !tbaa !9
  call void @free(ptr noundef %84) #6
  br label %85

85:                                               ; preds = %83, %80
  store ptr null, ptr %3, align 8
  store i32 1, ptr %7, align 4
  br label %86

86:                                               ; preds = %85, %71
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #6
  %87 = load ptr, ptr %3, align 8
  ret ptr %87
}

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

; Function Attrs: nounwind allocsize(0)
declare noalias ptr @malloc(i64 noundef) #2

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

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

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

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

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

; 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 = { nounwind 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 #3 = { 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 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 #5 = { nounwind allocsize(0,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 allocsize(0) }
attributes #8 = { nounwind willreturn memory(none) }
attributes #9 = { nounwind allocsize(0,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 = !{!"long", !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 = !{!12, !12, i64 0}
!12 = !{!"int", !7, i64 0}
!13 = !{!14, !12, i64 4}
!14 = !{!"tm_darray_s", !12, i64 0, !12, i64 4, !6, i64 8, !6, i64 16, !10, i64 24}
!15 = !{!14, !10, i64 24}
!16 = !{!14, !12, i64 0}
!17 = !{!14, !6, i64 8}
!18 = !{!14, !6, i64 16}


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

@stderr = external local_unnamed_addr global ptr, align 8
@.str = external hidden unnamed_addr constant [43 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [74 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [5 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [61 x i8], align 1

; Function Attrs: nounwind uwtable
define dso_local noalias noundef ptr @Tm_DArray_create(i64 noundef %0, i64 noundef %1) local_unnamed_addr #0 {
  %3 = tail call noalias dereferenceable_or_null(32) ptr @malloc(i64 noundef 32) #7
  %.not = icmp eq ptr %3, null
  br i1 %.not, label %4, label %11

4:                                                ; preds = %2
  %5 = load ptr, ptr @stderr, align 8, !tbaa !5
  %6 = tail call ptr @__errno_location() #8
  %7 = load i32, ptr %6, align 4, !tbaa !9
  %8 = icmp eq i32 %7, 0
  br i1 %8, label %41, label %9

9:                                                ; preds = %4
  %10 = tail call ptr @strerror(i32 noundef %7) #9
  br label %41

11:                                               ; preds = %2
  %12 = trunc i64 %1 to i32
  %13 = getelementptr inbounds i8, ptr %3, i64 4
  store i32 %12, ptr %13, align 4, !tbaa !11
  %14 = icmp sgt i32 %12, 0
  br i1 %14, label %25, label %15

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

20:                                               ; preds = %15
  %21 = tail call ptr @strerror(i32 noundef %18) #9
  br label %22

22:                                               ; preds = %15, %20
  %23 = phi ptr [ %21, %20 ], [ @.str.2, %15 ]
  %24 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %16, ptr noundef nonnull @.str.3, ptr noundef nonnull @.str.1, i32 noundef 9, ptr noundef %23) #10
  br label %44

25:                                               ; preds = %11
  %26 = tail call noalias ptr @calloc(i64 noundef %1, i64 noundef 8) #11
  %27 = getelementptr inbounds i8, ptr %3, i64 24
  store ptr %26, ptr %27, align 8, !tbaa !14
  %.not18 = icmp eq ptr %26, null
  br i1 %.not18, label %28, label %38

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

33:                                               ; preds = %28
  %34 = tail call ptr @strerror(i32 noundef %31) #9
  br label %35

35:                                               ; preds = %28, %33
  %36 = phi ptr [ %34, %33 ], [ @.str.2, %28 ]
  %37 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %29, ptr noundef nonnull @.str, ptr noundef nonnull @.str.1, i32 noundef 12, ptr noundef %36) #10
  br label %44

38:                                               ; preds = %25
  store i32 0, ptr %3, align 8, !tbaa !15
  %39 = getelementptr inbounds i8, ptr %3, i64 8
  store i64 %0, ptr %39, align 8, !tbaa !16
  %40 = getelementptr inbounds i8, ptr %3, i64 16
  store i64 300, ptr %40, align 8, !tbaa !17
  br label %45

41:                                               ; preds = %9, %4
  %42 = phi ptr [ %10, %9 ], [ @.str.2, %4 ]
  %43 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %5, ptr noundef nonnull @.str, ptr noundef nonnull @.str.1, i32 noundef 7, ptr noundef %42) #10
  store i32 0, ptr %6, align 4, !tbaa !9
  br label %45

44:                                               ; preds = %35, %22
  %.sink = phi ptr [ %30, %35 ], [ %17, %22 ]
  store i32 0, ptr %.sink, align 4, !tbaa !9
  tail call void @free(ptr noundef nonnull %3) #9
  br label %45

45:                                               ; preds = %41, %44, %38
  %.0 = phi ptr [ %3, %38 ], [ null, %44 ], [ null, %41 ]
  ret ptr %.0
}

; Function Attrs: mustprogress nofree nounwind willreturn allockind("alloc,uninitialized") allocsize(0) memory(inaccessiblemem: readwrite)
declare noalias noundef ptr @malloc(i64 noundef) local_unnamed_addr #1

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

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

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

; Function Attrs: mustprogress nofree nounwind willreturn allockind("alloc,zeroed") allocsize(0,1) memory(inaccessiblemem: readwrite)
declare noalias noundef ptr @calloc(i64 noundef, i64 noundef) local_unnamed_addr #5

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

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 nofree nounwind willreturn allockind("alloc,uninitialized") allocsize(0) memory(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 #2 = { 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 #3 = { 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 #4 = { 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 = { mustprogress nofree nounwind willreturn allockind("alloc,zeroed") allocsize(0,1) memory(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 = { 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 #7 = { nounwind allocsize(0) }
attributes #8 = { nounwind willreturn memory(none) }
attributes #9 = { nounwind }
attributes #10 = { cold nounwind }
attributes #11 = { nounwind allocsize(0,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 4}
!12 = !{!"tm_darray_s", !10, i64 0, !10, i64 4, !13, i64 8, !13, i64 16, !6, i64 24}
!13 = !{!"long", !7, i64 0}
!14 = !{!12, !6, i64 24}
!15 = !{!12, !10, i64 0}
!16 = !{!12, !13, i64 8}
!17 = !{!12, !13, i64 16}


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