; LLVM IR from unitreerobotics/kinect_teleoperate :: src/extern/glfw/src/tests (monitors)

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

@.str.1 = external hidden unnamed_addr constant [3 x i8], align 1

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

; Function Attrs: nounwind uwtable
define dso_local i32 @main(i32 noundef %0, ptr noundef %1) #1 {
  %3 = alloca i32, align 4
  %4 = alloca i32, align 4
  %5 = alloca ptr, align 8
  %6 = alloca i32, align 4
  %7 = alloca i32, align 4
  %8 = alloca i32, align 4
  %9 = alloca i32, align 4
  %10 = alloca ptr, align 8
  store i32 0, ptr %3, align 4
  store i32 %0, ptr %4, align 4, !tbaa !5
  store ptr %1, ptr %5, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #4
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #4
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #4
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #4
  store i32 0, ptr %9, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #4
  br label %11

11:                                               ; preds = %21, %2
  %12 = load i32, ptr %4, align 4, !tbaa !5
  %13 = load ptr, ptr %5, align 8, !tbaa !9
  %14 = call i32 @getopt(i32 noundef %12, ptr noundef %13, ptr noundef @.str.1)
  store i32 %14, ptr %6, align 4, !tbaa !5
  %15 = icmp ne i32 %14, -1
  br i1 %15, label %16, label %22

16:                                               ; preds = %11
  %17 = load i32, ptr %6, align 4, !tbaa !5
  switch i32 %17, label %20 [
    i32 104, label %18
    i32 116, label %19
  ]

18:                                               ; preds = %16
  call void @usage()
  call void @exit(i32 noundef 0) #5
  unreachable

19:                                               ; preds = %16
  store i32 1, ptr %9, align 4, !tbaa !5
  br label %21

20:                                               ; preds = %16
  call void @usage()
  call void @exit(i32 noundef 1) #5
  unreachable

21:                                               ; preds = %19
  br label %11, !llvm.loop !11

22:                                               ; preds = %11
  %23 = call ptr @glfwSetErrorCallback(ptr noundef @error_callback)
  call void @glfwInitHint(i32 noundef 331778, i32 noundef 0)
  %24 = call i32 @glfwInit()
  %25 = icmp ne i32 %24, 0
  br i1 %25, label %27, label %26

26:                                               ; preds = %22
  call void @exit(i32 noundef 1) #5
  unreachable

27:                                               ; preds = %22
  %28 = call ptr @glfwGetMonitors(ptr noundef %8)
  store ptr %28, ptr %10, align 8, !tbaa !9
  store i32 0, ptr %7, align 4, !tbaa !5
  br label %29

29:                                               ; preds = %53, %27
  %30 = load i32, ptr %7, align 4, !tbaa !5
  %31 = load i32, ptr %8, align 4, !tbaa !5
  %32 = icmp slt i32 %30, %31
  br i1 %32, label %33, label %56

33:                                               ; preds = %29
  %34 = load i32, ptr %9, align 4, !tbaa !5
  %35 = icmp eq i32 %34, 0
  br i1 %35, label %36, label %42

36:                                               ; preds = %33
  %37 = load ptr, ptr %10, align 8, !tbaa !9
  %38 = load i32, ptr %7, align 4, !tbaa !5
  %39 = sext i32 %38 to i64
  %40 = getelementptr inbounds ptr, ptr %37, i64 %39
  %41 = load ptr, ptr %40, align 8, !tbaa !9
  call void @list_modes(ptr noundef %41)
  br label %52

42:                                               ; preds = %33
  %43 = load i32, ptr %9, align 4, !tbaa !5
  %44 = icmp eq i32 %43, 1
  br i1 %44, label %45, label %51

45:                                               ; preds = %42
  %46 = load ptr, ptr %10, align 8, !tbaa !9
  %47 = load i32, ptr %7, align 4, !tbaa !5
  %48 = sext i32 %47 to i64
  %49 = getelementptr inbounds ptr, ptr %46, i64 %48
  %50 = load ptr, ptr %49, align 8, !tbaa !9
  call void @test_modes(ptr noundef %50)
  br label %51

51:                                               ; preds = %45, %42
  br label %52

52:                                               ; preds = %51, %36
  br label %53

53:                                               ; preds = %52
  %54 = load i32, ptr %7, align 4, !tbaa !5
  %55 = add nsw i32 %54, 1
  store i32 %55, ptr %7, align 4, !tbaa !5
  br label %29, !llvm.loop !13

56:                                               ; preds = %29
  call void @glfwTerminate()
  call void @exit(i32 noundef 0) #5
  unreachable
}

declare i32 @getopt(i32 noundef, ptr noundef, ptr noundef) #2

; Function Attrs: nounwind uwtable
declare hidden void @usage() #1

; Function Attrs: noreturn nounwind
declare void @exit(i32 noundef) #3

declare ptr @glfwSetErrorCallback(ptr noundef) #2

; Function Attrs: nounwind uwtable
declare hidden void @error_callback(i32 noundef, ptr noundef) #1

declare void @glfwInitHint(i32 noundef, i32 noundef) #2

declare i32 @glfwInit() #2

declare ptr @glfwGetMonitors(ptr noundef) #2

; Function Attrs: nounwind uwtable
declare hidden void @list_modes(ptr noundef) #1

; Function Attrs: nounwind uwtable
declare hidden void @test_modes(ptr noundef) #1

declare void @glfwTerminate() #2

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { 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 #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 = { 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 #4 = { nounwind }
attributes #5 = { noreturn 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 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"any pointer", !7, i64 0}
!11 = distinct !{!11, !12}
!12 = !{!"llvm.loop.mustprogress"}
!13 = distinct !{!13, !12}


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

@.str.1 = external hidden unnamed_addr constant [3 x i8], align 1

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

; Function Attrs: noreturn nounwind uwtable
define dso_local noundef i32 @main(i32 noundef %0, ptr noundef %1) local_unnamed_addr #1 {
.peel.begin:
  %2 = alloca i32, align 4
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %2) #5
  %3 = tail call i32 @getopt(i32 noundef %0, ptr noundef %1, ptr noundef nonnull @.str.1) #5
  switch i32 %3, label %.loopexit [
    i32 -1, label %.loopexit20
    i32 104, label %.loopexit21
    i32 116, label %.peel.next
  ]

.peel.next:                                       ; preds = %.peel.begin, %.peel.next
  %4 = tail call i32 @getopt(i32 noundef %0, ptr noundef %1, ptr noundef nonnull @.str.1) #5
  switch i32 %4, label %.loopexit [
    i32 -1, label %.loopexit20
    i32 104, label %.loopexit21
    i32 116, label %.peel.next
  ], !llvm.loop !5

.loopexit21:                                      ; preds = %.peel.next, %.peel.begin
  tail call void @usage()
  tail call void @exit(i32 noundef 0) #6
  unreachable

.loopexit:                                        ; preds = %.peel.next, %.peel.begin
  tail call void @usage()
  tail call void @exit(i32 noundef 1) #6
  unreachable

.loopexit20:                                      ; preds = %.peel.next, %.peel.begin
  %.lcssa17 = phi i1 [ true, %.peel.begin ], [ false, %.peel.next ]
  %5 = tail call ptr @glfwSetErrorCallback(ptr noundef nonnull @error_callback) #5
  tail call void @glfwInitHint(i32 noundef 331778, i32 noundef 0) #5
  %6 = tail call i32 @glfwInit() #5
  %.not12 = icmp eq i32 %6, 0
  br i1 %.not12, label %7, label %8

7:                                                ; preds = %.loopexit20
  tail call void @exit(i32 noundef 1) #6
  unreachable

8:                                                ; preds = %.loopexit20
  %9 = call ptr @glfwGetMonitors(ptr noundef nonnull %2) #5
  %10 = load i32, ptr %2, align 4, !tbaa !8
  %11 = icmp sgt i32 %10, 0
  br i1 %11, label %.lr.ph, label %._crit_edge

.lr.ph:                                           ; preds = %8
  br i1 %.lcssa17, label %.lr.ph.split.us, label %.lr.ph.split

.lr.ph.split.us:                                  ; preds = %.lr.ph, %.lr.ph.split.us
  %indvars.iv23 = phi i64 [ %indvars.iv.next24, %.lr.ph.split.us ], [ 0, %.lr.ph ]
  %12 = getelementptr inbounds ptr, ptr %9, i64 %indvars.iv23
  %13 = load ptr, ptr %12, align 8, !tbaa !12
  call void @list_modes(ptr noundef %13)
  %indvars.iv.next24 = add nuw nsw i64 %indvars.iv23, 1
  %14 = load i32, ptr %2, align 4, !tbaa !8
  %15 = sext i32 %14 to i64
  %16 = icmp slt i64 %indvars.iv.next24, %15
  br i1 %16, label %.lr.ph.split.us, label %._crit_edge, !llvm.loop !14

.lr.ph.split:                                     ; preds = %.lr.ph, %.lr.ph.split
  %indvars.iv = phi i64 [ %indvars.iv.next, %.lr.ph.split ], [ 0, %.lr.ph ]
  %17 = getelementptr inbounds ptr, ptr %9, i64 %indvars.iv
  %18 = load ptr, ptr %17, align 8, !tbaa !12
  call void @test_modes(ptr noundef %18)
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %19 = load i32, ptr %2, align 4, !tbaa !8
  %20 = sext i32 %19 to i64
  %21 = icmp slt i64 %indvars.iv.next, %20
  br i1 %21, label %.lr.ph.split, label %._crit_edge, !llvm.loop !14

._crit_edge:                                      ; preds = %.lr.ph.split, %.lr.ph.split.us, %8
  call void @glfwTerminate() #5
  call void @exit(i32 noundef 0) #6
  unreachable
}

declare i32 @getopt(i32 noundef, ptr noundef, ptr noundef) local_unnamed_addr #2

; Function Attrs: nounwind uwtable
declare hidden void @usage() local_unnamed_addr #3

; Function Attrs: noreturn nounwind
declare void @exit(i32 noundef) local_unnamed_addr #4

declare ptr @glfwSetErrorCallback(ptr noundef) local_unnamed_addr #2

; Function Attrs: nounwind uwtable
declare hidden void @error_callback(i32 noundef, ptr noundef) #3

declare void @glfwInitHint(i32 noundef, i32 noundef) local_unnamed_addr #2

declare i32 @glfwInit() local_unnamed_addr #2

declare ptr @glfwGetMonitors(ptr noundef) local_unnamed_addr #2

; Function Attrs: nounwind uwtable
declare hidden void @list_modes(ptr noundef) local_unnamed_addr #3

; Function Attrs: nounwind uwtable
declare hidden void @test_modes(ptr noundef) local_unnamed_addr #3

declare void @glfwTerminate() local_unnamed_addr #2

attributes #0 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { noreturn 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 #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 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 = { 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 #5 = { nounwind }
attributes #6 = { noreturn 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 = distinct !{!5, !6, !7}
!6 = !{!"llvm.loop.mustprogress"}
!7 = !{!"llvm.loop.peeled.count", i32 1}
!8 = !{!9, !9, i64 0}
!9 = !{!"int", !10, i64 0}
!10 = !{!"omnipotent char", !11, i64 0}
!11 = !{!"Simple C/C++ TBAA"}
!12 = !{!13, !13, i64 0}
!13 = !{!"any pointer", !10, i64 0}
!14 = distinct !{!14, !6}


; Effective O3 passes: GVNPass,GlobalOptPass,IPSCCPPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,LCSSAPass,LoopFullUnrollPass,LoopRotatePass,LoopSimplifyCFGPass,LoopSimplifyPass,LoopUnrollPass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass,TailCallElimPass