; 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 = external hidden unnamed_addr constant [53 x i8], align 1
@.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.3 = external hidden unnamed_addr constant [25 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [57 x i8], align 1
@.str.5 = external hidden unnamed_addr constant [29 x i8], align 1
@.str.6 = external hidden unnamed_addr constant [56 x i8], align 1
@.str.7 = external hidden unnamed_addr constant [28 x i8], align 1
@.str.8 = external hidden unnamed_addr constant [51 x i8], align 1
@.str.9 = external hidden unnamed_addr constant [23 x i8], align 1
@.str.10 = external hidden unnamed_addr constant [61 x i8], align 1
@.str.11 = external hidden unnamed_addr constant [33 x i8], align 1

; Function Attrs: nounwind uwtable
define dso_local ptr @test_create() #0 {
  %1 = alloca ptr, align 8
  %2 = call ptr @Tm_DArray_create(i64 noundef 4, i64 noundef 100)
  store ptr %2, ptr @array, align 8, !tbaa !5
  %3 = load ptr, ptr @array, align 8, !tbaa !5
  %4 = icmp ne ptr %3, null
  br i1 %4, label %18, label %5

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

10:                                               ; preds = %5
  br label %15

11:                                               ; preds = %5
  %12 = call ptr @__errno_location() #4
  %13 = load i32, ptr %12, align 4, !tbaa !9
  %14 = call ptr @strerror(i32 noundef %13) #5
  br label %15

15:                                               ; preds = %11, %10
  %16 = phi ptr [ @.str.2, %10 ], [ %14, %11 ]
  %17 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %6, ptr noundef @.str, ptr noundef @.str.1, i32 noundef 11, ptr noundef %16) #5
  store ptr @.str.3, ptr %1, align 8
  br label %91

18:                                               ; preds = %0
  %19 = load ptr, ptr @array, align 8, !tbaa !5
  %20 = getelementptr inbounds %struct.tm_darray_s, ptr %19, i32 0, i32 4
  %21 = load ptr, ptr %20, align 8, !tbaa !11
  %22 = icmp ne ptr %21, null
  br i1 %22, label %36, label %23

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

28:                                               ; preds = %23
  br label %33

29:                                               ; preds = %23
  %30 = call ptr @__errno_location() #4
  %31 = load i32, ptr %30, align 4, !tbaa !9
  %32 = call ptr @strerror(i32 noundef %31) #5
  br label %33

33:                                               ; preds = %29, %28
  %34 = phi ptr [ @.str.2, %28 ], [ %32, %29 ]
  %35 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %24, ptr noundef @.str.4, ptr noundef @.str.1, i32 noundef 12, ptr noundef %34) #5
  store ptr @.str.5, ptr %1, align 8
  br label %91

36:                                               ; preds = %18
  %37 = load ptr, ptr @array, align 8, !tbaa !5
  %38 = getelementptr inbounds %struct.tm_darray_s, ptr %37, i32 0, i32 0
  %39 = load i32, ptr %38, align 8, !tbaa !14
  %40 = icmp eq i32 %39, 0
  br i1 %40, label %54, label %41

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

46:                                               ; preds = %41
  br label %51

47:                                               ; preds = %41
  %48 = call ptr @__errno_location() #4
  %49 = load i32, ptr %48, align 4, !tbaa !9
  %50 = call ptr @strerror(i32 noundef %49) #5
  br label %51

51:                                               ; preds = %47, %46
  %52 = phi ptr [ @.str.2, %46 ], [ %50, %47 ]
  %53 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %42, ptr noundef @.str.6, ptr noundef @.str.1, i32 noundef 13, ptr noundef %52) #5
  store ptr @.str.7, ptr %1, align 8
  br label %91

54:                                               ; preds = %36
  %55 = load ptr, ptr @array, align 8, !tbaa !5
  %56 = getelementptr inbounds %struct.tm_darray_s, ptr %55, i32 0, i32 2
  %57 = load i64, ptr %56, align 8, !tbaa !15
  %58 = icmp eq i64 %57, 4
  br i1 %58, label %72, label %59

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

64:                                               ; preds = %59
  br label %69

65:                                               ; preds = %59
  %66 = call ptr @__errno_location() #4
  %67 = load i32, ptr %66, align 4, !tbaa !9
  %68 = call ptr @strerror(i32 noundef %67) #5
  br label %69

69:                                               ; preds = %65, %64
  %70 = phi ptr [ @.str.2, %64 ], [ %68, %65 ]
  %71 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %60, ptr noundef @.str.8, ptr noundef @.str.1, i32 noundef 14, ptr noundef %70) #5
  store ptr @.str.9, ptr %1, align 8
  br label %91

72:                                               ; preds = %54
  %73 = load ptr, ptr @array, align 8, !tbaa !5
  %74 = getelementptr inbounds %struct.tm_darray_s, ptr %73, i32 0, i32 1
  %75 = load i32, ptr %74, align 4, !tbaa !16
  %76 = icmp eq i32 %75, 100
  br i1 %76, label %90, label %77

77:                                               ; preds = %72
  %78 = load ptr, ptr @stderr, align 8, !tbaa !5
  %79 = call ptr @__errno_location() #4
  %80 = load i32, ptr %79, align 4, !tbaa !9
  %81 = icmp eq i32 %80, 0
  br i1 %81, label %82, label %83

82:                                               ; preds = %77
  br label %87

83:                                               ; preds = %77
  %84 = call ptr @__errno_location() #4
  %85 = load i32, ptr %84, align 4, !tbaa !9
  %86 = call ptr @strerror(i32 noundef %85) #5
  br label %87

87:                                               ; preds = %83, %82
  %88 = phi ptr [ @.str.2, %82 ], [ %86, %83 ]
  %89 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %78, ptr noundef @.str.10, ptr noundef @.str.1, i32 noundef 15, ptr noundef %88) #5
  store ptr @.str.11, ptr %1, align 8
  br label %91

90:                                               ; preds = %72
  store ptr null, ptr %1, align 8
  br label %91

91:                                               ; preds = %90, %87, %69, %51, %33, %15
  %92 = load ptr, ptr %1, align 8
  ret ptr %92
}

declare ptr @Tm_DArray_create(i64 noundef, i64 noundef) #1

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

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

; Function Attrs: nounwind
declare ptr @strerror(i32 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 = { "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 = { 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 willreturn memory(none) }
attributes #5 = { 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 = !{!12, !6, i64 24}
!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, !10, i64 0}
!15 = !{!12, !13, i64 8}
!16 = !{!12, !10, i64 4}


; 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 = external hidden unnamed_addr constant [53 x i8], align 1
@.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.3 = external hidden unnamed_addr constant [25 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [57 x i8], align 1
@.str.5 = external hidden unnamed_addr constant [29 x i8], align 1
@.str.6 = external hidden unnamed_addr constant [56 x i8], align 1
@.str.7 = external hidden unnamed_addr constant [28 x i8], align 1
@.str.8 = external hidden unnamed_addr constant [51 x i8], align 1
@.str.9 = external hidden unnamed_addr constant [23 x i8], align 1
@.str.10 = external hidden unnamed_addr constant [61 x i8], align 1
@.str.11 = external hidden unnamed_addr constant [33 x i8], align 1

; Function Attrs: nounwind uwtable
define dso_local noundef ptr @test_create() local_unnamed_addr #0 {
  %1 = tail call ptr @Tm_DArray_create(i64 noundef 4, i64 noundef 100) #5
  store ptr %1, ptr @array, align 8, !tbaa !5
  %.not = icmp eq ptr %1, null
  br i1 %.not, label %2, label %12

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

7:                                                ; preds = %2
  %8 = tail call ptr @strerror(i32 noundef %5) #5
  br label %9

9:                                                ; preds = %2, %7
  %10 = phi ptr [ %8, %7 ], [ @.str.2, %2 ]
  %11 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %3, ptr noundef nonnull @.str, ptr noundef nonnull @.str.1, i32 noundef 11, ptr noundef %10) #7
  br label %66

12:                                               ; preds = %0
  %13 = getelementptr inbounds i8, ptr %1, i64 24
  %14 = load ptr, ptr %13, align 8, !tbaa !11
  %.not7 = icmp eq ptr %14, null
  br i1 %.not7, label %15, label %25

15:                                               ; preds = %12
  %16 = load ptr, ptr @stderr, align 8, !tbaa !5
  %17 = tail call ptr @__errno_location() #6
  %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) #5
  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.4, ptr noundef nonnull @.str.1, i32 noundef 12, ptr noundef %23) #7
  br label %66

25:                                               ; preds = %12
  %26 = load i32, ptr %1, align 8, !tbaa !14
  %27 = icmp eq i32 %26, 0
  br i1 %27, label %38, label %28

28:                                               ; preds = %25
  %29 = load ptr, ptr @stderr, align 8, !tbaa !5
  %30 = tail call ptr @__errno_location() #6
  %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) #5
  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.6, ptr noundef nonnull @.str.1, i32 noundef 13, ptr noundef %36) #7
  br label %66

38:                                               ; preds = %25
  %39 = getelementptr inbounds i8, ptr %1, i64 8
  %40 = load i64, ptr %39, align 8, !tbaa !15
  %41 = icmp eq i64 %40, 4
  br i1 %41, label %52, label %42

42:                                               ; preds = %38
  %43 = load ptr, ptr @stderr, align 8, !tbaa !5
  %44 = tail call ptr @__errno_location() #6
  %45 = load i32, ptr %44, align 4, !tbaa !9
  %46 = icmp eq i32 %45, 0
  br i1 %46, label %49, label %47

47:                                               ; preds = %42
  %48 = tail call ptr @strerror(i32 noundef %45) #5
  br label %49

49:                                               ; preds = %42, %47
  %50 = phi ptr [ %48, %47 ], [ @.str.2, %42 ]
  %51 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %43, ptr noundef nonnull @.str.8, ptr noundef nonnull @.str.1, i32 noundef 14, ptr noundef %50) #7
  br label %66

52:                                               ; preds = %38
  %53 = getelementptr inbounds i8, ptr %1, i64 4
  %54 = load i32, ptr %53, align 4, !tbaa !16
  %55 = icmp eq i32 %54, 100
  br i1 %55, label %66, label %56

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

61:                                               ; preds = %56
  %62 = tail call ptr @strerror(i32 noundef %59) #5
  br label %63

63:                                               ; preds = %56, %61
  %64 = phi ptr [ %62, %61 ], [ @.str.2, %56 ]
  %65 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %57, ptr noundef nonnull @.str.10, ptr noundef nonnull @.str.1, i32 noundef 15, ptr noundef %64) #7
  br label %66

66:                                               ; preds = %52, %63, %49, %35, %22, %9
  %.0 = phi ptr [ @.str.11, %63 ], [ @.str.9, %49 ], [ @.str.7, %35 ], [ @.str.5, %22 ], [ @.str.3, %9 ], [ null, %52 ]
  ret ptr %.0
}

declare ptr @Tm_DArray_create(i64 noundef, 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

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 = { "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 = { nounwind }
attributes #6 = { nounwind willreturn memory(none) }
attributes #7 = { 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 = !{!12, !6, i64 24}
!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, !10, i64 0}
!15 = !{!12, !13, i64 8}
!16 = !{!12, !10, i64 4}


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