; LLVM IR from Samson-Mano/EM_Propogation_simulation :: EM_Propogation_simulation/src/ImGui/imgui.ll (ZN7ImGuiIO22AddInputCharacterUTF16Et)

; 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.ImGuiIO = type { i32, i32, %struct.ImVec2, float, float, ptr, ptr, float, float, float, float, float, float, float, ptr, ptr, float, i8, ptr, %struct.ImVec2, i8, i8, i8, i8, i8, i8, i8, i8, float, i8, i8, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, i8, i8, i8, i8, i8, i8, i8, float, i32, i32, i32, i32, i32, %struct.ImVec2, [652 x i32], [652 x i8], [16 x float], ptr, %struct.ImVec2, [5 x i8], float, float, i32, i8, i8, i8, i8, i32, [652 x %struct.ImGuiKeyData], i8, %struct.ImVec2, [5 x %struct.ImVec2], [5 x double], [5 x i8], [5 x i8], [5 x i16], [5 x i16], [5 x i8], [5 x i8], [5 x i8], i8, [5 x float], [5 x float], [5 x float], float, i8, i8, i8, i8, i16, %struct.ImVector }
%struct.ImGuiKeyData = type { i8, float, float, float }
%struct.ImVec2 = type { float, float }
%struct.ImVector = type { i32, i32, ptr }

; 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 uwtable
declare dso_local void @_ZN7ImGuiIO17AddInputCharacterEj(ptr noundef nonnull align 8 dereferenceable(14280), i32 noundef) #1 align 2

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN7ImGuiIO22AddInputCharacterUTF16Et(ptr noundef nonnull align 8 dereferenceable(14280) %0, i16 noundef zeroext %1) #1 align 2 {
  %3 = alloca ptr, align 8
  %4 = alloca i16, align 2
  %5 = alloca i16, align 2
  store ptr %0, ptr %3, align 8, !tbaa !5
  store i16 %1, ptr %4, align 2, !tbaa !9
  %6 = load ptr, ptr %3, align 8
  %7 = load i16, ptr %4, align 2, !tbaa !9
  %8 = zext i16 %7 to i32
  %9 = icmp eq i32 %8, 0
  br i1 %9, label %10, label %15

10:                                               ; preds = %2
  %11 = getelementptr inbounds %struct.ImGuiIO, ptr %6, i32 0, i32 90
  %12 = load i16, ptr %11, align 4, !tbaa !11
  %13 = zext i16 %12 to i32
  %14 = icmp eq i32 %13, 0
  br i1 %14, label %19, label %15

15:                                               ; preds = %10, %2
  %16 = getelementptr inbounds %struct.ImGuiIO, ptr %6, i32 0, i32 87
  %17 = load i8, ptr %16, align 1, !tbaa !19, !range !20, !noundef !21
  %18 = trunc i8 %17 to i1
  br i1 %18, label %20, label %19

19:                                               ; preds = %15, %10
  br label %52

20:                                               ; preds = %15
  %21 = load i16, ptr %4, align 2, !tbaa !9
  %22 = zext i16 %21 to i32
  %23 = and i32 %22, 64512
  %24 = icmp eq i32 %23, 55296
  br i1 %24, label %25, label %34

25:                                               ; preds = %20
  %26 = getelementptr inbounds %struct.ImGuiIO, ptr %6, i32 0, i32 90
  %27 = load i16, ptr %26, align 4, !tbaa !11
  %28 = zext i16 %27 to i32
  %29 = icmp ne i32 %28, 0
  br i1 %29, label %30, label %31

30:                                               ; preds = %25
  call void @_ZN7ImGuiIO17AddInputCharacterEj(ptr noundef nonnull align 8 dereferenceable(14280) %6, i32 noundef 65533)
  br label %31

31:                                               ; preds = %30, %25
  %32 = load i16, ptr %4, align 2, !tbaa !9
  %33 = getelementptr inbounds %struct.ImGuiIO, ptr %6, i32 0, i32 90
  store i16 %32, ptr %33, align 4, !tbaa !11
  br label %52

34:                                               ; preds = %20
  call void @llvm.lifetime.start.p0(i64 2, ptr %5) #2
  %35 = load i16, ptr %4, align 2, !tbaa !9
  store i16 %35, ptr %5, align 2, !tbaa !9
  %36 = getelementptr inbounds %struct.ImGuiIO, ptr %6, i32 0, i32 90
  %37 = load i16, ptr %36, align 4, !tbaa !11
  %38 = zext i16 %37 to i32
  %39 = icmp ne i32 %38, 0
  br i1 %39, label %40, label %49

40:                                               ; preds = %34
  %41 = load i16, ptr %4, align 2, !tbaa !9
  %42 = zext i16 %41 to i32
  %43 = and i32 %42, 64512
  %44 = icmp ne i32 %43, 56320
  br i1 %44, label %45, label %46

45:                                               ; preds = %40
  call void @_ZN7ImGuiIO17AddInputCharacterEj(ptr noundef nonnull align 8 dereferenceable(14280) %6, i32 noundef 65533)
  br label %47

46:                                               ; preds = %40
  store i16 -3, ptr %5, align 2, !tbaa !9
  br label %47

47:                                               ; preds = %46, %45
  %48 = getelementptr inbounds %struct.ImGuiIO, ptr %6, i32 0, i32 90
  store i16 0, ptr %48, align 4, !tbaa !11
  br label %49

49:                                               ; preds = %47, %34
  %50 = load i16, ptr %5, align 2, !tbaa !9
  %51 = zext i16 %50 to i32
  call void @_ZN7ImGuiIO17AddInputCharacterEj(ptr noundef nonnull align 8 dereferenceable(14280) %6, i32 noundef %51)
  call void @llvm.lifetime.end.p0(i64 2, ptr %5) #2
  br label %52

52:                                               ; preds = %49, %31, %19
  ret void
}

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { mustprogress 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 = !{!"short", !7, i64 0}
!11 = !{!12, !10, i64 14260}
!12 = !{!"_ZTS7ImGuiIO", !13, i64 0, !13, i64 4, !14, i64 8, !15, i64 16, !15, i64 20, !6, i64 24, !6, i64 32, !15, i64 40, !15, i64 44, !15, i64 48, !15, i64 52, !15, i64 56, !15, i64 60, !15, i64 64, !6, i64 72, !6, i64 80, !15, i64 88, !16, i64 92, !6, i64 96, !14, i64 104, !16, i64 112, !16, i64 113, !16, i64 114, !16, i64 115, !16, i64 116, !16, i64 117, !16, i64 118, !16, i64 119, !15, i64 120, !16, i64 124, !16, i64 125, !6, i64 128, !6, i64 136, !6, i64 144, !6, i64 152, !6, i64 160, !6, i64 168, !6, i64 176, !6, i64 184, !6, i64 192, !6, i64 200, !16, i64 208, !16, i64 209, !16, i64 210, !16, i64 211, !16, i64 212, !16, i64 213, !16, i64 214, !15, i64 216, !13, i64 220, !13, i64 224, !13, i64 228, !13, i64 232, !13, i64 236, !14, i64 240, !7, i64 248, !7, i64 2856, !7, i64 3508, !6, i64 3576, !14, i64 3584, !7, i64 3592, !15, i64 3600, !15, i64 3604, !17, i64 3608, !16, i64 3612, !16, i64 3613, !16, i64 3614, !16, i64 3615, !13, i64 3616, !7, i64 3620, !16, i64 14052, !14, i64 14056, !7, i64 14064, !7, i64 14104, !7, i64 14144, !7, i64 14149, !7, i64 14154, !7, i64 14164, !7, i64 14174, !7, i64 14179, !7, i64 14184, !16, i64 14189, !7, i64 14192, !7, i64 14212, !7, i64 14232, !15, i64 14252, !16, i64 14256, !16, i64 14257, !7, i64 14258, !16, i64 14259, !10, i64 14260, !18, i64 14264}
!13 = !{!"int", !7, i64 0}
!14 = !{!"_ZTS6ImVec2", !15, i64 0, !15, i64 4}
!15 = !{!"float", !7, i64 0}
!16 = !{!"bool", !7, i64 0}
!17 = !{!"_ZTS16ImGuiMouseSource", !7, i64 0}
!18 = !{!"_ZTS8ImVectorItE", !13, i64 0, !13, i64 4, !6, i64 8}
!19 = !{!12, !16, i64 14257}
!20 = !{i8 0, i8 2}
!21 = !{}


; 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 uwtable
declare dso_local void @_ZN7ImGuiIO17AddInputCharacterEj(ptr noundef nonnull align 8 dereferenceable(14280), i32 noundef) local_unnamed_addr #0 align 2

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN7ImGuiIO22AddInputCharacterUTF16Et(ptr noundef nonnull align 8 dereferenceable(14280) %0, i16 noundef zeroext %1) local_unnamed_addr #0 align 2 {
  %3 = icmp eq i16 %1, 0
  %4 = getelementptr inbounds i8, ptr %0, i64 14260
  %5 = load i16, ptr %4, align 4
  %6 = icmp eq i16 %5, 0
  %or.cond = select i1 %3, i1 %6, i1 false
  br i1 %or.cond, label %23, label %7

7:                                                ; preds = %2
  %8 = getelementptr inbounds i8, ptr %0, i64 14257
  %9 = load i8, ptr %8, align 1, !tbaa !5, !range !17, !noundef !18
  %10 = trunc nuw i8 %9 to i1
  br i1 %10, label %11, label %23

11:                                               ; preds = %7
  %12 = and i16 %1, -1024
  %13 = icmp eq i16 %12, -10240
  br i1 %13, label %14, label %17

14:                                               ; preds = %11
  br i1 %6, label %16, label %15

15:                                               ; preds = %14
  tail call void @_ZN7ImGuiIO17AddInputCharacterEj(ptr noundef nonnull align 8 dereferenceable(14280) %0, i32 noundef 65533)
  br label %16

16:                                               ; preds = %15, %14
  store i16 %1, ptr %4, align 4, !tbaa !19
  br label %23

17:                                               ; preds = %11
  br i1 %6, label %21, label %18

18:                                               ; preds = %17
  %.not7 = icmp eq i16 %12, -9216
  br i1 %.not7, label %20, label %19

19:                                               ; preds = %18
  tail call void @_ZN7ImGuiIO17AddInputCharacterEj(ptr noundef nonnull align 8 dereferenceable(14280) %0, i32 noundef 65533)
  br label %20

20:                                               ; preds = %18, %19
  %.0 = phi i16 [ %1, %19 ], [ -3, %18 ]
  store i16 0, ptr %4, align 4, !tbaa !19
  br label %21

21:                                               ; preds = %20, %17
  %.1 = phi i16 [ %.0, %20 ], [ %1, %17 ]
  %22 = zext i16 %.1 to i32
  tail call void @_ZN7ImGuiIO17AddInputCharacterEj(ptr noundef nonnull align 8 dereferenceable(14280) %0, i32 noundef %22)
  br label %23

23:                                               ; preds = %2, %7, %21, %16
  ret void
}

attributes #0 = { mustprogress 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, !13, i64 14257}
!6 = !{!"_ZTS7ImGuiIO", !7, i64 0, !7, i64 4, !10, i64 8, !11, i64 16, !11, i64 20, !12, i64 24, !12, i64 32, !11, i64 40, !11, i64 44, !11, i64 48, !11, i64 52, !11, i64 56, !11, i64 60, !11, i64 64, !12, i64 72, !12, i64 80, !11, i64 88, !13, i64 92, !12, i64 96, !10, i64 104, !13, i64 112, !13, i64 113, !13, i64 114, !13, i64 115, !13, i64 116, !13, i64 117, !13, i64 118, !13, i64 119, !11, i64 120, !13, i64 124, !13, i64 125, !12, i64 128, !12, i64 136, !12, i64 144, !12, i64 152, !12, i64 160, !12, i64 168, !12, i64 176, !12, i64 184, !12, i64 192, !12, i64 200, !13, i64 208, !13, i64 209, !13, i64 210, !13, i64 211, !13, i64 212, !13, i64 213, !13, i64 214, !11, i64 216, !7, i64 220, !7, i64 224, !7, i64 228, !7, i64 232, !7, i64 236, !10, i64 240, !8, i64 248, !8, i64 2856, !8, i64 3508, !12, i64 3576, !10, i64 3584, !8, i64 3592, !11, i64 3600, !11, i64 3604, !14, i64 3608, !13, i64 3612, !13, i64 3613, !13, i64 3614, !13, i64 3615, !7, i64 3616, !8, i64 3620, !13, i64 14052, !10, i64 14056, !8, i64 14064, !8, i64 14104, !8, i64 14144, !8, i64 14149, !8, i64 14154, !8, i64 14164, !8, i64 14174, !8, i64 14179, !8, i64 14184, !13, i64 14189, !8, i64 14192, !8, i64 14212, !8, i64 14232, !11, i64 14252, !13, i64 14256, !13, i64 14257, !8, i64 14258, !13, i64 14259, !15, i64 14260, !16, i64 14264}
!7 = !{!"int", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C++ TBAA"}
!10 = !{!"_ZTS6ImVec2", !11, i64 0, !11, i64 4}
!11 = !{!"float", !8, i64 0}
!12 = !{!"any pointer", !8, i64 0}
!13 = !{!"bool", !8, i64 0}
!14 = !{!"_ZTS16ImGuiMouseSource", !8, i64 0}
!15 = !{!"short", !8, i64 0}
!16 = !{!"_ZTS8ImVectorItE", !7, i64 0, !7, i64 4, !12, i64 8}
!17 = !{i8 0, i8 2}
!18 = !{}
!19 = !{!6, !15, i64 14260}


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