; 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_filled = type { %struct.nk_command, %struct.nk_color, 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_fill_polygon = external hidden unnamed_addr constant [80 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_fill_polygon(ptr noundef %0, ptr noundef %1, i32 noundef %2, i32 %3) #3 {
  %5 = alloca %struct.nk_color, align 1
  %6 = alloca ptr, align 8
  %7 = alloca ptr, align 8
  %8 = alloca i32, align 4
  %9 = alloca i32, align 4
  %10 = alloca i64, align 8
  %11 = alloca ptr, align 8
  %12 = alloca i32, align 4
  store i32 %3, ptr %5, align 1
  store ptr %0, ptr %6, align 8, !tbaa !5
  store ptr %1, ptr %7, align 8, !tbaa !5
  store i32 %2, ptr %8, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #4
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #4
  store i64 0, ptr %10, align 8, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 8, ptr %11) #4
  %13 = load ptr, ptr %6, align 8, !tbaa !5
  %14 = icmp ne ptr %13, null
  br i1 %14, label %15, label %16

15:                                               ; preds = %4
  br label %17

16:                                               ; preds = %4
  call void @__assert_fail(ptr noundef @.str.11, ptr noundef @.str.2, i32 noundef 9088, ptr noundef @__PRETTY_FUNCTION__.nk_fill_polygon) #5
  unreachable

17:                                               ; preds = %15
  %18 = load ptr, ptr %6, align 8, !tbaa !5
  %19 = icmp ne ptr %18, null
  br i1 %19, label %20, label %25

20:                                               ; preds = %17
  %21 = getelementptr inbounds %struct.nk_color, ptr %5, i32 0, i32 3
  %22 = load i8, ptr %21, align 1, !tbaa !13
  %23 = zext i8 %22 to i32
  %24 = icmp eq i32 %23, 0
  br i1 %24, label %25, label %26

25:                                               ; preds = %20, %17
  store i32 1, ptr %12, align 4
  br label %81

26:                                               ; preds = %20
  %27 = load i32, ptr %8, align 4, !tbaa !9
  %28 = sext i32 %27 to i64
  %29 = mul i64 4, %28
  %30 = add i64 32, %29
  store i64 %30, ptr %10, align 8, !tbaa !11
  %31 = load ptr, ptr %6, align 8, !tbaa !5
  %32 = load i64, ptr %10, align 8, !tbaa !11
  %33 = call ptr @nk_command_buffer_push(ptr noundef %31, i32 noundef 14, i64 noundef %32)
  store ptr %33, ptr %11, align 8, !tbaa !5
  %34 = load ptr, ptr %11, align 8, !tbaa !5
  %35 = icmp ne ptr %34, null
  br i1 %35, label %37, label %36

36:                                               ; preds = %26
  store i32 1, ptr %12, align 4
  br label %81

37:                                               ; preds = %26
  %38 = load ptr, ptr %11, align 8, !tbaa !5
  %39 = getelementptr inbounds %struct.nk_command_polygon_filled, ptr %38, i32 0, i32 1
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %39, ptr align 1 %5, i64 4, i1 false), !tbaa.struct !15
  %40 = load i32, ptr %8, align 4, !tbaa !9
  %41 = trunc i32 %40 to i16
  %42 = load ptr, ptr %11, align 8, !tbaa !5
  %43 = getelementptr inbounds %struct.nk_command_polygon_filled, ptr %42, i32 0, i32 2
  store i16 %41, ptr %43, align 4, !tbaa !17
  store i32 0, ptr %9, align 4, !tbaa !9
  br label %44

44:                                               ; preds = %77, %37
  %45 = load i32, ptr %9, align 4, !tbaa !9
  %46 = load i32, ptr %8, align 4, !tbaa !9
  %47 = icmp slt i32 %45, %46
  br i1 %47, label %48, label %80

48:                                               ; preds = %44
  %49 = load ptr, ptr %7, align 8, !tbaa !5
  %50 = load i32, ptr %9, align 4, !tbaa !9
  %51 = mul nsw i32 %50, 2
  %52 = add nsw i32 %51, 0
  %53 = sext i32 %52 to i64
  %54 = getelementptr inbounds float, ptr %49, i64 %53
  %55 = load float, ptr %54, align 4, !tbaa !21
  %56 = fptosi float %55 to i16
  %57 = load ptr, ptr %11, align 8, !tbaa !5
  %58 = getelementptr inbounds %struct.nk_command_polygon_filled, ptr %57, i32 0, i32 3
  %59 = load i32, ptr %9, align 4, !tbaa !9
  %60 = sext i32 %59 to i64
  %61 = getelementptr inbounds [1 x %struct.nk_vec2i], ptr %58, i64 0, i64 %60
  %62 = getelementptr inbounds %struct.nk_vec2i, ptr %61, i32 0, i32 0
  store i16 %56, ptr %62, align 2, !tbaa !23
  %63 = load ptr, ptr %7, align 8, !tbaa !5
  %64 = load i32, ptr %9, align 4, !tbaa !9
  %65 = mul nsw i32 %64, 2
  %66 = add nsw i32 %65, 1
  %67 = sext i32 %66 to i64
  %68 = getelementptr inbounds float, ptr %63, i64 %67
  %69 = load float, ptr %68, align 4, !tbaa !21
  %70 = fptosi float %69 to i16
  %71 = load ptr, ptr %11, align 8, !tbaa !5
  %72 = getelementptr inbounds %struct.nk_command_polygon_filled, ptr %71, i32 0, i32 3
  %73 = load i32, ptr %9, align 4, !tbaa !9
  %74 = sext i32 %73 to i64
  %75 = getelementptr inbounds [1 x %struct.nk_vec2i], ptr %72, i64 0, i64 %74
  %76 = getelementptr inbounds %struct.nk_vec2i, ptr %75, i32 0, i32 1
  store i16 %70, ptr %76, align 2, !tbaa !25
  br label %77

77:                                               ; preds = %48
  %78 = load i32, ptr %9, align 4, !tbaa !9
  %79 = add nsw i32 %78, 1
  store i32 %79, ptr %9, align 4, !tbaa !9
  br label %44, !llvm.loop !26

80:                                               ; preds = %44
  store i32 0, ptr %12, align 4
  br label %81

81:                                               ; preds = %80, %36, %25
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #4
  %82 = load i32, ptr %12, align 4
  switch i32 %82, label %84 [
    i32 0, label %83
    i32 1, label %83
  ]

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

84:                                               ; preds = %81
  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 = !{!"long", !7, i64 0}
!13 = !{!14, !7, i64 3}
!14 = !{!"nk_color", !7, i64 0, !7, i64 1, !7, i64 2, !7, i64 3}
!15 = !{i64 0, i64 1, !16, i64 1, i64 1, !16, i64 2, i64 1, !16, i64 3, i64 1, !16}
!16 = !{!7, !7, i64 0}
!17 = !{!18, !20, i64 20}
!18 = !{!"nk_command_polygon_filled", !19, i64 0, !14, i64 16, !20, i64 20, !7, i64 22}
!19 = !{!"nk_command", !10, i64 0, !12, i64 8}
!20 = !{!"short", !7, i64 0}
!21 = !{!22, !22, i64 0}
!22 = !{!"float", !7, i64 0}
!23 = !{!24, !20, i64 0}
!24 = !{!"nk_vec2i", !20, i64 0, !20, i64 2}
!25 = !{!24, !20, i64 2}
!26 = distinct !{!26, !27}
!27 = !{!"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_fill_polygon = external hidden unnamed_addr constant [80 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_fill_polygon(ptr noundef %0, ptr nocapture noundef readonly %1, i32 noundef %2, i32 %3) local_unnamed_addr #1 {
  %.sroa.0.0.extract.trunc = trunc i32 %3 to i24
  %.sroa.2.0.extract.shift = lshr i32 %3, 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 %5, label %6

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

6:                                                ; preds = %4
  %7 = icmp ult i32 %3, 16777216
  br i1 %7, label %.loopexit, label %8

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

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

.lr.ph:                                           ; preds = %13
  %18 = getelementptr inbounds i8, ptr %12, i64 22
  %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
  %19 = getelementptr inbounds i8, ptr %1, i64 %.idx
  %20 = load <8 x float>, ptr %19, align 4, !tbaa !15
  %21 = getelementptr inbounds [1 x %struct.nk_vec2i], ptr %18, i64 0, i64 %index
  %interleaved.vec = fptosi <8 x float> %20 to <8 x i16>
  store <8 x i16> %interleaved.vec, ptr %21, align 2, !tbaa !17
  %index.next = add nuw i64 %index, 4
  %22 = icmp eq i64 %index.next, %n.vec
  br i1 %22, label %middle.block, label %vector.body, !llvm.loop !18

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 ]
  %.idx28 = shl nsw i64 %indvars.iv, 3
  %23 = getelementptr inbounds i8, ptr %1, i64 %.idx28
  %24 = getelementptr inbounds [1 x %struct.nk_vec2i], ptr %18, i64 0, i64 %indvars.iv
  %25 = load <2 x float>, ptr %23, align 4, !tbaa !15
  %26 = fptosi <2 x float> %25 to <2 x i16>
  store <2 x i16> %26, ptr %24, align 2, !tbaa !17
  %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 !22

.loopexit:                                        ; preds = %scalar.ph, %middle.block, %13, %8, %6
  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_filled", !10, i64 0, !13, i64 16, !14, i64 20, !6, i64 22}
!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 = !{!16, !16, i64 0}
!16 = !{!"float", !6, i64 0}
!17 = !{!14, !14, i64 0}
!18 = distinct !{!18, !19, !20, !21}
!19 = !{!"llvm.loop.mustprogress"}
!20 = !{!"llvm.loop.isvectorized", i32 1}
!21 = !{!"llvm.loop.unroll.runtime.disable"}
!22 = distinct !{!22, !19, !21, !20}


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