; 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.3 = external hidden unnamed_addr constant [4 x i8], align 1
@.str.10 = external hidden unnamed_addr constant [4 x i8], align 1
@__PRETTY_FUNCTION__.nk_str_insert_at_rune = external hidden unnamed_addr constant [67 x i8], align 1
@.str.21 = external hidden unnamed_addr constant [5 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_str_append_text_char(ptr noundef, ptr noundef, i32 noundef) #2

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

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

17:                                               ; preds = %4
  br label %19

18:                                               ; preds = %4
  call void @__assert_fail(ptr noundef @.str.3, ptr noundef @.str.2, i32 noundef 8433, ptr noundef @__PRETTY_FUNCTION__.nk_str_insert_at_rune) #4
  unreachable

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

22:                                               ; preds = %19
  br label %24

23:                                               ; preds = %19
  call void @__assert_fail(ptr noundef @.str.21, ptr noundef @.str.2, i32 noundef 8434, ptr noundef @__PRETTY_FUNCTION__.nk_str_insert_at_rune) #4
  unreachable

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

27:                                               ; preds = %24
  br label %29

28:                                               ; preds = %24
  call void @__assert_fail(ptr noundef @.str.10, ptr noundef @.str.2, i32 noundef 8435, ptr noundef @__PRETTY_FUNCTION__.nk_str_insert_at_rune) #4
  unreachable

29:                                               ; preds = %27
  %30 = load ptr, ptr %6, align 8, !tbaa !5
  %31 = icmp ne ptr %30, null
  br i1 %31, label %32, label %38

32:                                               ; preds = %29
  %33 = load ptr, ptr %8, align 8, !tbaa !5
  %34 = icmp ne ptr %33, null
  br i1 %34, label %35, label %38

35:                                               ; preds = %32
  %36 = load i32, ptr %9, align 4, !tbaa !9
  %37 = icmp ne i32 %36, 0
  br i1 %37, label %39, label %38

38:                                               ; preds = %35, %32, %29
  store i32 0, ptr %5, align 4
  store i32 1, ptr %14, align 4
  br label %69

39:                                               ; preds = %35
  %40 = load ptr, ptr %6, align 8, !tbaa !5
  %41 = load i32, ptr %7, align 4, !tbaa !9
  %42 = call ptr @nk_str_at_rune(ptr noundef %40, i32 noundef %41, ptr noundef %11, ptr noundef %10)
  store ptr %42, ptr %12, align 8, !tbaa !5
  %43 = load ptr, ptr %6, align 8, !tbaa !5
  %44 = getelementptr inbounds %struct.nk_str, ptr %43, i32 0, i32 1
  %45 = load i32, ptr %44, align 8, !tbaa !11
  %46 = icmp ne i32 %45, 0
  br i1 %46, label %52, label %47

47:                                               ; preds = %39
  %48 = load ptr, ptr %6, align 8, !tbaa !5
  %49 = load ptr, ptr %8, align 8, !tbaa !5
  %50 = load i32, ptr %9, align 4, !tbaa !9
  %51 = call i32 @nk_str_append_text_char(ptr noundef %48, ptr noundef %49, i32 noundef %50)
  store i32 %51, ptr %5, align 4
  store i32 1, ptr %14, align 4
  br label %69

52:                                               ; preds = %39
  %53 = load ptr, ptr %6, align 8, !tbaa !5
  %54 = call ptr @nk_str_get_const(ptr noundef %53)
  store ptr %54, ptr %13, align 8, !tbaa !5
  %55 = load ptr, ptr %12, align 8, !tbaa !5
  %56 = icmp ne ptr %55, null
  br i1 %56, label %58, label %57

57:                                               ; preds = %52
  store i32 0, ptr %5, align 4
  store i32 1, ptr %14, align 4
  br label %69

58:                                               ; preds = %52
  %59 = load ptr, ptr %6, align 8, !tbaa !5
  %60 = load ptr, ptr %12, align 8, !tbaa !5
  %61 = load ptr, ptr %13, align 8, !tbaa !5
  %62 = ptrtoint ptr %60 to i64
  %63 = ptrtoint ptr %61 to i64
  %64 = sub i64 %62, %63
  %65 = trunc i64 %64 to i32
  %66 = load ptr, ptr %8, align 8, !tbaa !5
  %67 = load i32, ptr %9, align 4, !tbaa !9
  %68 = call i32 @nk_str_insert_at_char(ptr noundef %59, i32 noundef %65, ptr noundef %66, i32 noundef %67)
  store i32 %68, ptr %5, align 4
  store i32 1, ptr %14, align 4
  br label %69

69:                                               ; preds = %58, %57, %47, %38
  call void @llvm.lifetime.end.p0(i64 8, ptr %13) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %12) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #3
  %70 = load i32, ptr %5, align 4
  ret i32 %70
}

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

; Function Attrs: nounwind uwtable
declare dso_local ptr @nk_str_get_const(ptr 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, !10, i64 120}
!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}


; 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.3 = external hidden unnamed_addr constant [4 x i8], align 1
@.str.10 = external hidden unnamed_addr constant [4 x i8], align 1
@__PRETTY_FUNCTION__.nk_str_insert_at_rune = external hidden unnamed_addr constant [67 x i8], align 1
@.str.21 = external hidden unnamed_addr constant [5 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_str_append_text_char(ptr noundef, ptr noundef, i32 noundef) local_unnamed_addr #2

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

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

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

8:                                                ; preds = %4
  %.not26 = icmp eq ptr %2, null
  br i1 %.not26, label %9, label %10

9:                                                ; preds = %8
  tail call void @__assert_fail(ptr noundef nonnull @.str.21, ptr noundef nonnull @.str.2, i32 noundef 8434, ptr noundef nonnull @__PRETTY_FUNCTION__.nk_str_insert_at_rune) #4
  unreachable

10:                                               ; preds = %8
  %.not27 = icmp eq i32 %3, 0
  br i1 %.not27, label %11, label %12

11:                                               ; preds = %10
  tail call void @__assert_fail(ptr noundef nonnull @.str.10, ptr noundef nonnull @.str.2, i32 noundef 8435, ptr noundef nonnull @__PRETTY_FUNCTION__.nk_str_insert_at_rune) #4
  unreachable

12:                                               ; preds = %10
  %13 = call ptr @nk_str_at_rune(ptr noundef nonnull %0, i32 noundef %1, ptr noundef nonnull %6, ptr noundef nonnull %5)
  %14 = getelementptr inbounds i8, ptr %0, i64 120
  %15 = load i32, ptr %14, align 8, !tbaa !5
  %.not28 = icmp eq i32 %15, 0
  br i1 %.not28, label %16, label %18

16:                                               ; preds = %12
  %17 = call i32 @nk_str_append_text_char(ptr noundef nonnull %0, ptr noundef nonnull %2, i32 noundef %3)
  br label %26

18:                                               ; preds = %12
  %19 = call ptr @nk_str_get_const(ptr noundef nonnull %0)
  %.not29 = icmp eq ptr %13, null
  br i1 %.not29, label %26, label %20

20:                                               ; preds = %18
  %21 = ptrtoint ptr %13 to i64
  %22 = ptrtoint ptr %19 to i64
  %23 = sub i64 %21, %22
  %24 = trunc i64 %23 to i32
  %25 = call i32 @nk_str_insert_at_char(ptr noundef nonnull %0, i32 noundef %24, ptr noundef nonnull %2, i32 noundef %3)
  br label %26

26:                                               ; preds = %18, %20, %16
  %.0 = phi i32 [ %25, %20 ], [ %17, %16 ], [ 0, %18 ]
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %6) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %5) #3
  ret i32 %.0
}

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

; Function Attrs: nounwind uwtable
declare dso_local ptr @nk_str_get_const(ptr 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, !12, i64 120}
!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}


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