; 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_window = type { i32, i32, [64 x i8], i32, %struct.nk_rect, %struct.nk_scroll, %struct.nk_command_buffer, ptr, float, %struct.nk_property_state, %struct.nk_popup_state, %struct.nk_edit_state, i32, ptr, i32, ptr, ptr, ptr }
%struct.nk_rect = type { float, float, float, float }
%struct.nk_scroll = type { i32, i32 }
%struct.nk_command_buffer = type { ptr, %struct.nk_rect, i32, %union.nk_handle, i64, i64, i64 }
%union.nk_handle = type { ptr }
%struct.nk_property_state = type { i32, i32, [64 x i8], i32, i32, i32, i32, i32, i32, i32, i32 }
%struct.nk_popup_state = type { ptr, i32, %struct.nk_popup_buffer, i32, i32, i32, i32, i32, i32, %struct.nk_rect }
%struct.nk_popup_buffer = type { i64, i64, i64, i64, i32 }
%struct.nk_edit_state = type { i32, i32, i32, i32, i32, i32, i32, i32, %struct.nk_scroll, i8, i8 }

@.str.2 = external hidden unnamed_addr constant [103 x i8], align 1
@.str.33 = external hidden unnamed_addr constant [4 x i8], align 1
@__PRETTY_FUNCTION__.nk_window_collapse = external hidden unnamed_addr constant [84 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_strlen(ptr noundef) #2

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

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

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

13:                                               ; preds = %3
  br label %15

14:                                               ; preds = %3
  call void @__assert_fail(ptr noundef @.str.33, ptr noundef @.str.2, i32 noundef 16729, ptr noundef @__PRETTY_FUNCTION__.nk_window_collapse) #4
  unreachable

15:                                               ; preds = %13
  %16 = load ptr, ptr %4, align 8, !tbaa !5
  %17 = icmp ne ptr %16, null
  br i1 %17, label %19, label %18

18:                                               ; preds = %15
  store i32 1, ptr %10, align 4
  br label %46

19:                                               ; preds = %15
  %20 = load ptr, ptr %5, align 8, !tbaa !5
  %21 = call i32 @nk_strlen(ptr noundef %20)
  store i32 %21, ptr %7, align 4, !tbaa !9
  %22 = load ptr, ptr %5, align 8, !tbaa !5
  %23 = load i32, ptr %7, align 4, !tbaa !9
  %24 = call i32 @nk_murmur_hash(ptr noundef %22, i32 noundef %23, i32 noundef 64)
  store i32 %24, ptr %8, align 4, !tbaa !9
  %25 = load ptr, ptr %4, align 8, !tbaa !5
  %26 = load i32, ptr %8, align 4, !tbaa !9
  %27 = load ptr, ptr %5, align 8, !tbaa !5
  %28 = call ptr @nk_find_window(ptr noundef %25, i32 noundef %26, ptr noundef %27)
  store ptr %28, ptr %9, align 8, !tbaa !5
  %29 = load ptr, ptr %9, align 8, !tbaa !5
  %30 = icmp ne ptr %29, null
  br i1 %30, label %32, label %31

31:                                               ; preds = %19
  store i32 1, ptr %10, align 4
  br label %46

32:                                               ; preds = %19
  %33 = load i32, ptr %6, align 4, !tbaa !9
  %34 = icmp eq i32 %33, 0
  br i1 %34, label %35, label %40

35:                                               ; preds = %32
  %36 = load ptr, ptr %9, align 8, !tbaa !5
  %37 = getelementptr inbounds %struct.nk_window, ptr %36, i32 0, i32 3
  %38 = load i32, ptr %37, align 8, !tbaa !11
  %39 = or i32 %38, 32768
  store i32 %39, ptr %37, align 8, !tbaa !11
  br label %45

40:                                               ; preds = %32
  %41 = load ptr, ptr %9, align 8, !tbaa !5
  %42 = getelementptr inbounds %struct.nk_window, ptr %41, i32 0, i32 3
  %43 = load i32, ptr %42, align 8, !tbaa !11
  %44 = and i32 %43, -32769
  store i32 %44, ptr %42, align 8, !tbaa !11
  br label %45

45:                                               ; preds = %40, %35
  store i32 0, ptr %10, align 4
  br label %46

46:                                               ; preds = %45, %31, %18
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #3
  %47 = load i32, ptr %10, align 4
  switch i32 %47, label %49 [
    i32 0, label %48
    i32 1, label %48
  ]

48:                                               ; preds = %46, %46
  ret void

49:                                               ; preds = %46
  unreachable
}

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 72}
!12 = !{!"nk_window", !10, i64 0, !10, i64 4, !7, i64 8, !10, i64 72, !13, i64 76, !15, i64 92, !16, i64 104, !6, i64 168, !14, i64 176, !18, i64 180, !19, i64 288, !21, i64 384, !10, i64 428, !6, i64 432, !10, i64 440, !6, i64 448, !6, i64 456, !6, i64 464}
!13 = !{!"nk_rect", !14, i64 0, !14, i64 4, !14, i64 8, !14, i64 12}
!14 = !{!"float", !7, i64 0}
!15 = !{!"nk_scroll", !10, i64 0, !10, i64 4}
!16 = !{!"nk_command_buffer", !6, i64 0, !13, i64 8, !10, i64 24, !7, i64 32, !17, i64 40, !17, i64 48, !17, i64 56}
!17 = !{!"long", !7, i64 0}
!18 = !{!"nk_property_state", !10, i64 0, !10, i64 4, !7, i64 8, !10, i64 72, !10, i64 76, !10, i64 80, !10, i64 84, !10, i64 88, !10, i64 92, !10, i64 96, !10, i64 100}
!19 = !{!"nk_popup_state", !6, i64 0, !10, i64 8, !20, i64 16, !10, i64 56, !10, i64 60, !10, i64 64, !10, i64 68, !10, i64 72, !10, i64 76, !13, i64 80}
!20 = !{!"nk_popup_buffer", !17, i64 0, !17, i64 8, !17, i64 16, !17, i64 24, !10, i64 32}
!21 = !{!"nk_edit_state", !10, i64 0, !10, i64 4, !10, i64 8, !10, i64 12, !10, i64 16, !10, i64 20, !10, i64 24, !10, i64 28, !15, i64 32, !7, i64 40, !7, i64 41}


; 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.33 = external hidden unnamed_addr constant [4 x i8], align 1
@__PRETTY_FUNCTION__.nk_window_collapse = external hidden unnamed_addr constant [84 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_strlen(ptr noundef) local_unnamed_addr #1

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

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

; Function Attrs: nounwind uwtable
define dso_local void @nk_window_collapse(ptr noundef %0, ptr 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.33, ptr noundef nonnull @.str.2, i32 noundef 16729, ptr noundef nonnull @__PRETTY_FUNCTION__.nk_window_collapse) #2
  unreachable

5:                                                ; preds = %3
  %6 = tail call i32 @nk_strlen(ptr noundef %1)
  %7 = tail call i32 @nk_murmur_hash(ptr noundef %1, i32 noundef %6, i32 noundef 64)
  %8 = tail call ptr @nk_find_window(ptr noundef nonnull %0, i32 noundef %7, ptr noundef %1)
  %.not12 = icmp eq ptr %8, null
  br i1 %.not12, label %13, label %.sink.split

.sink.split:                                      ; preds = %5
  %9 = icmp eq i32 %2, 0
  %10 = getelementptr inbounds i8, ptr %8, i64 72
  %11 = load i32, ptr %10, align 8, !tbaa !5
  %12 = and i32 %11, -32769
  %masksel = select i1 %9, i32 32768, i32 0
  %.sink = or disjoint i32 %12, %masksel
  store i32 %.sink, ptr %10, align 8, !tbaa !5
  br label %13

13:                                               ; preds = %.sink.split, %5
  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, !7, i64 72}
!6 = !{!"nk_window", !7, i64 0, !7, i64 4, !8, i64 8, !7, i64 72, !10, i64 76, !12, i64 92, !13, i64 104, !14, i64 168, !11, i64 176, !16, i64 180, !17, i64 288, !19, i64 384, !7, i64 428, !14, i64 432, !7, i64 440, !14, i64 448, !14, i64 456, !14, i64 464}
!7 = !{!"int", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"nk_rect", !11, i64 0, !11, i64 4, !11, i64 8, !11, i64 12}
!11 = !{!"float", !8, i64 0}
!12 = !{!"nk_scroll", !7, i64 0, !7, i64 4}
!13 = !{!"nk_command_buffer", !14, i64 0, !10, i64 8, !7, i64 24, !8, i64 32, !15, i64 40, !15, i64 48, !15, i64 56}
!14 = !{!"any pointer", !8, i64 0}
!15 = !{!"long", !8, i64 0}
!16 = !{!"nk_property_state", !7, i64 0, !7, i64 4, !8, i64 8, !7, i64 72, !7, i64 76, !7, i64 80, !7, i64 84, !7, i64 88, !7, i64 92, !7, i64 96, !7, i64 100}
!17 = !{!"nk_popup_state", !14, i64 0, !7, i64 8, !18, i64 16, !7, i64 56, !7, i64 60, !7, i64 64, !7, i64 68, !7, i64 72, !7, i64 76, !10, i64 80}
!18 = !{!"nk_popup_buffer", !15, i64 0, !15, i64 8, !15, i64 16, !15, i64 24, !7, i64 32}
!19 = !{!"nk_edit_state", !7, i64 0, !7, i64 4, !7, i64 8, !7, i64 12, !7, i64 16, !7, i64 20, !7, i64 24, !7, i64 28, !12, i64 32, !8, i64 40, !8, i64 41}


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