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

; 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
@glad_glClearColor = external dso_local global ptr, align 8
@.str.1 = external hidden unnamed_addr constant [2 x i8], align 1
@stderr = external global ptr, align 8
@.str.2 = external hidden unnamed_addr constant [27 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [15 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [28 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(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 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) #5
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #5
  br label %8

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

13:                                               ; preds = %8
  %14 = load i32, ptr %6, align 4, !tbaa !5
  switch i32 %14, label %16 [
    i32 104, label %15
  ]

15:                                               ; preds = %13
  call void @usage()
  call void @exit(i32 noundef 0) #6
  unreachable

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

17:                                               ; preds = %8
  %18 = call ptr @glfwSetErrorCallback(ptr noundef @error_callback)
  %19 = call i32 @glfwInit()
  %20 = icmp ne i32 %19, 0
  br i1 %20, label %24, label %21

21:                                               ; preds = %17
  %22 = load ptr, ptr @stderr, align 8, !tbaa !9
  %23 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %22, ptr noundef @.str.2) #5
  call void @exit(i32 noundef 1) #6
  unreachable

24:                                               ; preds = %17
  %25 = call ptr @glfwCreateWindow(i32 noundef 200, i32 noundef 200, ptr noundef @.str.3, ptr noundef null, ptr noundef null)
  store ptr %25, ptr %7, align 8, !tbaa !9
  %26 = load ptr, ptr %7, align 8, !tbaa !9
  %27 = icmp ne ptr %26, null
  br i1 %27, label %31, label %28

28:                                               ; preds = %24
  call void @glfwTerminate()
  %29 = load ptr, ptr @stderr, align 8, !tbaa !9
  %30 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %29, ptr noundef @.str.4) #5
  call void @exit(i32 noundef 1) #6
  unreachable

31:                                               ; preds = %24
  %32 = load ptr, ptr %7, align 8, !tbaa !9
  call void @glfwMakeContextCurrent(ptr noundef %32)
  %33 = call i32 @gladLoadGL(ptr noundef @glfwGetProcAddress)
  call void @glfwSwapInterval(i32 noundef 1)
  %34 = load ptr, ptr %7, align 8, !tbaa !9
  %35 = call ptr @glfwSetKeyCallback(ptr noundef %34, ptr noundef @key_callback)
  %36 = load ptr, ptr @glad_glClearColor, align 8, !tbaa !9
  call void %36(float noundef 5.000000e-01, float noundef 5.000000e-01, float noundef 5.000000e-01, float noundef 0.000000e+00)
  br label %37

37:                                               ; preds = %42, %31
  %38 = load ptr, ptr %7, align 8, !tbaa !9
  %39 = call i32 @glfwWindowShouldClose(ptr noundef %38)
  %40 = icmp ne i32 %39, 0
  %41 = xor i1 %40, true
  br i1 %41, label %42, label %45

42:                                               ; preds = %37
  %43 = load ptr, ptr @glad_glClear, align 8, !tbaa !9
  call void %43(i32 noundef 16384)
  %44 = load ptr, ptr %7, align 8, !tbaa !9
  call void @glfwSwapBuffers(ptr noundef %44)
  call void @glfwWaitEvents()
  br label %37, !llvm.loop !11

45:                                               ; preds = %37
  call void @glfwTerminate()
  call void @exit(i32 noundef 0) #6
  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 i32 @glfwInit() #2

; Function Attrs: nounwind
declare i32 @fprintf(ptr noundef, ptr noundef, ...) #4

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 ptr @glfwSetKeyCallback(ptr noundef, ptr noundef) #2

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

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


; 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
@glad_glClearColor = external dso_local local_unnamed_addr global ptr, align 8
@.str.1 = external hidden unnamed_addr constant [2 x i8], align 1
@stderr = external local_unnamed_addr global ptr, align 8
@.str.2 = external hidden unnamed_addr constant [27 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [15 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [28 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(i32 noundef %0, ptr noundef %1) local_unnamed_addr #1 {
  %3 = tail call i32 @getopt(i32 noundef %0, ptr noundef %1, ptr noundef nonnull @.str.1) #5
  switch i32 %3, label %5 [
    i32 -1, label %6
    i32 104, label %4
  ]

4:                                                ; preds = %2
  tail call void @usage()
  tail call void @exit(i32 noundef 0) #6
  unreachable

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

6:                                                ; preds = %2
  %7 = tail call ptr @glfwSetErrorCallback(ptr noundef nonnull @error_callback) #5
  %8 = tail call i32 @glfwInit() #5
  %.not8 = icmp eq i32 %8, 0
  br i1 %.not8, label %9, label %12

9:                                                ; preds = %6
  %10 = load ptr, ptr @stderr, align 8, !tbaa !5
  %11 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %10, ptr noundef nonnull @.str.2) #7
  tail call void @exit(i32 noundef 1) #6
  unreachable

12:                                               ; preds = %6
  %13 = tail call ptr @glfwCreateWindow(i32 noundef 200, i32 noundef 200, ptr noundef nonnull @.str.3, ptr noundef null, ptr noundef null) #5
  %.not9 = icmp eq ptr %13, null
  br i1 %.not9, label %14, label %17

14:                                               ; preds = %12
  tail call void @glfwTerminate() #5
  %15 = load ptr, ptr @stderr, align 8, !tbaa !5
  %16 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %15, ptr noundef nonnull @.str.4) #7
  tail call void @exit(i32 noundef 1) #6
  unreachable

17:                                               ; preds = %12
  tail call void @glfwMakeContextCurrent(ptr noundef nonnull %13) #5
  %18 = tail call i32 @gladLoadGL(ptr noundef nonnull @glfwGetProcAddress)
  tail call void @glfwSwapInterval(i32 noundef 1) #5
  %19 = tail call ptr @glfwSetKeyCallback(ptr noundef nonnull %13, ptr noundef nonnull @key_callback) #5
  %20 = load ptr, ptr @glad_glClearColor, align 8, !tbaa !5
  tail call void %20(float noundef 5.000000e-01, float noundef 5.000000e-01, float noundef 5.000000e-01, float noundef 0.000000e+00) #5
  %21 = tail call i32 @glfwWindowShouldClose(ptr noundef nonnull %13) #5
  %.not1011 = icmp eq i32 %21, 0
  br i1 %.not1011, label %.lr.ph, label %._crit_edge

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

._crit_edge:                                      ; preds = %.lr.ph, %17
  tail call void @glfwTerminate() #5
  tail 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 #0

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

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: nofree nounwind
declare noundef i32 @fprintf(ptr nocapture noundef, ptr nocapture noundef readonly, ...) local_unnamed_addr #4

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 ptr @glfwSetKeyCallback(ptr noundef, ptr noundef) local_unnamed_addr #2

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

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 = { nofree 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 }
attributes #7 = { cold 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