; LLVM IR from unitreerobotics/kinect_teleoperate :: src/extern/glfw/src/tests (gamma)

; 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.2 = external hidden unnamed_addr constant [103 x i8], align 1
@.str.22 = external hidden unnamed_addr constant [5 x i8], align 1
@.str.126 = 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: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.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: nounwind uwtable
declare dso_local i32 @nk_utf_decode(ptr noundef, ptr noundef, i32 noundef) #2

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

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

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

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

; Function Attrs: nounwind 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 %15

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

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

18:                                               ; preds = %15
  br label %20

19:                                               ; preds = %15
  call void @__assert_fail(ptr noundef @.str.22, ptr noundef @.str.2, i32 noundef 22054, ptr noundef @__PRETTY_FUNCTION__.nk_textedit_text) #4
  unreachable

20:                                               ; preds = %18
  %21 = load ptr, ptr %5, align 8, !tbaa !5
  %22 = icmp ne ptr %21, null
  br i1 %22, label %23, label %32

23:                                               ; preds = %20
  %24 = load i32, ptr %6, align 4, !tbaa !9
  %25 = icmp ne i32 %24, 0
  br i1 %25, label %26, label %32

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

32:                                               ; preds = %26, %23, %20
  store i32 1, ptr %10, align 4
  br label %166

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

37:                                               ; preds = %153, %33
  %38 = load i32, ptr %9, align 4, !tbaa !9
  %39 = load i32, ptr %6, align 4, !tbaa !9
  %40 = icmp slt i32 %38, %39
  br i1 %40, label %41, label %44

41:                                               ; preds = %37
  %42 = load i32, ptr %8, align 4, !tbaa !9
  %43 = icmp ne i32 %42, 0
  br label %44

44:                                               ; preds = %41, %37
  %45 = phi i1 [ false, %37 ], [ %43, %41 ]
  br i1 %45, label %46, label %165

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

49:                                               ; preds = %46
  br label %153

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

53:                                               ; preds = %50
  %54 = load ptr, ptr %4, align 8, !tbaa !5
  %55 = getelementptr inbounds %struct.nk_text_edit, ptr %54, i32 0, i32 11
  %56 = load i8, ptr %55, align 8, !tbaa !23
  %57 = zext i8 %56 to i32
  %58 = icmp ne i32 %57, 0
  br i1 %58, label %59, label %60

59:                                               ; preds = %53
  br label %153

60:                                               ; preds = %53, %50
  %61 = load ptr, ptr %4, align 8, !tbaa !5
  %62 = getelementptr inbounds %struct.nk_text_edit, ptr %61, i32 0, i32 2
  %63 = load ptr, ptr %62, align 8, !tbaa !24
  %64 = icmp ne ptr %63, null
  br i1 %64, label %65, label %74

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

73:                                               ; preds = %65
  br label %153

74:                                               ; preds = %65, %60
  %75 = load ptr, ptr %4, align 8, !tbaa !5
  %76 = getelementptr inbounds %struct.nk_text_edit, ptr %75, i32 0, i32 5
  %77 = load i32, ptr %76, align 4, !tbaa !25
  %78 = load ptr, ptr %4, align 8, !tbaa !5
  %79 = getelementptr inbounds %struct.nk_text_edit, ptr %78, i32 0, i32 6
  %80 = load i32, ptr %79, align 8, !tbaa !26
  %81 = icmp ne i32 %77, %80
  br i1 %81, label %127, label %82

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

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

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

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

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

126:                                              ; preds = %119, %107
  br label %152

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

140:                                              ; preds = %127
  %141 = load ptr, ptr %4, align 8, !tbaa !5
  %142 = load ptr, ptr %4, align 8, !tbaa !5
  %143 = getelementptr inbounds %struct.nk_text_edit, ptr %142, i32 0, i32 4
  %144 = load i32, ptr %143, align 8, !tbaa !27
  call void @nk_textedit_makeundo_insert(ptr noundef %141, i32 noundef %144, i32 noundef 1)
  %145 = load ptr, ptr %4, align 8, !tbaa !5
  %146 = getelementptr inbounds %struct.nk_text_edit, ptr %145, i32 0, i32 4
  %147 = load i32, ptr %146, align 8, !tbaa !27
  %148 = add nsw i32 %147, 1
  store i32 %148, ptr %146, align 8, !tbaa !27
  %149 = load ptr, ptr %4, align 8, !tbaa !5
  %150 = getelementptr inbounds %struct.nk_text_edit, ptr %149, i32 0, i32 10
  store i8 0, ptr %150, align 1, !tbaa !29
  br label %151

151:                                              ; preds = %140, %127
  br label %152

152:                                              ; preds = %151, %126
  br label %153

153:                                              ; preds = %152, %73, %59, %49
  %154 = load i32, ptr %8, align 4, !tbaa !9
  %155 = load i32, ptr %9, align 4, !tbaa !9
  %156 = add nsw i32 %155, %154
  store i32 %156, ptr %9, align 4, !tbaa !9
  %157 = load ptr, ptr %5, align 8, !tbaa !5
  %158 = load i32, ptr %9, align 4, !tbaa !9
  %159 = sext i32 %158 to i64
  %160 = getelementptr inbounds i8, ptr %157, i64 %159
  %161 = load i32, ptr %6, align 4, !tbaa !9
  %162 = load i32, ptr %9, align 4, !tbaa !9
  %163 = sub nsw i32 %161, %162
  %164 = call i32 @nk_utf_decode(ptr noundef %160, ptr noundef %7, i32 noundef %163)
  store i32 %164, ptr %8, align 4, !tbaa !9
  br label %37, !llvm.loop !30

165:                                              ; preds = %44
  store i32 0, ptr %10, align 4
  br label %166

166:                                              ; preds = %165, %32
  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
  %167 = load i32, ptr %10, align 4
  switch i32 %167, label %169 [
    i32 0, label %168
    i32 1, label %168
  ]

168:                                              ; preds = %166, %166
  ret void

169:                                              ; preds = %166
  unreachable
}

; Function Attrs: nounwind uwtable
declare hidden void @nk_textedit_makeundo_replace(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 = { 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 }
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/C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"int", !7, i64 0}
!11 = !{!12, !7, i64 180}
!12 = !{!"nk_text_edit", !13, i64 0, !14, i64 24, !6, i64 152, !20, 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, !19, i64 188, !21, i64 192}
!13 = !{!"nk_clipboard", !7, i64 0, !6, i64 8, !6, i64 16}
!14 = !{!"nk_str", !15, i64 0, !10, i64 120}
!15 = !{!"nk_buffer", !7, i64 0, !16, i64 32, !10, i64 56, !17, i64 64, !19, i64 80, !18, i64 88, !18, i64 96, !18, i64 104, !18, i64 112}
!16 = !{!"nk_allocator", !7, i64 0, !6, i64 8, !6, i64 16}
!17 = !{!"nk_memory", !6, i64 0, !18, i64 8}
!18 = !{!"long", !7, i64 0}
!19 = !{!"float", !7, i64 0}
!20 = !{!"nk_vec2", !19, i64 0, !19, i64 4}
!21 = !{!"nk_text_undo_state", !7, i64 0, !7, i64 1188, !22, i64 5184, !22, i64 5186, !22, i64 5188, !22, i64 5190}
!22 = !{!"short", !7, i64 0}
!23 = !{!12, !7, i64 184}
!24 = !{!12, !6, i64 152}
!25 = !{!12, !10, i64 172}
!26 = !{!12, !10, i64 176}
!27 = !{!12, !10, i64 168}
!28 = !{!12, !10, i64 144}
!29 = !{!12, !7, i64 183}
!30 = distinct !{!30, !31}
!31 = !{!"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.2 = external hidden unnamed_addr constant [103 x i8], align 1
@.str.22 = external hidden unnamed_addr constant [5 x i8], align 1
@.str.126 = 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: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.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: nounwind uwtable
declare dso_local i32 @nk_utf_decode(ptr noundef, ptr noundef, i32 noundef) local_unnamed_addr #2

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

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

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

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

; Function Attrs: nounwind 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) #3
  %.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.126, ptr noundef nonnull @.str.2, i32 noundef 22053, ptr noundef nonnull @__PRETTY_FUNCTION__.nk_textedit_text) #4
  unreachable

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

7:                                                ; preds = %6
  tail call void @__assert_fail(ptr noundef nonnull @.str.22, ptr noundef nonnull @.str.2, i32 noundef 22054, ptr noundef nonnull @__PRETTY_FUNCTION__.nk_textedit_text) #4
  unreachable

8:                                                ; preds = %6
  %.not52 = icmp eq i32 %2, 0
  br i1 %.not52, 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, %60
  %.060 = phi i32 [ 0, %.lr.ph ], [ %61, %60 ]
  %.04459 = phi i32 [ %14, %.lr.ph ], [ %65, %60 ]
  %27 = load i32, ptr %4, align 4, !tbaa !21
  switch i32 %27, label %30 [
    i32 127, label %60
    i32 10, label %28
  ]

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

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

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

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

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

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 @nk_textedit_makeundo_replace(ptr noundef nonnull %0, i32 noundef %38, i32 noundef 1, i32 noundef 1)
  %45 = load i32, ptr %22, align 8, !tbaa !26
  call void @nk_str_delete_runes(ptr noundef nonnull %23, i32 noundef %45, i32 noundef 1)
  %.pre = load i32, ptr %22, align 8, !tbaa !26
  br label %46

46:                                               ; preds = %44, %41
  %47 = phi i32 [ %.pre, %44 ], [ %38, %41 ]
  %48 = sext i32 %.060 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)
  %.not57 = icmp eq i32 %50, 0
  br i1 %.not57, label %60, label %.sink.split

51:                                               ; preds = %37, %34
  call void @nk_textedit_delete_selection(ptr noundef nonnull %0)
  %52 = load i32, ptr %22, align 8, !tbaa !26
  %53 = sext i32 %.060 to i64
  %54 = getelementptr inbounds i8, ptr %1, i64 %53
  %55 = call i32 @nk_str_insert_text_utf8(ptr noundef nonnull %23, i32 noundef %52, ptr noundef nonnull %54, i32 noundef 1)
  %.not58 = icmp eq i32 %55, 0
  br i1 %.not58, label %60, label %56

56:                                               ; preds = %51
  %57 = load i32, ptr %22, align 8, !tbaa !26
  call void @nk_textedit_makeundo_insert(ptr noundef nonnull %0, i32 noundef %57, i32 noundef 1)
  br label %.sink.split

.sink.split:                                      ; preds = %46, %56
  %58 = load i32, ptr %22, align 8, !tbaa !26
  %59 = add nsw i32 %58, 1
  store i32 %59, ptr %22, align 8, !tbaa !26
  store i8 0, ptr %25, align 1, !tbaa !28
  br label %60

60:                                               ; preds = %.sink.split, %26, %46, %51, %32, %28
  %61 = add nsw i32 %.060, %.04459
  %62 = sext i32 %61 to i64
  %63 = getelementptr inbounds i8, ptr %1, i64 %62
  %64 = sub nsw i32 %2, %61
  %65 = call i32 @nk_utf_decode(ptr noundef nonnull %63, ptr noundef nonnull %4, i32 noundef %64)
  %66 = icmp slt i32 %61, %2
  %67 = icmp ne i32 %65, 0
  %68 = select i1 %66, i1 %67, i1 false
  br i1 %68, label %26, label %.loopexit, !llvm.loop !29

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

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

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 = { 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 }
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, !8, i64 180}
!6 = !{!"nk_text_edit", !7, i64 0, !11, i64 24, !10, i64 152, !18, i64 160, !14, i64 168, !14, i64 172, !14, 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, !19, i64 192}
!7 = !{!"nk_clipboard", !8, i64 0, !10, i64 8, !10, i64 16}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"any pointer", !8, i64 0}
!11 = !{!"nk_str", !12, i64 0, !14, i64 120}
!12 = !{!"nk_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 = !{!"nk_allocator", !8, i64 0, !10, i64 8, !10, i64 16}
!14 = !{!"int", !8, i64 0}
!15 = !{!"nk_memory", !10, i64 0, !16, i64 8}
!16 = !{!"long", !8, i64 0}
!17 = !{!"float", !8, i64 0}
!18 = !{!"nk_vec2", !17, i64 0, !17, i64 4}
!19 = !{!"nk_text_undo_state", !8, i64 0, !8, i64 1188, !20, i64 5184, !20, i64 5186, !20, i64 5188, !20, i64 5190}
!20 = !{!"short", !8, i64 0}
!21 = !{!14, !14, i64 0}
!22 = !{!6, !8, i64 184}
!23 = !{!6, !10, i64 152}
!24 = !{!6, !14, i64 172}
!25 = !{!6, !14, i64 176}
!26 = !{!6, !14, i64 168}
!27 = !{!6, !14, i64 144}
!28 = !{!6, !8, i64 183}
!29 = distinct !{!29, !30}
!30 = !{!"llvm.loop.mustprogress"}


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