; 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.24 = external hidden unnamed_addr constant [53 x i8], align 1
@.str.25 = external hidden unnamed_addr constant [25 x i8], align 1
@.str.26 = external hidden unnamed_addr constant [69 x i8], align 1
@.str.27 = external hidden unnamed_addr constant [41 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: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture) #2

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

; Function Attrs: nounwind uwtable
define dso_local ptr @test_expand_contract() #3 {
  %1 = alloca ptr, align 8
  %2 = alloca i32, align 4
  %3 = alloca i32, align 4
  call void @llvm.lifetime.start.p0(i64 4, ptr %2) #5
  %4 = load ptr, ptr @array, align 8, !tbaa !5
  %5 = getelementptr inbounds %struct.tm_darray_s, ptr %4, i32 0, i32 1
  %6 = load i32, ptr %5, align 4, !tbaa !9
  store i32 %6, ptr %2, align 4, !tbaa !13
  %7 = load ptr, ptr @array, align 8, !tbaa !5
  %8 = call i32 @Tm_DArray_expand(ptr noundef %7)
  %9 = load ptr, ptr @array, align 8, !tbaa !5
  %10 = getelementptr inbounds %struct.tm_darray_s, ptr %9, i32 0, i32 1
  %11 = load i32, ptr %10, align 4, !tbaa !9
  %12 = zext i32 %11 to i64
  %13 = load i32, ptr %2, align 4, !tbaa !13
  %14 = sext i32 %13 to i64
  %15 = load ptr, ptr @array, align 8, !tbaa !5
  %16 = getelementptr inbounds %struct.tm_darray_s, ptr %15, i32 0, i32 3
  %17 = load i64, ptr %16, align 8, !tbaa !14
  %18 = add i64 %14, %17
  %19 = icmp eq i64 %12, %18
  br i1 %19, label %33, label %20

20:                                               ; preds = %0
  %21 = load ptr, ptr @stderr, align 8, !tbaa !5
  %22 = call ptr @__errno_location() #6
  %23 = load i32, ptr %22, align 4, !tbaa !13
  %24 = icmp eq i32 %23, 0
  br i1 %24, label %25, label %26

25:                                               ; preds = %20
  br label %30

26:                                               ; preds = %20
  %27 = call ptr @__errno_location() #6
  %28 = load i32, ptr %27, align 4, !tbaa !13
  %29 = call ptr @strerror(i32 noundef %28) #5
  br label %30

30:                                               ; preds = %26, %25
  %31 = phi ptr [ @.str.2, %25 ], [ %29, %26 ]
  %32 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %21, ptr noundef @.str.24, ptr noundef @.str.1, i32 noundef 75, ptr noundef %31) #5
  store ptr @.str.25, ptr %1, align 8
  store i32 1, ptr %3, align 4
  br label %84

33:                                               ; preds = %0
  %34 = load ptr, ptr @array, align 8, !tbaa !5
  %35 = call i32 @Tm_DArray_contract(ptr noundef %34)
  %36 = load ptr, ptr @array, align 8, !tbaa !5
  %37 = getelementptr inbounds %struct.tm_darray_s, ptr %36, i32 0, i32 1
  %38 = load i32, ptr %37, align 4, !tbaa !9
  %39 = zext i32 %38 to i64
  %40 = load ptr, ptr @array, align 8, !tbaa !5
  %41 = getelementptr inbounds %struct.tm_darray_s, ptr %40, i32 0, i32 3
  %42 = load i64, ptr %41, align 8, !tbaa !14
  %43 = add i64 %42, 1
  %44 = icmp eq i64 %39, %43
  br i1 %44, label %58, label %45

45:                                               ; preds = %33
  %46 = load ptr, ptr @stderr, align 8, !tbaa !5
  %47 = call ptr @__errno_location() #6
  %48 = load i32, ptr %47, align 4, !tbaa !13
  %49 = icmp eq i32 %48, 0
  br i1 %49, label %50, label %51

50:                                               ; preds = %45
  br label %55

51:                                               ; preds = %45
  %52 = call ptr @__errno_location() #6
  %53 = load i32, ptr %52, align 4, !tbaa !13
  %54 = call ptr @strerror(i32 noundef %53) #5
  br label %55

55:                                               ; preds = %51, %50
  %56 = phi ptr [ @.str.2, %50 ], [ %54, %51 ]
  %57 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %46, ptr noundef @.str.26, ptr noundef @.str.1, i32 noundef 78, ptr noundef %56) #5
  store ptr @.str.27, ptr %1, align 8
  store i32 1, ptr %3, align 4
  br label %84

58:                                               ; preds = %33
  %59 = load ptr, ptr @array, align 8, !tbaa !5
  %60 = call i32 @Tm_DArray_contract(ptr noundef %59)
  %61 = load ptr, ptr @array, align 8, !tbaa !5
  %62 = getelementptr inbounds %struct.tm_darray_s, ptr %61, i32 0, i32 1
  %63 = load i32, ptr %62, align 4, !tbaa !9
  %64 = zext i32 %63 to i64
  %65 = load ptr, ptr @array, align 8, !tbaa !5
  %66 = getelementptr inbounds %struct.tm_darray_s, ptr %65, i32 0, i32 3
  %67 = load i64, ptr %66, align 8, !tbaa !14
  %68 = add i64 %67, 1
  %69 = icmp eq i64 %64, %68
  br i1 %69, label %83, label %70

70:                                               ; preds = %58
  %71 = load ptr, ptr @stderr, align 8, !tbaa !5
  %72 = call ptr @__errno_location() #6
  %73 = load i32, ptr %72, align 4, !tbaa !13
  %74 = icmp eq i32 %73, 0
  br i1 %74, label %75, label %76

75:                                               ; preds = %70
  br label %80

76:                                               ; preds = %70
  %77 = call ptr @__errno_location() #6
  %78 = load i32, ptr %77, align 4, !tbaa !13
  %79 = call ptr @strerror(i32 noundef %78) #5
  br label %80

80:                                               ; preds = %76, %75
  %81 = phi ptr [ @.str.2, %75 ], [ %79, %76 ]
  %82 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %71, ptr noundef @.str.26, ptr noundef @.str.1, i32 noundef 81, ptr noundef %81) #5
  store ptr @.str.27, ptr %1, align 8
  store i32 1, ptr %3, align 4
  br label %84

83:                                               ; preds = %58
  store ptr null, ptr %1, align 8
  store i32 1, ptr %3, align 4
  br label %84

84:                                               ; preds = %83, %80, %55, %30
  call void @llvm.lifetime.end.p0(i64 4, ptr %2) #5
  %85 = load ptr, ptr %1, align 8
  ret ptr %85
}

declare i32 @Tm_DArray_expand(ptr noundef) #4

declare i32 @Tm_DArray_contract(ptr noundef) #4

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

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

@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.24 = external hidden unnamed_addr constant [53 x i8], align 1
@.str.25 = external hidden unnamed_addr constant [25 x i8], align 1
@.str.26 = external hidden unnamed_addr constant [69 x i8], align 1
@.str.27 = external hidden unnamed_addr constant [41 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: nounwind uwtable
define dso_local noundef ptr @test_expand_contract() local_unnamed_addr #3 {
  %1 = load ptr, ptr @array, align 8, !tbaa !5
  %2 = getelementptr inbounds i8, ptr %1, i64 4
  %3 = load i32, ptr %2, align 4, !tbaa !9
  %4 = tail call i32 @Tm_DArray_expand(ptr noundef %1) #5
  %5 = load ptr, ptr @array, align 8, !tbaa !5
  %6 = getelementptr inbounds i8, ptr %5, i64 4
  %7 = load i32, ptr %6, align 4, !tbaa !9
  %8 = zext i32 %7 to i64
  %9 = sext i32 %3 to i64
  %10 = getelementptr inbounds i8, ptr %5, i64 16
  %11 = load i64, ptr %10, align 8, !tbaa !13
  %12 = add i64 %11, %9
  %13 = icmp eq i64 %12, %8
  br i1 %13, label %24, label %14

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

19:                                               ; preds = %14
  %20 = tail call ptr @strerror(i32 noundef %17) #5
  br label %21

21:                                               ; preds = %14, %19
  %22 = phi ptr [ %20, %19 ], [ @.str.2, %14 ]
  %23 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %15, ptr noundef nonnull @.str.24, ptr noundef nonnull @.str.1, i32 noundef 75, ptr noundef %22) #7
  br label %64

24:                                               ; preds = %0
  %25 = tail call i32 @Tm_DArray_contract(ptr noundef nonnull %5) #5
  %26 = load ptr, ptr @array, align 8, !tbaa !5
  %27 = getelementptr inbounds i8, ptr %26, i64 4
  %28 = load i32, ptr %27, align 4, !tbaa !9
  %29 = zext i32 %28 to i64
  %30 = getelementptr inbounds i8, ptr %26, i64 16
  %31 = load i64, ptr %30, align 8, !tbaa !13
  %32 = add i64 %31, 1
  %33 = icmp eq i64 %32, %29
  br i1 %33, label %44, label %34

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

39:                                               ; preds = %34
  %40 = tail call ptr @strerror(i32 noundef %37) #5
  br label %41

41:                                               ; preds = %34, %39
  %42 = phi ptr [ %40, %39 ], [ @.str.2, %34 ]
  %43 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %35, ptr noundef nonnull @.str.26, ptr noundef nonnull @.str.1, i32 noundef 78, ptr noundef %42) #7
  br label %64

44:                                               ; preds = %24
  %45 = tail call i32 @Tm_DArray_contract(ptr noundef nonnull %26) #5
  %46 = load ptr, ptr @array, align 8, !tbaa !5
  %47 = getelementptr inbounds i8, ptr %46, i64 4
  %48 = load i32, ptr %47, align 4, !tbaa !9
  %49 = zext i32 %48 to i64
  %50 = getelementptr inbounds i8, ptr %46, i64 16
  %51 = load i64, ptr %50, align 8, !tbaa !13
  %52 = add i64 %51, 1
  %53 = icmp eq i64 %52, %49
  br i1 %53, label %64, label %54

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

59:                                               ; preds = %54
  %60 = tail call ptr @strerror(i32 noundef %57) #5
  br label %61

61:                                               ; preds = %54, %59
  %62 = phi ptr [ %60, %59 ], [ @.str.2, %54 ]
  %63 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %55, ptr noundef nonnull @.str.26, ptr noundef nonnull @.str.1, i32 noundef 81, ptr noundef %62) #7
  br label %64

64:                                               ; preds = %44, %61, %41, %21
  %.0 = phi ptr [ @.str.27, %61 ], [ @.str.27, %41 ], [ @.str.25, %21 ], [ null, %44 ]
  ret ptr %.0
}

declare i32 @Tm_DArray_expand(ptr noundef) local_unnamed_addr #4

declare i32 @Tm_DArray_contract(ptr noundef) local_unnamed_addr #4

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


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