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

; 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_glClear = external dso_local global ptr, align 8
@.str.1 = external hidden unnamed_addr constant [49 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
declare dso_local i32 @gladLoadGL(ptr noundef) #1

; Function Attrs: nounwind uwtable
define dso_local i32 @main() #1 {
  %1 = alloca i32, align 4
  %2 = alloca ptr, align 8
  store i32 0, ptr %1, align 4
  call void @llvm.lifetime.start.p0(i64 8, ptr %2) #4
  %3 = call ptr @glfwSetErrorCallback(ptr noundef @error_callback)
  %4 = call i32 @glfwInit()
  %5 = icmp ne i32 %4, 0
  br i1 %5, label %7, label %6

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

7:                                                ; preds = %0
  %8 = call ptr @glfwCreateWindow(i32 noundef 400, i32 noundef 400, ptr noundef @.str.1, ptr noundef null, ptr noundef null)
  store ptr %8, ptr %2, align 8, !tbaa !5
  %9 = load ptr, ptr %2, align 8, !tbaa !5
  %10 = icmp ne ptr %9, null
  br i1 %10, label %12, label %11

11:                                               ; preds = %7
  call void @glfwTerminate()
  call void @exit(i32 noundef 1) #5
  unreachable

12:                                               ; preds = %7
  %13 = load ptr, ptr %2, align 8, !tbaa !5
  call void @glfwMakeContextCurrent(ptr noundef %13)
  %14 = call i32 @gladLoadGL(ptr noundef @glfwGetProcAddress)
  call void @glfwSwapInterval(i32 noundef 1)
  br label %15

15:                                               ; preds = %20, %12
  %16 = load ptr, ptr %2, align 8, !tbaa !5
  %17 = call i32 @glfwWindowShouldClose(ptr noundef %16)
  %18 = icmp ne i32 %17, 0
  %19 = xor i1 %18, true
  br i1 %19, label %20, label %23

20:                                               ; preds = %15
  %21 = load ptr, ptr @glad_glClear, align 8, !tbaa !5
  call void %21(i32 noundef 16384)
  %22 = load ptr, ptr %2, align 8, !tbaa !5
  call void @glfwSwapBuffers(ptr noundef %22)
  call void @glfwWaitEvents()
  br label %15, !llvm.loop !9

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

declare ptr @glfwSetErrorCallback(ptr noundef) #2

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

declare i32 @glfwInit() #2

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

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

declare void @glfwTerminate() #2

declare void @glfwMakeContextCurrent(ptr noundef) #2

declare ptr @glfwGetProcAddress(ptr noundef) #2

declare void @glfwSwapInterval(i32 noundef) #2

declare i32 @glfwWindowShouldClose(ptr noundef) #2

declare void @glfwSwapBuffers(ptr noundef) #2

declare void @glfwWaitEvents() #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 = !{!"any pointer", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = distinct !{!9, !10}
!10 = !{!"llvm.loop.mustprogress"}


; 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_glClear = external dso_local local_unnamed_addr global ptr, align 8
@.str.1 = external hidden unnamed_addr constant [49 x i8], align 1

; Function Attrs: nounwind uwtable
declare dso_local i32 @gladLoadGL(ptr noundef) local_unnamed_addr #0

; Function Attrs: noreturn nounwind uwtable
define dso_local noundef i32 @main() local_unnamed_addr #1 {
  %1 = tail call ptr @glfwSetErrorCallback(ptr noundef nonnull @error_callback) #4
  %2 = tail call i32 @glfwInit() #4
  %.not = icmp eq i32 %2, 0
  br i1 %.not, label %3, label %4

3:                                                ; preds = %0
  tail call void @exit(i32 noundef 1) #5
  unreachable

4:                                                ; preds = %0
  %5 = tail call ptr @glfwCreateWindow(i32 noundef 400, i32 noundef 400, ptr noundef nonnull @.str.1, ptr noundef null, ptr noundef null) #4
  %.not4 = icmp eq ptr %5, null
  br i1 %.not4, label %6, label %7

6:                                                ; preds = %4
  tail call void @glfwTerminate() #4
  tail call void @exit(i32 noundef 1) #5
  unreachable

7:                                                ; preds = %4
  tail call void @glfwMakeContextCurrent(ptr noundef nonnull %5) #4
  %8 = tail call i32 @gladLoadGL(ptr noundef nonnull @glfwGetProcAddress)
  tail call void @glfwSwapInterval(i32 noundef 1) #4
  %9 = tail call i32 @glfwWindowShouldClose(ptr noundef nonnull %5) #4
  %.not56 = icmp eq i32 %9, 0
  br i1 %.not56, label %.lr.ph, label %._crit_edge

.lr.ph:                                           ; preds = %7, %.lr.ph
  %10 = load ptr, ptr @glad_glClear, align 8, !tbaa !5
  tail call void %10(i32 noundef 16384) #4
  tail call void @glfwSwapBuffers(ptr noundef nonnull %5) #4
  tail call void @glfwWaitEvents() #4
  %11 = tail call i32 @glfwWindowShouldClose(ptr noundef nonnull %5) #4
  %.not5 = icmp eq i32 %11, 0
  br i1 %.not5, label %.lr.ph, label %._crit_edge, !llvm.loop !9

._crit_edge:                                      ; preds = %.lr.ph, %7
  tail call void @glfwTerminate() #4
  tail call void @exit(i32 noundef 0) #5
  unreachable
}

declare ptr @glfwSetErrorCallback(ptr noundef) local_unnamed_addr #2

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

declare i32 @glfwInit() local_unnamed_addr #2

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

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

declare void @glfwTerminate() local_unnamed_addr #2

declare void @glfwMakeContextCurrent(ptr noundef) local_unnamed_addr #2

declare ptr @glfwGetProcAddress(ptr noundef) #2

declare void @glfwSwapInterval(i32 noundef) local_unnamed_addr #2

declare i32 @glfwWindowShouldClose(ptr noundef) local_unnamed_addr #2

declare void @glfwSwapBuffers(ptr noundef) local_unnamed_addr #2

declare void @glfwWaitEvents() local_unnamed_addr #2

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 = { 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 = { 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 = !{!"any pointer", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = distinct !{!9, !10}
!10 = !{!"llvm.loop.mustprogress"}


; Effective O3 passes: GlobalOptPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass,TailCallElimPass