; LLVM IR from erwincoumans/tiny-differentiable-simulator :: src/visualizer/opengl (tiny_x11_opengl_window)

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

%class.TinyX11OpenGLWindow = type <{ %class.TinyWindowInterface, ptr, i8, i8, [6 x i8] }>
%class.TinyWindowInterface = type { ptr }
%struct.InternalData2 = type { ptr, i64, ptr, i64, %struct.XSetWindowAttributes, i64, ptr, %struct.XWindowAttributes, %union._XEvent, ptr, i32, i32, i32, ptr, ptr, ptr, ptr, ptr }
%struct.XSetWindowAttributes = type { i64, i64, i64, i64, i32, i32, i32, i64, i64, i32, i64, i64, i32, i64, i64 }
%struct.XWindowAttributes = type { i32, i32, i32, i32, i32, i32, ptr, i64, i32, i32, i32, i32, i64, i64, i32, i64, i32, i32, i64, i64, i64, i32, ptr }
%union._XEvent = type { [24 x i64] }

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

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

; Function Attrs: mustprogress nounwind uwtable
define dso_local noundef zeroext i1 @_ZN19TinyX11OpenGLWindow23is_modifier_key_pressedEi(ptr noundef nonnull align 8 dereferenceable(18) %0, i32 noundef %1) unnamed_addr #1 align 2 {
  %3 = alloca ptr, align 8
  %4 = alloca i32, align 4
  %5 = alloca i8, align 1
  store ptr %0, ptr %3, align 8, !tbaa !5
  store i32 %1, ptr %4, align 4, !tbaa !9
  %6 = load ptr, ptr %3, align 8
  call void @llvm.lifetime.start.p0(i64 1, ptr %5) #2
  store i8 0, ptr %5, align 1, !tbaa !11
  %7 = load i32, ptr %4, align 4, !tbaa !9
  switch i32 %7, label %32 [
    i32 156, label %8
    i32 154, label %16
    i32 155, label %24
  ]

8:                                                ; preds = %2
  %9 = getelementptr inbounds %class.TinyX11OpenGLWindow, ptr %6, i32 0, i32 1
  %10 = load ptr, ptr %9, align 8, !tbaa !13
  %11 = getelementptr inbounds %struct.InternalData2, ptr %10, i32 0, i32 10
  %12 = load i32, ptr %11, align 8, !tbaa !16
  %13 = and i32 %12, 1
  %14 = icmp ne i32 %13, 0
  %15 = zext i1 %14 to i8
  store i8 %15, ptr %5, align 1, !tbaa !11
  br label %33

16:                                               ; preds = %2
  %17 = getelementptr inbounds %class.TinyX11OpenGLWindow, ptr %6, i32 0, i32 1
  %18 = load ptr, ptr %17, align 8, !tbaa !13
  %19 = getelementptr inbounds %struct.InternalData2, ptr %18, i32 0, i32 10
  %20 = load i32, ptr %19, align 8, !tbaa !16
  %21 = and i32 %20, 2
  %22 = icmp ne i32 %21, 0
  %23 = zext i1 %22 to i8
  store i8 %23, ptr %5, align 1, !tbaa !11
  br label %33

24:                                               ; preds = %2
  %25 = getelementptr inbounds %class.TinyX11OpenGLWindow, ptr %6, i32 0, i32 1
  %26 = load ptr, ptr %25, align 8, !tbaa !13
  %27 = getelementptr inbounds %struct.InternalData2, ptr %26, i32 0, i32 10
  %28 = load i32, ptr %27, align 8, !tbaa !16
  %29 = and i32 %28, 4
  %30 = icmp ne i32 %29, 0
  %31 = zext i1 %30 to i8
  store i8 %31, ptr %5, align 1, !tbaa !11
  br label %33

32:                                               ; preds = %2
  br label %33

33:                                               ; preds = %32, %24, %16, %8
  %34 = load i8, ptr %5, align 1, !tbaa !11, !range !21, !noundef !22
  %35 = trunc i8 %34 to i1
  call void @llvm.lifetime.end.p0(i64 1, ptr %5) #2
  ret i1 %35
}

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { mustprogress 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 = { 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++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"int", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"bool", !7, i64 0}
!13 = !{!14, !6, i64 8}
!14 = !{!"_ZTS19TinyX11OpenGLWindow", !15, i64 0, !6, i64 8, !12, i64 16, !12, i64 17}
!15 = !{!"_ZTS19TinyWindowInterface"}
!16 = !{!17, !10, i64 496}
!17 = !{!"_ZTS13InternalData2", !6, i64 0, !18, i64 8, !6, i64 16, !18, i64 24, !19, i64 32, !18, i64 144, !6, i64 152, !20, i64 160, !7, i64 296, !6, i64 488, !10, i64 496, !10, i64 500, !10, i64 504, !6, i64 512, !6, i64 520, !6, i64 528, !6, i64 536, !6, i64 544}
!18 = !{!"long", !7, i64 0}
!19 = !{!"_ZTS20XSetWindowAttributes", !18, i64 0, !18, i64 8, !18, i64 16, !18, i64 24, !10, i64 32, !10, i64 36, !10, i64 40, !18, i64 48, !18, i64 56, !10, i64 64, !18, i64 72, !18, i64 80, !10, i64 88, !18, i64 96, !18, i64 104}
!20 = !{!"_ZTS17XWindowAttributes", !10, i64 0, !10, i64 4, !10, i64 8, !10, i64 12, !10, i64 16, !10, i64 20, !6, i64 24, !18, i64 32, !10, i64 40, !10, i64 44, !10, i64 48, !10, i64 52, !18, i64 56, !18, i64 64, !10, i64 72, !18, i64 80, !10, i64 88, !10, i64 92, !18, i64 96, !18, i64 104, !18, i64 112, !10, i64 120, !6, i64 128}
!21 = !{i8 0, i8 2}
!22 = !{}


; 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: mustprogress nofree norecurse nosync nounwind willreturn memory(read, inaccessiblemem: none) uwtable
define dso_local noundef zeroext i1 @_ZN19TinyX11OpenGLWindow23is_modifier_key_pressedEi(ptr nocapture noundef nonnull readonly align 8 dereferenceable(18) %0, i32 noundef %1) unnamed_addr #0 align 2 {
  switch i32 %1, label %23 [
    i32 156, label %3
    i32 154, label %9
    i32 155, label %16
  ]

3:                                                ; preds = %2
  %4 = getelementptr inbounds i8, ptr %0, i64 8
  %5 = load ptr, ptr %4, align 8, !tbaa !5
  %6 = getelementptr inbounds i8, ptr %5, i64 496
  %7 = load i32, ptr %6, align 8, !tbaa !12
  %8 = trunc i32 %7 to i8
  br label %23

9:                                                ; preds = %2
  %10 = getelementptr inbounds i8, ptr %0, i64 8
  %11 = load ptr, ptr %10, align 8, !tbaa !5
  %12 = getelementptr inbounds i8, ptr %11, i64 496
  %13 = load i32, ptr %12, align 8, !tbaa !12
  %14 = trunc i32 %13 to i8
  %15 = lshr i8 %14, 1
  br label %23

16:                                               ; preds = %2
  %17 = getelementptr inbounds i8, ptr %0, i64 8
  %18 = load ptr, ptr %17, align 8, !tbaa !5
  %19 = getelementptr inbounds i8, ptr %18, i64 496
  %20 = load i32, ptr %19, align 8, !tbaa !12
  %21 = trunc i32 %20 to i8
  %22 = lshr i8 %21, 2
  br label %23

23:                                               ; preds = %2, %16, %9, %3
  %.0 = phi i8 [ 0, %2 ], [ %22, %16 ], [ %15, %9 ], [ %8, %3 ]
  %24 = trunc i8 %.0 to i1
  ret i1 %24
}

attributes #0 = { mustprogress nofree norecurse nosync nounwind willreturn memory(read, inaccessiblemem: none) 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" }

!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, !8, i64 8}
!6 = !{!"_ZTS19TinyX11OpenGLWindow", !7, i64 0, !8, i64 8, !11, i64 16, !11, i64 17}
!7 = !{!"_ZTS19TinyWindowInterface"}
!8 = !{!"any pointer", !9, i64 0}
!9 = !{!"omnipotent char", !10, i64 0}
!10 = !{!"Simple C++ TBAA"}
!11 = !{!"bool", !9, i64 0}
!12 = !{!13, !16, i64 496}
!13 = !{!"_ZTS13InternalData2", !8, i64 0, !14, i64 8, !8, i64 16, !14, i64 24, !15, i64 32, !14, i64 144, !8, i64 152, !17, i64 160, !9, i64 296, !8, i64 488, !16, i64 496, !16, i64 500, !16, i64 504, !8, i64 512, !8, i64 520, !8, i64 528, !8, i64 536, !8, i64 544}
!14 = !{!"long", !9, i64 0}
!15 = !{!"_ZTS20XSetWindowAttributes", !14, i64 0, !14, i64 8, !14, i64 16, !14, i64 24, !16, i64 32, !16, i64 36, !16, i64 40, !14, i64 48, !14, i64 56, !16, i64 64, !14, i64 72, !14, i64 80, !16, i64 88, !14, i64 96, !14, i64 104}
!16 = !{!"int", !9, i64 0}
!17 = !{!"_ZTS17XWindowAttributes", !16, i64 0, !16, i64 4, !16, i64 8, !16, i64 12, !16, i64 16, !16, i64 20, !8, i64 24, !14, i64 32, !16, i64 40, !16, i64 44, !16, i64 48, !16, i64 52, !14, i64 56, !14, i64 64, !16, i64 72, !14, i64 80, !16, i64 88, !16, i64 92, !14, i64 96, !14, i64 104, !14, i64 112, !16, i64 120, !8, i64 128}


; Effective O3 passes: BDCEPass,GlobalOptPass,IPSCCPPass,InferFunctionAttrsPass,InstCombinePass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass