; 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_undo_record = type { i32, i16, i16, i16 }
%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 }

; 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: nocallback nofree nounwind willreturn memory(argmem: readwrite)
declare void @llvm.memcpy.p0.p0.i64(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i64, i1 immarg) #1

; Function Attrs: nounwind uwtable
declare dso_local i32 @nk_str_insert_text_runes(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 i32 @nk_str_rune_at(ptr noundef, i32 noundef) #2

; Function Attrs: nounwind uwtable
define dso_local void @nk_textedit_undo(ptr noundef %0) #2 {
  %2 = alloca ptr, align 8
  %3 = alloca ptr, align 8
  %4 = alloca %struct.nk_text_undo_record, align 4
  %5 = alloca ptr, align 8
  %6 = alloca i32, align 4
  %7 = alloca i32, align 4
  store ptr %0, ptr %2, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %3) #3
  %8 = load ptr, ptr %2, align 8, !tbaa !5
  %9 = getelementptr inbounds %struct.nk_text_edit, ptr %8, i32 0, i32 15
  store ptr %9, ptr %3, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 12, ptr %4) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #3
  %10 = load ptr, ptr %3, align 8, !tbaa !5
  %11 = getelementptr inbounds %struct.nk_text_undo_state, ptr %10, i32 0, i32 2
  %12 = load i16, ptr %11, align 4, !tbaa !9
  %13 = sext i16 %12 to i32
  %14 = icmp eq i32 %13, 0
  br i1 %14, label %15, label %16

15:                                               ; preds = %1
  store i32 1, ptr %6, align 4
  br label %209

16:                                               ; preds = %1
  %17 = load ptr, ptr %3, align 8, !tbaa !5
  %18 = getelementptr inbounds %struct.nk_text_undo_state, ptr %17, i32 0, i32 0
  %19 = load ptr, ptr %3, align 8, !tbaa !5
  %20 = getelementptr inbounds %struct.nk_text_undo_state, ptr %19, i32 0, i32 2
  %21 = load i16, ptr %20, align 4, !tbaa !9
  %22 = sext i16 %21 to i32
  %23 = sub nsw i32 %22, 1
  %24 = sext i32 %23 to i64
  %25 = getelementptr inbounds [99 x %struct.nk_text_undo_record], ptr %18, i64 0, i64 %24
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %4, ptr align 4 %25, i64 12, i1 false), !tbaa.struct !12
  %26 = load ptr, ptr %3, align 8, !tbaa !5
  %27 = getelementptr inbounds %struct.nk_text_undo_state, ptr %26, i32 0, i32 0
  %28 = load ptr, ptr %3, align 8, !tbaa !5
  %29 = getelementptr inbounds %struct.nk_text_undo_state, ptr %28, i32 0, i32 3
  %30 = load i16, ptr %29, align 2, !tbaa !16
  %31 = sext i16 %30 to i32
  %32 = sub nsw i32 %31, 1
  %33 = sext i32 %32 to i64
  %34 = getelementptr inbounds [99 x %struct.nk_text_undo_record], ptr %27, i64 0, i64 %33
  store ptr %34, ptr %5, align 8, !tbaa !5
  %35 = load ptr, ptr %5, align 8, !tbaa !5
  %36 = getelementptr inbounds %struct.nk_text_undo_record, ptr %35, i32 0, i32 3
  store i16 -1, ptr %36, align 4, !tbaa !17
  %37 = getelementptr inbounds %struct.nk_text_undo_record, ptr %4, i32 0, i32 2
  %38 = load i16, ptr %37, align 2, !tbaa !19
  %39 = load ptr, ptr %5, align 8, !tbaa !5
  %40 = getelementptr inbounds %struct.nk_text_undo_record, ptr %39, i32 0, i32 1
  store i16 %38, ptr %40, align 4, !tbaa !20
  %41 = getelementptr inbounds %struct.nk_text_undo_record, ptr %4, i32 0, i32 1
  %42 = load i16, ptr %41, align 4, !tbaa !20
  %43 = load ptr, ptr %5, align 8, !tbaa !5
  %44 = getelementptr inbounds %struct.nk_text_undo_record, ptr %43, i32 0, i32 2
  store i16 %42, ptr %44, align 2, !tbaa !19
  %45 = getelementptr inbounds %struct.nk_text_undo_record, ptr %4, i32 0, i32 0
  %46 = load i32, ptr %45, align 4, !tbaa !21
  %47 = load ptr, ptr %5, align 8, !tbaa !5
  %48 = getelementptr inbounds %struct.nk_text_undo_record, ptr %47, i32 0, i32 0
  store i32 %46, ptr %48, align 4, !tbaa !21
  %49 = getelementptr inbounds %struct.nk_text_undo_record, ptr %4, i32 0, i32 2
  %50 = load i16, ptr %49, align 2, !tbaa !19
  %51 = icmp ne i16 %50, 0
  br i1 %51, label %52, label %160

52:                                               ; preds = %16
  %53 = load ptr, ptr %3, align 8, !tbaa !5
  %54 = getelementptr inbounds %struct.nk_text_undo_state, ptr %53, i32 0, i32 4
  %55 = load i16, ptr %54, align 4, !tbaa !22
  %56 = sext i16 %55 to i32
  %57 = getelementptr inbounds %struct.nk_text_undo_record, ptr %4, i32 0, i32 2
  %58 = load i16, ptr %57, align 2, !tbaa !19
  %59 = sext i16 %58 to i32
  %60 = add nsw i32 %56, %59
  %61 = icmp sge i32 %60, 999
  br i1 %61, label %62, label %65

62:                                               ; preds = %52
  %63 = load ptr, ptr %5, align 8, !tbaa !5
  %64 = getelementptr inbounds %struct.nk_text_undo_record, ptr %63, i32 0, i32 1
  store i16 0, ptr %64, align 4, !tbaa !20
  br label %152

65:                                               ; preds = %52
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #3
  br label %66

66:                                               ; preds = %88, %65
  %67 = load ptr, ptr %3, align 8, !tbaa !5
  %68 = getelementptr inbounds %struct.nk_text_undo_state, ptr %67, i32 0, i32 4
  %69 = load i16, ptr %68, align 4, !tbaa !22
  %70 = sext i16 %69 to i32
  %71 = getelementptr inbounds %struct.nk_text_undo_record, ptr %4, i32 0, i32 2
  %72 = load i16, ptr %71, align 2, !tbaa !19
  %73 = sext i16 %72 to i32
  %74 = add nsw i32 %70, %73
  %75 = load ptr, ptr %3, align 8, !tbaa !5
  %76 = getelementptr inbounds %struct.nk_text_undo_state, ptr %75, i32 0, i32 5
  %77 = load i16, ptr %76, align 2, !tbaa !23
  %78 = sext i16 %77 to i32
  %79 = icmp sgt i32 %74, %78
  br i1 %79, label %80, label %89

80:                                               ; preds = %66
  %81 = load ptr, ptr %3, align 8, !tbaa !5
  call void @nk_textedit_discard_redo(ptr noundef %81)
  %82 = load ptr, ptr %3, align 8, !tbaa !5
  %83 = getelementptr inbounds %struct.nk_text_undo_state, ptr %82, i32 0, i32 3
  %84 = load i16, ptr %83, align 2, !tbaa !16
  %85 = sext i16 %84 to i32
  %86 = icmp eq i32 %85, 99
  br i1 %86, label %87, label %88

87:                                               ; preds = %80
  store i32 1, ptr %6, align 4
  br label %149

88:                                               ; preds = %80
  br label %66, !llvm.loop !24

89:                                               ; preds = %66
  %90 = load ptr, ptr %3, align 8, !tbaa !5
  %91 = getelementptr inbounds %struct.nk_text_undo_state, ptr %90, i32 0, i32 0
  %92 = load ptr, ptr %3, align 8, !tbaa !5
  %93 = getelementptr inbounds %struct.nk_text_undo_state, ptr %92, i32 0, i32 3
  %94 = load i16, ptr %93, align 2, !tbaa !16
  %95 = sext i16 %94 to i32
  %96 = sub nsw i32 %95, 1
  %97 = sext i32 %96 to i64
  %98 = getelementptr inbounds [99 x %struct.nk_text_undo_record], ptr %91, i64 0, i64 %97
  store ptr %98, ptr %5, align 8, !tbaa !5
  %99 = load ptr, ptr %3, align 8, !tbaa !5
  %100 = getelementptr inbounds %struct.nk_text_undo_state, ptr %99, i32 0, i32 5
  %101 = load i16, ptr %100, align 2, !tbaa !23
  %102 = sext i16 %101 to i32
  %103 = getelementptr inbounds %struct.nk_text_undo_record, ptr %4, i32 0, i32 2
  %104 = load i16, ptr %103, align 2, !tbaa !19
  %105 = sext i16 %104 to i32
  %106 = sub nsw i32 %102, %105
  %107 = trunc i32 %106 to i16
  %108 = load ptr, ptr %5, align 8, !tbaa !5
  %109 = getelementptr inbounds %struct.nk_text_undo_record, ptr %108, i32 0, i32 3
  store i16 %107, ptr %109, align 4, !tbaa !17
  %110 = load ptr, ptr %3, align 8, !tbaa !5
  %111 = getelementptr inbounds %struct.nk_text_undo_state, ptr %110, i32 0, i32 5
  %112 = load i16, ptr %111, align 2, !tbaa !23
  %113 = sext i16 %112 to i32
  %114 = getelementptr inbounds %struct.nk_text_undo_record, ptr %4, i32 0, i32 2
  %115 = load i16, ptr %114, align 2, !tbaa !19
  %116 = sext i16 %115 to i32
  %117 = sub nsw i32 %113, %116
  %118 = trunc i32 %117 to i16
  %119 = load ptr, ptr %3, align 8, !tbaa !5
  %120 = getelementptr inbounds %struct.nk_text_undo_state, ptr %119, i32 0, i32 5
  store i16 %118, ptr %120, align 2, !tbaa !23
  store i32 0, ptr %7, align 4, !tbaa !13
  br label %121

121:                                              ; preds = %145, %89
  %122 = load i32, ptr %7, align 4, !tbaa !13
  %123 = getelementptr inbounds %struct.nk_text_undo_record, ptr %4, i32 0, i32 2
  %124 = load i16, ptr %123, align 2, !tbaa !19
  %125 = sext i16 %124 to i32
  %126 = icmp slt i32 %122, %125
  br i1 %126, label %127, label %148

127:                                              ; preds = %121
  %128 = load ptr, ptr %2, align 8, !tbaa !5
  %129 = getelementptr inbounds %struct.nk_text_edit, ptr %128, i32 0, i32 1
  %130 = getelementptr inbounds %struct.nk_text_undo_record, ptr %4, i32 0, i32 0
  %131 = load i32, ptr %130, align 4, !tbaa !21
  %132 = load i32, ptr %7, align 4, !tbaa !13
  %133 = add nsw i32 %131, %132
  %134 = call i32 @nk_str_rune_at(ptr noundef %129, i32 noundef %133)
  %135 = load ptr, ptr %3, align 8, !tbaa !5
  %136 = getelementptr inbounds %struct.nk_text_undo_state, ptr %135, i32 0, i32 1
  %137 = load ptr, ptr %5, align 8, !tbaa !5
  %138 = getelementptr inbounds %struct.nk_text_undo_record, ptr %137, i32 0, i32 3
  %139 = load i16, ptr %138, align 4, !tbaa !17
  %140 = sext i16 %139 to i32
  %141 = load i32, ptr %7, align 4, !tbaa !13
  %142 = add nsw i32 %140, %141
  %143 = sext i32 %142 to i64
  %144 = getelementptr inbounds [999 x i32], ptr %136, i64 0, i64 %143
  store i32 %134, ptr %144, align 4, !tbaa !13
  br label %145

145:                                              ; preds = %127
  %146 = load i32, ptr %7, align 4, !tbaa !13
  %147 = add nsw i32 %146, 1
  store i32 %147, ptr %7, align 4, !tbaa !13
  br label %121, !llvm.loop !26

148:                                              ; preds = %121
  store i32 0, ptr %6, align 4
  br label %149

149:                                              ; preds = %148, %87
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #3
  %150 = load i32, ptr %6, align 4
  switch i32 %150, label %209 [
    i32 0, label %151
  ]

151:                                              ; preds = %149
  br label %152

152:                                              ; preds = %151, %62
  %153 = load ptr, ptr %2, align 8, !tbaa !5
  %154 = getelementptr inbounds %struct.nk_text_edit, ptr %153, i32 0, i32 1
  %155 = getelementptr inbounds %struct.nk_text_undo_record, ptr %4, i32 0, i32 0
  %156 = load i32, ptr %155, align 4, !tbaa !21
  %157 = getelementptr inbounds %struct.nk_text_undo_record, ptr %4, i32 0, i32 2
  %158 = load i16, ptr %157, align 2, !tbaa !19
  %159 = sext i16 %158 to i32
  call void @nk_str_delete_runes(ptr noundef %154, i32 noundef %156, i32 noundef %159)
  br label %160

160:                                              ; preds = %152, %16
  %161 = getelementptr inbounds %struct.nk_text_undo_record, ptr %4, i32 0, i32 1
  %162 = load i16, ptr %161, align 4, !tbaa !20
  %163 = icmp ne i16 %162, 0
  br i1 %163, label %164, label %190

164:                                              ; preds = %160
  %165 = load ptr, ptr %2, align 8, !tbaa !5
  %166 = getelementptr inbounds %struct.nk_text_edit, ptr %165, i32 0, i32 1
  %167 = getelementptr inbounds %struct.nk_text_undo_record, ptr %4, i32 0, i32 0
  %168 = load i32, ptr %167, align 4, !tbaa !21
  %169 = load ptr, ptr %3, align 8, !tbaa !5
  %170 = getelementptr inbounds %struct.nk_text_undo_state, ptr %169, i32 0, i32 1
  %171 = getelementptr inbounds %struct.nk_text_undo_record, ptr %4, i32 0, i32 3
  %172 = load i16, ptr %171, align 4, !tbaa !17
  %173 = sext i16 %172 to i64
  %174 = getelementptr inbounds [999 x i32], ptr %170, i64 0, i64 %173
  %175 = getelementptr inbounds %struct.nk_text_undo_record, ptr %4, i32 0, i32 1
  %176 = load i16, ptr %175, align 4, !tbaa !20
  %177 = sext i16 %176 to i32
  %178 = call i32 @nk_str_insert_text_runes(ptr noundef %166, i32 noundef %168, ptr noundef %174, i32 noundef %177)
  %179 = load ptr, ptr %3, align 8, !tbaa !5
  %180 = getelementptr inbounds %struct.nk_text_undo_state, ptr %179, i32 0, i32 4
  %181 = load i16, ptr %180, align 4, !tbaa !22
  %182 = sext i16 %181 to i32
  %183 = getelementptr inbounds %struct.nk_text_undo_record, ptr %4, i32 0, i32 1
  %184 = load i16, ptr %183, align 4, !tbaa !20
  %185 = sext i16 %184 to i32
  %186 = sub nsw i32 %182, %185
  %187 = trunc i32 %186 to i16
  %188 = load ptr, ptr %3, align 8, !tbaa !5
  %189 = getelementptr inbounds %struct.nk_text_undo_state, ptr %188, i32 0, i32 4
  store i16 %187, ptr %189, align 4, !tbaa !22
  br label %190

190:                                              ; preds = %164, %160
  %191 = getelementptr inbounds %struct.nk_text_undo_record, ptr %4, i32 0, i32 0
  %192 = load i32, ptr %191, align 4, !tbaa !21
  %193 = getelementptr inbounds %struct.nk_text_undo_record, ptr %4, i32 0, i32 1
  %194 = load i16, ptr %193, align 4, !tbaa !20
  %195 = sext i16 %194 to i32
  %196 = add nsw i32 %192, %195
  %197 = trunc i32 %196 to i16
  %198 = sext i16 %197 to i32
  %199 = load ptr, ptr %2, align 8, !tbaa !5
  %200 = getelementptr inbounds %struct.nk_text_edit, ptr %199, i32 0, i32 4
  store i32 %198, ptr %200, align 8, !tbaa !27
  %201 = load ptr, ptr %3, align 8, !tbaa !5
  %202 = getelementptr inbounds %struct.nk_text_undo_state, ptr %201, i32 0, i32 2
  %203 = load i16, ptr %202, align 4, !tbaa !9
  %204 = add i16 %203, -1
  store i16 %204, ptr %202, align 4, !tbaa !9
  %205 = load ptr, ptr %3, align 8, !tbaa !5
  %206 = getelementptr inbounds %struct.nk_text_undo_state, ptr %205, i32 0, i32 3
  %207 = load i16, ptr %206, align 2, !tbaa !16
  %208 = add i16 %207, -1
  store i16 %208, ptr %206, align 2, !tbaa !16
  store i32 0, ptr %6, align 4
  br label %209

209:                                              ; preds = %190, %149, %15
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #3
  call void @llvm.lifetime.end.p0(i64 12, ptr %4) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %3) #3
  %210 = load i32, ptr %6, align 4
  switch i32 %210, label %212 [
    i32 0, label %211
    i32 1, label %211
  ]

211:                                              ; preds = %209, %209
  ret void

212:                                              ; preds = %209
  unreachable
}

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

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
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 }

!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, !11, i64 5184}
!10 = !{!"nk_text_undo_state", !7, i64 0, !7, i64 1188, !11, i64 5184, !11, i64 5186, !11, i64 5188, !11, i64 5190}
!11 = !{!"short", !7, i64 0}
!12 = !{i64 0, i64 4, !13, i64 4, i64 2, !15, i64 6, i64 2, !15, i64 8, i64 2, !15}
!13 = !{!14, !14, i64 0}
!14 = !{!"int", !7, i64 0}
!15 = !{!11, !11, i64 0}
!16 = !{!10, !11, i64 5186}
!17 = !{!18, !11, i64 8}
!18 = !{!"nk_text_undo_record", !14, i64 0, !11, i64 4, !11, i64 6, !11, i64 8}
!19 = !{!18, !11, i64 6}
!20 = !{!18, !11, i64 4}
!21 = !{!18, !14, i64 0}
!22 = !{!10, !11, i64 5188}
!23 = !{!10, !11, i64 5190}
!24 = distinct !{!24, !25}
!25 = !{!"llvm.loop.mustprogress"}
!26 = distinct !{!26, !25}
!27 = !{!28, !14, i64 168}
!28 = !{!"nk_text_edit", !29, i64 0, !30, i64 24, !6, i64 152, !36, i64 160, !14, i64 168, !14, i64 172, !14, i64 176, !7, i64 180, !7, i64 181, !7, i64 182, !7, i64 183, !7, i64 184, !7, i64 185, !7, i64 186, !35, i64 188, !10, i64 192}
!29 = !{!"nk_clipboard", !7, i64 0, !6, i64 8, !6, i64 16}
!30 = !{!"nk_str", !31, i64 0, !14, i64 120}
!31 = !{!"nk_buffer", !7, i64 0, !32, i64 32, !14, i64 56, !33, i64 64, !35, i64 80, !34, i64 88, !34, i64 96, !34, i64 104, !34, i64 112}
!32 = !{!"nk_allocator", !7, i64 0, !6, i64 8, !6, i64 16}
!33 = !{!"nk_memory", !6, i64 0, !34, i64 8}
!34 = !{!"long", !7, i64 0}
!35 = !{!"float", !7, i64 0}
!36 = !{!"nk_vec2", !35, i64 0, !35, i64 4}


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

%struct.nk_text_undo_record = type { i32, i16, i16, i16 }

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

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

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

; Function Attrs: nounwind uwtable
define dso_local void @nk_textedit_undo(ptr noundef %0) local_unnamed_addr #0 {
  %2 = getelementptr inbounds i8, ptr %0, i64 192
  %3 = getelementptr inbounds i8, ptr %0, i64 5376
  %4 = load i16, ptr %3, align 4, !tbaa !5
  %5 = icmp eq i16 %4, 0
  br i1 %5, label %.thread, label %6

6:                                                ; preds = %1
  %7 = sext i16 %4 to i64
  %8 = add nsw i64 %7, -1
  %9 = getelementptr inbounds [99 x %struct.nk_text_undo_record], ptr %2, i64 0, i64 %8
  %.sroa.0.0.copyload = load i32, ptr %9, align 4, !tbaa !10
  %.sroa.8.0..sroa_idx = getelementptr inbounds i8, ptr %9, i64 4
  %.sroa.8.0.copyload = load i16, ptr %.sroa.8.0..sroa_idx, align 4, !tbaa !12
  %.sroa.13.0..sroa_idx = getelementptr inbounds i8, ptr %9, i64 6
  %.sroa.13.0.copyload = load i16, ptr %.sroa.13.0..sroa_idx, align 2, !tbaa !12
  %.sroa.21.0..sroa_idx = getelementptr inbounds i8, ptr %9, i64 8
  %.sroa.21.0.copyload = load i16, ptr %.sroa.21.0..sroa_idx, align 4, !tbaa !12
  %10 = getelementptr inbounds i8, ptr %0, i64 5378
  %11 = load i16, ptr %10, align 2, !tbaa !13
  %12 = sext i16 %11 to i64
  %13 = add nsw i64 %12, -1
  %14 = getelementptr inbounds [99 x %struct.nk_text_undo_record], ptr %2, i64 0, i64 %13
  %15 = getelementptr inbounds i8, ptr %14, i64 8
  store i16 -1, ptr %15, align 4, !tbaa !14
  %16 = getelementptr inbounds i8, ptr %14, i64 4
  store i16 %.sroa.13.0.copyload, ptr %16, align 4, !tbaa !16
  %17 = getelementptr inbounds i8, ptr %14, i64 6
  store i16 %.sroa.8.0.copyload, ptr %17, align 2, !tbaa !17
  store i32 %.sroa.0.0.copyload, ptr %14, align 4, !tbaa !18
  %.not = icmp eq i16 %.sroa.13.0.copyload, 0
  br i1 %.not, label %57, label %18

18:                                               ; preds = %6
  %19 = getelementptr inbounds i8, ptr %0, i64 5380
  %20 = load i16, ptr %19, align 4, !tbaa !19
  %21 = sext i16 %20 to i32
  %22 = sext i16 %.sroa.13.0.copyload to i32
  %23 = add nsw i32 %21, %22
  %24 = icmp sgt i32 %23, 998
  br i1 %24, label %31, label %.preheader

.preheader:                                       ; preds = %18
  %25 = getelementptr inbounds i8, ptr %0, i64 5382
  %26 = load i16, ptr %19, align 4, !tbaa !19
  %27 = sext i16 %26 to i32
  %28 = add nsw i32 %27, %22
  %29 = load i16, ptr %25, align 2, !tbaa !20
  %30 = sext i16 %29 to i32
  %.not5568 = icmp sgt i32 %28, %30
  br i1 %.not5568, label %.lr.ph69, label %._crit_edge70

31:                                               ; preds = %18
  store i16 0, ptr %16, align 4, !tbaa !16
  br label %._crit_edge

32:                                               ; preds = %.lr.ph69
  %33 = load i16, ptr %19, align 4, !tbaa !19
  %34 = sext i16 %33 to i32
  %35 = add nsw i32 %34, %22
  %36 = load i16, ptr %25, align 2, !tbaa !20
  %37 = sext i16 %36 to i32
  %.not55 = icmp sgt i32 %35, %37
  br i1 %.not55, label %.lr.ph69, label %._crit_edge70, !llvm.loop !21

.lr.ph69:                                         ; preds = %.preheader, %32
  tail call void @nk_textedit_discard_redo(ptr noundef nonnull %2)
  %38 = load i16, ptr %10, align 2, !tbaa !13
  %39 = icmp eq i16 %38, 99
  br i1 %39, label %.thread, label %32, !llvm.loop !21

._crit_edge70:                                    ; preds = %32, %.preheader
  %.lcssa66 = phi i16 [ %11, %.preheader ], [ %38, %32 ]
  %.lcssa = phi i16 [ %29, %.preheader ], [ %36, %32 ]
  %40 = sext i16 %.lcssa66 to i64
  %41 = add nsw i64 %40, -1
  %42 = sub i16 %.lcssa, %.sroa.13.0.copyload
  %43 = getelementptr inbounds [99 x %struct.nk_text_undo_record], ptr %2, i64 0, i64 %41, i32 3
  store i16 %42, ptr %43, align 4, !tbaa !14
  store i16 %42, ptr %25, align 2, !tbaa !20
  %44 = icmp sgt i16 %.sroa.13.0.copyload, 0
  br i1 %44, label %.lr.ph, label %._crit_edge

.lr.ph:                                           ; preds = %._crit_edge70
  %45 = getelementptr inbounds i8, ptr %0, i64 24
  %46 = getelementptr inbounds i8, ptr %0, i64 1380
  br label %47

47:                                               ; preds = %.lr.ph, %47
  %.060 = phi i32 [ 0, %.lr.ph ], [ %55, %47 ]
  %48 = add nsw i32 %.060, %.sroa.0.0.copyload
  %49 = tail call i32 @nk_str_rune_at(ptr noundef nonnull %45, i32 noundef %48)
  %50 = load i16, ptr %43, align 4, !tbaa !14
  %51 = sext i16 %50 to i32
  %52 = add nsw i32 %.060, %51
  %53 = sext i32 %52 to i64
  %54 = getelementptr inbounds [999 x i32], ptr %46, i64 0, i64 %53
  store i32 %49, ptr %54, align 4, !tbaa !10
  %55 = add nuw nsw i32 %.060, 1
  %exitcond.not = icmp eq i32 %55, %22
  br i1 %exitcond.not, label %._crit_edge, label %47, !llvm.loop !23

._crit_edge:                                      ; preds = %47, %._crit_edge70, %31
  %56 = getelementptr inbounds i8, ptr %0, i64 24
  tail call void @nk_str_delete_runes(ptr noundef nonnull %56, i32 noundef %.sroa.0.0.copyload, i32 noundef %22)
  br label %57

57:                                               ; preds = %._crit_edge, %6
  %.not56 = icmp eq i16 %.sroa.8.0.copyload, 0
  br i1 %.not56, label %68, label %58

58:                                               ; preds = %57
  %59 = getelementptr inbounds i8, ptr %0, i64 24
  %60 = getelementptr inbounds i8, ptr %0, i64 1380
  %61 = sext i16 %.sroa.21.0.copyload to i64
  %62 = getelementptr inbounds [999 x i32], ptr %60, i64 0, i64 %61
  %63 = sext i16 %.sroa.8.0.copyload to i32
  %64 = tail call i32 @nk_str_insert_text_runes(ptr noundef nonnull %59, i32 noundef %.sroa.0.0.copyload, ptr noundef nonnull %62, i32 noundef %63)
  %65 = getelementptr inbounds i8, ptr %0, i64 5380
  %66 = load i16, ptr %65, align 4, !tbaa !19
  %67 = sub i16 %66, %.sroa.8.0.copyload
  store i16 %67, ptr %65, align 4, !tbaa !19
  br label %68

68:                                               ; preds = %58, %57
  %69 = trunc i32 %.sroa.0.0.copyload to i16
  %70 = add i16 %.sroa.8.0.copyload, %69
  %71 = sext i16 %70 to i32
  %72 = getelementptr inbounds i8, ptr %0, i64 168
  store i32 %71, ptr %72, align 8, !tbaa !24
  %73 = load <2 x i16>, ptr %3, align 4, !tbaa !12
  %74 = add <2 x i16> %73, <i16 -1, i16 -1>
  store <2 x i16> %74, ptr %3, align 4, !tbaa !12
  br label %.thread

.thread:                                          ; preds = %.lr.ph69, %1, %68
  ret void
}

; Function Attrs: nounwind uwtable
declare hidden void @nk_textedit_discard_redo(ptr noundef) local_unnamed_addr #0

attributes #0 = { 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" }

!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, !9, i64 5184}
!6 = !{!"nk_text_undo_state", !7, i64 0, !7, i64 1188, !9, i64 5184, !9, i64 5186, !9, i64 5188, !9, i64 5190}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!"short", !7, i64 0}
!10 = !{!11, !11, i64 0}
!11 = !{!"int", !7, i64 0}
!12 = !{!9, !9, i64 0}
!13 = !{!6, !9, i64 5186}
!14 = !{!15, !9, i64 8}
!15 = !{!"nk_text_undo_record", !11, i64 0, !9, i64 4, !9, i64 6, !9, i64 8}
!16 = !{!15, !9, i64 4}
!17 = !{!15, !9, i64 6}
!18 = !{!15, !11, i64 0}
!19 = !{!6, !9, i64 5188}
!20 = !{!6, !9, i64 5190}
!21 = distinct !{!21, !22}
!22 = !{!"llvm.loop.mustprogress"}
!23 = distinct !{!23, !22}
!24 = !{!25, !11, i64 168}
!25 = !{!"nk_text_edit", !26, i64 0, !28, i64 24, !27, i64 152, !34, i64 160, !11, i64 168, !11, i64 172, !11, i64 176, !7, i64 180, !7, i64 181, !7, i64 182, !7, i64 183, !7, i64 184, !7, i64 185, !7, i64 186, !33, i64 188, !6, i64 192}
!26 = !{!"nk_clipboard", !7, i64 0, !27, i64 8, !27, i64 16}
!27 = !{!"any pointer", !7, i64 0}
!28 = !{!"nk_str", !29, i64 0, !11, i64 120}
!29 = !{!"nk_buffer", !7, i64 0, !30, i64 32, !11, i64 56, !31, i64 64, !33, i64 80, !32, i64 88, !32, i64 96, !32, i64 104, !32, i64 112}
!30 = !{!"nk_allocator", !7, i64 0, !27, i64 8, !27, i64 16}
!31 = !{!"nk_memory", !27, i64 0, !32, i64 8}
!32 = !{!"long", !7, i64 0}
!33 = !{!"float", !7, i64 0}
!34 = !{!"nk_vec2", !33, i64 0, !33, i64 4}


; Effective O3 passes: ConstraintEliminationPass,EarlyCSEPass,GVNPass,GlobalOptPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,JumpThreadingPass,LCSSAPass,LICMPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,ReassociatePass,SLPVectorizerPass,SROAPass,SimplifyCFGPass,TailCallElimPass