; LLVM IR from ClementineAccount/Albuquerque :: src/HelloSDL (main)

; 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.nk_text_edit = type { %struct.nk_clipboard, %struct.nk_str, ptr, %struct.nk_vec2, i32, i32, i32, i8, i8, i8, i8, i8, i8, i8, float, %struct.nk_text_undo_state }
%struct.nk_clipboard = type { %union.nk_handle, ptr, ptr }
%union.nk_handle = type { ptr }
%struct.nk_str = type { %struct.nk_buffer, i32 }
%struct.nk_buffer = type { [2 x %struct.nk_buffer_marker], %struct.nk_allocator, i32, %struct.nk_memory, float, i64, i64, i64, i64 }
%struct.nk_buffer_marker = type { i32, i64 }
%struct.nk_allocator = type { %union.nk_handle, ptr, ptr }
%struct.nk_memory = type { ptr, i64 }
%struct.nk_vec2 = type { float, float }
%struct.nk_text_undo_state = type { [99 x %struct.nk_text_undo_record], [999 x i32], i16, i16, i16, i16 }
%struct.nk_text_undo_record = type { i32, i16, i16, i16 }

@.str.1 = external hidden unnamed_addr constant [86 x i8], align 1
@.str.21 = external hidden unnamed_addr constant [5 x i8], align 1
@.str.132 = external hidden unnamed_addr constant [6 x i8], align 1
@__PRETTY_FUNCTION__.nk_textedit_text = external hidden unnamed_addr constant [64 x i8], align 1

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

; Function Attrs: noreturn nounwind
declare void @__assert_fail(ptr noundef, ptr noundef, i32 noundef, ptr noundef) #1

; 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 i32 @nk_utf_decode(ptr noundef, ptr noundef, i32 noundef) #2

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

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

; Function Attrs: mustprogress uwtable
declare dso_local void @nk_textedit_delete_selection(ptr noundef) #2

; Function Attrs: mustprogress uwtable
declare hidden void @_ZL27nk_textedit_makeundo_insertP12nk_text_editii(ptr noundef, i32 noundef, i32 noundef) #2

; Function Attrs: mustprogress uwtable
define dso_local void @nk_textedit_text(ptr noundef %0, ptr noundef %1, i32 noundef %2) #2 {
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca i32, align 4
  %7 = alloca i32, align 4
  %8 = alloca i32, align 4
  %9 = alloca i32, align 4
  %10 = alloca i32, align 4
  store ptr %0, ptr %4, align 8, !tbaa !5
  store ptr %1, ptr %5, align 8, !tbaa !5
  store i32 %2, ptr %6, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #3
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #3
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #3
  store i32 0, ptr %9, align 4, !tbaa !9
  %11 = load ptr, ptr %4, align 8, !tbaa !5
  %12 = icmp ne ptr %11, null
  br i1 %12, label %13, label %14

13:                                               ; preds = %3
  br label %16

14:                                               ; preds = %3
  call void @__assert_fail(ptr noundef @.str.132, ptr noundef @.str.1, i32 noundef 26148, ptr noundef @__PRETTY_FUNCTION__.nk_textedit_text) #4
  unreachable

15:                                               ; No predecessors!
  br label %16

16:                                               ; preds = %15, %13
  %17 = load ptr, ptr %5, align 8, !tbaa !5
  %18 = icmp ne ptr %17, null
  br i1 %18, label %19, label %20

19:                                               ; preds = %16
  br label %22

20:                                               ; preds = %16
  call void @__assert_fail(ptr noundef @.str.21, ptr noundef @.str.1, i32 noundef 26149, ptr noundef @__PRETTY_FUNCTION__.nk_textedit_text) #4
  unreachable

21:                                               ; No predecessors!
  br label %22

22:                                               ; preds = %21, %19
  %23 = load ptr, ptr %5, align 8, !tbaa !5
  %24 = icmp ne ptr %23, null
  br i1 %24, label %25, label %34

25:                                               ; preds = %22
  %26 = load i32, ptr %6, align 4, !tbaa !9
  %27 = icmp ne i32 %26, 0
  br i1 %27, label %28, label %34

28:                                               ; preds = %25
  %29 = load ptr, ptr %4, align 8, !tbaa !5
  %30 = getelementptr inbounds %struct.nk_text_edit, ptr %29, i32 0, i32 7
  %31 = load i8, ptr %30, align 4, !tbaa !11
  %32 = zext i8 %31 to i32
  %33 = icmp eq i32 %32, 0
  br i1 %33, label %34, label %35

34:                                               ; preds = %28, %25, %22
  store i32 1, ptr %10, align 4
  br label %186

35:                                               ; preds = %28
  %36 = load ptr, ptr %5, align 8, !tbaa !5
  %37 = load i32, ptr %6, align 4, !tbaa !9
  %38 = call i32 @nk_utf_decode(ptr noundef %36, ptr noundef %7, i32 noundef %37)
  store i32 %38, ptr %8, align 4, !tbaa !9
  br label %39

39:                                               ; preds = %173, %35
  %40 = load i32, ptr %9, align 4, !tbaa !9
  %41 = load i32, ptr %6, align 4, !tbaa !9
  %42 = icmp slt i32 %40, %41
  br i1 %42, label %43, label %46

43:                                               ; preds = %39
  %44 = load i32, ptr %8, align 4, !tbaa !9
  %45 = icmp ne i32 %44, 0
  br label %46

46:                                               ; preds = %43, %39
  %47 = phi i1 [ false, %39 ], [ %45, %43 ]
  br i1 %47, label %48, label %185

48:                                               ; preds = %46
  %49 = load i32, ptr %7, align 4, !tbaa !9
  %50 = icmp eq i32 %49, 127
  br i1 %50, label %51, label %52

51:                                               ; preds = %48
  br label %173

52:                                               ; preds = %48
  %53 = load i32, ptr %7, align 4, !tbaa !9
  %54 = icmp eq i32 %53, 10
  br i1 %54, label %55, label %61

55:                                               ; preds = %52
  %56 = load ptr, ptr %4, align 8, !tbaa !5
  %57 = getelementptr inbounds %struct.nk_text_edit, ptr %56, i32 0, i32 11
  %58 = load i8, ptr %57, align 8, !tbaa !24
  %59 = icmp ne i8 %58, 0
  br i1 %59, label %60, label %61

60:                                               ; preds = %55
  br label %173

61:                                               ; preds = %55, %52
  %62 = load ptr, ptr %4, align 8, !tbaa !5
  %63 = getelementptr inbounds %struct.nk_text_edit, ptr %62, i32 0, i32 2
  %64 = load ptr, ptr %63, align 8, !tbaa !25
  %65 = icmp ne ptr %64, null
  br i1 %65, label %66, label %75

66:                                               ; preds = %61
  %67 = load ptr, ptr %4, align 8, !tbaa !5
  %68 = getelementptr inbounds %struct.nk_text_edit, ptr %67, i32 0, i32 2
  %69 = load ptr, ptr %68, align 8, !tbaa !25
  %70 = load ptr, ptr %4, align 8, !tbaa !5
  %71 = load i32, ptr %7, align 4, !tbaa !9
  %72 = call noundef i32 %69(ptr noundef %70, i32 noundef %71)
  %73 = icmp ne i32 %72, 0
  br i1 %73, label %75, label %74

74:                                               ; preds = %66
  br label %173

75:                                               ; preds = %66, %61
  %76 = load ptr, ptr %4, align 8, !tbaa !5
  %77 = getelementptr inbounds %struct.nk_text_edit, ptr %76, i32 0, i32 5
  %78 = load i32, ptr %77, align 4, !tbaa !26
  %79 = load ptr, ptr %4, align 8, !tbaa !5
  %80 = getelementptr inbounds %struct.nk_text_edit, ptr %79, i32 0, i32 6
  %81 = load i32, ptr %80, align 8, !tbaa !27
  %82 = icmp ne i32 %78, %81
  br i1 %82, label %128, label %83

83:                                               ; preds = %75
  %84 = load ptr, ptr %4, align 8, !tbaa !5
  %85 = getelementptr inbounds %struct.nk_text_edit, ptr %84, i32 0, i32 4
  %86 = load i32, ptr %85, align 8, !tbaa !28
  %87 = load ptr, ptr %4, align 8, !tbaa !5
  %88 = getelementptr inbounds %struct.nk_text_edit, ptr %87, i32 0, i32 1
  %89 = getelementptr inbounds %struct.nk_str, ptr %88, i32 0, i32 1
  %90 = load i32, ptr %89, align 8, !tbaa !29
  %91 = icmp slt i32 %86, %90
  br i1 %91, label %92, label %128

92:                                               ; preds = %83
  %93 = load ptr, ptr %4, align 8, !tbaa !5
  %94 = getelementptr inbounds %struct.nk_text_edit, ptr %93, i32 0, i32 7
  %95 = load i8, ptr %94, align 4, !tbaa !11
  %96 = zext i8 %95 to i32
  %97 = icmp eq i32 %96, 2
  br i1 %97, label %98, label %108

98:                                               ; preds = %92
  %99 = load ptr, ptr %4, align 8, !tbaa !5
  %100 = load ptr, ptr %4, align 8, !tbaa !5
  %101 = getelementptr inbounds %struct.nk_text_edit, ptr %100, i32 0, i32 4
  %102 = load i32, ptr %101, align 8, !tbaa !28
  call void @_ZL28nk_textedit_makeundo_replaceP12nk_text_editiii(ptr noundef %99, i32 noundef %102, i32 noundef 1, i32 noundef 1)
  %103 = load ptr, ptr %4, align 8, !tbaa !5
  %104 = getelementptr inbounds %struct.nk_text_edit, ptr %103, i32 0, i32 1
  %105 = load ptr, ptr %4, align 8, !tbaa !5
  %106 = getelementptr inbounds %struct.nk_text_edit, ptr %105, i32 0, i32 4
  %107 = load i32, ptr %106, align 8, !tbaa !28
  call void @nk_str_delete_runes(ptr noundef %104, i32 noundef %107, i32 noundef 1)
  br label %108

108:                                              ; preds = %98, %92
  %109 = load ptr, ptr %4, align 8, !tbaa !5
  %110 = getelementptr inbounds %struct.nk_text_edit, ptr %109, i32 0, i32 1
  %111 = load ptr, ptr %4, align 8, !tbaa !5
  %112 = getelementptr inbounds %struct.nk_text_edit, ptr %111, i32 0, i32 4
  %113 = load i32, ptr %112, align 8, !tbaa !28
  %114 = load ptr, ptr %5, align 8, !tbaa !5
  %115 = load i32, ptr %9, align 4, !tbaa !9
  %116 = sext i32 %115 to i64
  %117 = getelementptr inbounds i8, ptr %114, i64 %116
  %118 = call i32 @nk_str_insert_text_utf8(ptr noundef %110, i32 noundef %113, ptr noundef %117, i32 noundef 1)
  %119 = icmp ne i32 %118, 0
  br i1 %119, label %120, label %127

120:                                              ; preds = %108
  %121 = load ptr, ptr %4, align 8, !tbaa !5
  %122 = getelementptr inbounds %struct.nk_text_edit, ptr %121, i32 0, i32 4
  %123 = load i32, ptr %122, align 8, !tbaa !28
  %124 = add nsw i32 %123, 1
  store i32 %124, ptr %122, align 8, !tbaa !28
  %125 = load ptr, ptr %4, align 8, !tbaa !5
  %126 = getelementptr inbounds %struct.nk_text_edit, ptr %125, i32 0, i32 10
  store i8 0, ptr %126, align 1, !tbaa !30
  br label %127

127:                                              ; preds = %120, %108
  br label %172

128:                                              ; preds = %83, %75
  %129 = load ptr, ptr %4, align 8, !tbaa !5
  call void @nk_textedit_delete_selection(ptr noundef %129)
  %130 = load ptr, ptr %4, align 8, !tbaa !5
  %131 = getelementptr inbounds %struct.nk_text_edit, ptr %130, i32 0, i32 1
  %132 = load ptr, ptr %4, align 8, !tbaa !5
  %133 = getelementptr inbounds %struct.nk_text_edit, ptr %132, i32 0, i32 4
  %134 = load i32, ptr %133, align 8, !tbaa !28
  %135 = load ptr, ptr %5, align 8, !tbaa !5
  %136 = load i32, ptr %9, align 4, !tbaa !9
  %137 = sext i32 %136 to i64
  %138 = getelementptr inbounds i8, ptr %135, i64 %137
  %139 = call i32 @nk_str_insert_text_utf8(ptr noundef %131, i32 noundef %134, ptr noundef %138, i32 noundef 1)
  %140 = icmp ne i32 %139, 0
  br i1 %140, label %141, label %171

141:                                              ; preds = %128
  %142 = load ptr, ptr %4, align 8, !tbaa !5
  %143 = load ptr, ptr %4, align 8, !tbaa !5
  %144 = getelementptr inbounds %struct.nk_text_edit, ptr %143, i32 0, i32 4
  %145 = load i32, ptr %144, align 8, !tbaa !28
  call void @_ZL27nk_textedit_makeundo_insertP12nk_text_editii(ptr noundef %142, i32 noundef %145, i32 noundef 1)
  %146 = load ptr, ptr %4, align 8, !tbaa !5
  %147 = getelementptr inbounds %struct.nk_text_edit, ptr %146, i32 0, i32 4
  %148 = load i32, ptr %147, align 8, !tbaa !28
  %149 = add nsw i32 %148, 1
  %150 = load ptr, ptr %4, align 8, !tbaa !5
  %151 = getelementptr inbounds %struct.nk_text_edit, ptr %150, i32 0, i32 1
  %152 = getelementptr inbounds %struct.nk_str, ptr %151, i32 0, i32 1
  %153 = load i32, ptr %152, align 8, !tbaa !29
  %154 = icmp slt i32 %149, %153
  br i1 %154, label %155, label %160

155:                                              ; preds = %141
  %156 = load ptr, ptr %4, align 8, !tbaa !5
  %157 = getelementptr inbounds %struct.nk_text_edit, ptr %156, i32 0, i32 4
  %158 = load i32, ptr %157, align 8, !tbaa !28
  %159 = add nsw i32 %158, 1
  br label %165

160:                                              ; preds = %141
  %161 = load ptr, ptr %4, align 8, !tbaa !5
  %162 = getelementptr inbounds %struct.nk_text_edit, ptr %161, i32 0, i32 1
  %163 = getelementptr inbounds %struct.nk_str, ptr %162, i32 0, i32 1
  %164 = load i32, ptr %163, align 8, !tbaa !29
  br label %165

165:                                              ; preds = %160, %155
  %166 = phi i32 [ %159, %155 ], [ %164, %160 ]
  %167 = load ptr, ptr %4, align 8, !tbaa !5
  %168 = getelementptr inbounds %struct.nk_text_edit, ptr %167, i32 0, i32 4
  store i32 %166, ptr %168, align 8, !tbaa !28
  %169 = load ptr, ptr %4, align 8, !tbaa !5
  %170 = getelementptr inbounds %struct.nk_text_edit, ptr %169, i32 0, i32 10
  store i8 0, ptr %170, align 1, !tbaa !30
  br label %171

171:                                              ; preds = %165, %128
  br label %172

172:                                              ; preds = %171, %127
  br label %173

173:                                              ; preds = %172, %74, %60, %51
  %174 = load i32, ptr %8, align 4, !tbaa !9
  %175 = load i32, ptr %9, align 4, !tbaa !9
  %176 = add nsw i32 %175, %174
  store i32 %176, ptr %9, align 4, !tbaa !9
  %177 = load ptr, ptr %5, align 8, !tbaa !5
  %178 = load i32, ptr %9, align 4, !tbaa !9
  %179 = sext i32 %178 to i64
  %180 = getelementptr inbounds i8, ptr %177, i64 %179
  %181 = load i32, ptr %6, align 4, !tbaa !9
  %182 = load i32, ptr %9, align 4, !tbaa !9
  %183 = sub nsw i32 %181, %182
  %184 = call i32 @nk_utf_decode(ptr noundef %180, ptr noundef %7, i32 noundef %183)
  store i32 %184, ptr %8, align 4, !tbaa !9
  br label %39, !llvm.loop !31

185:                                              ; preds = %46
  store i32 0, ptr %10, align 4
  br label %186

186:                                              ; preds = %185, %34
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #3
  %187 = load i32, ptr %10, align 4
  switch i32 %187, label %189 [
    i32 0, label %188
    i32 1, label %188
  ]

188:                                              ; preds = %186, %186
  ret void

189:                                              ; preds = %186
  unreachable
}

; Function Attrs: mustprogress uwtable
declare hidden void @_ZL28nk_textedit_makeundo_replaceP12nk_text_editiii(ptr noundef, i32 noundef, i32 noundef, i32 noundef) #2

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { noreturn nounwind "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 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 }
attributes #4 = { noreturn 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, !7, i64 180}
!12 = !{!"_ZTS12nk_text_edit", !13, i64 0, !14, i64 24, !6, i64 152, !21, i64 160, !10, i64 168, !10, i64 172, !10, i64 176, !7, i64 180, !7, i64 181, !7, i64 182, !7, i64 183, !7, i64 184, !7, i64 185, !7, i64 186, !20, i64 188, !22, i64 192}
!13 = !{!"_ZTS12nk_clipboard", !7, i64 0, !6, i64 8, !6, i64 16}
!14 = !{!"_ZTS6nk_str", !15, i64 0, !10, i64 120}
!15 = !{!"_ZTS9nk_buffer", !7, i64 0, !16, i64 32, !17, i64 56, !18, i64 64, !20, i64 80, !19, i64 88, !19, i64 96, !19, i64 104, !19, i64 112}
!16 = !{!"_ZTS12nk_allocator", !7, i64 0, !6, i64 8, !6, i64 16}
!17 = !{!"_ZTS18nk_allocation_type", !7, i64 0}
!18 = !{!"_ZTS9nk_memory", !6, i64 0, !19, i64 8}
!19 = !{!"long", !7, i64 0}
!20 = !{!"float", !7, i64 0}
!21 = !{!"_ZTS7nk_vec2", !20, i64 0, !20, i64 4}
!22 = !{!"_ZTS18nk_text_undo_state", !7, i64 0, !7, i64 1188, !23, i64 5184, !23, i64 5186, !23, i64 5188, !23, i64 5190}
!23 = !{!"short", !7, i64 0}
!24 = !{!12, !7, i64 184}
!25 = !{!12, !6, i64 152}
!26 = !{!12, !10, i64 172}
!27 = !{!12, !10, i64 176}
!28 = !{!12, !10, i64 168}
!29 = !{!12, !10, i64 144}
!30 = !{!12, !7, i64 183}
!31 = distinct !{!31, !32}
!32 = !{!"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"

@.str.1 = external hidden unnamed_addr constant [86 x i8], align 1
@.str.21 = external hidden unnamed_addr constant [5 x i8], align 1
@.str.132 = external hidden unnamed_addr constant [6 x i8], align 1
@__PRETTY_FUNCTION__.nk_textedit_text = external hidden unnamed_addr constant [64 x i8], align 1

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

; Function Attrs: noreturn nounwind
declare void @__assert_fail(ptr noundef, ptr noundef, i32 noundef, ptr noundef) local_unnamed_addr #1

; 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 i32 @nk_utf_decode(ptr noundef, ptr noundef, i32 noundef) local_unnamed_addr #2

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

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

; Function Attrs: mustprogress uwtable
declare dso_local void @nk_textedit_delete_selection(ptr noundef) local_unnamed_addr #2

; Function Attrs: mustprogress uwtable
declare hidden void @_ZL27nk_textedit_makeundo_insertP12nk_text_editii(ptr noundef, i32 noundef, i32 noundef) local_unnamed_addr #2

; Function Attrs: mustprogress uwtable
define dso_local void @nk_textedit_text(ptr noundef %0, ptr noundef %1, i32 noundef %2) local_unnamed_addr #2 {
  %4 = alloca i32, align 4
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %4) #4
  %.not = icmp eq ptr %0, null
  br i1 %.not, label %5, label %6

5:                                                ; preds = %3
  tail call void @__assert_fail(ptr noundef nonnull @.str.132, ptr noundef nonnull @.str.1, i32 noundef 26148, ptr noundef nonnull @__PRETTY_FUNCTION__.nk_textedit_text) #5
  unreachable

6:                                                ; preds = %3
  %.not57 = icmp eq ptr %1, null
  br i1 %.not57, label %7, label %8

7:                                                ; preds = %6
  tail call void @__assert_fail(ptr noundef nonnull @.str.21, ptr noundef nonnull @.str.1, i32 noundef 26149, ptr noundef nonnull @__PRETTY_FUNCTION__.nk_textedit_text) #5
  unreachable

8:                                                ; preds = %6
  %.not58 = icmp eq i32 %2, 0
  br i1 %.not58, label %.loopexit, label %9

9:                                                ; preds = %8
  %10 = getelementptr inbounds i8, ptr %0, i64 180
  %11 = load i8, ptr %10, align 4, !tbaa !5
  %12 = icmp eq i8 %11, 0
  br i1 %12, label %.loopexit, label %13

13:                                               ; preds = %9
  %14 = call i32 @nk_utf_decode(ptr noundef nonnull %1, ptr noundef nonnull %4, i32 noundef %2)
  %15 = icmp sgt i32 %2, 0
  %16 = icmp ne i32 %14, 0
  %17 = select i1 %15, i1 %16, i1 false
  br i1 %17, label %.lr.ph, label %.loopexit

.lr.ph:                                           ; preds = %13
  %18 = getelementptr inbounds i8, ptr %0, i64 184
  %19 = getelementptr inbounds i8, ptr %0, i64 152
  %20 = getelementptr inbounds i8, ptr %0, i64 172
  %21 = getelementptr inbounds i8, ptr %0, i64 176
  %22 = getelementptr inbounds i8, ptr %0, i64 168
  %23 = getelementptr inbounds i8, ptr %0, i64 24
  %24 = getelementptr inbounds i8, ptr %0, i64 144
  %25 = getelementptr inbounds i8, ptr %0, i64 183
  br label %26

26:                                               ; preds = %.lr.ph, %64
  %.066 = phi i32 [ 0, %.lr.ph ], [ %65, %64 ]
  %.04865 = phi i32 [ %14, %.lr.ph ], [ %69, %64 ]
  %27 = load i32, ptr %4, align 4, !tbaa !22
  switch i32 %27, label %30 [
    i32 127, label %64
    i32 10, label %28
  ]

28:                                               ; preds = %26
  %29 = load i8, ptr %18, align 8, !tbaa !23
  %.not59 = icmp eq i8 %29, 0
  br i1 %.not59, label %30, label %64

30:                                               ; preds = %26, %28
  %31 = load ptr, ptr %19, align 8, !tbaa !24
  %.not60 = icmp eq ptr %31, null
  br i1 %.not60, label %34, label %32

32:                                               ; preds = %30
  %33 = call noundef i32 %31(ptr noundef nonnull %0, i32 noundef %27)
  %.not61 = icmp eq i32 %33, 0
  br i1 %.not61, label %64, label %34

34:                                               ; preds = %32, %30
  %35 = load i32, ptr %20, align 4, !tbaa !25
  %36 = load i32, ptr %21, align 8, !tbaa !26
  %.not62 = icmp eq i32 %35, %36
  br i1 %.not62, label %37, label %54

37:                                               ; preds = %34
  %38 = load i32, ptr %22, align 8, !tbaa !27
  %39 = load i32, ptr %24, align 8, !tbaa !28
  %40 = icmp slt i32 %38, %39
  br i1 %40, label %41, label %54

41:                                               ; preds = %37
  %42 = load i8, ptr %10, align 4, !tbaa !5
  %43 = icmp eq i8 %42, 2
  br i1 %43, label %44, label %46

44:                                               ; preds = %41
  call void @_ZL28nk_textedit_makeundo_replaceP12nk_text_editiii(ptr noundef nonnull %0, i32 noundef %38, i32 noundef 1, i32 noundef 1)
  %45 = load i32, ptr %22, align 8, !tbaa !27
  call void @nk_str_delete_runes(ptr noundef nonnull %23, i32 noundef %45, i32 noundef 1)
  %.pre = load i32, ptr %22, align 8, !tbaa !27
  br label %46

46:                                               ; preds = %44, %41
  %47 = phi i32 [ %.pre, %44 ], [ %38, %41 ]
  %48 = sext i32 %.066 to i64
  %49 = getelementptr inbounds i8, ptr %1, i64 %48
  %50 = call i32 @nk_str_insert_text_utf8(ptr noundef nonnull %23, i32 noundef %47, ptr noundef nonnull %49, i32 noundef 1)
  %.not63 = icmp eq i32 %50, 0
  br i1 %.not63, label %64, label %51

51:                                               ; preds = %46
  %52 = load i32, ptr %22, align 8, !tbaa !27
  %53 = add nsw i32 %52, 1
  br label %.sink.split

54:                                               ; preds = %37, %34
  call void @nk_textedit_delete_selection(ptr noundef nonnull %0)
  %55 = load i32, ptr %22, align 8, !tbaa !27
  %56 = sext i32 %.066 to i64
  %57 = getelementptr inbounds i8, ptr %1, i64 %56
  %58 = call i32 @nk_str_insert_text_utf8(ptr noundef nonnull %23, i32 noundef %55, ptr noundef nonnull %57, i32 noundef 1)
  %.not64 = icmp eq i32 %58, 0
  br i1 %.not64, label %64, label %59

59:                                               ; preds = %54
  %60 = load i32, ptr %22, align 8, !tbaa !27
  call void @_ZL27nk_textedit_makeundo_insertP12nk_text_editii(ptr noundef nonnull %0, i32 noundef %60, i32 noundef 1)
  %61 = load i32, ptr %22, align 8, !tbaa !27
  %62 = add nsw i32 %61, 1
  %63 = load i32, ptr %24, align 8, !tbaa !28
  %. = call i32 @llvm.smin.i32(i32 %62, i32 %63)
  br label %.sink.split

.sink.split:                                      ; preds = %59, %51
  %.sink = phi i32 [ %53, %51 ], [ %., %59 ]
  store i32 %.sink, ptr %22, align 8, !tbaa !27
  store i8 0, ptr %25, align 1, !tbaa !29
  br label %64

64:                                               ; preds = %.sink.split, %26, %46, %54, %32, %28
  %65 = add nsw i32 %.066, %.04865
  %66 = sext i32 %65 to i64
  %67 = getelementptr inbounds i8, ptr %1, i64 %66
  %68 = sub nsw i32 %2, %65
  %69 = call i32 @nk_utf_decode(ptr noundef nonnull %67, ptr noundef nonnull %4, i32 noundef %68)
  %70 = icmp slt i32 %65, %2
  %71 = icmp ne i32 %69, 0
  %72 = select i1 %70, i1 %71, i1 false
  br i1 %72, label %26, label %.loopexit, !llvm.loop !30

.loopexit:                                        ; preds = %64, %13, %8, %9
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %4) #4
  ret void
}

; Function Attrs: mustprogress uwtable
declare hidden void @_ZL28nk_textedit_makeundo_replaceP12nk_text_editiii(ptr noundef, i32 noundef, i32 noundef, i32 noundef) local_unnamed_addr #2

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare i32 @llvm.smin.i32(i32, i32) #3

attributes #0 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { noreturn nounwind "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 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 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #4 = { nounwind }
attributes #5 = { noreturn 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, !8, i64 180}
!6 = !{!"_ZTS12nk_text_edit", !7, i64 0, !11, i64 24, !10, i64 152, !19, i64 160, !18, i64 168, !18, i64 172, !18, i64 176, !8, i64 180, !8, i64 181, !8, i64 182, !8, i64 183, !8, i64 184, !8, i64 185, !8, i64 186, !17, i64 188, !20, i64 192}
!7 = !{!"_ZTS12nk_clipboard", !8, i64 0, !10, i64 8, !10, i64 16}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C++ TBAA"}
!10 = !{!"any pointer", !8, i64 0}
!11 = !{!"_ZTS6nk_str", !12, i64 0, !18, i64 120}
!12 = !{!"_ZTS9nk_buffer", !8, i64 0, !13, i64 32, !14, i64 56, !15, i64 64, !17, i64 80, !16, i64 88, !16, i64 96, !16, i64 104, !16, i64 112}
!13 = !{!"_ZTS12nk_allocator", !8, i64 0, !10, i64 8, !10, i64 16}
!14 = !{!"_ZTS18nk_allocation_type", !8, i64 0}
!15 = !{!"_ZTS9nk_memory", !10, i64 0, !16, i64 8}
!16 = !{!"long", !8, i64 0}
!17 = !{!"float", !8, i64 0}
!18 = !{!"int", !8, i64 0}
!19 = !{!"_ZTS7nk_vec2", !17, i64 0, !17, i64 4}
!20 = !{!"_ZTS18nk_text_undo_state", !8, i64 0, !8, i64 1188, !21, i64 5184, !21, i64 5186, !21, i64 5188, !21, i64 5190}
!21 = !{!"short", !8, i64 0}
!22 = !{!18, !18, i64 0}
!23 = !{!6, !8, i64 184}
!24 = !{!6, !10, i64 152}
!25 = !{!6, !18, i64 172}
!26 = !{!6, !18, i64 176}
!27 = !{!6, !18, i64 168}
!28 = !{!6, !18, i64 144}
!29 = !{!6, !8, i64 183}
!30 = distinct !{!30, !31}
!31 = !{!"llvm.loop.mustprogress"}


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