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

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

; Function Attrs: nounwind uwtable
define dso_local void @nk_textedit_delete_selection(ptr noundef %0) #0 {
  %2 = alloca ptr, align 8
  store ptr %0, ptr %2, align 8, !tbaa !5
  %3 = load ptr, ptr %2, align 8, !tbaa !5
  call void @nk_textedit_clamp(ptr noundef %3)
  %4 = load ptr, ptr %2, align 8, !tbaa !5
  %5 = getelementptr inbounds %struct.nk_text_edit, ptr %4, i32 0, i32 5
  %6 = load i32, ptr %5, align 4, !tbaa !9
  %7 = load ptr, ptr %2, align 8, !tbaa !5
  %8 = getelementptr inbounds %struct.nk_text_edit, ptr %7, i32 0, i32 6
  %9 = load i32, ptr %8, align 8, !tbaa !22
  %10 = icmp ne i32 %6, %9
  br i1 %10, label %11, label %60

11:                                               ; preds = %1
  %12 = load ptr, ptr %2, align 8, !tbaa !5
  %13 = getelementptr inbounds %struct.nk_text_edit, ptr %12, i32 0, i32 5
  %14 = load i32, ptr %13, align 4, !tbaa !9
  %15 = load ptr, ptr %2, align 8, !tbaa !5
  %16 = getelementptr inbounds %struct.nk_text_edit, ptr %15, i32 0, i32 6
  %17 = load i32, ptr %16, align 8, !tbaa !22
  %18 = icmp slt i32 %14, %17
  br i1 %18, label %19, label %38

19:                                               ; preds = %11
  %20 = load ptr, ptr %2, align 8, !tbaa !5
  %21 = load ptr, ptr %2, align 8, !tbaa !5
  %22 = getelementptr inbounds %struct.nk_text_edit, ptr %21, i32 0, i32 5
  %23 = load i32, ptr %22, align 4, !tbaa !9
  %24 = load ptr, ptr %2, align 8, !tbaa !5
  %25 = getelementptr inbounds %struct.nk_text_edit, ptr %24, i32 0, i32 6
  %26 = load i32, ptr %25, align 8, !tbaa !22
  %27 = load ptr, ptr %2, align 8, !tbaa !5
  %28 = getelementptr inbounds %struct.nk_text_edit, ptr %27, i32 0, i32 5
  %29 = load i32, ptr %28, align 4, !tbaa !9
  %30 = sub nsw i32 %26, %29
  call void @nk_textedit_delete(ptr noundef %20, i32 noundef %23, i32 noundef %30)
  %31 = load ptr, ptr %2, align 8, !tbaa !5
  %32 = getelementptr inbounds %struct.nk_text_edit, ptr %31, i32 0, i32 5
  %33 = load i32, ptr %32, align 4, !tbaa !9
  %34 = load ptr, ptr %2, align 8, !tbaa !5
  %35 = getelementptr inbounds %struct.nk_text_edit, ptr %34, i32 0, i32 4
  store i32 %33, ptr %35, align 8, !tbaa !23
  %36 = load ptr, ptr %2, align 8, !tbaa !5
  %37 = getelementptr inbounds %struct.nk_text_edit, ptr %36, i32 0, i32 6
  store i32 %33, ptr %37, align 8, !tbaa !22
  br label %57

38:                                               ; preds = %11
  %39 = load ptr, ptr %2, align 8, !tbaa !5
  %40 = load ptr, ptr %2, align 8, !tbaa !5
  %41 = getelementptr inbounds %struct.nk_text_edit, ptr %40, i32 0, i32 6
  %42 = load i32, ptr %41, align 8, !tbaa !22
  %43 = load ptr, ptr %2, align 8, !tbaa !5
  %44 = getelementptr inbounds %struct.nk_text_edit, ptr %43, i32 0, i32 5
  %45 = load i32, ptr %44, align 4, !tbaa !9
  %46 = load ptr, ptr %2, align 8, !tbaa !5
  %47 = getelementptr inbounds %struct.nk_text_edit, ptr %46, i32 0, i32 6
  %48 = load i32, ptr %47, align 8, !tbaa !22
  %49 = sub nsw i32 %45, %48
  call void @nk_textedit_delete(ptr noundef %39, i32 noundef %42, i32 noundef %49)
  %50 = load ptr, ptr %2, align 8, !tbaa !5
  %51 = getelementptr inbounds %struct.nk_text_edit, ptr %50, i32 0, i32 6
  %52 = load i32, ptr %51, align 8, !tbaa !22
  %53 = load ptr, ptr %2, align 8, !tbaa !5
  %54 = getelementptr inbounds %struct.nk_text_edit, ptr %53, i32 0, i32 4
  store i32 %52, ptr %54, align 8, !tbaa !23
  %55 = load ptr, ptr %2, align 8, !tbaa !5
  %56 = getelementptr inbounds %struct.nk_text_edit, ptr %55, i32 0, i32 5
  store i32 %52, ptr %56, align 4, !tbaa !9
  br label %57

57:                                               ; preds = %38, %19
  %58 = load ptr, ptr %2, align 8, !tbaa !5
  %59 = getelementptr inbounds %struct.nk_text_edit, ptr %58, i32 0, i32 10
  store i8 0, ptr %59, align 1, !tbaa !24
  br label %60

60:                                               ; preds = %57, %1
  ret void
}

; Function Attrs: nounwind uwtable
declare hidden void @nk_textedit_clamp(ptr noundef) #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, !6, i64 0}
!6 = !{!"any pointer", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !15, i64 172}
!10 = !{!"nk_text_edit", !11, i64 0, !12, i64 24, !6, i64 152, !19, i64 160, !15, i64 168, !15, i64 172, !15, i64 176, !7, i64 180, !7, i64 181, !7, i64 182, !7, i64 183, !7, i64 184, !7, i64 185, !7, i64 186, !18, i64 188, !20, i64 192}
!11 = !{!"nk_clipboard", !7, i64 0, !6, i64 8, !6, i64 16}
!12 = !{!"nk_str", !13, i64 0, !15, i64 120}
!13 = !{!"nk_buffer", !7, i64 0, !14, i64 32, !15, i64 56, !16, i64 64, !18, i64 80, !17, i64 88, !17, i64 96, !17, i64 104, !17, i64 112}
!14 = !{!"nk_allocator", !7, i64 0, !6, i64 8, !6, i64 16}
!15 = !{!"int", !7, i64 0}
!16 = !{!"nk_memory", !6, i64 0, !17, i64 8}
!17 = !{!"long", !7, i64 0}
!18 = !{!"float", !7, i64 0}
!19 = !{!"nk_vec2", !18, i64 0, !18, i64 4}
!20 = !{!"nk_text_undo_state", !7, i64 0, !7, i64 1188, !21, i64 5184, !21, i64 5186, !21, i64 5188, !21, i64 5190}
!21 = !{!"short", !7, i64 0}
!22 = !{!10, !15, i64 176}
!23 = !{!10, !15, i64 168}
!24 = !{!10, !7, i64 183}


; 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: nounwind uwtable
declare dso_local void @nk_textedit_delete(ptr noundef, i32 noundef, i32 noundef) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
define dso_local void @nk_textedit_delete_selection(ptr noundef %0) local_unnamed_addr #0 {
  tail call void @nk_textedit_clamp(ptr noundef %0)
  %2 = getelementptr inbounds i8, ptr %0, i64 172
  %3 = load i32, ptr %2, align 4, !tbaa !5
  %4 = getelementptr inbounds i8, ptr %0, i64 176
  %5 = load i32, ptr %4, align 8, !tbaa !21
  %.not = icmp eq i32 %3, %5
  br i1 %.not, label %17, label %6

6:                                                ; preds = %1
  %7 = icmp slt i32 %3, %5
  br i1 %7, label %8, label %11

8:                                                ; preds = %6
  %9 = sub nsw i32 %5, %3
  tail call void @nk_textedit_delete(ptr noundef nonnull %0, i32 noundef %3, i32 noundef %9)
  %10 = load i32, ptr %2, align 4, !tbaa !5
  store i32 %10, ptr %4, align 8, !tbaa !21
  br label %14

11:                                               ; preds = %6
  %12 = sub nsw i32 %3, %5
  tail call void @nk_textedit_delete(ptr noundef nonnull %0, i32 noundef %5, i32 noundef %12)
  %13 = load i32, ptr %4, align 8, !tbaa !21
  store i32 %13, ptr %2, align 4, !tbaa !5
  br label %14

14:                                               ; preds = %11, %8
  %.sink = phi i32 [ %10, %8 ], [ %13, %11 ]
  %15 = getelementptr inbounds i8, ptr %0, i64 168
  store i32 %.sink, ptr %15, align 8
  %16 = getelementptr inbounds i8, ptr %0, i64 183
  store i8 0, ptr %16, align 1, !tbaa !22
  br label %17

17:                                               ; preds = %14, %1
  ret void
}

; Function Attrs: nounwind uwtable
declare hidden void @nk_textedit_clamp(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, !14, i64 172}
!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 = !{!6, !14, i64 176}
!22 = !{!6, !8, i64 183}


; Effective O3 passes: CorrelatedValuePropagationPass,EarlyCSEPass,GlobalOptPass,InstCombinePass,MergedLoadStoreMotionPass,SROAPass,TailCallElimPass