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

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

@stderr = external global ptr, align 8
@.str.1 = external hidden unnamed_addr constant [27 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [6 x i8], align 1
@.str.3 = 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
declare dso_local void @key(ptr noundef, i32 noundef, i32 noundef, i32 noundef, i32 noundef) #1

; Function Attrs: nounwind uwtable
declare dso_local void @reshape(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 i32, align 4
  %8 = 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) #5
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #5
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #5
  %9 = call i32 @glfwInit()
  %10 = icmp ne i32 %9, 0
  br i1 %10, label %14, label %11

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

14:                                               ; preds = %2
  call void @glfwWindowHint(i32 noundef 135173, i32 noundef 16)
  call void @glfwWindowHint(i32 noundef 131082, i32 noundef 1)
  %15 = call ptr @glfwCreateWindow(i32 noundef 300, i32 noundef 300, ptr noundef @.str.2, ptr noundef null, ptr noundef null)
  store ptr %15, ptr %6, align 8, !tbaa !9
  %16 = load ptr, ptr %6, align 8, !tbaa !9
  %17 = icmp ne ptr %16, null
  br i1 %17, label %21, label %18

18:                                               ; preds = %14
  %19 = load ptr, ptr @stderr, align 8, !tbaa !9
  %20 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %19, ptr noundef @.str.3) #5
  call void @glfwTerminate()
  call void @exit(i32 noundef 1) #6
  unreachable

21:                                               ; preds = %14
  %22 = load ptr, ptr %6, align 8, !tbaa !9
  %23 = call ptr @glfwSetFramebufferSizeCallback(ptr noundef %22, ptr noundef @reshape)
  %24 = load ptr, ptr %6, align 8, !tbaa !9
  %25 = call ptr @glfwSetKeyCallback(ptr noundef %24, ptr noundef @key)
  %26 = load ptr, ptr %6, align 8, !tbaa !9
  call void @glfwMakeContextCurrent(ptr noundef %26)
  %27 = call i32 @gladLoadGL(ptr noundef @glfwGetProcAddress)
  call void @glfwSwapInterval(i32 noundef 1)
  %28 = load ptr, ptr %6, align 8, !tbaa !9
  call void @glfwGetFramebufferSize(ptr noundef %28, ptr noundef %7, ptr noundef %8)
  %29 = load ptr, ptr %6, align 8, !tbaa !9
  %30 = load i32, ptr %7, align 4, !tbaa !5
  %31 = load i32, ptr %8, align 4, !tbaa !5
  call void @reshape(ptr noundef %29, i32 noundef %30, i32 noundef %31)
  call void @init()
  br label %32

32:                                               ; preds = %37, %21
  %33 = load ptr, ptr %6, align 8, !tbaa !9
  %34 = call i32 @glfwWindowShouldClose(ptr noundef %33)
  %35 = icmp ne i32 %34, 0
  %36 = xor i1 %35, true
  br i1 %36, label %37, label %39

37:                                               ; preds = %32
  call void @draw()
  call void @animate()
  %38 = load ptr, ptr %6, align 8, !tbaa !9
  call void @glfwSwapBuffers(ptr noundef %38)
  call void @glfwPollEvents()
  br label %32, !llvm.loop !11

39:                                               ; preds = %32
  call void @glfwTerminate()
  call void @exit(i32 noundef 0) #6
  unreachable
}

declare i32 @glfwInit() #2

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

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

declare void @glfwWindowHint(i32 noundef, i32 noundef) #2

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

declare void @glfwTerminate() #2

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

declare ptr @glfwSetKeyCallback(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

; Function Attrs: nounwind uwtable
declare hidden void @init() #1

declare i32 @glfwWindowShouldClose(ptr noundef) #2

; Function Attrs: nounwind uwtable
declare hidden void @draw() #1

; Function Attrs: nounwind uwtable
declare hidden void @animate() #1

declare void @glfwSwapBuffers(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 = { 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 = { 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 = !{!"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"

@stderr = external local_unnamed_addr global ptr, align 8
@.str.1 = external hidden unnamed_addr constant [27 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [6 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [28 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 @key(ptr noundef, i32 noundef, i32 noundef, i32 noundef, i32 noundef) #1

; Function Attrs: nounwind uwtable
declare dso_local void @reshape(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) #6
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %4) #6
  %5 = tail call i32 @glfwInit() #6
  %.not = icmp eq i32 %5, 0
  br i1 %.not, label %6, label %9

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

9:                                                ; preds = %2
  tail call void @glfwWindowHint(i32 noundef 135173, i32 noundef 16) #6
  tail call void @glfwWindowHint(i32 noundef 131082, i32 noundef 1) #6
  %10 = tail call ptr @glfwCreateWindow(i32 noundef 300, i32 noundef 300, ptr noundef nonnull @.str.2, ptr noundef null, ptr noundef null) #6
  %.not8 = icmp eq ptr %10, null
  br i1 %.not8, label %11, label %14

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

14:                                               ; preds = %9
  %15 = tail call ptr @glfwSetFramebufferSizeCallback(ptr noundef nonnull %10, ptr noundef nonnull @reshape) #6
  %16 = tail call ptr @glfwSetKeyCallback(ptr noundef nonnull %10, ptr noundef nonnull @key) #6
  tail call void @glfwMakeContextCurrent(ptr noundef nonnull %10) #6
  %17 = tail call i32 @gladLoadGL(ptr noundef nonnull @glfwGetProcAddress)
  tail call void @glfwSwapInterval(i32 noundef 1) #6
  call void @glfwGetFramebufferSize(ptr noundef nonnull %10, ptr noundef nonnull %3, ptr noundef nonnull %4) #6
  %18 = load i32, ptr %3, align 4, !tbaa !9
  %19 = load i32, ptr %4, align 4, !tbaa !9
  call void @reshape(ptr noundef nonnull %10, i32 noundef %18, i32 noundef %19)
  call void @init()
  %20 = call i32 @glfwWindowShouldClose(ptr noundef nonnull %10) #6
  %.not910 = icmp eq i32 %20, 0
  br i1 %.not910, label %.lr.ph, label %._crit_edge

.lr.ph:                                           ; preds = %14, %.lr.ph
  call void @draw()
  call void @animate()
  call void @glfwSwapBuffers(ptr noundef nonnull %10) #6
  call void @glfwPollEvents() #6
  %21 = call i32 @glfwWindowShouldClose(ptr noundef nonnull %10) #6
  %.not9 = icmp eq i32 %21, 0
  br i1 %.not9, label %.lr.ph, label %._crit_edge, !llvm.loop !11

._crit_edge:                                      ; preds = %.lr.ph, %14
  call void @glfwTerminate() #6
  call void @exit(i32 noundef 0) #8
  unreachable
}

declare i32 @glfwInit() local_unnamed_addr #3

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

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

declare void @glfwWindowHint(i32 noundef, i32 noundef) local_unnamed_addr #3

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

declare ptr @glfwSetKeyCallback(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

; Function Attrs: nounwind uwtable
declare hidden void @init() local_unnamed_addr #1

declare i32 @glfwWindowShouldClose(ptr noundef) local_unnamed_addr #3

; Function Attrs: nounwind uwtable
declare hidden void @draw() local_unnamed_addr #1

; Function Attrs: nounwind uwtable
declare hidden void @animate() local_unnamed_addr #1

declare void @glfwSwapBuffers(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 = { 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 = { 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 #6 = { nounwind }
attributes #7 = { cold nounwind }
attributes #8 = { 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 = !{!10, !10, i64 0}
!10 = !{!"int", !7, i64 0}
!11 = distinct !{!11, !12}
!12 = !{!"llvm.loop.mustprogress"}


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