; LLVM IR from septag/dmon :: test-incremental (dmon_init)

; 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.dmon__state = type { [64 x ptr], [64 x i32], ptr, i32, i64, %union.pthread_mutex_t, i8 }
%union.pthread_mutex_t = type { %struct.__pthread_mutex_s }
%struct.__pthread_mutex_s = type { i32, i32, i32, i32, i32, i16, i16, %struct.__pthread_internal_list }
%struct.__pthread_internal_list = type { ptr, ptr }
%union.pthread_mutexattr_t = type { i32 }

@_dmon_init = external hidden global i8, align 1
@.str = external hidden unnamed_addr constant [12 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [52 x i8], align 1
@__PRETTY_FUNCTION__.dmon_init = external hidden unnamed_addr constant [21 x i8], align 1
@_dmon = external hidden global %struct.dmon__state, align 8
@.str.3 = external hidden unnamed_addr constant [34 x i8], align 1

; Function Attrs: nounwind uwtable
define dso_local void @dmon_init() #0 {
  %1 = alloca %union.pthread_mutexattr_t, align 4
  %2 = alloca i32, align 4
  %3 = alloca i32, align 4
  %4 = load i8, ptr @_dmon_init, align 1, !tbaa !5, !range !9, !noundef !10
  %5 = trunc i8 %4 to i1
  br i1 %5, label %7, label %6

6:                                                ; preds = %0
  br label %8

7:                                                ; preds = %0
  call void @__assert_fail(ptr noundef @.str, ptr noundef @.str.1, i32 noundef 1162, ptr noundef @__PRETTY_FUNCTION__.dmon_init) #4
  unreachable

8:                                                ; preds = %6
  call void @llvm.lifetime.start.p0(i64 4, ptr %1) #5
  %9 = call i32 @pthread_mutexattr_init(ptr noundef %1) #5
  %10 = call i32 @pthread_mutexattr_settype(ptr noundef %1, i32 noundef 1) #5
  %11 = call i32 @pthread_mutex_init(ptr noundef getelementptr inbounds (%struct.dmon__state, ptr @_dmon, i32 0, i32 5), ptr noundef %1) #5
  call void @llvm.lifetime.start.p0(i64 4, ptr %2) #5
  %12 = call i32 @pthread_create(ptr noundef getelementptr inbounds (%struct.dmon__state, ptr @_dmon, i32 0, i32 4), ptr noundef null, ptr noundef @_dmon_thread, ptr noundef null) #5
  store i32 %12, ptr %2, align 4, !tbaa !11
  %13 = load i32, ptr %2, align 4, !tbaa !11
  %14 = load i32, ptr %2, align 4, !tbaa !11
  %15 = icmp eq i32 %14, 0
  br i1 %15, label %16, label %18

16:                                               ; preds = %8
  br i1 true, label %17, label %18

17:                                               ; preds = %16
  br label %19

18:                                               ; preds = %16, %8
  call void @__assert_fail(ptr noundef @.str.3, ptr noundef @.str.1, i32 noundef 1171, ptr noundef @__PRETTY_FUNCTION__.dmon_init) #4
  unreachable

19:                                               ; preds = %17
  call void @llvm.lifetime.start.p0(i64 4, ptr %3) #5
  store i32 0, ptr %3, align 4, !tbaa !11
  br label %20

20:                                               ; preds = %31, %19
  %21 = load i32, ptr %3, align 4, !tbaa !11
  %22 = icmp slt i32 %21, 64
  br i1 %22, label %24, label %23

23:                                               ; preds = %20
  call void @llvm.lifetime.end.p0(i64 4, ptr %3) #5
  br label %34

24:                                               ; preds = %20
  %25 = load i32, ptr %3, align 4, !tbaa !11
  %26 = sub nsw i32 64, %25
  %27 = sub nsw i32 %26, 1
  %28 = load i32, ptr %3, align 4, !tbaa !11
  %29 = sext i32 %28 to i64
  %30 = getelementptr inbounds [64 x i32], ptr getelementptr inbounds (%struct.dmon__state, ptr @_dmon, i32 0, i32 1), i64 0, i64 %29
  store i32 %27, ptr %30, align 4, !tbaa !11
  br label %31

31:                                               ; preds = %24
  %32 = load i32, ptr %3, align 4, !tbaa !11
  %33 = add nsw i32 %32, 1
  store i32 %33, ptr %3, align 4, !tbaa !11
  br label %20, !llvm.loop !13

34:                                               ; preds = %23
  store i8 1, ptr @_dmon_init, align 1, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 4, ptr %2) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %1) #5
  ret void
}

; Function Attrs: noreturn nounwind
declare void @__assert_fail(ptr noundef, ptr noundef, i32 noundef, ptr noundef) #1

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

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

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

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

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

; Function Attrs: nounwind uwtable
declare hidden ptr @_dmon_thread(ptr noundef) #0

; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #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 = { 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 #2 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 = { noreturn nounwind }
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 = !{!"_Bool", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{i8 0, i8 2}
!10 = !{}
!11 = !{!12, !12, i64 0}
!12 = !{!"int", !7, i64 0}
!13 = distinct !{!13, !14}
!14 = !{!"llvm.loop.mustprogress"}


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

%struct.dmon__state = type { [64 x ptr], [64 x i32], ptr, i32, i64, %union.pthread_mutex_t, i8 }
%union.pthread_mutex_t = type { %struct.__pthread_mutex_s }
%struct.__pthread_mutex_s = type { i32, i32, i32, i32, i32, i16, i16, %struct.__pthread_internal_list }
%struct.__pthread_internal_list = type { ptr, ptr }
%union.pthread_mutexattr_t = type { i32 }

@_dmon_init = external hidden local_unnamed_addr global i8, align 1
@.str = external hidden unnamed_addr constant [12 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [52 x i8], align 1
@__PRETTY_FUNCTION__.dmon_init = external hidden unnamed_addr constant [21 x i8], align 1
@_dmon = external hidden global %struct.dmon__state, align 8
@.str.3 = external hidden unnamed_addr constant [34 x i8], align 1

; Function Attrs: nounwind uwtable
define dso_local void @dmon_init() local_unnamed_addr #0 {
  %1 = alloca %union.pthread_mutexattr_t, align 4
  %2 = load i8, ptr @_dmon_init, align 1, !tbaa !5, !range !9, !noundef !10
  %3 = trunc nuw i8 %2 to i1
  br i1 %3, label %4, label %5

4:                                                ; preds = %0
  tail call void @__assert_fail(ptr noundef nonnull @.str, ptr noundef nonnull @.str.1, i32 noundef 1162, ptr noundef nonnull @__PRETTY_FUNCTION__.dmon_init) #4
  unreachable

5:                                                ; preds = %0
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %1) #5
  %6 = call i32 @pthread_mutexattr_init(ptr noundef nonnull %1) #5
  %7 = call i32 @pthread_mutexattr_settype(ptr noundef nonnull %1, i32 noundef 1) #5
  %8 = call i32 @pthread_mutex_init(ptr noundef nonnull getelementptr inbounds (i8, ptr @_dmon, i64 792), ptr noundef nonnull %1) #5
  %9 = call i32 @pthread_create(ptr noundef nonnull getelementptr inbounds (i8, ptr @_dmon, i64 784), ptr noundef null, ptr noundef nonnull @_dmon_thread, ptr noundef null) #5
  %10 = icmp eq i32 %9, 0
  br i1 %10, label %.preheader.preheader, label %11

.preheader.preheader:                             ; preds = %5
  store <4 x i32> <i32 63, i32 62, i32 61, i32 60>, ptr getelementptr inbounds (i8, ptr @_dmon, i64 512), align 8, !tbaa !11
  store <4 x i32> <i32 59, i32 58, i32 57, i32 56>, ptr getelementptr inbounds (i8, ptr @_dmon, i64 528), align 8, !tbaa !11
  store <4 x i32> <i32 55, i32 54, i32 53, i32 52>, ptr getelementptr inbounds (i8, ptr @_dmon, i64 544), align 8, !tbaa !11
  store <4 x i32> <i32 51, i32 50, i32 49, i32 48>, ptr getelementptr inbounds (i8, ptr @_dmon, i64 560), align 8, !tbaa !11
  store <4 x i32> <i32 47, i32 46, i32 45, i32 44>, ptr getelementptr inbounds (i8, ptr @_dmon, i64 576), align 8, !tbaa !11
  store <4 x i32> <i32 43, i32 42, i32 41, i32 40>, ptr getelementptr inbounds (i8, ptr @_dmon, i64 592), align 8, !tbaa !11
  store <4 x i32> <i32 39, i32 38, i32 37, i32 36>, ptr getelementptr inbounds (i8, ptr @_dmon, i64 608), align 8, !tbaa !11
  store <4 x i32> <i32 35, i32 34, i32 33, i32 32>, ptr getelementptr inbounds (i8, ptr @_dmon, i64 624), align 8, !tbaa !11
  store <4 x i32> <i32 31, i32 30, i32 29, i32 28>, ptr getelementptr inbounds (i8, ptr @_dmon, i64 640), align 8, !tbaa !11
  store <4 x i32> <i32 27, i32 26, i32 25, i32 24>, ptr getelementptr inbounds (i8, ptr @_dmon, i64 656), align 8, !tbaa !11
  store <4 x i32> <i32 23, i32 22, i32 21, i32 20>, ptr getelementptr inbounds (i8, ptr @_dmon, i64 672), align 8, !tbaa !11
  store <4 x i32> <i32 19, i32 18, i32 17, i32 16>, ptr getelementptr inbounds (i8, ptr @_dmon, i64 688), align 8, !tbaa !11
  store <4 x i32> <i32 15, i32 14, i32 13, i32 12>, ptr getelementptr inbounds (i8, ptr @_dmon, i64 704), align 8, !tbaa !11
  store <4 x i32> <i32 11, i32 10, i32 9, i32 8>, ptr getelementptr inbounds (i8, ptr @_dmon, i64 720), align 8, !tbaa !11
  store <4 x i32> <i32 7, i32 6, i32 5, i32 4>, ptr getelementptr inbounds (i8, ptr @_dmon, i64 736), align 8, !tbaa !11
  store <4 x i32> <i32 3, i32 2, i32 1, i32 0>, ptr getelementptr inbounds (i8, ptr @_dmon, i64 752), align 8, !tbaa !11
  store i8 1, ptr @_dmon_init, align 1, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %1) #5
  ret void

11:                                               ; preds = %5
  call void @__assert_fail(ptr noundef nonnull @.str.3, ptr noundef nonnull @.str.1, i32 noundef 1171, ptr noundef nonnull @__PRETTY_FUNCTION__.dmon_init) #4
  unreachable
}

; Function Attrs: noreturn nounwind
declare void @__assert_fail(ptr noundef, ptr noundef, i32 noundef, ptr noundef) local_unnamed_addr #1

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

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

; Function Attrs: nounwind
declare i32 @pthread_mutexattr_settype(ptr noundef, i32 noundef) local_unnamed_addr #3

; Function Attrs: nounwind
declare i32 @pthread_mutex_init(ptr noundef, ptr noundef) local_unnamed_addr #3

; Function Attrs: nounwind
declare i32 @pthread_create(ptr noundef, ptr noundef, ptr noundef, ptr noundef) local_unnamed_addr #3

; Function Attrs: nounwind uwtable
declare hidden ptr @_dmon_thread(ptr noundef) #0

; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #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 = { 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 #2 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 = { noreturn nounwind }
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 = !{!"_Bool", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{i8 0, i8 2}
!10 = !{}
!11 = !{!12, !12, i64 0}
!12 = !{!"int", !7, i64 0}


; Effective O3 passes: GVNPass,GlobalOptPass,IPSCCPPass,IndVarSimplifyPass,InferAlignmentPass,InferFunctionAttrsPass,InstCombinePass,LoopRotatePass,LoopSimplifyPass,SLPVectorizerPass,SROAPass,SimplifyCFGPass,TailCallElimPass