; 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_color = type { i8, i8, i8, i8 }
%struct.nk_command_buffer = type { ptr, %struct.nk_rect, i32, %union.nk_handle, i64, i64, i64 }
%union.nk_handle = type { ptr }
%struct.nk_command_image = type { %struct.nk_command, i16, i16, i16, i16, %struct.nk_image, %struct.nk_color }
%struct.nk_command = type { i32, i64 }
%struct.nk_image = type { %union.nk_handle, i16, i16, [4 x 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_draw_image = external hidden unnamed_addr constant [105 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_draw_image(ptr noundef %0, <2 x float> %1, <2 x float> %2, ptr noundef %3, i32 %4) #4 {
  %6 = alloca %struct.nk_rect, align 4
  %7 = alloca %struct.nk_color, align 1
  %8 = alloca ptr, align 8
  %9 = alloca ptr, align 8
  %10 = alloca ptr, align 8
  %11 = alloca i32, align 4
  %12 = alloca ptr, align 8
  %13 = getelementptr inbounds { <2 x float>, <2 x float> }, ptr %6, i32 0, i32 0
  store <2 x float> %1, ptr %13, align 4
  %14 = getelementptr inbounds { <2 x float>, <2 x float> }, ptr %6, i32 0, i32 1
  store <2 x float> %2, ptr %14, align 4
  store i32 %4, ptr %7, align 1
  store ptr %0, ptr %8, align 8, !tbaa !5
  store ptr %3, ptr %9, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #5
  %15 = load ptr, ptr %8, 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 9127, ptr noundef @__PRETTY_FUNCTION__.nk_draw_image) #6
  unreachable

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

22:                                               ; preds = %19
  store i32 1, ptr %11, align 4
  br label %133

23:                                               ; preds = %19
  %24 = load ptr, ptr %8, align 8, !tbaa !5
  %25 = getelementptr inbounds %struct.nk_command_buffer, ptr %24, i32 0, i32 2
  %26 = load i32, ptr %25, align 8, !tbaa !9
  %27 = icmp ne i32 %26, 0
  br i1 %27, label %28, label %87

28:                                               ; preds = %23
  call void @llvm.lifetime.start.p0(i64 8, ptr %12) #5
  %29 = load ptr, ptr %8, align 8, !tbaa !5
  %30 = getelementptr inbounds %struct.nk_command_buffer, ptr %29, i32 0, i32 1
  store ptr %30, ptr %12, align 8, !tbaa !5
  %31 = load ptr, ptr %12, align 8, !tbaa !5
  %32 = getelementptr inbounds %struct.nk_rect, ptr %31, i32 0, i32 2
  %33 = load float, ptr %32, align 4, !tbaa !15
  %34 = fcmp oeq float %33, 0.000000e+00
  br i1 %34, label %82, label %35

35:                                               ; preds = %28
  %36 = load ptr, ptr %12, align 8, !tbaa !5
  %37 = getelementptr inbounds %struct.nk_rect, ptr %36, i32 0, i32 3
  %38 = load float, ptr %37, align 4, !tbaa !16
  %39 = fcmp oeq float %38, 0.000000e+00
  br i1 %39, label %82, label %40

40:                                               ; preds = %35
  %41 = load ptr, ptr %12, align 8, !tbaa !5
  %42 = getelementptr inbounds %struct.nk_rect, ptr %41, i32 0, i32 0
  %43 = load float, ptr %42, align 4, !tbaa !17
  %44 = getelementptr inbounds %struct.nk_rect, ptr %6, i32 0, i32 0
  %45 = load float, ptr %44, align 4, !tbaa !17
  %46 = getelementptr inbounds %struct.nk_rect, ptr %6, i32 0, i32 2
  %47 = load float, ptr %46, align 4, !tbaa !15
  %48 = fadd float %45, %47
  %49 = fcmp ogt float %43, %48
  br i1 %49, label %82, label %50

50:                                               ; preds = %40
  %51 = load ptr, ptr %12, align 8, !tbaa !5
  %52 = getelementptr inbounds %struct.nk_rect, ptr %51, i32 0, i32 0
  %53 = load float, ptr %52, align 4, !tbaa !17
  %54 = load ptr, ptr %12, align 8, !tbaa !5
  %55 = getelementptr inbounds %struct.nk_rect, ptr %54, i32 0, i32 2
  %56 = load float, ptr %55, align 4, !tbaa !15
  %57 = fadd float %53, %56
  %58 = getelementptr inbounds %struct.nk_rect, ptr %6, i32 0, i32 0
  %59 = load float, ptr %58, align 4, !tbaa !17
  %60 = fcmp olt float %57, %59
  br i1 %60, label %82, label %61

61:                                               ; preds = %50
  %62 = load ptr, ptr %12, align 8, !tbaa !5
  %63 = getelementptr inbounds %struct.nk_rect, ptr %62, i32 0, i32 1
  %64 = load float, ptr %63, align 4, !tbaa !18
  %65 = getelementptr inbounds %struct.nk_rect, ptr %6, i32 0, i32 1
  %66 = load float, ptr %65, align 4, !tbaa !18
  %67 = getelementptr inbounds %struct.nk_rect, ptr %6, i32 0, i32 3
  %68 = load float, ptr %67, align 4, !tbaa !16
  %69 = fadd float %66, %68
  %70 = fcmp ogt float %64, %69
  br i1 %70, label %82, label %71

71:                                               ; preds = %61
  %72 = load ptr, ptr %12, align 8, !tbaa !5
  %73 = getelementptr inbounds %struct.nk_rect, ptr %72, i32 0, i32 1
  %74 = load float, ptr %73, align 4, !tbaa !18
  %75 = load ptr, ptr %12, align 8, !tbaa !5
  %76 = getelementptr inbounds %struct.nk_rect, ptr %75, i32 0, i32 3
  %77 = load float, ptr %76, align 4, !tbaa !16
  %78 = fadd float %74, %77
  %79 = getelementptr inbounds %struct.nk_rect, ptr %6, i32 0, i32 1
  %80 = load float, ptr %79, align 4, !tbaa !18
  %81 = fcmp olt float %78, %80
  br i1 %81, label %82, label %83

82:                                               ; preds = %71, %61, %50, %40, %35, %28
  store i32 1, ptr %11, align 4
  br label %84

83:                                               ; preds = %71
  store i32 0, ptr %11, align 4
  br label %84

84:                                               ; preds = %83, %82
  call void @llvm.lifetime.end.p0(i64 8, ptr %12) #5
  %85 = load i32, ptr %11, align 4
  switch i32 %85, label %133 [
    i32 0, label %86
  ]

86:                                               ; preds = %84
  br label %87

87:                                               ; preds = %86, %23
  %88 = load ptr, ptr %8, align 8, !tbaa !5
  %89 = call ptr @nk_command_buffer_push(ptr noundef %88, i32 noundef 17, i64 noundef 56)
  store ptr %89, ptr %10, align 8, !tbaa !5
  %90 = load ptr, ptr %10, align 8, !tbaa !5
  %91 = icmp ne ptr %90, null
  br i1 %91, label %93, label %92

92:                                               ; preds = %87
  store i32 1, ptr %11, align 4
  br label %133

93:                                               ; preds = %87
  %94 = getelementptr inbounds %struct.nk_rect, ptr %6, i32 0, i32 0
  %95 = load float, ptr %94, align 4, !tbaa !17
  %96 = fptosi float %95 to i16
  %97 = load ptr, ptr %10, align 8, !tbaa !5
  %98 = getelementptr inbounds %struct.nk_command_image, ptr %97, i32 0, i32 1
  store i16 %96, ptr %98, align 8, !tbaa !19
  %99 = getelementptr inbounds %struct.nk_rect, ptr %6, i32 0, i32 1
  %100 = load float, ptr %99, align 4, !tbaa !18
  %101 = fptosi float %100 to i16
  %102 = load ptr, ptr %10, align 8, !tbaa !5
  %103 = getelementptr inbounds %struct.nk_command_image, ptr %102, i32 0, i32 2
  store i16 %101, ptr %103, align 2, !tbaa !25
  %104 = getelementptr inbounds %struct.nk_rect, ptr %6, i32 0, i32 2
  %105 = load float, ptr %104, align 4, !tbaa !15
  %106 = fcmp olt float 0.000000e+00, %105
  br i1 %106, label %107, label %110

107:                                              ; preds = %93
  %108 = getelementptr inbounds %struct.nk_rect, ptr %6, i32 0, i32 2
  %109 = load float, ptr %108, align 4, !tbaa !15
  br label %111

110:                                              ; preds = %93
  br label %111

111:                                              ; preds = %110, %107
  %112 = phi float [ %109, %107 ], [ 0.000000e+00, %110 ]
  %113 = fptoui float %112 to i16
  %114 = load ptr, ptr %10, align 8, !tbaa !5
  %115 = getelementptr inbounds %struct.nk_command_image, ptr %114, i32 0, i32 3
  store i16 %113, ptr %115, align 4, !tbaa !26
  %116 = getelementptr inbounds %struct.nk_rect, ptr %6, i32 0, i32 3
  %117 = load float, ptr %116, align 4, !tbaa !16
  %118 = fcmp olt float 0.000000e+00, %117
  br i1 %118, label %119, label %122

119:                                              ; preds = %111
  %120 = getelementptr inbounds %struct.nk_rect, ptr %6, i32 0, i32 3
  %121 = load float, ptr %120, align 4, !tbaa !16
  br label %123

122:                                              ; preds = %111
  br label %123

123:                                              ; preds = %122, %119
  %124 = phi float [ %121, %119 ], [ 0.000000e+00, %122 ]
  %125 = fptoui float %124 to i16
  %126 = load ptr, ptr %10, align 8, !tbaa !5
  %127 = getelementptr inbounds %struct.nk_command_image, ptr %126, i32 0, i32 4
  store i16 %125, ptr %127, align 2, !tbaa !27
  %128 = load ptr, ptr %10, align 8, !tbaa !5
  %129 = getelementptr inbounds %struct.nk_command_image, ptr %128, i32 0, i32 5
  %130 = load ptr, ptr %9, align 8, !tbaa !5
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %129, ptr align 8 %130, i64 24, i1 false), !tbaa.struct !28
  %131 = load ptr, ptr %10, align 8, !tbaa !5
  %132 = getelementptr inbounds %struct.nk_command_image, ptr %131, i32 0, i32 6
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %132, ptr align 1 %7, i64 4, i1 false), !tbaa.struct !31
  store i32 0, ptr %11, align 4
  br label %133

133:                                              ; preds = %123, %92, %84, %22
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #5
  %134 = load i32, ptr %11, align 4
  switch i32 %134, label %136 [
    i32 0, label %135
    i32 1, label %135
  ]

135:                                              ; preds = %133, %133
  ret void

136:                                              ; preds = %133
  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 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 #5 = { nounwind }
attributes #6 = { 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, !13, i64 24}
!10 = !{!"nk_command_buffer", !6, i64 0, !11, i64 8, !13, i64 24, !7, i64 32, !14, i64 40, !14, i64 48, !14, i64 56}
!11 = !{!"nk_rect", !12, i64 0, !12, i64 4, !12, i64 8, !12, i64 12}
!12 = !{!"float", !7, i64 0}
!13 = !{!"int", !7, i64 0}
!14 = !{!"long", !7, i64 0}
!15 = !{!11, !12, i64 8}
!16 = !{!11, !12, i64 12}
!17 = !{!11, !12, i64 0}
!18 = !{!11, !12, i64 4}
!19 = !{!20, !22, i64 16}
!20 = !{!"nk_command_image", !21, i64 0, !22, i64 16, !22, i64 18, !22, i64 20, !22, i64 22, !23, i64 24, !24, i64 48}
!21 = !{!"nk_command", !13, i64 0, !14, i64 8}
!22 = !{!"short", !7, i64 0}
!23 = !{!"nk_image", !7, i64 0, !22, i64 8, !22, i64 10, !7, i64 12}
!24 = !{!"nk_color", !7, i64 0, !7, i64 1, !7, i64 2, !7, i64 3}
!25 = !{!20, !22, i64 18}
!26 = !{!20, !22, i64 20}
!27 = !{!20, !22, i64 22}
!28 = !{i64 0, i64 8, !29, i64 8, i64 2, !30, i64 10, i64 2, !30, i64 12, i64 8, !29}
!29 = !{!7, !7, i64 0}
!30 = !{!22, !22, i64 0}
!31 = !{i64 0, i64 1, !29, i64 1, i64 1, !29, i64 2, i64 1, !29, i64 3, i64 1, !29}


; 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_draw_image = external hidden unnamed_addr constant [105 x i8], align 1

; Function Attrs: mustprogress 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) #0

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

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

; Function Attrs: nounwind uwtable
define dso_local void @nk_draw_image(ptr noundef %0, <2 x float> %1, <2 x float> %2, ptr nocapture noundef readonly %3, i32 %4) local_unnamed_addr #3 {
  %.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 9127, ptr noundef nonnull @__PRETTY_FUNCTION__.nk_draw_image) #4
  unreachable

7:                                                ; preds = %5
  %8 = getelementptr inbounds i8, ptr %0, i64 24
  %9 = load i32, ptr %8, align 8, !tbaa !5
  %.not44 = icmp eq i32 %9, 0
  br i1 %.not44, label %.critedge, label %10

10:                                               ; preds = %7
  %11 = getelementptr inbounds i8, ptr %0, i64 8
  %12 = getelementptr inbounds i8, ptr %0, i64 16
  %13 = load float, ptr %12, align 4, !tbaa !14
  %14 = fcmp oeq float %13, 0.000000e+00
  br i1 %14, label %44, label %15

15:                                               ; preds = %10
  %16 = getelementptr inbounds i8, ptr %0, i64 20
  %17 = load float, ptr %16, align 4, !tbaa !15
  %18 = fcmp oeq float %17, 0.000000e+00
  br i1 %18, label %44, label %19

19:                                               ; preds = %15
  %20 = load float, ptr %11, align 4, !tbaa !16
  %.sroa.021.0.vec.extract = extractelement <2 x float> %1, i64 0
  %21 = fadd <2 x float> %1, %2
  %22 = extractelement <2 x float> %21, i64 0
  %23 = fcmp ogt float %20, %22
  %24 = fadd float %13, %20
  %25 = fcmp olt float %24, %.sroa.021.0.vec.extract
  %or.cond = or i1 %23, %25
  br i1 %or.cond, label %44, label %26

26:                                               ; preds = %19
  %27 = getelementptr inbounds i8, ptr %0, i64 12
  %28 = load float, ptr %27, align 4, !tbaa !17
  %.sroa.021.4.vec.extract = extractelement <2 x float> %1, i64 1
  %29 = fadd <2 x float> %1, %2
  %30 = extractelement <2 x float> %29, i64 1
  %31 = fcmp ogt float %28, %30
  %32 = fadd float %17, %28
  %33 = fcmp olt float %32, %.sroa.021.4.vec.extract
  %or.cond48 = or i1 %31, %33
  br i1 %or.cond48, label %44, label %.critedge

.critedge:                                        ; preds = %26, %7
  %34 = tail call ptr @nk_command_buffer_push(ptr noundef nonnull %0, i32 noundef 17, i64 noundef 56)
  %.not45 = icmp eq ptr %34, null
  br i1 %.not45, label %44, label %35

35:                                               ; preds = %.critedge
  %36 = getelementptr inbounds i8, ptr %34, i64 16
  %37 = fptosi <2 x float> %1 to <2 x i16>
  store <2 x i16> %37, ptr %36, align 8, !tbaa !18
  %38 = getelementptr inbounds i8, ptr %34, i64 20
  %39 = fcmp ogt <2 x float> %2, zeroinitializer
  %40 = select <2 x i1> %39, <2 x float> %2, <2 x float> zeroinitializer
  %41 = fptoui <2 x float> %40 to <2 x i16>
  store <2 x i16> %41, ptr %38, align 4, !tbaa !18
  %42 = getelementptr inbounds i8, ptr %34, i64 24
  tail call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 8 dereferenceable(24) %42, ptr noundef nonnull align 8 dereferenceable(24) %3, i64 24, i1 false), !tbaa.struct !20
  %43 = getelementptr inbounds i8, ptr %34, i64 48
  store i32 %4, ptr %43, align 8
  br label %44

44:                                               ; preds = %.critedge, %26, %19, %15, %10, %35
  ret void
}

attributes #0 = { mustprogress nocallback nofree 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 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 #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, !12, i64 24}
!6 = !{!"nk_command_buffer", !7, i64 0, !10, i64 8, !12, i64 24, !8, i64 32, !13, i64 40, !13, i64 48, !13, i64 56}
!7 = !{!"any pointer", !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 = !{!"int", !8, i64 0}
!13 = !{!"long", !8, i64 0}
!14 = !{!10, !11, i64 8}
!15 = !{!10, !11, i64 12}
!16 = !{!10, !11, i64 0}
!17 = !{!10, !11, i64 4}
!18 = !{!19, !19, i64 0}
!19 = !{!"short", !8, i64 0}
!20 = !{i64 0, i64 8, !21, i64 8, i64 2, !18, i64 10, i64 2, !18, i64 12, i64 8, !21}
!21 = !{!8, !8, i64 0}


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