; 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_color = type { i8, i8, i8, i8 }
%struct.nk_command_polygon = type { %struct.nk_command, %struct.nk_color, i16, i16, [1 x %struct.nk_vec2i] }
%struct.nk_command = type { i32, i64 }
%struct.nk_vec2i = type { i16, i16 }

@.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_stroke_polygon = external hidden unnamed_addr constant [89 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: nocallback nofree nounwind willreturn memory(argmem: readwrite)
declare void @llvm.memcpy.p0.p0.i64(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i64, i1 immarg) #1

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

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

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

17:                                               ; preds = %5
  br label %19

18:                                               ; preds = %5
  call void @__assert_fail(ptr noundef @.str.11, ptr noundef @.str.2, i32 noundef 9067, ptr noundef @__PRETTY_FUNCTION__.nk_stroke_polygon) #5
  unreachable

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

22:                                               ; preds = %19
  %23 = getelementptr inbounds %struct.nk_color, ptr %6, i32 0, i32 3
  %24 = load i8, ptr %23, align 1, !tbaa !15
  %25 = zext i8 %24 to i32
  %26 = icmp eq i32 %25, 0
  br i1 %26, label %30, label %27

27:                                               ; preds = %22
  %28 = load float, ptr %10, align 4, !tbaa !11
  %29 = fcmp ole float %28, 0.000000e+00
  br i1 %29, label %30, label %31

30:                                               ; preds = %27, %22, %19
  store i32 1, ptr %14, align 4
  br label %89

31:                                               ; preds = %27
  %32 = load i32, ptr %9, align 4, !tbaa !9
  %33 = sext i32 %32 to i64
  %34 = mul i64 4, %33
  %35 = add i64 32, %34
  store i64 %35, ptr %12, align 8, !tbaa !13
  %36 = load ptr, ptr %7, align 8, !tbaa !5
  %37 = load i64, ptr %12, align 8, !tbaa !13
  %38 = call ptr @nk_command_buffer_push(ptr noundef %36, i32 noundef 13, i64 noundef %37)
  store ptr %38, ptr %13, align 8, !tbaa !5
  %39 = load ptr, ptr %13, align 8, !tbaa !5
  %40 = icmp ne ptr %39, null
  br i1 %40, label %42, label %41

41:                                               ; preds = %31
  store i32 1, ptr %14, align 4
  br label %89

42:                                               ; preds = %31
  %43 = load ptr, ptr %13, align 8, !tbaa !5
  %44 = getelementptr inbounds %struct.nk_command_polygon, ptr %43, i32 0, i32 1
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %44, ptr align 1 %6, i64 4, i1 false), !tbaa.struct !17
  %45 = load float, ptr %10, align 4, !tbaa !11
  %46 = fptoui float %45 to i16
  %47 = load ptr, ptr %13, align 8, !tbaa !5
  %48 = getelementptr inbounds %struct.nk_command_polygon, ptr %47, i32 0, i32 2
  store i16 %46, ptr %48, align 4, !tbaa !19
  %49 = load i32, ptr %9, align 4, !tbaa !9
  %50 = trunc i32 %49 to i16
  %51 = load ptr, ptr %13, align 8, !tbaa !5
  %52 = getelementptr inbounds %struct.nk_command_polygon, ptr %51, i32 0, i32 3
  store i16 %50, ptr %52, align 2, !tbaa !23
  store i32 0, ptr %11, align 4, !tbaa !9
  br label %53

53:                                               ; preds = %85, %42
  %54 = load i32, ptr %11, align 4, !tbaa !9
  %55 = load i32, ptr %9, align 4, !tbaa !9
  %56 = icmp slt i32 %54, %55
  br i1 %56, label %57, label %88

57:                                               ; preds = %53
  %58 = load ptr, ptr %8, align 8, !tbaa !5
  %59 = load i32, ptr %11, align 4, !tbaa !9
  %60 = mul nsw i32 %59, 2
  %61 = sext i32 %60 to i64
  %62 = getelementptr inbounds float, ptr %58, i64 %61
  %63 = load float, ptr %62, align 4, !tbaa !11
  %64 = fptosi float %63 to i16
  %65 = load ptr, ptr %13, align 8, !tbaa !5
  %66 = getelementptr inbounds %struct.nk_command_polygon, ptr %65, i32 0, i32 4
  %67 = load i32, ptr %11, align 4, !tbaa !9
  %68 = sext i32 %67 to i64
  %69 = getelementptr inbounds [1 x %struct.nk_vec2i], ptr %66, i64 0, i64 %68
  %70 = getelementptr inbounds %struct.nk_vec2i, ptr %69, i32 0, i32 0
  store i16 %64, ptr %70, align 4, !tbaa !24
  %71 = load ptr, ptr %8, align 8, !tbaa !5
  %72 = load i32, ptr %11, align 4, !tbaa !9
  %73 = mul nsw i32 %72, 2
  %74 = add nsw i32 %73, 1
  %75 = sext i32 %74 to i64
  %76 = getelementptr inbounds float, ptr %71, i64 %75
  %77 = load float, ptr %76, align 4, !tbaa !11
  %78 = fptosi float %77 to i16
  %79 = load ptr, ptr %13, align 8, !tbaa !5
  %80 = getelementptr inbounds %struct.nk_command_polygon, ptr %79, i32 0, i32 4
  %81 = load i32, ptr %11, align 4, !tbaa !9
  %82 = sext i32 %81 to i64
  %83 = getelementptr inbounds [1 x %struct.nk_vec2i], ptr %80, i64 0, i64 %82
  %84 = getelementptr inbounds %struct.nk_vec2i, ptr %83, i32 0, i32 1
  store i16 %78, ptr %84, align 2, !tbaa !26
  br label %85

85:                                               ; preds = %57
  %86 = load i32, ptr %11, align 4, !tbaa !9
  %87 = add nsw i32 %86, 1
  store i32 %87, ptr %11, align 4, !tbaa !9
  br label %53, !llvm.loop !27

88:                                               ; preds = %53
  store i32 0, ptr %14, align 4
  br label %89

89:                                               ; preds = %88, %41, %30
  call void @llvm.lifetime.end.p0(i64 8, ptr %13) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %12) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #4
  %90 = load i32, ptr %14, align 4
  switch i32 %90, label %92 [
    i32 0, label %91
    i32 1, label %91
  ]

91:                                               ; preds = %89, %89
  ret void

92:                                               ; preds = %89
  unreachable
}

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { 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 #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, !10, i64 0}
!10 = !{!"int", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"float", !7, i64 0}
!13 = !{!14, !14, i64 0}
!14 = !{!"long", !7, i64 0}
!15 = !{!16, !7, i64 3}
!16 = !{!"nk_color", !7, i64 0, !7, i64 1, !7, i64 2, !7, i64 3}
!17 = !{i64 0, i64 1, !18, i64 1, i64 1, !18, i64 2, i64 1, !18, i64 3, i64 1, !18}
!18 = !{!7, !7, i64 0}
!19 = !{!20, !22, i64 20}
!20 = !{!"nk_command_polygon", !21, i64 0, !16, i64 16, !22, i64 20, !22, i64 22, !7, i64 24}
!21 = !{!"nk_command", !10, i64 0, !14, i64 8}
!22 = !{!"short", !7, i64 0}
!23 = !{!20, !22, i64 22}
!24 = !{!25, !22, i64 0}
!25 = !{!"nk_vec2i", !22, i64 0, !22, i64 2}
!26 = !{!25, !22, i64 2}
!27 = distinct !{!27, !28}
!28 = !{!"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"

%struct.nk_vec2i = type { i16, i16 }

@.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_stroke_polygon = external hidden unnamed_addr constant [89 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 hidden ptr @nk_command_buffer_push(ptr noundef, i32 noundef, i64 noundef) local_unnamed_addr #1

; Function Attrs: nounwind uwtable
define dso_local void @nk_stroke_polygon(ptr noundef %0, ptr nocapture noundef readonly %1, i32 noundef %2, float noundef %3, i32 %4) local_unnamed_addr #1 {
  %.sroa.0.0.extract.trunc = trunc i32 %4 to i24
  %.sroa.2.0.extract.shift = lshr i32 %4, 24
  %.sroa.2.0.extract.trunc = trunc nuw i32 %.sroa.2.0.extract.shift to i8
  %.not = icmp eq ptr %0, null
  br i1 %.not, label %6, label %7

6:                                                ; preds = %5
  tail call void @__assert_fail(ptr noundef nonnull @.str.11, ptr noundef nonnull @.str.2, i32 noundef 9067, ptr noundef nonnull @__PRETTY_FUNCTION__.nk_stroke_polygon) #2
  unreachable

7:                                                ; preds = %5
  %8 = icmp ult i32 %4, 16777216
  %9 = fcmp ole float %3, 0.000000e+00
  %or.cond5 = or i1 %9, %8
  br i1 %or.cond5, label %.loopexit, label %10

10:                                               ; preds = %7
  %11 = sext i32 %2 to i64
  %12 = shl nsw i64 %11, 2
  %13 = add nsw i64 %12, 32
  %14 = tail call ptr @nk_command_buffer_push(ptr noundef nonnull %0, i32 noundef 13, i64 noundef %13)
  %.not30 = icmp eq ptr %14, null
  br i1 %.not30, label %.loopexit, label %15

15:                                               ; preds = %10
  %16 = getelementptr inbounds i8, ptr %14, i64 16
  store i24 %.sroa.0.0.extract.trunc, ptr %16, align 8
  %.sroa.2.0..sroa_idx = getelementptr inbounds i8, ptr %14, i64 19
  store i8 %.sroa.2.0.extract.trunc, ptr %.sroa.2.0..sroa_idx, align 1, !tbaa !5
  %17 = fptoui float %3 to i16
  %18 = getelementptr inbounds i8, ptr %14, i64 20
  store i16 %17, ptr %18, align 4, !tbaa !8
  %19 = trunc i32 %2 to i16
  %20 = getelementptr inbounds i8, ptr %14, i64 22
  store i16 %19, ptr %20, align 2, !tbaa !15
  %21 = icmp sgt i32 %2, 0
  br i1 %21, label %.lr.ph, label %.loopexit

.lr.ph:                                           ; preds = %15
  %22 = getelementptr inbounds i8, ptr %14, i64 24
  %wide.trip.count = zext nneg i32 %2 to i64
  %min.iters.check = icmp ult i32 %2, 4
  br i1 %min.iters.check, label %scalar.ph.preheader, label %vector.ph

vector.ph:                                        ; preds = %.lr.ph
  %n.vec = and i64 %wide.trip.count, 2147483644
  br label %vector.body

vector.body:                                      ; preds = %vector.body, %vector.ph
  %index = phi i64 [ 0, %vector.ph ], [ %index.next, %vector.body ]
  %.idx = shl nsw i64 %index, 3
  %23 = getelementptr inbounds i8, ptr %1, i64 %.idx
  %24 = load <8 x float>, ptr %23, align 4, !tbaa !16
  %25 = getelementptr inbounds [1 x %struct.nk_vec2i], ptr %22, i64 0, i64 %index
  %interleaved.vec = fptosi <8 x float> %24 to <8 x i16>
  store <8 x i16> %interleaved.vec, ptr %25, align 2, !tbaa !18
  %index.next = add nuw i64 %index, 4
  %26 = icmp eq i64 %index.next, %n.vec
  br i1 %26, label %middle.block, label %vector.body, !llvm.loop !19

middle.block:                                     ; preds = %vector.body
  %cmp.n = icmp eq i64 %n.vec, %wide.trip.count
  br i1 %cmp.n, label %.loopexit, label %scalar.ph.preheader

scalar.ph.preheader:                              ; preds = %middle.block, %.lr.ph
  %indvars.iv.ph = phi i64 [ 0, %.lr.ph ], [ %n.vec, %middle.block ]
  br label %scalar.ph

scalar.ph:                                        ; preds = %scalar.ph.preheader, %scalar.ph
  %indvars.iv = phi i64 [ %indvars.iv.next, %scalar.ph ], [ %indvars.iv.ph, %scalar.ph.preheader ]
  %.idx34 = shl nsw i64 %indvars.iv, 3
  %27 = getelementptr inbounds i8, ptr %1, i64 %.idx34
  %28 = getelementptr inbounds [1 x %struct.nk_vec2i], ptr %22, i64 0, i64 %indvars.iv
  %29 = load <2 x float>, ptr %27, align 4, !tbaa !16
  %30 = fptosi <2 x float> %29 to <2 x i16>
  store <2 x i16> %30, ptr %28, align 4, !tbaa !18
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %exitcond.not = icmp eq i64 %indvars.iv.next, %wide.trip.count
  br i1 %exitcond.not, label %.loopexit, label %scalar.ph, !llvm.loop !23

.loopexit:                                        ; preds = %scalar.ph, %middle.block, %15, %10, %7
  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 = !{!"omnipotent char", !7, i64 0}
!7 = !{!"Simple C/C++ TBAA"}
!8 = !{!9, !14, i64 20}
!9 = !{!"nk_command_polygon", !10, i64 0, !13, i64 16, !14, i64 20, !14, i64 22, !6, i64 24}
!10 = !{!"nk_command", !11, i64 0, !12, i64 8}
!11 = !{!"int", !6, i64 0}
!12 = !{!"long", !6, i64 0}
!13 = !{!"nk_color", !6, i64 0, !6, i64 1, !6, i64 2, !6, i64 3}
!14 = !{!"short", !6, i64 0}
!15 = !{!9, !14, i64 22}
!16 = !{!17, !17, i64 0}
!17 = !{!"float", !6, i64 0}
!18 = !{!14, !14, i64 0}
!19 = distinct !{!19, !20, !21, !22}
!20 = !{!"llvm.loop.mustprogress"}
!21 = !{!"llvm.loop.isvectorized", i32 1}
!22 = !{!"llvm.loop.unroll.runtime.disable"}
!23 = distinct !{!23, !20, !22, !21}


; Effective O3 passes: EarlyCSEPass,GlobalOptPass,IPSCCPPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,LICMPass,LoopLoadEliminationPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,LoopVectorizePass,PostOrderFunctionAttrsPass,ReassociatePass,SLPVectorizerPass,SROAPass,SimplifyCFGPass,TailCallElimPass,VectorCombinePass