; 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_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.8 = external hidden unnamed_addr constant [7 x i8], align 1
@__PRETTY_FUNCTION__.nk_buffer_reset = external hidden unnamed_addr constant [73 x i8], align 1

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

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

7:                                                ; preds = %2
  br label %9

8:                                                ; preds = %2
  call void @__assert_fail(ptr noundef @.str.8, ptr noundef @.str.2, i32 noundef 8204, ptr noundef @__PRETTY_FUNCTION__.nk_buffer_reset) #2
  unreachable

9:                                                ; preds = %7
  %10 = load ptr, ptr %3, align 8, !tbaa !5
  %11 = icmp ne ptr %10, null
  br i1 %11, label %13, label %12

12:                                               ; preds = %9
  br label %109

13:                                               ; preds = %9
  %14 = load i32, ptr %4, align 4, !tbaa !9
  %15 = icmp eq i32 %14, 1
  br i1 %15, label %16, label %65

16:                                               ; preds = %13
  %17 = load ptr, ptr %3, align 8, !tbaa !5
  %18 = getelementptr inbounds %struct.nk_buffer, ptr %17, i32 0, i32 3
  %19 = getelementptr inbounds %struct.nk_memory, ptr %18, i32 0, i32 1
  %20 = load i64, ptr %19, align 8, !tbaa !11
  %21 = load ptr, ptr %3, align 8, !tbaa !5
  %22 = getelementptr inbounds %struct.nk_buffer, ptr %21, i32 0, i32 0
  %23 = load i32, ptr %4, align 4, !tbaa !9
  %24 = zext i32 %23 to i64
  %25 = getelementptr inbounds [2 x %struct.nk_buffer_marker], ptr %22, i64 0, i64 %24
  %26 = getelementptr inbounds %struct.nk_buffer_marker, ptr %25, i32 0, i32 1
  %27 = load i64, ptr %26, align 8, !tbaa !17
  %28 = sub i64 %20, %27
  %29 = load ptr, ptr %3, align 8, !tbaa !5
  %30 = getelementptr inbounds %struct.nk_buffer, ptr %29, i32 0, i32 6
  %31 = load i64, ptr %30, align 8, !tbaa !19
  %32 = sub i64 %31, %28
  store i64 %32, ptr %30, align 8, !tbaa !19
  %33 = load ptr, ptr %3, align 8, !tbaa !5
  %34 = getelementptr inbounds %struct.nk_buffer, ptr %33, i32 0, i32 0
  %35 = load i32, ptr %4, align 4, !tbaa !9
  %36 = zext i32 %35 to i64
  %37 = getelementptr inbounds [2 x %struct.nk_buffer_marker], ptr %34, i64 0, i64 %36
  %38 = getelementptr inbounds %struct.nk_buffer_marker, ptr %37, i32 0, i32 0
  %39 = load i32, ptr %38, align 8, !tbaa !20
  %40 = icmp ne i32 %39, 0
  br i1 %40, label %41, label %51

41:                                               ; preds = %16
  %42 = load ptr, ptr %3, align 8, !tbaa !5
  %43 = getelementptr inbounds %struct.nk_buffer, ptr %42, i32 0, i32 0
  %44 = load i32, ptr %4, align 4, !tbaa !9
  %45 = zext i32 %44 to i64
  %46 = getelementptr inbounds [2 x %struct.nk_buffer_marker], ptr %43, i64 0, i64 %45
  %47 = getelementptr inbounds %struct.nk_buffer_marker, ptr %46, i32 0, i32 1
  %48 = load i64, ptr %47, align 8, !tbaa !17
  %49 = load ptr, ptr %3, align 8, !tbaa !5
  %50 = getelementptr inbounds %struct.nk_buffer, ptr %49, i32 0, i32 8
  store i64 %48, ptr %50, align 8, !tbaa !21
  br label %58

51:                                               ; preds = %16
  %52 = load ptr, ptr %3, align 8, !tbaa !5
  %53 = getelementptr inbounds %struct.nk_buffer, ptr %52, i32 0, i32 3
  %54 = getelementptr inbounds %struct.nk_memory, ptr %53, i32 0, i32 1
  %55 = load i64, ptr %54, align 8, !tbaa !11
  %56 = load ptr, ptr %3, align 8, !tbaa !5
  %57 = getelementptr inbounds %struct.nk_buffer, ptr %56, i32 0, i32 8
  store i64 %55, ptr %57, align 8, !tbaa !21
  br label %58

58:                                               ; preds = %51, %41
  %59 = load ptr, ptr %3, align 8, !tbaa !5
  %60 = getelementptr inbounds %struct.nk_buffer, ptr %59, i32 0, i32 0
  %61 = load i32, ptr %4, align 4, !tbaa !9
  %62 = zext i32 %61 to i64
  %63 = getelementptr inbounds [2 x %struct.nk_buffer_marker], ptr %60, i64 0, i64 %62
  %64 = getelementptr inbounds %struct.nk_buffer_marker, ptr %63, i32 0, i32 0
  store i32 0, ptr %64, align 8, !tbaa !20
  br label %109

65:                                               ; preds = %13
  %66 = load ptr, ptr %3, align 8, !tbaa !5
  %67 = getelementptr inbounds %struct.nk_buffer, ptr %66, i32 0, i32 5
  %68 = load i64, ptr %67, align 8, !tbaa !22
  %69 = load ptr, ptr %3, align 8, !tbaa !5
  %70 = getelementptr inbounds %struct.nk_buffer, ptr %69, i32 0, i32 0
  %71 = load i32, ptr %4, align 4, !tbaa !9
  %72 = zext i32 %71 to i64
  %73 = getelementptr inbounds [2 x %struct.nk_buffer_marker], ptr %70, i64 0, i64 %72
  %74 = getelementptr inbounds %struct.nk_buffer_marker, ptr %73, i32 0, i32 1
  %75 = load i64, ptr %74, align 8, !tbaa !17
  %76 = sub i64 %68, %75
  %77 = load ptr, ptr %3, align 8, !tbaa !5
  %78 = getelementptr inbounds %struct.nk_buffer, ptr %77, i32 0, i32 6
  %79 = load i64, ptr %78, align 8, !tbaa !19
  %80 = sub i64 %79, %76
  store i64 %80, ptr %78, align 8, !tbaa !19
  %81 = load ptr, ptr %3, align 8, !tbaa !5
  %82 = getelementptr inbounds %struct.nk_buffer, ptr %81, i32 0, i32 0
  %83 = load i32, ptr %4, align 4, !tbaa !9
  %84 = zext i32 %83 to i64
  %85 = getelementptr inbounds [2 x %struct.nk_buffer_marker], ptr %82, i64 0, i64 %84
  %86 = getelementptr inbounds %struct.nk_buffer_marker, ptr %85, i32 0, i32 0
  %87 = load i32, ptr %86, align 8, !tbaa !20
  %88 = icmp ne i32 %87, 0
  br i1 %88, label %89, label %99

89:                                               ; preds = %65
  %90 = load ptr, ptr %3, align 8, !tbaa !5
  %91 = getelementptr inbounds %struct.nk_buffer, ptr %90, i32 0, i32 0
  %92 = load i32, ptr %4, align 4, !tbaa !9
  %93 = zext i32 %92 to i64
  %94 = getelementptr inbounds [2 x %struct.nk_buffer_marker], ptr %91, i64 0, i64 %93
  %95 = getelementptr inbounds %struct.nk_buffer_marker, ptr %94, i32 0, i32 1
  %96 = load i64, ptr %95, align 8, !tbaa !17
  %97 = load ptr, ptr %3, align 8, !tbaa !5
  %98 = getelementptr inbounds %struct.nk_buffer, ptr %97, i32 0, i32 5
  store i64 %96, ptr %98, align 8, !tbaa !22
  br label %102

99:                                               ; preds = %65
  %100 = load ptr, ptr %3, align 8, !tbaa !5
  %101 = getelementptr inbounds %struct.nk_buffer, ptr %100, i32 0, i32 5
  store i64 0, ptr %101, align 8, !tbaa !22
  br label %102

102:                                              ; preds = %99, %89
  %103 = load ptr, ptr %3, align 8, !tbaa !5
  %104 = getelementptr inbounds %struct.nk_buffer, ptr %103, i32 0, i32 0
  %105 = load i32, ptr %4, align 4, !tbaa !9
  %106 = zext i32 %105 to i64
  %107 = getelementptr inbounds [2 x %struct.nk_buffer_marker], ptr %104, i64 0, i64 %106
  %108 = getelementptr inbounds %struct.nk_buffer_marker, ptr %107, i32 0, i32 0
  store i32 0, ptr %108, align 8, !tbaa !20
  br label %109

109:                                              ; preds = %102, %58, %12
  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, !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, !15, i64 72}
!12 = !{!"nk_buffer", !7, i64 0, !13, i64 32, !10, i64 56, !14, i64 64, !16, i64 80, !15, i64 88, !15, i64 96, !15, i64 104, !15, i64 112}
!13 = !{!"nk_allocator", !7, i64 0, !6, i64 8, !6, i64 16}
!14 = !{!"nk_memory", !6, i64 0, !15, i64 8}
!15 = !{!"long", !7, i64 0}
!16 = !{!"float", !7, i64 0}
!17 = !{!18, !15, i64 8}
!18 = !{!"nk_buffer_marker", !10, i64 0, !15, i64 8}
!19 = !{!12, !15, i64 96}
!20 = !{!18, !10, i64 0}
!21 = !{!12, !15, i64 112}
!22 = !{!12, !15, i64 88}


; 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_buffer_marker = type { i32, i64 }

@.str.2 = external hidden unnamed_addr constant [103 x i8], align 1
@.str.8 = external hidden unnamed_addr constant [7 x i8], align 1
@__PRETTY_FUNCTION__.nk_buffer_reset = external hidden unnamed_addr constant [73 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
define dso_local void @nk_buffer_reset(ptr noundef %0, i32 noundef %1) local_unnamed_addr #1 {
  %.not = icmp eq ptr %0, null
  br i1 %.not, label %3, label %4

3:                                                ; preds = %2
  tail call void @__assert_fail(ptr noundef nonnull @.str.8, ptr noundef nonnull @.str.2, i32 noundef 8204, ptr noundef nonnull @__PRETTY_FUNCTION__.nk_buffer_reset) #2
  unreachable

4:                                                ; preds = %2
  %5 = icmp eq i32 %1, 1
  br i1 %5, label %6, label %17

6:                                                ; preds = %4
  %7 = getelementptr inbounds i8, ptr %0, i64 72
  %8 = load i64, ptr %7, align 8, !tbaa !5
  %9 = getelementptr inbounds i8, ptr %0, i64 16
  %10 = getelementptr inbounds i8, ptr %0, i64 24
  %11 = load i64, ptr %10, align 8, !tbaa !15
  %.neg29 = sub i64 %11, %8
  %12 = getelementptr inbounds i8, ptr %0, i64 96
  %13 = load i64, ptr %12, align 8, !tbaa !17
  %14 = add i64 %.neg29, %13
  store i64 %14, ptr %12, align 8, !tbaa !17
  %15 = load i32, ptr %9, align 8, !tbaa !18
  %.not30 = icmp eq i32 %15, 0
  %spec.select33 = select i1 %.not30, i64 %8, i64 %11
  %16 = getelementptr inbounds i8, ptr %0, i64 112
  store i64 %spec.select33, ptr %16, align 8
  br label %28

17:                                               ; preds = %4
  %18 = getelementptr inbounds i8, ptr %0, i64 88
  %19 = load i64, ptr %18, align 8, !tbaa !19
  %20 = zext i32 %1 to i64
  %21 = getelementptr inbounds [2 x %struct.nk_buffer_marker], ptr %0, i64 0, i64 %20
  %22 = getelementptr inbounds i8, ptr %21, i64 8
  %23 = load i64, ptr %22, align 8, !tbaa !15
  %.neg = sub i64 %23, %19
  %24 = getelementptr inbounds i8, ptr %0, i64 96
  %25 = load i64, ptr %24, align 8, !tbaa !17
  %26 = add i64 %.neg, %25
  store i64 %26, ptr %24, align 8, !tbaa !17
  %27 = load i32, ptr %21, align 8, !tbaa !18
  %.not28 = icmp eq i32 %27, 0
  %spec.select = select i1 %.not28, i64 0, i64 %23
  store i64 %spec.select, ptr %18, align 8, !tbaa !19
  br label %28

28:                                               ; preds = %17, %6
  %.sink = phi ptr [ %21, %17 ], [ %9, %6 ]
  store i32 0, ptr %.sink, align 8, !tbaa !18
  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, !13, i64 72}
!6 = !{!"nk_buffer", !7, i64 0, !9, i64 32, !11, i64 56, !12, i64 64, !14, i64 80, !13, i64 88, !13, i64 96, !13, i64 104, !13, i64 112}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!"nk_allocator", !7, i64 0, !10, i64 8, !10, i64 16}
!10 = !{!"any pointer", !7, i64 0}
!11 = !{!"int", !7, i64 0}
!12 = !{!"nk_memory", !10, i64 0, !13, i64 8}
!13 = !{!"long", !7, i64 0}
!14 = !{!"float", !7, i64 0}
!15 = !{!16, !13, i64 8}
!16 = !{!"nk_buffer_marker", !11, i64 0, !13, i64 8}
!17 = !{!6, !13, i64 96}
!18 = !{!16, !11, i64 0}
!19 = !{!6, !13, i64 88}


; Effective O3 passes: EarlyCSEPass,GlobalOptPass,IPSCCPPass,InstCombinePass,JumpThreadingPass,MergedLoadStoreMotionPass,ReassociatePass,SROAPass,SimplifyCFGPass,TailCallElimPass