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

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

@dt = external dso_local global double, align 8
@.str.1 = external hidden unnamed_addr constant [16 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
declare dso_local void @init_vertices() #1

; Function Attrs: nounwind uwtable
declare dso_local void @init_grid() #1

; Function Attrs: nounwind uwtable
declare dso_local void @draw_scene(ptr noundef) #1

; Function Attrs: nounwind uwtable
declare dso_local void @init_opengl() #1

; Function Attrs: nounwind uwtable
declare dso_local void @adjust_grid() #1

; Function Attrs: nounwind uwtable
declare dso_local void @calc_grid() #1

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

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

; Function Attrs: nounwind uwtable
declare dso_local void @cursor_position_callback(ptr noundef, double noundef, double noundef) #1

; Function Attrs: nounwind uwtable
declare dso_local void @scroll_callback(ptr noundef, double noundef, double noundef) #1

; Function Attrs: nounwind uwtable
declare dso_local void @framebuffer_size_callback(ptr noundef, i32 noundef, i32 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 ptr, align 8
  %7 = alloca double, align 8
  %8 = alloca double, align 8
  %9 = alloca double, align 8
  %10 = alloca i32, align 4
  %11 = alloca i32, align 4
  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 8, ptr %6) #4
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #4
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #4
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #4
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #4
  call void @llvm.lifetime.start.p0(i64 4, ptr %11) #4
  %12 = call ptr @glfwSetErrorCallback(ptr noundef @error_callback)
  %13 = call i32 @glfwInit()
  %14 = icmp ne i32 %13, 0
  br i1 %14, label %16, label %15

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

16:                                               ; preds = %2
  %17 = call ptr @glfwCreateWindow(i32 noundef 640, i32 noundef 480, ptr noundef @.str.1, ptr noundef null, ptr noundef null)
  store ptr %17, ptr %6, align 8, !tbaa !9
  %18 = load ptr, ptr %6, align 8, !tbaa !9
  %19 = icmp ne ptr %18, null
  br i1 %19, label %21, label %20

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

21:                                               ; preds = %16
  %22 = load ptr, ptr %6, align 8, !tbaa !9
  %23 = call ptr @glfwSetKeyCallback(ptr noundef %22, ptr noundef @key_callback)
  %24 = load ptr, ptr %6, align 8, !tbaa !9
  %25 = call ptr @glfwSetFramebufferSizeCallback(ptr noundef %24, ptr noundef @framebuffer_size_callback)
  %26 = load ptr, ptr %6, align 8, !tbaa !9
  %27 = call ptr @glfwSetMouseButtonCallback(ptr noundef %26, ptr noundef @mouse_button_callback)
  %28 = load ptr, ptr %6, align 8, !tbaa !9
  %29 = call ptr @glfwSetCursorPosCallback(ptr noundef %28, ptr noundef @cursor_position_callback)
  %30 = load ptr, ptr %6, align 8, !tbaa !9
  %31 = call ptr @glfwSetScrollCallback(ptr noundef %30, ptr noundef @scroll_callback)
  %32 = load ptr, ptr %6, 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 %6, align 8, !tbaa !9
  call void @glfwGetFramebufferSize(ptr noundef %34, ptr noundef %10, ptr noundef %11)
  %35 = load ptr, ptr %6, align 8, !tbaa !9
  %36 = load i32, ptr %10, align 4, !tbaa !5
  %37 = load i32, ptr %11, align 4, !tbaa !5
  call void @framebuffer_size_callback(ptr noundef %35, i32 noundef %36, i32 noundef %37)
  call void @init_opengl()
  call void @init_vertices()
  call void @init_grid()
  call void @adjust_grid()
  %38 = call double @glfwGetTime()
  %39 = fsub double %38, 1.000000e-02
  store double %39, ptr %9, align 8, !tbaa !11
  br label %40

40:                                               ; preds = %65, %21
  %41 = load ptr, ptr %6, align 8, !tbaa !9
  %42 = call i32 @glfwWindowShouldClose(ptr noundef %41)
  %43 = icmp ne i32 %42, 0
  %44 = xor i1 %43, true
  br i1 %44, label %45, label %67

45:                                               ; preds = %40
  %46 = call double @glfwGetTime()
  store double %46, ptr %7, align 8, !tbaa !11
  %47 = load double, ptr %7, align 8, !tbaa !11
  %48 = load double, ptr %9, align 8, !tbaa !11
  %49 = fsub double %47, %48
  store double %49, ptr %8, align 8, !tbaa !11
  %50 = load double, ptr %7, align 8, !tbaa !11
  store double %50, ptr %9, align 8, !tbaa !11
  br label %51

51:                                               ; preds = %60, %45
  %52 = load double, ptr %8, align 8, !tbaa !11
  %53 = fcmp ogt double %52, 0.000000e+00
  br i1 %53, label %54, label %65

54:                                               ; preds = %51
  %55 = load double, ptr %8, align 8, !tbaa !11
  %56 = fcmp ogt double %55, 1.000000e-02
  br i1 %56, label %57, label %58

57:                                               ; preds = %54
  br label %60

58:                                               ; preds = %54
  %59 = load double, ptr %8, align 8, !tbaa !11
  br label %60

60:                                               ; preds = %58, %57
  %61 = phi double [ 1.000000e-02, %57 ], [ %59, %58 ]
  store double %61, ptr @dt, align 8, !tbaa !11
  %62 = load double, ptr @dt, align 8, !tbaa !11
  %63 = load double, ptr %8, align 8, !tbaa !11
  %64 = fsub double %63, %62
  store double %64, ptr %8, align 8, !tbaa !11
  call void @calc_grid()
  br label %51, !llvm.loop !13

65:                                               ; preds = %51
  call void @adjust_grid()
  %66 = load ptr, ptr %6, align 8, !tbaa !9
  call void @draw_scene(ptr noundef %66)
  call void @glfwPollEvents()
  br label %40, !llvm.loop !15

67:                                               ; preds = %40
  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 ptr @glfwSetKeyCallback(ptr noundef, ptr noundef) #2

declare ptr @glfwSetFramebufferSizeCallback(ptr noundef, ptr noundef) #2

declare ptr @glfwSetMouseButtonCallback(ptr noundef, ptr noundef) #2

declare ptr @glfwSetCursorPosCallback(ptr noundef, ptr noundef) #2

declare ptr @glfwSetScrollCallback(ptr noundef, ptr noundef) #2

declare void @glfwMakeContextCurrent(ptr noundef) #2

declare ptr @glfwGetProcAddress(ptr noundef) #2

declare void @glfwSwapInterval(i32 noundef) #2

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

declare double @glfwGetTime() #2

declare i32 @glfwWindowShouldClose(ptr noundef) #2

declare void @glfwPollEvents() #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 = !{!12, !12, i64 0}
!12 = !{!"double", !7, i64 0}
!13 = distinct !{!13, !14}
!14 = !{!"llvm.loop.mustprogress"}
!15 = distinct !{!15, !14}


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

@dt = external dso_local local_unnamed_addr global double, align 8
@.str.1 = external hidden unnamed_addr constant [16 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: nounwind uwtable
declare dso_local i32 @gladLoadGL(ptr noundef) local_unnamed_addr #1

; Function Attrs: nounwind uwtable
declare dso_local void @init_vertices() local_unnamed_addr #1

; Function Attrs: nounwind uwtable
declare dso_local void @init_grid() local_unnamed_addr #1

; Function Attrs: nounwind uwtable
declare dso_local void @draw_scene(ptr noundef) local_unnamed_addr #1

; Function Attrs: nounwind uwtable
declare dso_local void @init_opengl() local_unnamed_addr #1

; Function Attrs: nounwind uwtable
declare dso_local void @adjust_grid() local_unnamed_addr #1

; Function Attrs: nounwind uwtable
declare dso_local void @calc_grid() local_unnamed_addr #1

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

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

; Function Attrs: nounwind uwtable
declare dso_local void @cursor_position_callback(ptr noundef, double noundef, double noundef) #1

; Function Attrs: nounwind uwtable
declare dso_local void @scroll_callback(ptr noundef, double noundef, double noundef) #1

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

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

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

8:                                                ; preds = %2
  %9 = tail call ptr @glfwCreateWindow(i32 noundef 640, i32 noundef 480, ptr noundef nonnull @.str.1, ptr noundef null, ptr noundef null) #5
  %.not20 = icmp eq ptr %9, null
  br i1 %.not20, label %10, label %11

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

11:                                               ; preds = %8
  %12 = tail call ptr @glfwSetKeyCallback(ptr noundef nonnull %9, ptr noundef nonnull @key_callback) #5
  %13 = tail call ptr @glfwSetFramebufferSizeCallback(ptr noundef nonnull %9, ptr noundef nonnull @framebuffer_size_callback) #5
  %14 = tail call ptr @glfwSetMouseButtonCallback(ptr noundef nonnull %9, ptr noundef nonnull @mouse_button_callback) #5
  %15 = tail call ptr @glfwSetCursorPosCallback(ptr noundef nonnull %9, ptr noundef nonnull @cursor_position_callback) #5
  %16 = tail call ptr @glfwSetScrollCallback(ptr noundef nonnull %9, ptr noundef nonnull @scroll_callback) #5
  tail call void @glfwMakeContextCurrent(ptr noundef nonnull %9) #5
  %17 = tail call i32 @gladLoadGL(ptr noundef nonnull @glfwGetProcAddress)
  tail call void @glfwSwapInterval(i32 noundef 1) #5
  call void @glfwGetFramebufferSize(ptr noundef nonnull %9, ptr noundef nonnull %3, ptr noundef nonnull %4) #5
  %18 = load i32, ptr %3, align 4, !tbaa !5
  %19 = load i32, ptr %4, align 4, !tbaa !5
  call void @framebuffer_size_callback(ptr noundef nonnull %9, i32 noundef %18, i32 noundef %19)
  call void @init_opengl()
  call void @init_vertices()
  call void @init_grid()
  call void @adjust_grid()
  %20 = call double @glfwGetTime() #5
  %21 = call i32 @glfwWindowShouldClose(ptr noundef nonnull %9) #5
  %.not2123 = icmp eq i32 %21, 0
  br i1 %.not2123, label %.lr.ph26.preheader, label %._crit_edge27

.lr.ph26.preheader:                               ; preds = %11
  %22 = fadd double %20, -1.000000e-02
  br label %.lr.ph26

.lr.ph26:                                         ; preds = %.lr.ph26.preheader, %._crit_edge
  %.024 = phi double [ %23, %._crit_edge ], [ %22, %.lr.ph26.preheader ]
  %23 = call double @glfwGetTime() #5
  %24 = fsub double %23, %.024
  %25 = fcmp ogt double %24, 0.000000e+00
  br i1 %25, label %.lr.ph, label %._crit_edge

.lr.ph:                                           ; preds = %.lr.ph26, %.lr.ph
  %.01822 = phi double [ %28, %.lr.ph ], [ %24, %.lr.ph26 ]
  %26 = fcmp ogt double %.01822, 1.000000e-02
  %27 = select i1 %26, double 1.000000e-02, double %.01822
  store double %27, ptr @dt, align 8, !tbaa !9
  %28 = fsub double %.01822, %27
  call void @calc_grid()
  %29 = fcmp ogt double %28, 0.000000e+00
  br i1 %29, label %.lr.ph, label %._crit_edge, !llvm.loop !11

._crit_edge:                                      ; preds = %.lr.ph, %.lr.ph26
  call void @adjust_grid()
  call void @draw_scene(ptr noundef nonnull %9)
  call void @glfwPollEvents() #5
  %30 = call i32 @glfwWindowShouldClose(ptr noundef nonnull %9) #5
  %.not21 = icmp eq i32 %30, 0
  br i1 %.not21, label %.lr.ph26, label %._crit_edge27, !llvm.loop !13

._crit_edge27:                                    ; preds = %._crit_edge, %11
  call void @glfwTerminate() #5
  call void @exit(i32 noundef 0) #6
  unreachable
}

declare ptr @glfwSetErrorCallback(ptr noundef) local_unnamed_addr #3

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

declare i32 @glfwInit() local_unnamed_addr #3

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

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

declare void @glfwTerminate() local_unnamed_addr #3

declare ptr @glfwSetKeyCallback(ptr noundef, ptr noundef) local_unnamed_addr #3

declare ptr @glfwSetFramebufferSizeCallback(ptr noundef, ptr noundef) local_unnamed_addr #3

declare ptr @glfwSetMouseButtonCallback(ptr noundef, ptr noundef) local_unnamed_addr #3

declare ptr @glfwSetCursorPosCallback(ptr noundef, ptr noundef) local_unnamed_addr #3

declare ptr @glfwSetScrollCallback(ptr noundef, ptr noundef) local_unnamed_addr #3

declare void @glfwMakeContextCurrent(ptr noundef) local_unnamed_addr #3

declare ptr @glfwGetProcAddress(ptr noundef) #3

declare void @glfwSwapInterval(i32 noundef) local_unnamed_addr #3

declare void @glfwGetFramebufferSize(ptr noundef, ptr noundef, ptr noundef) local_unnamed_addr #3

declare double @glfwGetTime() local_unnamed_addr #3

declare i32 @glfwWindowShouldClose(ptr noundef) local_unnamed_addr #3

declare void @glfwPollEvents() local_unnamed_addr #3

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 = { 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 #3 = { "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 = !{!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 = !{!"double", !7, i64 0}
!11 = distinct !{!11, !12}
!12 = !{!"llvm.loop.mustprogress"}
!13 = distinct !{!13, !12}


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