; LLVM IR from erincatto/box2d-lite :: extern/glfw/src/window.ll (glfwInputWindowFocus)

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

%struct._GLFWwindow = type { ptr, i32, i32, i32, i32, i32, i32, ptr, %struct.GLFWvidmode, ptr, ptr, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, [8 x i8], [349 x i8], double, double, %struct._GLFWcontext, %struct.anon, %struct._GLFWwindowX11 }
%struct.GLFWvidmode = type { i32, i32, i32, i32, i32, i32 }
%struct._GLFWcontext = type { i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, %struct._GLFWcontextGLX, %struct._GLFWcontextEGL, %struct._GLFWcontextOSMesa }
%struct._GLFWcontextGLX = type { ptr, i64 }
%struct._GLFWcontextEGL = type { ptr, ptr, ptr, ptr }
%struct._GLFWcontextOSMesa = type { ptr, i32, i32, ptr }
%struct.anon = type { ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr }
%struct._GLFWwindowX11 = type { i64, i64, ptr, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i64 }

; Function Attrs: nounwind uwtable
define dso_local void @_glfwInputWindowFocus(ptr noundef %0, i32 noundef %1) #0 {
  %3 = alloca ptr, align 8
  %4 = alloca i32, align 4
  %5 = alloca i32, align 4
  %6 = alloca i32, align 4
  %7 = alloca i32, align 4
  store ptr %0, ptr %3, align 8, !tbaa !5
  store i32 %1, ptr %4, align 4, !tbaa !9
  %8 = load ptr, ptr %3, align 8, !tbaa !5
  %9 = getelementptr inbounds %struct._GLFWwindow, ptr %8, i32 0, i32 26
  %10 = getelementptr inbounds %struct.anon, ptr %9, i32 0, i32 4
  %11 = load ptr, ptr %10, align 8, !tbaa !11
  %12 = icmp ne ptr %11, null
  br i1 %12, label %13, label %20

13:                                               ; preds = %2
  %14 = load ptr, ptr %3, align 8, !tbaa !5
  %15 = getelementptr inbounds %struct._GLFWwindow, ptr %14, i32 0, i32 26
  %16 = getelementptr inbounds %struct.anon, ptr %15, i32 0, i32 4
  %17 = load ptr, ptr %16, align 8, !tbaa !11
  %18 = load ptr, ptr %3, align 8, !tbaa !5
  %19 = load i32, ptr %4, align 4, !tbaa !9
  call void %17(ptr noundef %18, i32 noundef %19)
  br label %20

20:                                               ; preds = %13, %2
  %21 = load i32, ptr %4, align 4, !tbaa !9
  %22 = icmp ne i32 %21, 0
  br i1 %22, label %67, label %23

23:                                               ; preds = %20
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #3
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #3
  store i32 0, ptr %5, align 4, !tbaa !9
  br label %24

24:                                               ; preds = %43, %23
  %25 = load i32, ptr %5, align 4, !tbaa !9
  %26 = icmp sle i32 %25, 348
  br i1 %26, label %27, label %46

27:                                               ; preds = %24
  %28 = load ptr, ptr %3, align 8, !tbaa !5
  %29 = getelementptr inbounds %struct._GLFWwindow, ptr %28, i32 0, i32 22
  %30 = load i32, ptr %5, align 4, !tbaa !9
  %31 = sext i32 %30 to i64
  %32 = getelementptr inbounds [349 x i8], ptr %29, i64 0, i64 %31
  %33 = load i8, ptr %32, align 1, !tbaa !22
  %34 = sext i8 %33 to i32
  %35 = icmp eq i32 %34, 1
  br i1 %35, label %36, label %42

36:                                               ; preds = %27
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #3
  %37 = load i32, ptr %5, align 4, !tbaa !9
  %38 = call i32 @_glfwPlatformGetKeyScancode(i32 noundef %37)
  store i32 %38, ptr %7, align 4, !tbaa !9
  %39 = load ptr, ptr %3, align 8, !tbaa !5
  %40 = load i32, ptr %5, align 4, !tbaa !9
  %41 = load i32, ptr %7, align 4, !tbaa !9
  call void @_glfwInputKey(ptr noundef %39, i32 noundef %40, i32 noundef %41, i32 noundef 0, i32 noundef 0)
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #3
  br label %42

42:                                               ; preds = %36, %27
  br label %43

43:                                               ; preds = %42
  %44 = load i32, ptr %5, align 4, !tbaa !9
  %45 = add nsw i32 %44, 1
  store i32 %45, ptr %5, align 4, !tbaa !9
  br label %24, !llvm.loop !23

46:                                               ; preds = %24
  store i32 0, ptr %6, align 4, !tbaa !9
  br label %47

47:                                               ; preds = %63, %46
  %48 = load i32, ptr %6, align 4, !tbaa !9
  %49 = icmp sle i32 %48, 7
  br i1 %49, label %50, label %66

50:                                               ; preds = %47
  %51 = load ptr, ptr %3, align 8, !tbaa !5
  %52 = getelementptr inbounds %struct._GLFWwindow, ptr %51, i32 0, i32 21
  %53 = load i32, ptr %6, align 4, !tbaa !9
  %54 = sext i32 %53 to i64
  %55 = getelementptr inbounds [8 x i8], ptr %52, i64 0, i64 %54
  %56 = load i8, ptr %55, align 1, !tbaa !22
  %57 = sext i8 %56 to i32
  %58 = icmp eq i32 %57, 1
  br i1 %58, label %59, label %62

59:                                               ; preds = %50
  %60 = load ptr, ptr %3, align 8, !tbaa !5
  %61 = load i32, ptr %6, align 4, !tbaa !9
  call void @_glfwInputMouseClick(ptr noundef %60, i32 noundef %61, i32 noundef 0, i32 noundef 0)
  br label %62

62:                                               ; preds = %59, %50
  br label %63

63:                                               ; preds = %62
  %64 = load i32, ptr %6, align 4, !tbaa !9
  %65 = add nsw i32 %64, 1
  store i32 %65, ptr %6, align 4, !tbaa !9
  br label %47, !llvm.loop !25

66:                                               ; preds = %47
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #3
  br label %67

67:                                               ; preds = %66, %20
  ret void
}

; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture) #1

declare i32 @_glfwPlatformGetKeyScancode(i32 noundef) #2

declare void @_glfwInputKey(ptr noundef, i32 noundef, i32 noundef, i32 noundef, i32 noundef) #2

; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #1

declare void @_glfwInputMouseClick(ptr noundef, i32 noundef, i32 noundef, i32 noundef) #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 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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}
!11 = !{!12, !6, i64 720}
!12 = !{!"_GLFWwindow", !6, i64 0, !10, i64 8, !10, i64 12, !10, i64 16, !10, i64 20, !10, i64 24, !10, i64 28, !6, i64 32, !13, i64 40, !6, i64 64, !6, i64 72, !10, i64 80, !10, i64 84, !10, i64 88, !10, i64 92, !10, i64 96, !10, i64 100, !10, i64 104, !10, i64 108, !10, i64 112, !10, i64 116, !7, i64 120, !7, i64 128, !14, i64 480, !14, i64 488, !15, i64 496, !20, i64 688, !21, i64 824}
!13 = !{!"GLFWvidmode", !10, i64 0, !10, i64 4, !10, i64 8, !10, i64 12, !10, i64 16, !10, i64 20}
!14 = !{!"double", !7, i64 0}
!15 = !{!"_GLFWcontext", !10, i64 0, !10, i64 4, !10, i64 8, !10, i64 12, !10, i64 16, !10, i64 20, !10, i64 24, !10, i64 28, !10, i64 32, !10, i64 36, !10, i64 40, !6, i64 48, !6, i64 56, !6, i64 64, !6, i64 72, !6, i64 80, !6, i64 88, !6, i64 96, !6, i64 104, !6, i64 112, !16, i64 120, !18, i64 136, !19, i64 168}
!16 = !{!"_GLFWcontextGLX", !6, i64 0, !17, i64 8}
!17 = !{!"long", !7, i64 0}
!18 = !{!"_GLFWcontextEGL", !6, i64 0, !6, i64 8, !6, i64 16, !6, i64 24}
!19 = !{!"_GLFWcontextOSMesa", !6, i64 0, !10, i64 8, !10, i64 12, !6, i64 16}
!20 = !{!"", !6, i64 0, !6, i64 8, !6, i64 16, !6, i64 24, !6, i64 32, !6, i64 40, !6, i64 48, !6, i64 56, !6, i64 64, !6, i64 72, !6, i64 80, !6, i64 88, !6, i64 96, !6, i64 104, !6, i64 112, !6, i64 120, !6, i64 128}
!21 = !{!"_GLFWwindowX11", !17, i64 0, !17, i64 8, !6, i64 16, !10, i64 24, !10, i64 28, !10, i64 32, !10, i64 36, !10, i64 40, !10, i64 44, !10, i64 48, !10, i64 52, !10, i64 56, !10, i64 60, !10, i64 64, !10, i64 68, !17, i64 72}
!22 = !{!7, !7, i64 0}
!23 = distinct !{!23, !24}
!24 = !{!"llvm.loop.mustprogress"}
!25 = distinct !{!25, !24}


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

; Function Attrs: nounwind uwtable
define dso_local void @_glfwInputWindowFocus(ptr noundef %0, i32 noundef %1) local_unnamed_addr #0 {
  %3 = getelementptr inbounds i8, ptr %0, i64 720
  %4 = load ptr, ptr %3, align 8, !tbaa !5
  %.not = icmp eq ptr %4, null
  br i1 %.not, label %6, label %5

5:                                                ; preds = %2
  tail call void %4(ptr noundef nonnull %0, i32 noundef %1) #2
  br label %6

6:                                                ; preds = %5, %2
  %.not20 = icmp eq i32 %1, 0
  br i1 %.not20, label %.preheader21, label %.loopexit

.preheader21:                                     ; preds = %6
  %7 = getelementptr inbounds i8, ptr %0, i64 128
  br label %11

.preheader:                                       ; preds = %18
  %8 = getelementptr inbounds i8, ptr %0, i64 120
  %9 = load i8, ptr %8, align 1, !tbaa !20
  %10 = icmp eq i8 %9, 1
  br i1 %10, label %19, label %20

11:                                               ; preds = %.preheader21, %18
  %indvars.iv = phi i64 [ 0, %.preheader21 ], [ %indvars.iv.next, %18 ]
  %12 = getelementptr inbounds [349 x i8], ptr %7, i64 0, i64 %indvars.iv
  %13 = load i8, ptr %12, align 1, !tbaa !20
  %14 = icmp eq i8 %13, 1
  br i1 %14, label %15, label %18

15:                                               ; preds = %11
  %16 = trunc nuw nsw i64 %indvars.iv to i32
  %17 = tail call i32 @_glfwPlatformGetKeyScancode(i32 noundef %16) #2
  tail call void @_glfwInputKey(ptr noundef nonnull %0, i32 noundef %16, i32 noundef %17, i32 noundef 0, i32 noundef 0) #2
  br label %18

18:                                               ; preds = %11, %15
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %exitcond.not = icmp eq i64 %indvars.iv.next, 349
  br i1 %exitcond.not, label %.preheader, label %11, !llvm.loop !21

19:                                               ; preds = %.preheader
  tail call void @_glfwInputMouseClick(ptr noundef nonnull %0, i32 noundef 0, i32 noundef 0, i32 noundef 0) #2
  br label %20

20:                                               ; preds = %.preheader, %19
  %21 = getelementptr inbounds i8, ptr %0, i64 121
  %22 = load i8, ptr %21, align 1, !tbaa !20
  %23 = icmp eq i8 %22, 1
  br i1 %23, label %24, label %25

24:                                               ; preds = %20
  tail call void @_glfwInputMouseClick(ptr noundef nonnull %0, i32 noundef 1, i32 noundef 0, i32 noundef 0) #2
  br label %25

25:                                               ; preds = %24, %20
  %26 = getelementptr inbounds i8, ptr %0, i64 122
  %27 = load i8, ptr %26, align 1, !tbaa !20
  %28 = icmp eq i8 %27, 1
  br i1 %28, label %29, label %30

29:                                               ; preds = %25
  tail call void @_glfwInputMouseClick(ptr noundef nonnull %0, i32 noundef 2, i32 noundef 0, i32 noundef 0) #2
  br label %30

30:                                               ; preds = %29, %25
  %31 = getelementptr inbounds i8, ptr %0, i64 123
  %32 = load i8, ptr %31, align 1, !tbaa !20
  %33 = icmp eq i8 %32, 1
  br i1 %33, label %34, label %35

34:                                               ; preds = %30
  tail call void @_glfwInputMouseClick(ptr noundef nonnull %0, i32 noundef 3, i32 noundef 0, i32 noundef 0) #2
  br label %35

35:                                               ; preds = %34, %30
  %36 = getelementptr inbounds i8, ptr %0, i64 124
  %37 = load i8, ptr %36, align 1, !tbaa !20
  %38 = icmp eq i8 %37, 1
  br i1 %38, label %39, label %40

39:                                               ; preds = %35
  tail call void @_glfwInputMouseClick(ptr noundef nonnull %0, i32 noundef 4, i32 noundef 0, i32 noundef 0) #2
  br label %40

40:                                               ; preds = %39, %35
  %41 = getelementptr inbounds i8, ptr %0, i64 125
  %42 = load i8, ptr %41, align 1, !tbaa !20
  %43 = icmp eq i8 %42, 1
  br i1 %43, label %44, label %45

44:                                               ; preds = %40
  tail call void @_glfwInputMouseClick(ptr noundef nonnull %0, i32 noundef 5, i32 noundef 0, i32 noundef 0) #2
  br label %45

45:                                               ; preds = %44, %40
  %46 = getelementptr inbounds i8, ptr %0, i64 126
  %47 = load i8, ptr %46, align 1, !tbaa !20
  %48 = icmp eq i8 %47, 1
  br i1 %48, label %49, label %50

49:                                               ; preds = %45
  tail call void @_glfwInputMouseClick(ptr noundef nonnull %0, i32 noundef 6, i32 noundef 0, i32 noundef 0) #2
  br label %50

50:                                               ; preds = %49, %45
  %51 = getelementptr inbounds i8, ptr %0, i64 127
  %52 = load i8, ptr %51, align 1, !tbaa !20
  %53 = icmp eq i8 %52, 1
  br i1 %53, label %54, label %.loopexit

54:                                               ; preds = %50
  tail call void @_glfwInputMouseClick(ptr noundef nonnull %0, i32 noundef 7, i32 noundef 0, i32 noundef 0) #2
  br label %.loopexit

.loopexit:                                        ; preds = %50, %54, %6
  ret void
}

declare i32 @_glfwPlatformGetKeyScancode(i32 noundef) local_unnamed_addr #1

declare void @_glfwInputKey(ptr noundef, i32 noundef, i32 noundef, i32 noundef, i32 noundef) local_unnamed_addr #1

declare void @_glfwInputMouseClick(ptr noundef, i32 noundef, i32 noundef, i32 noundef) local_unnamed_addr #1

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 = { "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 = { 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, !7, i64 720}
!6 = !{!"_GLFWwindow", !7, i64 0, !10, i64 8, !10, i64 12, !10, i64 16, !10, i64 20, !10, i64 24, !10, i64 28, !7, i64 32, !11, i64 40, !7, i64 64, !7, i64 72, !10, i64 80, !10, i64 84, !10, i64 88, !10, i64 92, !10, i64 96, !10, i64 100, !10, i64 104, !10, i64 108, !10, i64 112, !10, i64 116, !8, i64 120, !8, i64 128, !12, i64 480, !12, i64 488, !13, i64 496, !18, i64 688, !19, i64 824}
!7 = !{!"any pointer", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"int", !8, i64 0}
!11 = !{!"GLFWvidmode", !10, i64 0, !10, i64 4, !10, i64 8, !10, i64 12, !10, i64 16, !10, i64 20}
!12 = !{!"double", !8, i64 0}
!13 = !{!"_GLFWcontext", !10, i64 0, !10, i64 4, !10, i64 8, !10, i64 12, !10, i64 16, !10, i64 20, !10, i64 24, !10, i64 28, !10, i64 32, !10, i64 36, !10, i64 40, !7, i64 48, !7, i64 56, !7, i64 64, !7, i64 72, !7, i64 80, !7, i64 88, !7, i64 96, !7, i64 104, !7, i64 112, !14, i64 120, !16, i64 136, !17, i64 168}
!14 = !{!"_GLFWcontextGLX", !7, i64 0, !15, i64 8}
!15 = !{!"long", !8, i64 0}
!16 = !{!"_GLFWcontextEGL", !7, i64 0, !7, i64 8, !7, i64 16, !7, i64 24}
!17 = !{!"_GLFWcontextOSMesa", !7, i64 0, !10, i64 8, !10, i64 12, !7, i64 16}
!18 = !{!"", !7, i64 0, !7, i64 8, !7, i64 16, !7, i64 24, !7, i64 32, !7, i64 40, !7, i64 48, !7, i64 56, !7, i64 64, !7, i64 72, !7, i64 80, !7, i64 88, !7, i64 96, !7, i64 104, !7, i64 112, !7, i64 120, !7, i64 128}
!19 = !{!"_GLFWwindowX11", !15, i64 0, !15, i64 8, !7, i64 16, !10, i64 24, !10, i64 28, !10, i64 32, !10, i64 36, !10, i64 40, !10, i64 44, !10, i64 48, !10, i64 52, !10, i64 56, !10, i64 60, !10, i64 64, !10, i64 68, !15, i64 72}
!20 = !{!8, !8, i64 0}
!21 = distinct !{!21, !22}
!22 = !{!"llvm.loop.mustprogress"}


; Effective O3 passes: CorrelatedValuePropagationPass,EarlyCSEPass,GVNPass,GlobalOptPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,LICMPass,LoopRotatePass,LoopSimplifyPass,SROAPass,SimplifyCFGPass,TailCallElimPass