; LLVM IR from mkazhdan/DMG :: Util/XPlatform.ll (ZN8IOServer4LoadEv)

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

%"class.boost::recursive_timed_mutex" = type <{ %union.pthread_mutex_t, %union.pthread_cond_t, i8, [7 x i8], i64, i32, [4 x 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_cond_t = type { %struct.__pthread_cond_s }
%struct.__pthread_cond_s = type { %union.__atomic_wide_counter, %union.__atomic_wide_counter, [2 x i32], [2 x i32], i32, i32, [2 x i32] }
%union.__atomic_wide_counter = type { i64 }

@_ZN8IOServer6_countE = external dso_local global i32, align 4
@_ZN8IOServer11_stdoutLockE = external dso_local global %"class.boost::recursive_timed_mutex", align 8
@_ZN8IOServer11_stderrLockE = external dso_local global %"class.boost::recursive_timed_mutex", align 8
@_ZN8IOServer11_systemLockE = external dso_local global %"class.boost::recursive_timed_mutex", align 8

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN8IOServer4LoadEv() #0 align 2 {
  %1 = load i32, ptr @_ZN8IOServer6_countE, align 4, !tbaa !5
  %2 = icmp ne i32 %1, 0
  br i1 %2, label %4, label %3

3:                                                ; preds = %0
  call void @_Z25InitializeCriticalSectionPN5boost21recursive_timed_mutexE(ptr noundef @_ZN8IOServer11_stdoutLockE)
  call void @_Z25InitializeCriticalSectionPN5boost21recursive_timed_mutexE(ptr noundef @_ZN8IOServer11_stderrLockE)
  call void @_Z25InitializeCriticalSectionPN5boost21recursive_timed_mutexE(ptr noundef @_ZN8IOServer11_systemLockE)
  br label %4

4:                                                ; preds = %3, %0
  %5 = load i32, ptr @_ZN8IOServer6_countE, align 4, !tbaa !5
  %6 = add nsw i32 %5, 1
  store i32 %6, ptr @_ZN8IOServer6_countE, align 4, !tbaa !5
  ret void
}

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local void @_Z25InitializeCriticalSectionPN5boost21recursive_timed_mutexE(ptr noundef) #1

attributes #0 = { mustprogress 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 = { inlinehint mustprogress 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" }

!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 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}


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

%"class.boost::recursive_timed_mutex" = type <{ %union.pthread_mutex_t, %union.pthread_cond_t, i8, [7 x i8], i64, i32, [4 x 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_cond_t = type { %struct.__pthread_cond_s }
%struct.__pthread_cond_s = type { %union.__atomic_wide_counter, %union.__atomic_wide_counter, [2 x i32], [2 x i32], i32, i32, [2 x i32] }
%union.__atomic_wide_counter = type { i64 }

@_ZN8IOServer6_countE = external dso_local local_unnamed_addr global i32, align 4
@_ZN8IOServer11_stdoutLockE = external dso_local global %"class.boost::recursive_timed_mutex", align 8
@_ZN8IOServer11_stderrLockE = external dso_local global %"class.boost::recursive_timed_mutex", align 8
@_ZN8IOServer11_systemLockE = external dso_local global %"class.boost::recursive_timed_mutex", align 8

; Function Attrs: mustprogress nounwind uwtable
define dso_local void @_ZN8IOServer4LoadEv() local_unnamed_addr #0 align 2 {
  %1 = load i32, ptr @_ZN8IOServer6_countE, align 4, !tbaa !5
  %.not = icmp eq i32 %1, 0
  br i1 %.not, label %2, label %3

2:                                                ; preds = %0
  tail call void @_Z25InitializeCriticalSectionPN5boost21recursive_timed_mutexE(ptr noundef nonnull @_ZN8IOServer11_stdoutLockE)
  tail call void @_Z25InitializeCriticalSectionPN5boost21recursive_timed_mutexE(ptr noundef nonnull @_ZN8IOServer11_stderrLockE)
  tail call void @_Z25InitializeCriticalSectionPN5boost21recursive_timed_mutexE(ptr noundef nonnull @_ZN8IOServer11_systemLockE)
  %.pre = load i32, ptr @_ZN8IOServer6_countE, align 4, !tbaa !5
  br label %3

3:                                                ; preds = %2, %0
  %4 = phi i32 [ %.pre, %2 ], [ %1, %0 ]
  %5 = add nsw i32 %4, 1
  store i32 %5, ptr @_ZN8IOServer6_countE, align 4, !tbaa !5
  ret void
}

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local void @_Z25InitializeCriticalSectionPN5boost21recursive_timed_mutexE(ptr noundef) local_unnamed_addr #1

attributes #0 = { mustprogress 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 = { inlinehint mustprogress 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" }

!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 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}


; Effective O3 passes: GVNPass,GlobalOptPass,InstCombinePass,PostOrderFunctionAttrsPass,TailCallElimPass