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

; 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 @_glfwInputKey(ptr noundef %0, i32 noundef %1, i32 noundef %2, i32 noundef %3, i32 noundef %4) #0 {
  %6 = alloca ptr, align 8
  %7 = alloca i32, align 4
  %8 = alloca i32, align 4
  %9 = alloca i32, align 4
  %10 = alloca i32, align 4
  %11 = alloca i32, align 4
  %12 = alloca i32, align 4
  store ptr %0, ptr %6, align 8, !tbaa !5
  store i32 %1, ptr %7, align 4, !tbaa !9
  store i32 %2, ptr %8, align 4, !tbaa !9
  store i32 %3, ptr %9, align 4, !tbaa !9
  store i32 %4, ptr %10, align 4, !tbaa !9
  %13 = load i32, ptr %7, align 4, !tbaa !9
  %14 = icmp sge i32 %13, 0
  br i1 %14, label %15, label %74

15:                                               ; preds = %5
  %16 = load i32, ptr %7, align 4, !tbaa !9
  %17 = icmp sle i32 %16, 348
  br i1 %17, label %18, label %74

18:                                               ; preds = %15
  call void @llvm.lifetime.start.p0(i64 4, ptr %11) #2
  store i32 0, ptr %11, align 4, !tbaa !9
  %19 = load i32, ptr %9, align 4, !tbaa !9
  %20 = icmp eq i32 %19, 0
  br i1 %20, label %21, label %31

21:                                               ; preds = %18
  %22 = load ptr, ptr %6, align 8, !tbaa !5
  %23 = getelementptr inbounds %struct._GLFWwindow, ptr %22, i32 0, i32 22
  %24 = load i32, ptr %7, align 4, !tbaa !9
  %25 = sext i32 %24 to i64
  %26 = getelementptr inbounds [349 x i8], ptr %23, i64 0, i64 %25
  %27 = load i8, ptr %26, align 1, !tbaa !11
  %28 = sext i8 %27 to i32
  %29 = icmp eq i32 %28, 0
  br i1 %29, label %30, label %31

30:                                               ; preds = %21
  store i32 1, ptr %12, align 4
  br label %71

31:                                               ; preds = %21, %18
  %32 = load i32, ptr %9, align 4, !tbaa !9
  %33 = icmp eq i32 %32, 1
  br i1 %33, label %34, label %44

34:                                               ; preds = %31
  %35 = load ptr, ptr %6, align 8, !tbaa !5
  %36 = getelementptr inbounds %struct._GLFWwindow, ptr %35, i32 0, i32 22
  %37 = load i32, ptr %7, align 4, !tbaa !9
  %38 = sext i32 %37 to i64
  %39 = getelementptr inbounds [349 x i8], ptr %36, i64 0, i64 %38
  %40 = load i8, ptr %39, align 1, !tbaa !11
  %41 = sext i8 %40 to i32
  %42 = icmp eq i32 %41, 1
  br i1 %42, label %43, label %44

43:                                               ; preds = %34
  store i32 1, ptr %11, align 4, !tbaa !9
  br label %44

44:                                               ; preds = %43, %34, %31
  %45 = load i32, ptr %9, align 4, !tbaa !9
  %46 = icmp eq i32 %45, 0
  br i1 %46, label %47, label %58

47:                                               ; preds = %44
  %48 = load ptr, ptr %6, align 8, !tbaa !5
  %49 = getelementptr inbounds %struct._GLFWwindow, ptr %48, i32 0, i32 17
  %50 = load i32, ptr %49, align 8, !tbaa !12
  %51 = icmp ne i32 %50, 0
  br i1 %51, label %52, label %58

52:                                               ; preds = %47
  %53 = load ptr, ptr %6, align 8, !tbaa !5
  %54 = getelementptr inbounds %struct._GLFWwindow, ptr %53, i32 0, i32 22
  %55 = load i32, ptr %7, align 4, !tbaa !9
  %56 = sext i32 %55 to i64
  %57 = getelementptr inbounds [349 x i8], ptr %54, i64 0, i64 %56
  store i8 3, ptr %57, align 1, !tbaa !11
  br label %66

58:                                               ; preds = %47, %44
  %59 = load i32, ptr %9, align 4, !tbaa !9
  %60 = trunc i32 %59 to i8
  %61 = load ptr, ptr %6, align 8, !tbaa !5
  %62 = getelementptr inbounds %struct._GLFWwindow, ptr %61, i32 0, i32 22
  %63 = load i32, ptr %7, align 4, !tbaa !9
  %64 = sext i32 %63 to i64
  %65 = getelementptr inbounds [349 x i8], ptr %62, i64 0, i64 %64
  store i8 %60, ptr %65, align 1, !tbaa !11
  br label %66

66:                                               ; preds = %58, %52
  %67 = load i32, ptr %11, align 4, !tbaa !9
  %68 = icmp ne i32 %67, 0
  br i1 %68, label %69, label %70

69:                                               ; preds = %66
  store i32 2, ptr %9, align 4, !tbaa !9
  br label %70

70:                                               ; preds = %69, %66
  store i32 0, ptr %12, align 4
  br label %71

71:                                               ; preds = %70, %30
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #2
  %72 = load i32, ptr %12, align 4
  switch i32 %72, label %99 [
    i32 0, label %73
    i32 1, label %98
  ]

73:                                               ; preds = %71
  br label %74

74:                                               ; preds = %73, %15, %5
  %75 = load ptr, ptr %6, align 8, !tbaa !5
  %76 = getelementptr inbounds %struct._GLFWwindow, ptr %75, i32 0, i32 19
  %77 = load i32, ptr %76, align 8, !tbaa !23
  %78 = icmp ne i32 %77, 0
  br i1 %78, label %82, label %79

79:                                               ; preds = %74
  %80 = load i32, ptr %10, align 4, !tbaa !9
  %81 = and i32 %80, -49
  store i32 %81, ptr %10, align 4, !tbaa !9
  br label %82

82:                                               ; preds = %79, %74
  %83 = load ptr, ptr %6, align 8, !tbaa !5
  %84 = getelementptr inbounds %struct._GLFWwindow, ptr %83, i32 0, i32 26
  %85 = getelementptr inbounds %struct.anon, ptr %84, i32 0, i32 13
  %86 = load ptr, ptr %85, align 8, !tbaa !24
  %87 = icmp ne ptr %86, null
  br i1 %87, label %88, label %98

88:                                               ; preds = %82
  %89 = load ptr, ptr %6, align 8, !tbaa !5
  %90 = getelementptr inbounds %struct._GLFWwindow, ptr %89, i32 0, i32 26
  %91 = getelementptr inbounds %struct.anon, ptr %90, i32 0, i32 13
  %92 = load ptr, ptr %91, align 8, !tbaa !24
  %93 = load ptr, ptr %6, align 8, !tbaa !5
  %94 = load i32, ptr %7, align 4, !tbaa !9
  %95 = load i32, ptr %8, align 4, !tbaa !9
  %96 = load i32, ptr %9, align 4, !tbaa !9
  %97 = load i32, ptr %10, align 4, !tbaa !9
  call void %92(ptr noundef %93, i32 noundef %94, i32 noundef %95, i32 noundef %96, i32 noundef %97)
  br label %98

98:                                               ; preds = %88, %82, %71
  ret void

99:                                               ; preds = %71
  unreachable
}

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

; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #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 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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, !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 = !{!7, !7, i64 0}
!12 = !{!13, !10, i64 104}
!13 = !{!"_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, !14, 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, !15, i64 480, !15, i64 488, !16, i64 496, !21, i64 688, !22, i64 824}
!14 = !{!"GLFWvidmode", !10, i64 0, !10, i64 4, !10, i64 8, !10, i64 12, !10, i64 16, !10, i64 20}
!15 = !{!"double", !7, i64 0}
!16 = !{!"_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, !17, i64 120, !19, i64 136, !20, i64 168}
!17 = !{!"_GLFWcontextGLX", !6, i64 0, !18, i64 8}
!18 = !{!"long", !7, i64 0}
!19 = !{!"_GLFWcontextEGL", !6, i64 0, !6, i64 8, !6, i64 16, !6, i64 24}
!20 = !{!"_GLFWcontextOSMesa", !6, i64 0, !10, i64 8, !10, i64 12, !6, i64 16}
!21 = !{!"", !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}
!22 = !{!"_GLFWwindowX11", !18, i64 0, !18, 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, !18, i64 72}
!23 = !{!13, !10, i64 112}
!24 = !{!13, !6, i64 792}


; 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 @_glfwInputKey(ptr noundef %0, i32 noundef %1, i32 noundef %2, i32 noundef %3, i32 noundef %4) local_unnamed_addr #0 {
  %or.cond = icmp ult i32 %1, 349
  br i1 %or.cond, label %6, label %.thread51

6:                                                ; preds = %5
  switch i32 %3, label %.thread47 [
    i32 0, label %7
    i32 1, label %20
  ]

7:                                                ; preds = %6
  %8 = getelementptr inbounds i8, ptr %0, i64 128
  %9 = zext nneg i32 %1 to i64
  %10 = getelementptr inbounds [349 x i8], ptr %8, i64 0, i64 %9
  %11 = load i8, ptr %10, align 1, !tbaa !5
  %12 = icmp eq i8 %11, 0
  br i1 %12, label %32, label %17

.thread47:                                        ; preds = %6
  %13 = trunc i32 %3 to i8
  %14 = getelementptr inbounds i8, ptr %0, i64 128
  %15 = zext nneg i32 %1 to i64
  %16 = getelementptr inbounds [349 x i8], ptr %14, i64 0, i64 %15
  store i8 %13, ptr %16, align 1, !tbaa !5
  br label %25

17:                                               ; preds = %7
  %18 = getelementptr inbounds i8, ptr %0, i64 104
  %19 = load i32, ptr %18, align 8, !tbaa !8
  %.not = icmp eq i32 %19, 0
  br i1 %.not, label %.thread44, label %.thread41

.thread44:                                        ; preds = %17
  store i8 0, ptr %10, align 1, !tbaa !5
  br label %25

.thread41:                                        ; preds = %17
  store i8 3, ptr %10, align 1, !tbaa !5
  br label %25

20:                                               ; preds = %6
  %21 = getelementptr inbounds i8, ptr %0, i64 128
  %22 = zext nneg i32 %1 to i64
  %23 = getelementptr inbounds [349 x i8], ptr %21, i64 0, i64 %22
  %24 = load i8, ptr %23, align 1, !tbaa !5
  %.fr = freeze i8 %24
  %.not55 = icmp eq i8 %.fr, 1
  store i8 1, ptr %23, align 1, !tbaa !5
  br i1 %.not55, label %.thread51, label %25

25:                                               ; preds = %.thread47, %.thread44, %.thread41, %20
  br label %.thread51

.thread51:                                        ; preds = %25, %20, %5
  %.2 = phi i32 [ %3, %5 ], [ 2, %20 ], [ %3, %25 ]
  %26 = getelementptr inbounds i8, ptr %0, i64 792
  %27 = load ptr, ptr %26, align 8, !tbaa !21
  %.not34 = icmp eq ptr %27, null
  br i1 %.not34, label %32, label %28

28:                                               ; preds = %.thread51
  %29 = getelementptr inbounds i8, ptr %0, i64 112
  %30 = load i32, ptr %29, align 8, !tbaa !22
  %.not33 = icmp eq i32 %30, 0
  %31 = and i32 %4, -49
  %spec.select36 = select i1 %.not33, i32 %31, i32 %4
  tail call void %27(ptr noundef nonnull %0, i32 noundef %1, i32 noundef %2, i32 noundef %.2, i32 noundef %spec.select36) #1
  br label %32

32:                                               ; preds = %7, %28, %.thread51
  ret void
}

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


; Effective O3 passes: CorrelatedValuePropagationPass,EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,SROAPass,SimplifyCFGPass,TailCallElimPass