; 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_rect = type { float, float, float, float }
%struct.nk_command_buffer = type { ptr, %struct.nk_rect, i32, %union.nk_handle, i64, i64, i64 }
%union.nk_handle = type { ptr }
%struct.nk_command_scissor = type { %struct.nk_command, i16, i16, i16, i16 }
%struct.nk_command = type { i32, i64 }

@.str.2 = external hidden unnamed_addr constant [103 x i8], align 1
@.str.11 = external hidden unnamed_addr constant [2 x i8], align 1
@__PRETTY_FUNCTION__.nk_push_scissor = external hidden unnamed_addr constant [65 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
define dso_local void @nk_push_scissor(ptr noundef %0, <2 x float> %1, <2 x float> %2) #2 {
  %4 = alloca %struct.nk_rect, align 4
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca i32, align 4
  %8 = getelementptr inbounds { <2 x float>, <2 x float> }, ptr %4, i32 0, i32 0
  store <2 x float> %1, ptr %8, align 4
  %9 = getelementptr inbounds { <2 x float>, <2 x float> }, ptr %4, i32 0, i32 1
  store <2 x float> %2, ptr %9, align 4
  store ptr %0, ptr %5, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #4
  %10 = load ptr, ptr %5, align 8, !tbaa !5
  %11 = icmp ne ptr %10, null
  br i1 %11, label %12, label %13

12:                                               ; preds = %3
  br label %14

13:                                               ; preds = %3
  call void @__assert_fail(ptr noundef @.str.11, ptr noundef @.str.2, i32 noundef 8800, ptr noundef @__PRETTY_FUNCTION__.nk_push_scissor) #5
  unreachable

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

17:                                               ; preds = %14
  store i32 1, ptr %7, align 4
  br label %79

18:                                               ; preds = %14
  %19 = getelementptr inbounds %struct.nk_rect, ptr %4, i32 0, i32 0
  %20 = load float, ptr %19, align 4, !tbaa !9
  %21 = load ptr, ptr %5, align 8, !tbaa !5
  %22 = getelementptr inbounds %struct.nk_command_buffer, ptr %21, i32 0, i32 1
  %23 = getelementptr inbounds %struct.nk_rect, ptr %22, i32 0, i32 0
  store float %20, ptr %23, align 8, !tbaa !12
  %24 = getelementptr inbounds %struct.nk_rect, ptr %4, i32 0, i32 1
  %25 = load float, ptr %24, align 4, !tbaa !16
  %26 = load ptr, ptr %5, align 8, !tbaa !5
  %27 = getelementptr inbounds %struct.nk_command_buffer, ptr %26, i32 0, i32 1
  %28 = getelementptr inbounds %struct.nk_rect, ptr %27, i32 0, i32 1
  store float %25, ptr %28, align 4, !tbaa !17
  %29 = getelementptr inbounds %struct.nk_rect, ptr %4, i32 0, i32 2
  %30 = load float, ptr %29, align 4, !tbaa !18
  %31 = load ptr, ptr %5, align 8, !tbaa !5
  %32 = getelementptr inbounds %struct.nk_command_buffer, ptr %31, i32 0, i32 1
  %33 = getelementptr inbounds %struct.nk_rect, ptr %32, i32 0, i32 2
  store float %30, ptr %33, align 8, !tbaa !19
  %34 = getelementptr inbounds %struct.nk_rect, ptr %4, i32 0, i32 3
  %35 = load float, ptr %34, align 4, !tbaa !20
  %36 = load ptr, ptr %5, align 8, !tbaa !5
  %37 = getelementptr inbounds %struct.nk_command_buffer, ptr %36, i32 0, i32 1
  %38 = getelementptr inbounds %struct.nk_rect, ptr %37, i32 0, i32 3
  store float %35, ptr %38, align 4, !tbaa !21
  %39 = load ptr, ptr %5, align 8, !tbaa !5
  %40 = call ptr @nk_command_buffer_push(ptr noundef %39, i32 noundef 1, i64 noundef 24)
  store ptr %40, ptr %6, align 8, !tbaa !5
  %41 = load ptr, ptr %6, align 8, !tbaa !5
  %42 = icmp ne ptr %41, null
  br i1 %42, label %44, label %43

43:                                               ; preds = %18
  store i32 1, ptr %7, align 4
  br label %79

44:                                               ; preds = %18
  %45 = getelementptr inbounds %struct.nk_rect, ptr %4, i32 0, i32 0
  %46 = load float, ptr %45, align 4, !tbaa !9
  %47 = fptosi float %46 to i16
  %48 = load ptr, ptr %6, align 8, !tbaa !5
  %49 = getelementptr inbounds %struct.nk_command_scissor, ptr %48, i32 0, i32 1
  store i16 %47, ptr %49, align 8, !tbaa !22
  %50 = getelementptr inbounds %struct.nk_rect, ptr %4, i32 0, i32 1
  %51 = load float, ptr %50, align 4, !tbaa !16
  %52 = fptosi float %51 to i16
  %53 = load ptr, ptr %6, align 8, !tbaa !5
  %54 = getelementptr inbounds %struct.nk_command_scissor, ptr %53, i32 0, i32 2
  store i16 %52, ptr %54, align 2, !tbaa !26
  %55 = getelementptr inbounds %struct.nk_rect, ptr %4, i32 0, i32 2
  %56 = load float, ptr %55, align 4, !tbaa !18
  %57 = fcmp olt float 0.000000e+00, %56
  br i1 %57, label %58, label %61

58:                                               ; preds = %44
  %59 = getelementptr inbounds %struct.nk_rect, ptr %4, i32 0, i32 2
  %60 = load float, ptr %59, align 4, !tbaa !18
  br label %62

61:                                               ; preds = %44
  br label %62

62:                                               ; preds = %61, %58
  %63 = phi float [ %60, %58 ], [ 0.000000e+00, %61 ]
  %64 = fptoui float %63 to i16
  %65 = load ptr, ptr %6, align 8, !tbaa !5
  %66 = getelementptr inbounds %struct.nk_command_scissor, ptr %65, i32 0, i32 3
  store i16 %64, ptr %66, align 4, !tbaa !27
  %67 = getelementptr inbounds %struct.nk_rect, ptr %4, i32 0, i32 3
  %68 = load float, ptr %67, align 4, !tbaa !20
  %69 = fcmp olt float 0.000000e+00, %68
  br i1 %69, label %70, label %73

70:                                               ; preds = %62
  %71 = getelementptr inbounds %struct.nk_rect, ptr %4, i32 0, i32 3
  %72 = load float, ptr %71, align 4, !tbaa !20
  br label %74

73:                                               ; preds = %62
  br label %74

74:                                               ; preds = %73, %70
  %75 = phi float [ %72, %70 ], [ 0.000000e+00, %73 ]
  %76 = fptoui float %75 to i16
  %77 = load ptr, ptr %6, align 8, !tbaa !5
  %78 = getelementptr inbounds %struct.nk_command_scissor, ptr %77, i32 0, i32 4
  store i16 %76, ptr %78, align 2, !tbaa !28
  store i32 0, ptr %7, align 4
  br label %79

79:                                               ; preds = %74, %43, %17
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #4
  %80 = load i32, ptr %7, align 4
  switch i32 %80, label %82 [
    i32 0, label %81
    i32 1, label %81
  ]

81:                                               ; preds = %79, %79
  ret void

82:                                               ; preds = %79
  unreachable
}

; Function Attrs: nounwind uwtable
declare hidden ptr @nk_command_buffer_push(ptr noundef, i32 noundef, i64 noundef) #3

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"="64" "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 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 #4 = { nounwind }
attributes #5 = { 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, !11, i64 0}
!10 = !{!"nk_rect", !11, i64 0, !11, i64 4, !11, i64 8, !11, i64 12}
!11 = !{!"float", !7, i64 0}
!12 = !{!13, !11, i64 8}
!13 = !{!"nk_command_buffer", !6, i64 0, !10, i64 8, !14, i64 24, !7, i64 32, !15, i64 40, !15, i64 48, !15, i64 56}
!14 = !{!"int", !7, i64 0}
!15 = !{!"long", !7, i64 0}
!16 = !{!10, !11, i64 4}
!17 = !{!13, !11, i64 12}
!18 = !{!10, !11, i64 8}
!19 = !{!13, !11, i64 16}
!20 = !{!10, !11, i64 12}
!21 = !{!13, !11, i64 20}
!22 = !{!23, !25, i64 16}
!23 = !{!"nk_command_scissor", !24, i64 0, !25, i64 16, !25, i64 18, !25, i64 20, !25, i64 22}
!24 = !{!"nk_command", !14, i64 0, !15, i64 8}
!25 = !{!"short", !7, i64 0}
!26 = !{!23, !25, i64 18}
!27 = !{!23, !25, i64 20}
!28 = !{!23, !25, i64 22}


; 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.11 = external hidden unnamed_addr constant [2 x i8], align 1
@__PRETTY_FUNCTION__.nk_push_scissor = external hidden unnamed_addr constant [65 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_push_scissor(ptr noundef %0, <2 x float> %1, <2 x float> %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.11, ptr noundef nonnull @.str.2, i32 noundef 8800, ptr noundef nonnull @__PRETTY_FUNCTION__.nk_push_scissor) #3
  unreachable

5:                                                ; preds = %3
  %6 = getelementptr inbounds i8, ptr %0, i64 8
  %7 = shufflevector <2 x float> %1, <2 x float> %2, <4 x i32> <i32 0, i32 1, i32 2, i32 3>
  store <4 x float> %7, ptr %6, align 8, !tbaa !5
  %8 = tail call ptr @nk_command_buffer_push(ptr noundef nonnull %0, i32 noundef 1, i64 noundef 24)
  %.not25 = icmp eq ptr %8, null
  br i1 %.not25, label %16, label %9

9:                                                ; preds = %5
  %10 = fptosi <2 x float> %1 to <2 x i16>
  %11 = getelementptr inbounds i8, ptr %8, i64 16
  store <2 x i16> %10, ptr %11, align 8, !tbaa !9
  %12 = fcmp ogt <2 x float> %2, zeroinitializer
  %13 = getelementptr inbounds i8, ptr %8, i64 20
  %14 = select <2 x i1> %12, <2 x float> %2, <2 x float> zeroinitializer
  %15 = fptoui <2 x float> %14 to <2 x i16>
  store <2 x i16> %15, ptr %13, align 4, !tbaa !9
  br label %16

16:                                               ; preds = %5, %9
  ret void
}

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

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"="64" "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 }

!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 = !{!"float", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"short", !7, i64 0}


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