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

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

@glad_glBegin = external dso_local global ptr, align 8
@glad_glBeginQuery = external dso_local global ptr, align 8
@glad_glClear = external dso_local global ptr, align 8
@glad_glEnd = external dso_local global ptr, align 8
@glad_glEndQuery = external dso_local global ptr, align 8
@glad_glFinish = external dso_local global ptr, align 8
@glad_glGenQueries = external dso_local global ptr, align 8
@glad_glGetQueryObjectiv = external dso_local global ptr, align 8
@glad_glReadPixels = external dso_local global ptr, align 8
@glad_glVertex2f = external dso_local global ptr, align 8
@swap_clear = external dso_local global i32, align 4
@swap_finish = external dso_local global i32, align 4
@swap_occlusion_query = external dso_local global i32, align 4
@swap_read_pixels = external dso_local global i32, align 4
@occlusion_query = 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 @swap_buffers(ptr noundef %0) #1 {
  %2 = alloca ptr, align 8
  %3 = alloca i32, align 4
  %4 = alloca [4 x i8], align 1
  store ptr %0, ptr %2, align 8, !tbaa !5
  %5 = load ptr, ptr %2, align 8, !tbaa !5
  call void @glfwSwapBuffers(ptr noundef %5)
  %6 = load i32, ptr @swap_clear, align 4, !tbaa !9
  %7 = icmp ne i32 %6, 0
  br i1 %7, label %8, label %10

8:                                                ; preds = %1
  %9 = load ptr, ptr @glad_glClear, align 8, !tbaa !5
  call void %9(i32 noundef 16384)
  br label %10

10:                                               ; preds = %8, %1
  %11 = load i32, ptr @swap_finish, align 4, !tbaa !9
  %12 = icmp ne i32 %11, 0
  br i1 %12, label %13, label %15

13:                                               ; preds = %10
  %14 = load ptr, ptr @glad_glFinish, align 8, !tbaa !5
  call void %14()
  br label %15

15:                                               ; preds = %13, %10
  %16 = load i32, ptr @swap_occlusion_query, align 4, !tbaa !9
  %17 = icmp ne i32 %16, 0
  br i1 %17, label %18, label %32

18:                                               ; preds = %15
  call void @llvm.lifetime.start.p0(i64 4, ptr %3) #3
  %19 = load i32, ptr @occlusion_query, align 4, !tbaa !9
  %20 = icmp ne i32 %19, 0
  br i1 %20, label %23, label %21

21:                                               ; preds = %18
  %22 = load ptr, ptr @glad_glGenQueries, align 8, !tbaa !5
  call void %22(i32 noundef 1, ptr noundef @occlusion_query)
  br label %23

23:                                               ; preds = %21, %18
  %24 = load ptr, ptr @glad_glBeginQuery, align 8, !tbaa !5
  %25 = load i32, ptr @occlusion_query, align 4, !tbaa !9
  call void %24(i32 noundef 35092, i32 noundef %25)
  %26 = load ptr, ptr @glad_glBegin, align 8, !tbaa !5
  call void %26(i32 noundef 0)
  %27 = load ptr, ptr @glad_glVertex2f, align 8, !tbaa !5
  call void %27(float noundef 0.000000e+00, float noundef 0.000000e+00)
  %28 = load ptr, ptr @glad_glEnd, align 8, !tbaa !5
  call void %28()
  %29 = load ptr, ptr @glad_glEndQuery, align 8, !tbaa !5
  call void %29(i32 noundef 35092)
  %30 = load ptr, ptr @glad_glGetQueryObjectiv, align 8, !tbaa !5
  %31 = load i32, ptr @occlusion_query, align 4, !tbaa !9
  call void %30(i32 noundef %31, i32 noundef 34918, ptr noundef %3)
  call void @llvm.lifetime.end.p0(i64 4, ptr %3) #3
  br label %32

32:                                               ; preds = %23, %15
  %33 = load i32, ptr @swap_read_pixels, align 4, !tbaa !9
  %34 = icmp ne i32 %33, 0
  br i1 %34, label %35, label %38

35:                                               ; preds = %32
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #3
  %36 = load ptr, ptr @glad_glReadPixels, align 8, !tbaa !5
  %37 = getelementptr inbounds [4 x i8], ptr %4, i64 0, i64 0
  call void %36(i32 noundef 0, i32 noundef 0, i32 noundef 1, i32 noundef 1, i32 noundef 6408, i32 noundef 5121, ptr noundef %37)
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #3
  br label %38

38:                                               ; preds = %35, %32
  ret void
}

declare void @glfwSwapBuffers(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}


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

@glad_glBegin = external dso_local local_unnamed_addr global ptr, align 8
@glad_glBeginQuery = external dso_local local_unnamed_addr global ptr, align 8
@glad_glClear = external dso_local local_unnamed_addr global ptr, align 8
@glad_glEnd = external dso_local local_unnamed_addr global ptr, align 8
@glad_glEndQuery = external dso_local local_unnamed_addr global ptr, align 8
@glad_glFinish = external dso_local local_unnamed_addr global ptr, align 8
@glad_glGenQueries = external dso_local local_unnamed_addr global ptr, align 8
@glad_glGetQueryObjectiv = external dso_local local_unnamed_addr global ptr, align 8
@glad_glReadPixels = external dso_local local_unnamed_addr global ptr, align 8
@glad_glVertex2f = external dso_local local_unnamed_addr global ptr, align 8
@swap_clear = external dso_local local_unnamed_addr global i32, align 4
@swap_finish = external dso_local local_unnamed_addr global i32, align 4
@swap_occlusion_query = external dso_local local_unnamed_addr global i32, align 4
@swap_read_pixels = external dso_local local_unnamed_addr global i32, align 4
@occlusion_query = external dso_local global i32, align 4

; 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: nounwind uwtable
define dso_local void @swap_buffers(ptr noundef %0) local_unnamed_addr #1 {
  %2 = alloca i32, align 4
  %3 = alloca [4 x i8], align 1
  tail call void @glfwSwapBuffers(ptr noundef %0) #3
  %4 = load i32, ptr @swap_clear, align 4, !tbaa !5
  %.not = icmp eq i32 %4, 0
  br i1 %.not, label %7, label %5

5:                                                ; preds = %1
  %6 = load ptr, ptr @glad_glClear, align 8, !tbaa !9
  tail call void %6(i32 noundef 16384) #3
  br label %7

7:                                                ; preds = %5, %1
  %8 = load i32, ptr @swap_finish, align 4, !tbaa !5
  %.not1 = icmp eq i32 %8, 0
  br i1 %.not1, label %11, label %9

9:                                                ; preds = %7
  %10 = load ptr, ptr @glad_glFinish, align 8, !tbaa !9
  tail call void %10() #3
  br label %11

11:                                               ; preds = %9, %7
  %12 = load i32, ptr @swap_occlusion_query, align 4, !tbaa !5
  %.not2 = icmp eq i32 %12, 0
  br i1 %.not2, label %26, label %13

13:                                               ; preds = %11
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %2) #3
  %14 = load i32, ptr @occlusion_query, align 4, !tbaa !5
  %.not3 = icmp eq i32 %14, 0
  br i1 %.not3, label %15, label %17

15:                                               ; preds = %13
  %16 = load ptr, ptr @glad_glGenQueries, align 8, !tbaa !9
  tail call void %16(i32 noundef 1, ptr noundef nonnull @occlusion_query) #3
  %.pre = load i32, ptr @occlusion_query, align 4, !tbaa !5
  br label %17

17:                                               ; preds = %15, %13
  %18 = phi i32 [ %.pre, %15 ], [ %14, %13 ]
  %19 = load ptr, ptr @glad_glBeginQuery, align 8, !tbaa !9
  tail call void %19(i32 noundef 35092, i32 noundef %18) #3
  %20 = load ptr, ptr @glad_glBegin, align 8, !tbaa !9
  tail call void %20(i32 noundef 0) #3
  %21 = load ptr, ptr @glad_glVertex2f, align 8, !tbaa !9
  tail call void %21(float noundef 0.000000e+00, float noundef 0.000000e+00) #3
  %22 = load ptr, ptr @glad_glEnd, align 8, !tbaa !9
  tail call void %22() #3
  %23 = load ptr, ptr @glad_glEndQuery, align 8, !tbaa !9
  tail call void %23(i32 noundef 35092) #3
  %24 = load ptr, ptr @glad_glGetQueryObjectiv, align 8, !tbaa !9
  %25 = load i32, ptr @occlusion_query, align 4, !tbaa !5
  call void %24(i32 noundef %25, i32 noundef 34918, ptr noundef nonnull %2) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %2) #3
  br label %26

26:                                               ; preds = %17, %11
  %27 = load i32, ptr @swap_read_pixels, align 4, !tbaa !5
  %.not4 = icmp eq i32 %27, 0
  br i1 %.not4, label %30, label %28

28:                                               ; preds = %26
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %3) #3
  %29 = load ptr, ptr @glad_glReadPixels, align 8, !tbaa !9
  call void %29(i32 noundef 0, i32 noundef 0, i32 noundef 1, i32 noundef 1, i32 noundef 6408, i32 noundef 5121, ptr noundef nonnull %3) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %3) #3
  br label %30

30:                                               ; preds = %28, %26
  ret void
}

declare void @glfwSwapBuffers(ptr noundef) local_unnamed_addr #2

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


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