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

; 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_heap_s = type { ptr, ptr, ptr, ptr, i32, i32, i32, i32, i64, ptr, ptr, ptr, ptr }
%struct.tm_cell_s = type { ptr, ptr, ptr, i8 }
%struct.tm_object_header_s = type { ptr }

@stderr = external global ptr, align 8
@.str.9 = external hidden unnamed_addr constant [70 x i8], align 1
@.str.13 = external hidden unnamed_addr constant [39 x i8], align 1
@.str.14 = external hidden unnamed_addr constant [5 x i8], align 1
@.str.15 = external hidden unnamed_addr constant [43 x i8], align 1

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

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

; Function Attrs: nounwind uwtable
declare dso_local void @Tm_flip(ptr noundef) #2

; Function Attrs: nounwind uwtable
declare dso_local void @Tm_scan(ptr noundef) #2

; Function Attrs: nounwind uwtable
define dso_local ptr @Tm_allocate(ptr noundef %0) #2 {
  %2 = alloca ptr, align 8
  %3 = alloca ptr, align 8
  %4 = alloca ptr, align 8
  store ptr %0, ptr %2, align 8, !tbaa !5
  %5 = load ptr, ptr %2, align 8, !tbaa !5
  %6 = getelementptr inbounds %struct.tm_heap_s, ptr %5, i32 0, i32 5
  %7 = load i32, ptr %6, align 4, !tbaa !9
  %8 = load ptr, ptr %2, align 8, !tbaa !5
  %9 = getelementptr inbounds %struct.tm_heap_s, ptr %8, i32 0, i32 6
  %10 = load i32, ptr %9, align 8, !tbaa !13
  %11 = icmp sge i32 %7, %10
  br i1 %11, label %12, label %16

12:                                               ; preds = %1
  %13 = load ptr, ptr %2, align 8, !tbaa !5
  %14 = getelementptr inbounds %struct.tm_heap_s, ptr %13, i32 0, i32 5
  store i32 0, ptr %14, align 4, !tbaa !9
  %15 = load ptr, ptr %2, align 8, !tbaa !5
  call void @Tm_scan(ptr noundef %15)
  br label %16

16:                                               ; preds = %12, %1
  %17 = load ptr, ptr %2, align 8, !tbaa !5
  %18 = getelementptr inbounds %struct.tm_heap_s, ptr %17, i32 0, i32 2
  %19 = load ptr, ptr %18, align 8, !tbaa !14
  %20 = getelementptr inbounds %struct.tm_cell_s, ptr %19, i32 0, i32 0
  %21 = load ptr, ptr %20, align 8, !tbaa !15
  %22 = load ptr, ptr %2, align 8, !tbaa !5
  %23 = getelementptr inbounds %struct.tm_heap_s, ptr %22, i32 0, i32 0
  %24 = load ptr, ptr %23, align 8, !tbaa !17
  %25 = icmp eq ptr %21, %24
  br i1 %25, label %26, label %50

26:                                               ; preds = %16
  %27 = load ptr, ptr %2, align 8, !tbaa !5
  call void @Tm_flip(ptr noundef %27)
  %28 = load ptr, ptr %2, align 8, !tbaa !5
  %29 = getelementptr inbounds %struct.tm_heap_s, ptr %28, i32 0, i32 2
  %30 = load ptr, ptr %29, align 8, !tbaa !14
  %31 = load ptr, ptr %2, align 8, !tbaa !5
  %32 = getelementptr inbounds %struct.tm_heap_s, ptr %31, i32 0, i32 0
  %33 = load ptr, ptr %32, align 8, !tbaa !17
  %34 = icmp ne ptr %30, %33
  br i1 %34, label %49, label %35

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

40:                                               ; preds = %35
  br label %45

41:                                               ; preds = %35
  %42 = call ptr @__errno_location() #5
  %43 = load i32, ptr %42, align 4, !tbaa !18
  %44 = call ptr @strerror(i32 noundef %43) #6
  br label %45

45:                                               ; preds = %41, %40
  %46 = phi ptr [ @.str.14, %40 ], [ %44, %41 ]
  %47 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %36, ptr noundef @.str.13, ptr noundef @.str.9, i32 noundef 372, ptr noundef %46) #6
  %48 = call ptr @__errno_location() #5
  store i32 0, ptr %48, align 4, !tbaa !18
  br label %97

49:                                               ; preds = %26
  br label %50

50:                                               ; preds = %49, %16
  %51 = load ptr, ptr %2, align 8, !tbaa !5
  %52 = getelementptr inbounds %struct.tm_heap_s, ptr %51, i32 0, i32 8
  %53 = load i64, ptr %52, align 8, !tbaa !19
  %54 = call noalias ptr @calloc(i64 noundef 1, i64 noundef %53) #7
  store ptr %54, ptr %3, align 8, !tbaa !5
  %55 = load ptr, ptr %3, align 8, !tbaa !5
  %56 = icmp ne ptr %55, null
  br i1 %56, label %71, label %57

57:                                               ; preds = %50
  %58 = load ptr, ptr @stderr, align 8, !tbaa !5
  %59 = call ptr @__errno_location() #5
  %60 = load i32, ptr %59, align 4, !tbaa !18
  %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() #5
  %65 = load i32, ptr %64, align 4, !tbaa !18
  %66 = call ptr @strerror(i32 noundef %65) #6
  br label %67

67:                                               ; preds = %63, %62
  %68 = phi ptr [ @.str.14, %62 ], [ %66, %63 ]
  %69 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %58, ptr noundef @.str.15, ptr noundef @.str.9, i32 noundef 376, ptr noundef %68) #6
  %70 = call ptr @__errno_location() #5
  store i32 0, ptr %70, align 4, !tbaa !18
  br label %97

71:                                               ; preds = %50
  %72 = load ptr, ptr %2, align 8, !tbaa !5
  %73 = getelementptr inbounds %struct.tm_heap_s, ptr %72, i32 0, i32 2
  %74 = load ptr, ptr %73, align 8, !tbaa !14
  store ptr %74, ptr %4, align 8, !tbaa !5
  %75 = load ptr, ptr %4, align 8, !tbaa !5
  %76 = load ptr, ptr %3, align 8, !tbaa !5
  %77 = getelementptr inbounds %struct.tm_object_header_s, ptr %76, i32 0, i32 0
  store ptr %75, ptr %77, align 8, !tbaa !20
  %78 = load ptr, ptr %3, align 8, !tbaa !5
  %79 = load ptr, ptr %3, align 8, !tbaa !5
  %80 = getelementptr inbounds %struct.tm_object_header_s, ptr %79, i32 0, i32 0
  %81 = load ptr, ptr %80, align 8, !tbaa !20
  %82 = getelementptr inbounds %struct.tm_cell_s, ptr %81, i32 0, i32 2
  store ptr %78, ptr %82, align 8, !tbaa !22
  %83 = load ptr, ptr %2, align 8, !tbaa !5
  %84 = getelementptr inbounds %struct.tm_heap_s, ptr %83, i32 0, i32 2
  %85 = load ptr, ptr %84, align 8, !tbaa !14
  %86 = getelementptr inbounds %struct.tm_cell_s, ptr %85, i32 0, i32 0
  %87 = load ptr, ptr %86, align 8, !tbaa !15
  %88 = load ptr, ptr %2, align 8, !tbaa !5
  %89 = getelementptr inbounds %struct.tm_heap_s, ptr %88, i32 0, i32 2
  store ptr %87, ptr %89, align 8, !tbaa !14
  %90 = load ptr, ptr %2, align 8, !tbaa !5
  %91 = getelementptr inbounds %struct.tm_heap_s, ptr %90, i32 0, i32 5
  %92 = load i32, ptr %91, align 4, !tbaa !9
  %93 = add nsw i32 %92, 1
  store i32 %93, ptr %91, align 4, !tbaa !9
  %94 = load ptr, ptr %2, align 8, !tbaa !5
  %95 = getelementptr inbounds %struct.tm_heap_s, ptr %94, i32 0, i32 7
  store i32 1, ptr %95, align 4, !tbaa !23
  %96 = load ptr, ptr %3, align 8, !tbaa !5
  ret ptr %96

97:                                               ; preds = %67, %45
  call void @exit(i32 noundef 1) #8
  unreachable
}

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

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

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

attributes #0 = { 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 #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 = { 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 = { 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 = { 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 #5 = { nounwind willreturn memory(none) }
attributes #6 = { nounwind }
attributes #7 = { nounwind allocsize(0,1) }
attributes #8 = { noreturn 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, !11, i64 36}
!10 = !{!"tm_heap_s", !6, i64 0, !6, i64 8, !6, i64 16, !6, i64 24, !11, i64 32, !11, i64 36, !11, i64 40, !11, i64 44, !12, i64 48, !6, i64 56, !6, i64 64, !6, i64 72, !6, i64 80}
!11 = !{!"int", !7, i64 0}
!12 = !{!"long", !7, i64 0}
!13 = !{!10, !11, i64 40}
!14 = !{!10, !6, i64 16}
!15 = !{!16, !6, i64 0}
!16 = !{!"tm_cell_s", !6, i64 0, !6, i64 8, !6, i64 16, !7, i64 24}
!17 = !{!10, !6, i64 0}
!18 = !{!11, !11, i64 0}
!19 = !{!10, !12, i64 48}
!20 = !{!21, !6, i64 0}
!21 = !{!"tm_object_header_s", !6, i64 0}
!22 = !{!16, !6, i64 16}
!23 = !{!10, !11, i64 44}


; 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.9 = external hidden unnamed_addr constant [70 x i8], align 1
@.str.13 = external hidden unnamed_addr constant [39 x i8], align 1
@.str.14 = external hidden unnamed_addr constant [5 x i8], align 1
@.str.15 = external hidden unnamed_addr constant [43 x i8], align 1

; 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 #0

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

; Function Attrs: nounwind uwtable
declare dso_local void @Tm_flip(ptr noundef) local_unnamed_addr #2

; Function Attrs: nounwind uwtable
declare dso_local void @Tm_scan(ptr noundef) local_unnamed_addr #2

; Function Attrs: nounwind uwtable
define dso_local noundef ptr @Tm_allocate(ptr noundef %0) local_unnamed_addr #2 {
  %2 = getelementptr inbounds i8, ptr %0, i64 36
  %3 = load i32, ptr %2, align 4, !tbaa !5
  %4 = getelementptr inbounds i8, ptr %0, i64 40
  %5 = load i32, ptr %4, align 8, !tbaa !12
  %.not = icmp slt i32 %3, %5
  br i1 %.not, label %7, label %6

6:                                                ; preds = %1
  store i32 0, ptr %2, align 4, !tbaa !5
  tail call void @Tm_scan(ptr noundef nonnull %0)
  br label %7

7:                                                ; preds = %6, %1
  %8 = getelementptr inbounds i8, ptr %0, i64 16
  %9 = load ptr, ptr %8, align 8, !tbaa !13
  %10 = load ptr, ptr %9, align 8, !tbaa !14
  %11 = load ptr, ptr %0, align 8, !tbaa !16
  %12 = icmp eq ptr %10, %11
  br i1 %12, label %13, label %21

13:                                               ; preds = %7
  tail call void @Tm_flip(ptr noundef nonnull %0)
  %14 = load ptr, ptr %8, align 8, !tbaa !13
  %15 = load ptr, ptr %0, align 8, !tbaa !16
  %.not23 = icmp eq ptr %14, %15
  br i1 %.not23, label %16, label %21

16:                                               ; preds = %13
  %17 = load ptr, ptr @stderr, align 8, !tbaa !17
  %18 = tail call ptr @__errno_location() #6
  %19 = load i32, ptr %18, align 4, !tbaa !18
  %20 = icmp eq i32 %19, 0
  br i1 %20, label %38, label %.sink.split

21:                                               ; preds = %13, %7
  %22 = phi ptr [ %14, %13 ], [ %9, %7 ]
  %23 = getelementptr inbounds i8, ptr %0, i64 48
  %24 = load i64, ptr %23, align 8, !tbaa !19
  %25 = tail call noalias ptr @calloc(i64 noundef 1, i64 noundef %24) #7
  %.not24 = icmp eq ptr %25, null
  br i1 %.not24, label %26, label %31

26:                                               ; preds = %21
  %27 = load ptr, ptr @stderr, align 8, !tbaa !17
  %28 = tail call ptr @__errno_location() #6
  %29 = load i32, ptr %28, align 4, !tbaa !18
  %30 = icmp eq i32 %29, 0
  br i1 %30, label %38, label %.sink.split

31:                                               ; preds = %21
  store ptr %22, ptr %25, align 8, !tbaa !20
  %32 = getelementptr inbounds i8, ptr %22, i64 16
  store ptr %25, ptr %32, align 8, !tbaa !22
  %33 = load ptr, ptr %22, align 8, !tbaa !14
  store ptr %33, ptr %8, align 8, !tbaa !13
  %34 = load i32, ptr %2, align 4, !tbaa !5
  %35 = add nsw i32 %34, 1
  store i32 %35, ptr %2, align 4, !tbaa !5
  %36 = getelementptr inbounds i8, ptr %0, i64 44
  store i32 1, ptr %36, align 4, !tbaa !23
  ret ptr %25

.sink.split:                                      ; preds = %26, %16
  %.sink28 = phi i32 [ %19, %16 ], [ %29, %26 ]
  %.sink26.ph = phi i32 [ 372, %16 ], [ 376, %26 ]
  %.str.15.sink.ph = phi ptr [ @.str.13, %16 ], [ @.str.15, %26 ]
  %.sink25.ph = phi ptr [ %17, %16 ], [ %27, %26 ]
  %.sink.ph = phi ptr [ %18, %16 ], [ %28, %26 ]
  %37 = tail call ptr @strerror(i32 noundef %.sink28) #8
  br label %38

38:                                               ; preds = %.sink.split, %26, %16
  %.sink27 = phi ptr [ @.str.14, %16 ], [ @.str.14, %26 ], [ %37, %.sink.split ]
  %.sink26 = phi i32 [ 372, %16 ], [ 376, %26 ], [ %.sink26.ph, %.sink.split ]
  %.str.15.sink = phi ptr [ @.str.13, %16 ], [ @.str.15, %26 ], [ %.str.15.sink.ph, %.sink.split ]
  %.sink25 = phi ptr [ %17, %16 ], [ %27, %26 ], [ %.sink25.ph, %.sink.split ]
  %.sink = phi ptr [ %18, %16 ], [ %28, %26 ], [ %.sink.ph, %.sink.split ]
  %39 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %.sink25, ptr noundef nonnull %.str.15.sink, ptr noundef nonnull @.str.9, i32 noundef %.sink26, ptr noundef %.sink27) #9
  store i32 0, ptr %.sink, align 4, !tbaa !18
  tail call void @exit(i32 noundef 1) #10
  unreachable
}

; 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: noreturn nounwind
declare void @exit(i32 noundef) local_unnamed_addr #5

attributes #0 = { 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 #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 = { 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 = { 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 = { 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 #6 = { nounwind willreturn memory(none) }
attributes #7 = { nounwind allocsize(0,1) }
attributes #8 = { nounwind }
attributes #9 = { cold nounwind }
attributes #10 = { noreturn 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, !10, i64 36}
!6 = !{!"tm_heap_s", !7, i64 0, !7, i64 8, !7, i64 16, !7, i64 24, !10, i64 32, !10, i64 36, !10, i64 40, !10, i64 44, !11, i64 48, !7, i64 56, !7, i64 64, !7, i64 72, !7, i64 80}
!7 = !{!"any pointer", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"int", !8, i64 0}
!11 = !{!"long", !8, i64 0}
!12 = !{!6, !10, i64 40}
!13 = !{!6, !7, i64 16}
!14 = !{!15, !7, i64 0}
!15 = !{!"tm_cell_s", !7, i64 0, !7, i64 8, !7, i64 16, !8, i64 24}
!16 = !{!6, !7, i64 0}
!17 = !{!7, !7, i64 0}
!18 = !{!10, !10, i64 0}
!19 = !{!6, !11, i64 48}
!20 = !{!21, !7, i64 0}
!21 = !{!"tm_object_header_s", !7, i64 0}
!22 = !{!15, !7, i64 16}
!23 = !{!6, !10, i64 44}


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