; 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_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 }
%union.nk_handle = type { ptr }
%struct.nk_memory = type { ptr, i64 }

@.str.2 = external hidden unnamed_addr constant [103 x i8], align 1
@.str.17 = external hidden unnamed_addr constant [2 x i8], align 1
@.str.23 = external hidden unnamed_addr constant [43 x i8], align 1
@__PRETTY_FUNCTION__.nk_str_delete_chars = external hidden unnamed_addr constant [52 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_len(ptr noundef, i32 noundef) #2

; Function Attrs: nounwind uwtable
declare hidden ptr @nk_memcopy(ptr noundef, ptr noundef, i64 noundef) #2

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

; Function Attrs: nounwind uwtable
define dso_local void @nk_str_delete_chars(ptr noundef %0, i32 noundef %1, i32 noundef %2) #2 {
  %4 = alloca ptr, align 8
  %5 = alloca i32, align 4
  %6 = alloca i32, align 4
  %7 = alloca ptr, align 8
  %8 = alloca ptr, align 8
  store ptr %0, ptr %4, align 8, !tbaa !5
  store i32 %1, ptr %5, align 4, !tbaa !9
  store i32 %2, ptr %6, align 4, !tbaa !9
  %9 = load ptr, ptr %4, align 8, !tbaa !5
  %10 = icmp ne ptr %9, null
  br i1 %10, label %11, label %12

11:                                               ; preds = %3
  br label %13

12:                                               ; preds = %3
  call void @__assert_fail(ptr noundef @.str.17, ptr noundef @.str.2, i32 noundef 8553, ptr noundef @__PRETTY_FUNCTION__.nk_str_delete_chars) #3
  unreachable

13:                                               ; preds = %11
  %14 = load ptr, ptr %4, align 8, !tbaa !5
  %15 = icmp ne ptr %14, null
  br i1 %15, label %16, label %37

16:                                               ; preds = %13
  %17 = load i32, ptr %6, align 4, !tbaa !9
  %18 = icmp ne i32 %17, 0
  br i1 %18, label %19, label %37

19:                                               ; preds = %16
  %20 = load i32, ptr %5, align 4, !tbaa !9
  %21 = sext i32 %20 to i64
  %22 = load ptr, ptr %4, align 8, !tbaa !5
  %23 = getelementptr inbounds %struct.nk_str, ptr %22, i32 0, i32 0
  %24 = getelementptr inbounds %struct.nk_buffer, ptr %23, i32 0, i32 5
  %25 = load i64, ptr %24, align 8, !tbaa !11
  %26 = icmp ugt i64 %21, %25
  br i1 %26, label %37, label %27

27:                                               ; preds = %19
  %28 = load i32, ptr %5, align 4, !tbaa !9
  %29 = load i32, ptr %6, align 4, !tbaa !9
  %30 = add nsw i32 %28, %29
  %31 = sext i32 %30 to i64
  %32 = load ptr, ptr %4, align 8, !tbaa !5
  %33 = getelementptr inbounds %struct.nk_str, ptr %32, i32 0, i32 0
  %34 = getelementptr inbounds %struct.nk_buffer, ptr %33, i32 0, i32 5
  %35 = load i64, ptr %34, align 8, !tbaa !11
  %36 = icmp ugt i64 %31, %35
  br i1 %36, label %37, label %38

37:                                               ; preds = %27, %19, %16, %13
  br label %114

38:                                               ; preds = %27
  %39 = load i32, ptr %5, align 4, !tbaa !9
  %40 = load i32, ptr %6, align 4, !tbaa !9
  %41 = add nsw i32 %39, %40
  %42 = sext i32 %41 to i64
  %43 = load ptr, ptr %4, align 8, !tbaa !5
  %44 = getelementptr inbounds %struct.nk_str, ptr %43, i32 0, i32 0
  %45 = getelementptr inbounds %struct.nk_buffer, ptr %44, i32 0, i32 5
  %46 = load i64, ptr %45, align 8, !tbaa !11
  %47 = icmp ult i64 %42, %46
  br i1 %47, label %48, label %97

48:                                               ; preds = %38
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #4
  %49 = load ptr, ptr %4, align 8, !tbaa !5
  %50 = getelementptr inbounds %struct.nk_str, ptr %49, i32 0, i32 0
  %51 = getelementptr inbounds %struct.nk_buffer, ptr %50, i32 0, i32 3
  %52 = getelementptr inbounds %struct.nk_memory, ptr %51, i32 0, i32 0
  %53 = load ptr, ptr %52, align 8, !tbaa !18
  %54 = load i32, ptr %5, align 4, !tbaa !9
  %55 = sext i32 %54 to i64
  %56 = getelementptr inbounds i8, ptr %53, i64 %55
  store ptr %56, ptr %7, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #4
  %57 = load ptr, ptr %4, align 8, !tbaa !5
  %58 = getelementptr inbounds %struct.nk_str, ptr %57, i32 0, i32 0
  %59 = getelementptr inbounds %struct.nk_buffer, ptr %58, i32 0, i32 3
  %60 = getelementptr inbounds %struct.nk_memory, ptr %59, i32 0, i32 0
  %61 = load ptr, ptr %60, align 8, !tbaa !18
  %62 = load i32, ptr %5, align 4, !tbaa !9
  %63 = load i32, ptr %6, align 4, !tbaa !9
  %64 = add nsw i32 %62, %63
  %65 = sext i32 %64 to i64
  %66 = getelementptr inbounds i8, ptr %61, i64 %65
  store ptr %66, ptr %8, align 8, !tbaa !5
  %67 = load ptr, ptr %7, align 8, !tbaa !5
  %68 = load ptr, ptr %8, align 8, !tbaa !5
  %69 = load ptr, ptr %4, align 8, !tbaa !5
  %70 = getelementptr inbounds %struct.nk_str, ptr %69, i32 0, i32 0
  %71 = getelementptr inbounds %struct.nk_buffer, ptr %70, i32 0, i32 5
  %72 = load i64, ptr %71, align 8, !tbaa !11
  %73 = load i32, ptr %5, align 4, !tbaa !9
  %74 = load i32, ptr %6, align 4, !tbaa !9
  %75 = add nsw i32 %73, %74
  %76 = sext i32 %75 to i64
  %77 = sub i64 %72, %76
  %78 = call ptr @nk_memcopy(ptr noundef %67, ptr noundef %68, i64 noundef %77)
  %79 = load ptr, ptr %4, align 8, !tbaa !5
  %80 = getelementptr inbounds %struct.nk_str, ptr %79, i32 0, i32 0
  %81 = getelementptr inbounds %struct.nk_buffer, ptr %80, i32 0, i32 5
  %82 = load i64, ptr %81, align 8, !tbaa !11
  %83 = trunc i64 %82 to i32
  %84 = load i32, ptr %6, align 4, !tbaa !9
  %85 = sub nsw i32 %83, %84
  %86 = icmp sge i32 %85, 0
  br i1 %86, label %87, label %88

87:                                               ; preds = %48
  br label %89

88:                                               ; preds = %48
  call void @__assert_fail(ptr noundef @.str.23, ptr noundef @.str.2, i32 noundef 8562, ptr noundef @__PRETTY_FUNCTION__.nk_str_delete_chars) #3
  unreachable

89:                                               ; preds = %87
  %90 = load i32, ptr %6, align 4, !tbaa !9
  %91 = sext i32 %90 to i64
  %92 = load ptr, ptr %4, align 8, !tbaa !5
  %93 = getelementptr inbounds %struct.nk_str, ptr %92, i32 0, i32 0
  %94 = getelementptr inbounds %struct.nk_buffer, ptr %93, i32 0, i32 5
  %95 = load i64, ptr %94, align 8, !tbaa !11
  %96 = sub i64 %95, %91
  store i64 %96, ptr %94, align 8, !tbaa !11
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #4
  br label %100

97:                                               ; preds = %38
  %98 = load ptr, ptr %4, align 8, !tbaa !5
  %99 = load i32, ptr %6, align 4, !tbaa !9
  call void @nk_str_remove_chars(ptr noundef %98, i32 noundef %99)
  br label %100

100:                                              ; preds = %97, %89
  %101 = load ptr, ptr %4, align 8, !tbaa !5
  %102 = getelementptr inbounds %struct.nk_str, ptr %101, i32 0, i32 0
  %103 = getelementptr inbounds %struct.nk_buffer, ptr %102, i32 0, i32 3
  %104 = getelementptr inbounds %struct.nk_memory, ptr %103, i32 0, i32 0
  %105 = load ptr, ptr %104, align 8, !tbaa !18
  %106 = load ptr, ptr %4, align 8, !tbaa !5
  %107 = getelementptr inbounds %struct.nk_str, ptr %106, i32 0, i32 0
  %108 = getelementptr inbounds %struct.nk_buffer, ptr %107, i32 0, i32 5
  %109 = load i64, ptr %108, align 8, !tbaa !11
  %110 = trunc i64 %109 to i32
  %111 = call i32 @nk_utf_len(ptr noundef %105, i32 noundef %110)
  %112 = load ptr, ptr %4, align 8, !tbaa !5
  %113 = getelementptr inbounds %struct.nk_str, ptr %112, i32 0, i32 1
  store i32 %111, ptr %113, align 8, !tbaa !19
  br label %114

114:                                              ; preds = %100, %37
  ret void
}

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 = { noreturn nounwind }
attributes #4 = { 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, !16, i64 88}
!12 = !{!"nk_str", !13, i64 0, !10, i64 120}
!13 = !{!"nk_buffer", !7, i64 0, !14, i64 32, !10, i64 56, !15, i64 64, !17, i64 80, !16, i64 88, !16, i64 96, !16, i64 104, !16, i64 112}
!14 = !{!"nk_allocator", !7, i64 0, !6, i64 8, !6, i64 16}
!15 = !{!"nk_memory", !6, i64 0, !16, i64 8}
!16 = !{!"long", !7, i64 0}
!17 = !{!"float", !7, i64 0}
!18 = !{!12, !6, i64 64}
!19 = !{!12, !10, i64 120}


; 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.17 = external hidden unnamed_addr constant [2 x i8], align 1
@.str.23 = external hidden unnamed_addr constant [43 x i8], align 1
@__PRETTY_FUNCTION__.nk_str_delete_chars = external hidden unnamed_addr constant [52 x i8], align 1

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

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

; Function Attrs: nounwind uwtable
declare hidden ptr @nk_memcopy(ptr noundef, ptr noundef, i64 noundef) local_unnamed_addr #1

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

; Function Attrs: nounwind uwtable
define dso_local void @nk_str_delete_chars(ptr noundef %0, i32 noundef %1, i32 noundef %2) local_unnamed_addr #1 {
  %.not = icmp eq ptr %0, null
  br i1 %.not, label %4, label %5

4:                                                ; preds = %3
  tail call void @__assert_fail(ptr noundef nonnull @.str.17, ptr noundef nonnull @.str.2, i32 noundef 8553, ptr noundef nonnull @__PRETTY_FUNCTION__.nk_str_delete_chars) #2
  unreachable

5:                                                ; preds = %3
  %.not34 = icmp eq i32 %2, 0
  br i1 %.not34, label %38, label %6

6:                                                ; preds = %5
  %7 = sext i32 %1 to i64
  %8 = getelementptr inbounds i8, ptr %0, i64 88
  %9 = load i64, ptr %8, align 8, !tbaa !5
  %10 = icmp ult i64 %9, %7
  br i1 %10, label %38, label %11

11:                                               ; preds = %6
  %12 = add nsw i32 %2, %1
  %13 = sext i32 %12 to i64
  %14 = icmp ult i64 %9, %13
  br i1 %14, label %38, label %15

15:                                               ; preds = %11
  %16 = icmp ugt i64 %9, %13
  br i1 %16, label %17, label %30

17:                                               ; preds = %15
  %18 = getelementptr inbounds i8, ptr %0, i64 64
  %19 = load ptr, ptr %18, align 8, !tbaa !16
  %20 = getelementptr inbounds i8, ptr %19, i64 %7
  %21 = getelementptr inbounds i8, ptr %19, i64 %13
  %22 = sub i64 %9, %13
  %23 = tail call ptr @nk_memcopy(ptr noundef %20, ptr noundef %21, i64 noundef %22)
  %24 = load i64, ptr %8, align 8, !tbaa !5
  %25 = trunc i64 %24 to i32
  %.not35 = icmp slt i32 %25, %2
  br i1 %.not35, label %26, label %27

26:                                               ; preds = %17
  tail call void @__assert_fail(ptr noundef nonnull @.str.23, ptr noundef nonnull @.str.2, i32 noundef 8562, ptr noundef nonnull @__PRETTY_FUNCTION__.nk_str_delete_chars) #2
  unreachable

27:                                               ; preds = %17
  %28 = sext i32 %2 to i64
  %29 = sub i64 %24, %28
  store i64 %29, ptr %8, align 8, !tbaa !5
  br label %31

30:                                               ; preds = %15
  tail call void @nk_str_remove_chars(ptr noundef nonnull %0, i32 noundef %2)
  %.pre = load i64, ptr %8, align 8, !tbaa !5
  br label %31

31:                                               ; preds = %30, %27
  %32 = phi i64 [ %.pre, %30 ], [ %29, %27 ]
  %33 = getelementptr inbounds i8, ptr %0, i64 64
  %34 = load ptr, ptr %33, align 8, !tbaa !16
  %35 = trunc i64 %32 to i32
  %36 = tail call i32 @nk_utf_len(ptr noundef %34, i32 noundef %35)
  %37 = getelementptr inbounds i8, ptr %0, i64 120
  store i32 %36, ptr %37, align 8, !tbaa !17
  br label %38

38:                                               ; preds = %5, %6, %11, %31
  ret void
}

attributes #0 = { 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 #1 = { 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 #2 = { 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, !14, i64 88}
!6 = !{!"nk_str", !7, i64 0, !12, i64 120}
!7 = !{!"nk_buffer", !8, i64 0, !10, i64 32, !12, i64 56, !13, i64 64, !15, i64 80, !14, i64 88, !14, i64 96, !14, i64 104, !14, i64 112}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"nk_allocator", !8, i64 0, !11, i64 8, !11, i64 16}
!11 = !{!"any pointer", !8, i64 0}
!12 = !{!"int", !8, i64 0}
!13 = !{!"nk_memory", !11, i64 0, !14, i64 8}
!14 = !{!"long", !8, i64 0}
!15 = !{!"float", !8, i64 0}
!16 = !{!6, !11, i64 64}
!17 = !{!6, !12, i64 120}


; Effective O3 passes: EarlyCSEPass,GVNPass,GlobalOptPass,InferFunctionAttrsPass,InstCombinePass,ReassociatePass,SROAPass,SimplifyCFGPass,TailCallElimPass