; 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.9 = external hidden unnamed_addr constant [8 x i8], align 1
@.str.10 = external hidden unnamed_addr constant [4 x i8], align 1
@__PRETTY_FUNCTION__.nk_str_at_const = external hidden unnamed_addr constant [74 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
define dso_local ptr @nk_str_at_const(ptr noundef %0, i32 noundef %1, ptr noundef %2, ptr noundef %3) #2 {
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca i32, align 4
  %8 = alloca ptr, align 8
  %9 = alloca ptr, align 8
  %10 = alloca i32, align 4
  %11 = alloca i32, align 4
  %12 = alloca i32, align 4
  %13 = alloca ptr, align 8
  %14 = alloca i32, align 4
  %15 = 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 ptr %3, ptr %9, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #3
  store i32 0, ptr %10, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %11) #3
  store i32 0, ptr %11, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %12) #3
  store i32 0, ptr %12, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %13) #3
  call void @llvm.lifetime.start.p0(i64 4, ptr %14) #3
  %16 = load ptr, ptr %6, align 8, !tbaa !5
  %17 = icmp ne ptr %16, null
  br i1 %17, label %18, label %19

18:                                               ; preds = %4
  br label %20

19:                                               ; preds = %4
  call void @__assert_fail(ptr noundef @.str.3, ptr noundef @.str.2, i32 noundef 8650, ptr noundef @__PRETTY_FUNCTION__.nk_str_at_const) #4
  unreachable

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

23:                                               ; preds = %20
  br label %25

24:                                               ; preds = %20
  call void @__assert_fail(ptr noundef @.str.9, ptr noundef @.str.2, i32 noundef 8651, ptr noundef @__PRETTY_FUNCTION__.nk_str_at_const) #4
  unreachable

25:                                               ; preds = %23
  %26 = load ptr, ptr %9, align 8, !tbaa !5
  %27 = icmp ne ptr %26, null
  br i1 %27, label %28, label %29

28:                                               ; preds = %25
  br label %30

29:                                               ; preds = %25
  call void @__assert_fail(ptr noundef @.str.10, ptr noundef @.str.2, i32 noundef 8652, ptr noundef @__PRETTY_FUNCTION__.nk_str_at_const) #4
  unreachable

30:                                               ; preds = %28
  %31 = load ptr, ptr %6, align 8, !tbaa !5
  %32 = icmp ne ptr %31, null
  br i1 %32, label %33, label %39

33:                                               ; preds = %30
  %34 = load ptr, ptr %8, align 8, !tbaa !5
  %35 = icmp ne ptr %34, null
  br i1 %35, label %36, label %39

36:                                               ; preds = %33
  %37 = load ptr, ptr %9, align 8, !tbaa !5
  %38 = icmp ne ptr %37, null
  br i1 %38, label %40, label %39

39:                                               ; preds = %36, %33, %30
  store ptr null, ptr %5, align 8
  store i32 1, ptr %15, align 4
  br label %96

40:                                               ; preds = %36
  %41 = load i32, ptr %7, align 4, !tbaa !9
  %42 = icmp slt i32 %41, 0
  br i1 %42, label %43, label %46

43:                                               ; preds = %40
  %44 = load ptr, ptr %8, align 8, !tbaa !5
  store i32 0, ptr %44, align 4, !tbaa !9
  %45 = load ptr, ptr %9, align 8, !tbaa !5
  store i32 0, ptr %45, align 4, !tbaa !9
  store ptr null, ptr %5, align 8
  store i32 1, ptr %15, align 4
  br label %96

46:                                               ; preds = %40
  %47 = load ptr, ptr %6, align 8, !tbaa !5
  %48 = getelementptr inbounds %struct.nk_str, ptr %47, i32 0, i32 0
  %49 = getelementptr inbounds %struct.nk_buffer, ptr %48, i32 0, i32 3
  %50 = getelementptr inbounds %struct.nk_memory, ptr %49, i32 0, i32 0
  %51 = load ptr, ptr %50, align 8, !tbaa !11
  store ptr %51, ptr %13, align 8, !tbaa !5
  %52 = load ptr, ptr %6, align 8, !tbaa !5
  %53 = getelementptr inbounds %struct.nk_str, ptr %52, i32 0, i32 0
  %54 = getelementptr inbounds %struct.nk_buffer, ptr %53, i32 0, i32 5
  %55 = load i64, ptr %54, align 8, !tbaa !18
  %56 = trunc i64 %55 to i32
  store i32 %56, ptr %14, align 4, !tbaa !9
  %57 = load ptr, ptr %13, align 8, !tbaa !5
  %58 = load ptr, ptr %8, align 8, !tbaa !5
  %59 = load i32, ptr %14, align 4, !tbaa !9
  %60 = call i32 @nk_utf_decode(ptr noundef %57, ptr noundef %58, i32 noundef %59)
  store i32 %60, ptr %12, align 4, !tbaa !9
  br label %61

61:                                               ; preds = %71, %46
  %62 = load i32, ptr %12, align 4, !tbaa !9
  %63 = icmp ne i32 %62, 0
  br i1 %63, label %64, label %86

64:                                               ; preds = %61
  %65 = load i32, ptr %10, align 4, !tbaa !9
  %66 = load i32, ptr %7, align 4, !tbaa !9
  %67 = icmp eq i32 %65, %66
  br i1 %67, label %68, label %71

68:                                               ; preds = %64
  %69 = load i32, ptr %12, align 4, !tbaa !9
  %70 = load ptr, ptr %9, align 8, !tbaa !5
  store i32 %69, ptr %70, align 4, !tbaa !9
  br label %86

71:                                               ; preds = %64
  %72 = load i32, ptr %10, align 4, !tbaa !9
  %73 = add nsw i32 %72, 1
  store i32 %73, ptr %10, align 4, !tbaa !9
  %74 = load i32, ptr %11, align 4, !tbaa !9
  %75 = load i32, ptr %12, align 4, !tbaa !9
  %76 = add nsw i32 %74, %75
  store i32 %76, ptr %11, align 4, !tbaa !9
  %77 = load ptr, ptr %13, align 8, !tbaa !5
  %78 = load i32, ptr %11, align 4, !tbaa !9
  %79 = sext i32 %78 to i64
  %80 = getelementptr inbounds i8, ptr %77, i64 %79
  %81 = load ptr, ptr %8, align 8, !tbaa !5
  %82 = load i32, ptr %14, align 4, !tbaa !9
  %83 = load i32, ptr %11, align 4, !tbaa !9
  %84 = sub nsw i32 %82, %83
  %85 = call i32 @nk_utf_decode(ptr noundef %80, ptr noundef %81, i32 noundef %84)
  store i32 %85, ptr %12, align 4, !tbaa !9
  br label %61, !llvm.loop !19

86:                                               ; preds = %68, %61
  %87 = load i32, ptr %10, align 4, !tbaa !9
  %88 = load i32, ptr %7, align 4, !tbaa !9
  %89 = icmp ne i32 %87, %88
  br i1 %89, label %90, label %91

90:                                               ; preds = %86
  store ptr null, ptr %5, align 8
  store i32 1, ptr %15, align 4
  br label %96

91:                                               ; preds = %86
  %92 = load ptr, ptr %13, align 8, !tbaa !5
  %93 = load i32, ptr %11, align 4, !tbaa !9
  %94 = sext i32 %93 to i64
  %95 = getelementptr inbounds i8, ptr %92, i64 %94
  store ptr %95, ptr %5, align 8
  store i32 1, ptr %15, align 4
  br label %96

96:                                               ; preds = %91, %90, %43, %39
  call void @llvm.lifetime.end.p0(i64 4, ptr %14) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %13) #3
  call void @llvm.lifetime.end.p0(i64 4, 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
  %97 = load ptr, ptr %5, align 8
  ret ptr %97
}

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, !6, i64 64}
!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, !16, i64 88}
!19 = distinct !{!19, !20}
!20 = !{!"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.3 = external hidden unnamed_addr constant [4 x i8], align 1
@.str.9 = external hidden unnamed_addr constant [8 x i8], align 1
@.str.10 = external hidden unnamed_addr constant [4 x i8], align 1
@__PRETTY_FUNCTION__.nk_str_at_const = external hidden unnamed_addr constant [74 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_decode(ptr noundef, ptr noundef, i32 noundef) local_unnamed_addr #1

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

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

6:                                                ; preds = %4
  %.not41 = icmp eq ptr %2, null
  br i1 %.not41, label %7, label %8

7:                                                ; preds = %6
  tail call void @__assert_fail(ptr noundef nonnull @.str.9, ptr noundef nonnull @.str.2, i32 noundef 8651, ptr noundef nonnull @__PRETTY_FUNCTION__.nk_str_at_const) #2
  unreachable

8:                                                ; preds = %6
  %.not42 = icmp eq ptr %3, null
  br i1 %.not42, label %9, label %10

9:                                                ; preds = %8
  tail call void @__assert_fail(ptr noundef nonnull @.str.10, ptr noundef nonnull @.str.2, i32 noundef 8652, ptr noundef nonnull @__PRETTY_FUNCTION__.nk_str_at_const) #2
  unreachable

10:                                               ; preds = %8
  %11 = icmp slt i32 %1, 0
  br i1 %11, label %12, label %13

12:                                               ; preds = %10
  store i32 0, ptr %2, align 4, !tbaa !5
  store i32 0, ptr %3, align 4, !tbaa !5
  br label %31

13:                                               ; preds = %10
  %14 = getelementptr inbounds i8, ptr %0, i64 64
  %15 = load ptr, ptr %14, align 8, !tbaa !9
  %16 = getelementptr inbounds i8, ptr %0, i64 88
  %17 = load i64, ptr %16, align 8, !tbaa !17
  %18 = trunc i64 %17 to i32
  %19 = tail call i32 @nk_utf_decode(ptr noundef %15, ptr noundef nonnull %2, i32 noundef %18)
  %.not4350 = icmp eq i32 %19, 0
  br i1 %.not4350, label %.loopexit, label %.lr.ph

.lr.ph:                                           ; preds = %13, %21
  %.03453 = phi i32 [ %22, %21 ], [ 0, %13 ]
  %.03552 = phi i32 [ %27, %21 ], [ %19, %13 ]
  %.03651 = phi i32 [ %23, %21 ], [ 0, %13 ]
  %20 = icmp eq i32 %.03453, %1
  br i1 %20, label %.loopexit.thread, label %21

.loopexit.thread:                                 ; preds = %.lr.ph
  store i32 %.03552, ptr %3, align 4, !tbaa !5
  br label %28

21:                                               ; preds = %.lr.ph
  %22 = add nuw nsw i32 %.03453, 1
  %23 = add nsw i32 %.03552, %.03651
  %24 = sext i32 %23 to i64
  %25 = getelementptr inbounds i8, ptr %15, i64 %24
  %26 = sub nsw i32 %18, %23
  %27 = tail call i32 @nk_utf_decode(ptr noundef %25, ptr noundef nonnull %2, i32 noundef %26)
  %.not43 = icmp eq i32 %27, 0
  br i1 %.not43, label %.loopexit, label %.lr.ph, !llvm.loop !18

.loopexit:                                        ; preds = %21, %13
  %.03649 = phi i32 [ 0, %13 ], [ %23, %21 ]
  %.03446 = phi i32 [ 0, %13 ], [ %22, %21 ]
  %.not44 = icmp eq i32 %.03446, %1
  br i1 %.not44, label %28, label %31

28:                                               ; preds = %.loopexit.thread, %.loopexit
  %.0364962 = phi i32 [ %.03651, %.loopexit.thread ], [ %.03649, %.loopexit ]
  %29 = sext i32 %.0364962 to i64
  %30 = getelementptr inbounds i8, ptr %15, i64 %29
  br label %31

31:                                               ; preds = %.loopexit, %28, %12
  %.0 = phi ptr [ null, %12 ], [ %30, %28 ], [ null, %.loopexit ]
  ret ptr %.0
}

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


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