; LLVM IR from modlfo/AudioEngine :: AudioEngine/JuceLibraryCode/juce_gui_basics.ll (ZN4juce7Desktop21setScreenSaverEnabledEb)

; 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.juce::ScopedXLock" = type { i8 }

@_ZN4juce7displayE = external global ptr, align 8
@_ZN4juceL18screenSaverAllowedE = external hidden global i8, align 1
@_ZZN4juce7Desktop21setScreenSaverEnabledEbE19xScreenSaverSuspend = external hidden global ptr, align 8
@.str.256 = external hidden unnamed_addr constant [10 x i8], align 1
@.str.257 = external hidden unnamed_addr constant [20 x i8], align 1

declare i32 @__gxx_personality_v0(...)

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

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

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN4juce7Desktop21setScreenSaverEnabledEb(i1 noundef zeroext %0) #1 align 2 personality ptr @__gxx_personality_v0 {
  %2 = alloca i8, align 1
  %3 = alloca ptr, align 8
  %4 = alloca %"class.juce::ScopedXLock", align 1
  %5 = alloca ptr, align 8
  %6 = alloca i32, align 4
  %7 = zext i1 %0 to i8
  store i8 %7, ptr %2, align 1, !tbaa !5
  %8 = load i8, ptr @_ZN4juceL18screenSaverAllowedE, align 1, !tbaa !5, !range !9, !noundef !10
  %9 = trunc i8 %8 to i1
  %10 = zext i1 %9 to i32
  %11 = load i8, ptr %2, align 1, !tbaa !5, !range !9, !noundef !10
  %12 = trunc i8 %11 to i1
  %13 = zext i1 %12 to i32
  %14 = icmp ne i32 %10, %13
  br i1 %14, label %15, label %49

15:                                               ; preds = %1
  %16 = load i8, ptr %2, align 1, !tbaa !5, !range !9, !noundef !10
  %17 = trunc i8 %16 to i1
  %18 = zext i1 %17 to i8
  store i8 %18, ptr @_ZN4juceL18screenSaverAllowedE, align 1, !tbaa !5
  %19 = load ptr, ptr @_ZN4juce7displayE, align 8, !tbaa !11
  %20 = icmp ne ptr %19, null
  br i1 %20, label %21, label %48

21:                                               ; preds = %15
  %22 = load ptr, ptr @_ZZN4juce7Desktop21setScreenSaverEnabledEbE19xScreenSaverSuspend, align 8, !tbaa !11
  %23 = icmp eq ptr %22, null
  br i1 %23, label %24, label %32

24:                                               ; preds = %21
  call void @llvm.lifetime.start.p0(i64 8, ptr %3) #4
  %25 = call ptr @dlopen(ptr noundef @.str.256, i32 noundef 258) #4
  store ptr %25, ptr %3, align 8, !tbaa !11
  %26 = load ptr, ptr %3, align 8, !tbaa !11
  %27 = icmp ne ptr %26, null
  br i1 %27, label %28, label %31

28:                                               ; preds = %24
  %29 = load ptr, ptr %3, align 8, !tbaa !11
  %30 = call ptr @dlsym(ptr noundef %29, ptr noundef @.str.257) #4
  store ptr %30, ptr @_ZZN4juce7Desktop21setScreenSaverEnabledEbE19xScreenSaverSuspend, align 8, !tbaa !11
  br label %31

31:                                               ; preds = %28, %24
  call void @llvm.lifetime.end.p0(i64 8, ptr %3) #4
  br label %32

32:                                               ; preds = %31, %21
  call void @llvm.lifetime.start.p0(i64 1, ptr %4) #4
  call void @_ZN4juce11ScopedXLockC1Ev(ptr noundef nonnull align 1 dereferenceable(1) %4)
  %33 = load ptr, ptr @_ZZN4juce7Desktop21setScreenSaverEnabledEbE19xScreenSaverSuspend, align 8, !tbaa !11
  %34 = icmp ne ptr %33, null
  br i1 %34, label %35, label %47

35:                                               ; preds = %32
  %36 = load ptr, ptr @_ZZN4juce7Desktop21setScreenSaverEnabledEbE19xScreenSaverSuspend, align 8, !tbaa !11
  %37 = load ptr, ptr @_ZN4juce7displayE, align 8, !tbaa !11
  %38 = load i8, ptr %2, align 1, !tbaa !5, !range !9, !noundef !10
  %39 = trunc i8 %38 to i1
  %40 = xor i1 %39, true
  %41 = zext i1 %40 to i32
  invoke void %36(ptr noundef %37, i32 noundef %41)
          to label %42 unwind label %43

42:                                               ; preds = %35
  br label %47

43:                                               ; preds = %35
  %44 = landingpad { ptr, i32 }
          cleanup
  %45 = extractvalue { ptr, i32 } %44, 0
  store ptr %45, ptr %5, align 8
  %46 = extractvalue { ptr, i32 } %44, 1
  store i32 %46, ptr %6, align 4
  call void @_ZN4juce11ScopedXLockD1Ev(ptr noundef nonnull align 1 dereferenceable(1) %4) #4
  call void @llvm.lifetime.end.p0(i64 1, ptr %4) #4
  br label %50

47:                                               ; preds = %42, %32
  call void @_ZN4juce11ScopedXLockD1Ev(ptr noundef nonnull align 1 dereferenceable(1) %4) #4
  call void @llvm.lifetime.end.p0(i64 1, ptr %4) #4
  br label %48

48:                                               ; preds = %47, %15
  br label %49

49:                                               ; preds = %48, %1
  ret void

50:                                               ; preds = %43
  %51 = load ptr, ptr %5, align 8
  %52 = load i32, ptr %6, align 4
  %53 = insertvalue { ptr, i32 } poison, ptr %51, 0
  %54 = insertvalue { ptr, i32 } %53, i32 %52, 1
  resume { ptr, i32 } %54
}

declare void @_ZN4juce11ScopedXLockC1Ev(ptr noundef nonnull align 1 dereferenceable(1)) unnamed_addr #2

; Function Attrs: nounwind
declare void @_ZN4juce11ScopedXLockD1Ev(ptr noundef nonnull align 1 dereferenceable(1)) unnamed_addr #3

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

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

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

!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++ TBAA"}
!9 = !{i8 0, i8 2}
!10 = !{}
!11 = !{!12, !12, i64 0}
!12 = !{!"any pointer", !7, i64 0}


; 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.juce::ScopedXLock" = type { i8 }

@_ZN4juce7displayE = external local_unnamed_addr global ptr, align 8
@_ZN4juceL18screenSaverAllowedE = external hidden local_unnamed_addr global i8, align 1
@_ZZN4juce7Desktop21setScreenSaverEnabledEbE19xScreenSaverSuspend = external hidden local_unnamed_addr global ptr, align 8
@.str.256 = external hidden unnamed_addr constant [10 x i8], align 1
@.str.257 = external hidden unnamed_addr constant [20 x i8], align 1

declare i32 @__gxx_personality_v0(...)

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

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

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN4juce7Desktop21setScreenSaverEnabledEb(i1 noundef zeroext %0) local_unnamed_addr #1 align 2 personality ptr @__gxx_personality_v0 {
  %2 = alloca %"class.juce::ScopedXLock", align 1
  %3 = load i8, ptr @_ZN4juceL18screenSaverAllowedE, align 1, !tbaa !5, !range !9, !noundef !10
  %4 = zext i1 %0 to i8
  %.not = icmp eq i8 %3, %4
  br i1 %.not, label %23, label %5

5:                                                ; preds = %1
  store i8 %4, ptr @_ZN4juceL18screenSaverAllowedE, align 1, !tbaa !5
  %6 = load ptr, ptr @_ZN4juce7displayE, align 8, !tbaa !11
  %.not7 = icmp eq ptr %6, null
  br i1 %.not7, label %23, label %7

7:                                                ; preds = %5
  %8 = load ptr, ptr @_ZZN4juce7Desktop21setScreenSaverEnabledEbE19xScreenSaverSuspend, align 8, !tbaa !11
  %9 = icmp eq ptr %8, null
  br i1 %9, label %10, label %14

10:                                               ; preds = %7
  %11 = tail call ptr @dlopen(ptr noundef nonnull @.str.256, i32 noundef 258) #4
  %.not8 = icmp eq ptr %11, null
  br i1 %.not8, label %14, label %12

12:                                               ; preds = %10
  %13 = tail call ptr @dlsym(ptr noundef nonnull %11, ptr noundef nonnull @.str.257) #4
  store ptr %13, ptr @_ZZN4juce7Desktop21setScreenSaverEnabledEbE19xScreenSaverSuspend, align 8, !tbaa !11
  br label %14

14:                                               ; preds = %10, %12, %7
  call void @llvm.lifetime.start.p0(i64 1, ptr nonnull %2) #4
  call void @_ZN4juce11ScopedXLockC1Ev(ptr noundef nonnull align 1 dereferenceable(1) %2)
  %15 = load ptr, ptr @_ZZN4juce7Desktop21setScreenSaverEnabledEbE19xScreenSaverSuspend, align 8, !tbaa !11
  %.not9 = icmp eq ptr %15, null
  br i1 %.not9, label %22, label %16

16:                                               ; preds = %14
  %17 = load ptr, ptr @_ZN4juce7displayE, align 8, !tbaa !11
  %18 = xor i1 %0, true
  %19 = zext i1 %18 to i32
  invoke void %15(ptr noundef %17, i32 noundef %19)
          to label %22 unwind label %20

20:                                               ; preds = %16
  %21 = landingpad { ptr, i32 }
          cleanup
  call void @_ZN4juce11ScopedXLockD1Ev(ptr noundef nonnull align 1 dereferenceable(1) %2) #4
  call void @llvm.lifetime.end.p0(i64 1, ptr nonnull %2) #4
  resume { ptr, i32 } %21

22:                                               ; preds = %16, %14
  call void @_ZN4juce11ScopedXLockD1Ev(ptr noundef nonnull align 1 dereferenceable(1) %2) #4
  call void @llvm.lifetime.end.p0(i64 1, ptr nonnull %2) #4
  br label %23

23:                                               ; preds = %5, %22, %1
  ret void
}

declare void @_ZN4juce11ScopedXLockC1Ev(ptr noundef nonnull align 1 dereferenceable(1)) unnamed_addr #2

; Function Attrs: nounwind
declare void @_ZN4juce11ScopedXLockD1Ev(ptr noundef nonnull align 1 dereferenceable(1)) unnamed_addr #3

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

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

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

!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++ TBAA"}
!9 = !{i8 0, i8 2}
!10 = !{}
!11 = !{!12, !12, i64 0}
!12 = !{!"any pointer", !7, i64 0}


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