; LLVM IR from unitreerobotics/kinect_teleoperate :: src/extern/glfw/src/examples (boing)

; 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.GLFWvidmode = type { i32, i32, i32, i32, i32, i32 }

@windowed_xpos = external dso_local global i32, align 4
@windowed_ypos = external dso_local global i32, align 4
@windowed_width = external dso_local global i32, align 4
@windowed_height = external dso_local global i32, align 4

; 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: nounwind uwtable
define dso_local void @key_callback(ptr noundef %0, i32 noundef %1, i32 noundef %2, i32 noundef %3, i32 noundef %4) #1 {
  %6 = alloca ptr, align 8
  %7 = alloca i32, align 4
  %8 = alloca i32, align 4
  %9 = alloca i32, align 4
  %10 = alloca i32, align 4
  %11 = alloca ptr, align 8
  %12 = alloca ptr, align 8
  store ptr %0, ptr %6, align 8, !tbaa !5
  store i32 %1, ptr %7, align 4, !tbaa !9
  store i32 %2, ptr %8, align 4, !tbaa !9
  store i32 %3, ptr %9, align 4, !tbaa !9
  store i32 %4, ptr %10, align 4, !tbaa !9
  %13 = load i32, ptr %9, align 4, !tbaa !9
  %14 = icmp ne i32 %13, 1
  br i1 %14, label %15, label %16

15:                                               ; preds = %5
  br label %68

16:                                               ; preds = %5
  %17 = load i32, ptr %7, align 4, !tbaa !9
  %18 = icmp eq i32 %17, 256
  br i1 %18, label %19, label %24

19:                                               ; preds = %16
  %20 = load i32, ptr %10, align 4, !tbaa !9
  %21 = icmp eq i32 %20, 0
  br i1 %21, label %22, label %24

22:                                               ; preds = %19
  %23 = load ptr, ptr %6, align 8, !tbaa !5
  call void @glfwSetWindowShouldClose(ptr noundef %23, i32 noundef 1)
  br label %24

24:                                               ; preds = %22, %19, %16
  %25 = load i32, ptr %7, align 4, !tbaa !9
  %26 = icmp eq i32 %25, 257
  br i1 %26, label %27, label %30

27:                                               ; preds = %24
  %28 = load i32, ptr %10, align 4, !tbaa !9
  %29 = icmp eq i32 %28, 4
  br i1 %29, label %36, label %30

30:                                               ; preds = %27, %24
  %31 = load i32, ptr %7, align 4, !tbaa !9
  %32 = icmp eq i32 %31, 300
  br i1 %32, label %33, label %68

33:                                               ; preds = %30
  %34 = load i32, ptr %10, align 4, !tbaa !9
  %35 = icmp eq i32 %34, 4
  br i1 %35, label %36, label %68

36:                                               ; preds = %33, %27
  %37 = load ptr, ptr %6, align 8, !tbaa !5
  %38 = call ptr @glfwGetWindowMonitor(ptr noundef %37)
  %39 = icmp ne ptr %38, null
  br i1 %39, label %40, label %46

40:                                               ; preds = %36
  %41 = load ptr, ptr %6, align 8, !tbaa !5
  %42 = load i32, ptr @windowed_xpos, align 4, !tbaa !9
  %43 = load i32, ptr @windowed_ypos, align 4, !tbaa !9
  %44 = load i32, ptr @windowed_width, align 4, !tbaa !9
  %45 = load i32, ptr @windowed_height, align 4, !tbaa !9
  call void @glfwSetWindowMonitor(ptr noundef %41, ptr noundef null, i32 noundef %42, i32 noundef %43, i32 noundef %44, i32 noundef %45, i32 noundef 0)
  br label %67

46:                                               ; preds = %36
  call void @llvm.lifetime.start.p0(i64 8, ptr %11) #3
  %47 = call ptr @glfwGetPrimaryMonitor()
  store ptr %47, ptr %11, align 8, !tbaa !5
  %48 = load ptr, ptr %11, align 8, !tbaa !5
  %49 = icmp ne ptr %48, null
  br i1 %49, label %50, label %66

50:                                               ; preds = %46
  call void @llvm.lifetime.start.p0(i64 8, ptr %12) #3
  %51 = load ptr, ptr %11, align 8, !tbaa !5
  %52 = call ptr @glfwGetVideoMode(ptr noundef %51)
  store ptr %52, ptr %12, align 8, !tbaa !5
  %53 = load ptr, ptr %6, align 8, !tbaa !5
  call void @glfwGetWindowPos(ptr noundef %53, ptr noundef @windowed_xpos, ptr noundef @windowed_ypos)
  %54 = load ptr, ptr %6, align 8, !tbaa !5
  call void @glfwGetWindowSize(ptr noundef %54, ptr noundef @windowed_width, ptr noundef @windowed_height)
  %55 = load ptr, ptr %6, align 8, !tbaa !5
  %56 = load ptr, ptr %11, align 8, !tbaa !5
  %57 = load ptr, ptr %12, align 8, !tbaa !5
  %58 = getelementptr inbounds %struct.GLFWvidmode, ptr %57, i32 0, i32 0
  %59 = load i32, ptr %58, align 4, !tbaa !11
  %60 = load ptr, ptr %12, align 8, !tbaa !5
  %61 = getelementptr inbounds %struct.GLFWvidmode, ptr %60, i32 0, i32 1
  %62 = load i32, ptr %61, align 4, !tbaa !13
  %63 = load ptr, ptr %12, align 8, !tbaa !5
  %64 = getelementptr inbounds %struct.GLFWvidmode, ptr %63, i32 0, i32 5
  %65 = load i32, ptr %64, align 4, !tbaa !14
  call void @glfwSetWindowMonitor(ptr noundef %55, ptr noundef %56, i32 noundef 0, i32 noundef 0, i32 noundef %59, i32 noundef %62, i32 noundef %65)
  call void @llvm.lifetime.end.p0(i64 8, ptr %12) #3
  br label %66

66:                                               ; preds = %50, %46
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #3
  br label %67

67:                                               ; preds = %66, %40
  br label %68

68:                                               ; preds = %67, %33, %30, %15
  ret void
}

declare void @glfwSetWindowShouldClose(ptr noundef, i32 noundef) #2

declare ptr @glfwGetWindowMonitor(ptr noundef) #2

declare void @glfwSetWindowMonitor(ptr noundef, ptr noundef, i32 noundef, i32 noundef, i32 noundef, i32 noundef, i32 noundef) #2

declare ptr @glfwGetPrimaryMonitor() #2

declare ptr @glfwGetVideoMode(ptr noundef) #2

declare void @glfwGetWindowPos(ptr noundef, ptr noundef, ptr noundef) #2

declare void @glfwGetWindowSize(ptr noundef, ptr noundef, ptr noundef) #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 = { 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, !10, i64 0}
!10 = !{!"int", !7, i64 0}
!11 = !{!12, !10, i64 0}
!12 = !{!"GLFWvidmode", !10, i64 0, !10, i64 4, !10, i64 8, !10, i64 12, !10, i64 16, !10, i64 20}
!13 = !{!12, !10, i64 4}
!14 = !{!12, !10, i64 20}


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

@windowed_xpos = external dso_local global i32, align 4
@windowed_ypos = external dso_local global i32, align 4
@windowed_width = external dso_local global i32, align 4
@windowed_height = external dso_local global i32, align 4

; Function Attrs: nounwind uwtable
define dso_local void @key_callback(ptr noundef %0, i32 noundef %1, i32 noundef %2, i32 noundef %3, i32 noundef %4) local_unnamed_addr #0 {
  %.not = icmp eq i32 %3, 1
  br i1 %.not, label %6, label %29

6:                                                ; preds = %5
  %7 = icmp eq i32 %1, 256
  %8 = icmp eq i32 %4, 0
  %or.cond = and i1 %7, %8
  br i1 %or.cond, label %.thread, label %9

.thread:                                          ; preds = %6
  tail call void @glfwSetWindowShouldClose(ptr noundef %0, i32 noundef 1) #2
  br label %29

9:                                                ; preds = %6
  %10 = icmp eq i32 %1, 257
  %11 = icmp eq i32 %4, 4
  %12 = icmp eq i32 %1, 300
  %or.cond326 = or i1 %10, %12
  %or.cond25 = and i1 %or.cond326, %11
  br i1 %or.cond25, label %13, label %29

13:                                               ; preds = %9
  %14 = tail call ptr @glfwGetWindowMonitor(ptr noundef %0) #2
  %.not23 = icmp eq ptr %14, null
  br i1 %.not23, label %20, label %15

15:                                               ; preds = %13
  %16 = load i32, ptr @windowed_xpos, align 4, !tbaa !5
  %17 = load i32, ptr @windowed_ypos, align 4, !tbaa !5
  %18 = load i32, ptr @windowed_width, align 4, !tbaa !5
  %19 = load i32, ptr @windowed_height, align 4, !tbaa !5
  tail call void @glfwSetWindowMonitor(ptr noundef %0, ptr noundef null, i32 noundef %16, i32 noundef %17, i32 noundef %18, i32 noundef %19, i32 noundef 0) #2
  br label %29

20:                                               ; preds = %13
  %21 = tail call ptr @glfwGetPrimaryMonitor() #2
  %.not24 = icmp eq ptr %21, null
  br i1 %.not24, label %29, label %22

22:                                               ; preds = %20
  %23 = tail call ptr @glfwGetVideoMode(ptr noundef nonnull %21) #2
  tail call void @glfwGetWindowPos(ptr noundef %0, ptr noundef nonnull @windowed_xpos, ptr noundef nonnull @windowed_ypos) #2
  tail call void @glfwGetWindowSize(ptr noundef %0, ptr noundef nonnull @windowed_width, ptr noundef nonnull @windowed_height) #2
  %24 = load i32, ptr %23, align 4, !tbaa !9
  %25 = getelementptr inbounds i8, ptr %23, i64 4
  %26 = load i32, ptr %25, align 4, !tbaa !11
  %27 = getelementptr inbounds i8, ptr %23, i64 20
  %28 = load i32, ptr %27, align 4, !tbaa !12
  tail call void @glfwSetWindowMonitor(ptr noundef %0, ptr noundef nonnull %21, i32 noundef 0, i32 noundef 0, i32 noundef %24, i32 noundef %26, i32 noundef %28) #2
  br label %29

29:                                               ; preds = %.thread, %20, %22, %9, %15, %5
  ret void
}

declare void @glfwSetWindowShouldClose(ptr noundef, i32 noundef) local_unnamed_addr #1

declare ptr @glfwGetWindowMonitor(ptr noundef) local_unnamed_addr #1

declare void @glfwSetWindowMonitor(ptr noundef, ptr noundef, i32 noundef, i32 noundef, i32 noundef, i32 noundef, i32 noundef) local_unnamed_addr #1

declare ptr @glfwGetPrimaryMonitor() local_unnamed_addr #1

declare ptr @glfwGetVideoMode(ptr noundef) local_unnamed_addr #1

declare void @glfwGetWindowPos(ptr noundef, ptr noundef, ptr noundef) local_unnamed_addr #1

declare void @glfwGetWindowSize(ptr noundef, ptr noundef, ptr noundef) local_unnamed_addr #1

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 = { "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 }

!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, !6, i64 0}
!10 = !{!"GLFWvidmode", !6, i64 0, !6, i64 4, !6, i64 8, !6, i64 12, !6, i64 16, !6, i64 20}
!11 = !{!10, !6, i64 4}
!12 = !{!10, !6, i64 20}


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