; LLVM IR from Eukky/TRender :: lib/imgui/imgui.ll (ZN7ImGuiIO22AddInputCharactersUTF8EPKc)

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

; 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 @_ZN7ImGuiIO17AddInputCharacterEt(ptr noundef nonnull align 8 dereferenceable(5400), i16 noundef zeroext) #1 align 2

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN7ImGuiIO22AddInputCharactersUTF8EPKc(ptr noundef nonnull align 8 dereferenceable(5400) %0, ptr noundef %1) #1 align 2 {
  %3 = alloca ptr, align 8
  %4 = alloca ptr, align 8
  %5 = alloca i32, align 4
  %6 = alloca [17 x i16], align 16
  %7 = alloca i32, align 4
  store ptr %0, ptr %3, align 8, !tbaa !5
  store ptr %1, ptr %4, align 8, !tbaa !5
  %8 = load ptr, ptr %3, align 8
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #3
  store i32 17, ptr %5, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 34, ptr %6) #3
  %9 = getelementptr inbounds [17 x i16], ptr %6, i64 0, i64 0
  %10 = load ptr, ptr %4, align 8, !tbaa !5
  %11 = call noundef i32 @_Z17ImTextStrFromUtf8PtiPKcS1_PS1_(ptr noundef %9, i32 noundef 17, ptr noundef %10, ptr noundef null, ptr noundef null)
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #3
  store i32 0, ptr %7, align 4, !tbaa !9
  br label %12

12:                                               ; preds = %30, %2
  %13 = load i32, ptr %7, align 4, !tbaa !9
  %14 = icmp slt i32 %13, 17
  br i1 %14, label %15, label %22

15:                                               ; preds = %12
  %16 = load i32, ptr %7, align 4, !tbaa !9
  %17 = sext i32 %16 to i64
  %18 = getelementptr inbounds [17 x i16], ptr %6, i64 0, i64 %17
  %19 = load i16, ptr %18, align 2, !tbaa !11
  %20 = zext i16 %19 to i32
  %21 = icmp ne i32 %20, 0
  br label %22

22:                                               ; preds = %15, %12
  %23 = phi i1 [ false, %12 ], [ %21, %15 ]
  br i1 %23, label %25, label %24

24:                                               ; preds = %22
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #3
  br label %33

25:                                               ; preds = %22
  %26 = load i32, ptr %7, align 4, !tbaa !9
  %27 = sext i32 %26 to i64
  %28 = getelementptr inbounds [17 x i16], ptr %6, i64 0, i64 %27
  %29 = load i16, ptr %28, align 2, !tbaa !11
  call void @_ZN7ImGuiIO17AddInputCharacterEt(ptr noundef nonnull align 8 dereferenceable(5400) %8, i16 noundef zeroext %29)
  br label %30

30:                                               ; preds = %25
  %31 = load i32, ptr %7, align 4, !tbaa !9
  %32 = add nsw i32 %31, 1
  store i32 %32, ptr %7, align 4, !tbaa !9
  br label %12, !llvm.loop !13

33:                                               ; preds = %24
  call void @llvm.lifetime.end.p0(i64 34, ptr %6) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #3
  ret void
}

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef i32 @_Z17ImTextStrFromUtf8PtiPKcS1_PS1_(ptr noundef, i32 noundef, ptr noundef, ptr noundef, ptr noundef) #2

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 = { 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 #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++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"int", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"short", !7, i64 0}
!13 = distinct !{!13, !14}
!14 = !{!"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"

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

; Function Attrs: mustprogress 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 @_ZN7ImGuiIO17AddInputCharacterEt(ptr noundef nonnull align 8 dereferenceable(5400), i16 noundef zeroext) local_unnamed_addr #1 align 2

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN7ImGuiIO22AddInputCharactersUTF8EPKc(ptr noundef nonnull align 8 dereferenceable(5400) %0, ptr noundef %1) local_unnamed_addr #1 align 2 {
  %3 = alloca [17 x i16], align 16
  call void @llvm.lifetime.start.p0(i64 34, ptr nonnull %3) #3
  %4 = call noundef i32 @_Z17ImTextStrFromUtf8PtiPKcS1_PS1_(ptr noundef nonnull %3, i32 noundef 17, ptr noundef %1, ptr noundef null, ptr noundef null)
  %5 = load i16, ptr %3, align 16, !tbaa !5
  %.not = icmp eq i16 %5, 0
  br i1 %.not, label %.critedge, label %6

.critedge:                                        ; preds = %54, %51, %48, %45, %42, %39, %36, %33, %30, %27, %24, %21, %18, %15, %12, %9, %6, %2
  call void @llvm.lifetime.end.p0(i64 34, ptr nonnull %3) #3
  ret void

6:                                                ; preds = %2
  call void @_ZN7ImGuiIO17AddInputCharacterEt(ptr noundef nonnull align 8 dereferenceable(5400) %0, i16 noundef zeroext %5)
  %7 = getelementptr inbounds i8, ptr %3, i64 2
  %8 = load i16, ptr %7, align 2, !tbaa !5
  %.not.1 = icmp eq i16 %8, 0
  br i1 %.not.1, label %.critedge, label %9

9:                                                ; preds = %6
  call void @_ZN7ImGuiIO17AddInputCharacterEt(ptr noundef nonnull align 8 dereferenceable(5400) %0, i16 noundef zeroext %8)
  %10 = getelementptr inbounds i8, ptr %3, i64 4
  %11 = load i16, ptr %10, align 4, !tbaa !5
  %.not.2 = icmp eq i16 %11, 0
  br i1 %.not.2, label %.critedge, label %12

12:                                               ; preds = %9
  call void @_ZN7ImGuiIO17AddInputCharacterEt(ptr noundef nonnull align 8 dereferenceable(5400) %0, i16 noundef zeroext %11)
  %13 = getelementptr inbounds i8, ptr %3, i64 6
  %14 = load i16, ptr %13, align 2, !tbaa !5
  %.not.3 = icmp eq i16 %14, 0
  br i1 %.not.3, label %.critedge, label %15

15:                                               ; preds = %12
  call void @_ZN7ImGuiIO17AddInputCharacterEt(ptr noundef nonnull align 8 dereferenceable(5400) %0, i16 noundef zeroext %14)
  %16 = getelementptr inbounds i8, ptr %3, i64 8
  %17 = load i16, ptr %16, align 8, !tbaa !5
  %.not.4 = icmp eq i16 %17, 0
  br i1 %.not.4, label %.critedge, label %18

18:                                               ; preds = %15
  call void @_ZN7ImGuiIO17AddInputCharacterEt(ptr noundef nonnull align 8 dereferenceable(5400) %0, i16 noundef zeroext %17)
  %19 = getelementptr inbounds i8, ptr %3, i64 10
  %20 = load i16, ptr %19, align 2, !tbaa !5
  %.not.5 = icmp eq i16 %20, 0
  br i1 %.not.5, label %.critedge, label %21

21:                                               ; preds = %18
  call void @_ZN7ImGuiIO17AddInputCharacterEt(ptr noundef nonnull align 8 dereferenceable(5400) %0, i16 noundef zeroext %20)
  %22 = getelementptr inbounds i8, ptr %3, i64 12
  %23 = load i16, ptr %22, align 4, !tbaa !5
  %.not.6 = icmp eq i16 %23, 0
  br i1 %.not.6, label %.critedge, label %24

24:                                               ; preds = %21
  call void @_ZN7ImGuiIO17AddInputCharacterEt(ptr noundef nonnull align 8 dereferenceable(5400) %0, i16 noundef zeroext %23)
  %25 = getelementptr inbounds i8, ptr %3, i64 14
  %26 = load i16, ptr %25, align 2, !tbaa !5
  %.not.7 = icmp eq i16 %26, 0
  br i1 %.not.7, label %.critedge, label %27

27:                                               ; preds = %24
  call void @_ZN7ImGuiIO17AddInputCharacterEt(ptr noundef nonnull align 8 dereferenceable(5400) %0, i16 noundef zeroext %26)
  %28 = getelementptr inbounds i8, ptr %3, i64 16
  %29 = load i16, ptr %28, align 16, !tbaa !5
  %.not.8 = icmp eq i16 %29, 0
  br i1 %.not.8, label %.critedge, label %30

30:                                               ; preds = %27
  call void @_ZN7ImGuiIO17AddInputCharacterEt(ptr noundef nonnull align 8 dereferenceable(5400) %0, i16 noundef zeroext %29)
  %31 = getelementptr inbounds i8, ptr %3, i64 18
  %32 = load i16, ptr %31, align 2, !tbaa !5
  %.not.9 = icmp eq i16 %32, 0
  br i1 %.not.9, label %.critedge, label %33

33:                                               ; preds = %30
  call void @_ZN7ImGuiIO17AddInputCharacterEt(ptr noundef nonnull align 8 dereferenceable(5400) %0, i16 noundef zeroext %32)
  %34 = getelementptr inbounds i8, ptr %3, i64 20
  %35 = load i16, ptr %34, align 4, !tbaa !5
  %.not.10 = icmp eq i16 %35, 0
  br i1 %.not.10, label %.critedge, label %36

36:                                               ; preds = %33
  call void @_ZN7ImGuiIO17AddInputCharacterEt(ptr noundef nonnull align 8 dereferenceable(5400) %0, i16 noundef zeroext %35)
  %37 = getelementptr inbounds i8, ptr %3, i64 22
  %38 = load i16, ptr %37, align 2, !tbaa !5
  %.not.11 = icmp eq i16 %38, 0
  br i1 %.not.11, label %.critedge, label %39

39:                                               ; preds = %36
  call void @_ZN7ImGuiIO17AddInputCharacterEt(ptr noundef nonnull align 8 dereferenceable(5400) %0, i16 noundef zeroext %38)
  %40 = getelementptr inbounds i8, ptr %3, i64 24
  %41 = load i16, ptr %40, align 8, !tbaa !5
  %.not.12 = icmp eq i16 %41, 0
  br i1 %.not.12, label %.critedge, label %42

42:                                               ; preds = %39
  call void @_ZN7ImGuiIO17AddInputCharacterEt(ptr noundef nonnull align 8 dereferenceable(5400) %0, i16 noundef zeroext %41)
  %43 = getelementptr inbounds i8, ptr %3, i64 26
  %44 = load i16, ptr %43, align 2, !tbaa !5
  %.not.13 = icmp eq i16 %44, 0
  br i1 %.not.13, label %.critedge, label %45

45:                                               ; preds = %42
  call void @_ZN7ImGuiIO17AddInputCharacterEt(ptr noundef nonnull align 8 dereferenceable(5400) %0, i16 noundef zeroext %44)
  %46 = getelementptr inbounds i8, ptr %3, i64 28
  %47 = load i16, ptr %46, align 4, !tbaa !5
  %.not.14 = icmp eq i16 %47, 0
  br i1 %.not.14, label %.critedge, label %48

48:                                               ; preds = %45
  call void @_ZN7ImGuiIO17AddInputCharacterEt(ptr noundef nonnull align 8 dereferenceable(5400) %0, i16 noundef zeroext %47)
  %49 = getelementptr inbounds i8, ptr %3, i64 30
  %50 = load i16, ptr %49, align 2, !tbaa !5
  %.not.15 = icmp eq i16 %50, 0
  br i1 %.not.15, label %.critedge, label %51

51:                                               ; preds = %48
  call void @_ZN7ImGuiIO17AddInputCharacterEt(ptr noundef nonnull align 8 dereferenceable(5400) %0, i16 noundef zeroext %50)
  %52 = getelementptr inbounds i8, ptr %3, i64 32
  %53 = load i16, ptr %52, align 16, !tbaa !5
  %.not.16 = icmp eq i16 %53, 0
  br i1 %.not.16, label %.critedge, label %54

54:                                               ; preds = %51
  call void @_ZN7ImGuiIO17AddInputCharacterEt(ptr noundef nonnull align 8 dereferenceable(5400) %0, i16 noundef zeroext %53)
  br label %.critedge
}

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef i32 @_Z17ImTextStrFromUtf8PtiPKcS1_PS1_(ptr noundef, i32 noundef, ptr noundef, ptr noundef, ptr noundef) local_unnamed_addr #2

attributes #0 = { mustprogress 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 = { 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 #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 = !{!"short", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}


; Effective O3 passes: EarlyCSEPass,GVNPass,GlobalOptPass,IndVarSimplifyPass,InferAlignmentPass,InferFunctionAttrsPass,InstCombinePass,LoopRotatePass,SROAPass,SimplifyCFGPass