; LLVM IR from NOAA-PMEL/Ferret :: xgks/src/lib (gd)

; 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.gdImageStruct = type { ptr, i32, i32, i32, [256 x i32], [256 x i32], [256 x i32], [256 x i32], i32, ptr, i32, ptr, ptr, [256 x i32], [256 x i32], i32, i32, ptr, i32, i32, i32, i32, i32 }

; 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: nounwind uwtable
define dso_local void @gdImageSetPixel(ptr noundef %0, i32 noundef %1, i32 noundef %2, i32 noundef %3) #1 {
  %5 = alloca ptr, align 8
  %6 = alloca i32, align 4
  %7 = alloca i32, align 4
  %8 = alloca i32, align 4
  %9 = alloca i32, align 4
  %10 = alloca i32, align 4
  store ptr %0, ptr %5, align 8, !tbaa !5
  store i32 %1, ptr %6, align 4, !tbaa !9
  store i32 %2, ptr %7, align 4, !tbaa !9
  store i32 %3, ptr %8, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #2
  %11 = load i32, ptr %6, align 4, !tbaa !9
  %12 = load ptr, ptr %5, align 8, !tbaa !5
  %13 = getelementptr inbounds %struct.gdImageStruct, ptr %12, i32 0, i32 19
  %14 = load i32, ptr %13, align 4, !tbaa !11
  %15 = icmp slt i32 %11, %14
  br i1 %15, label %34, label %16

16:                                               ; preds = %4
  %17 = load i32, ptr %6, align 4, !tbaa !9
  %18 = load ptr, ptr %5, align 8, !tbaa !5
  %19 = getelementptr inbounds %struct.gdImageStruct, ptr %18, i32 0, i32 21
  %20 = load i32, ptr %19, align 4, !tbaa !13
  %21 = icmp sgt i32 %17, %20
  br i1 %21, label %34, label %22

22:                                               ; preds = %16
  %23 = load i32, ptr %7, align 4, !tbaa !9
  %24 = load ptr, ptr %5, align 8, !tbaa !5
  %25 = getelementptr inbounds %struct.gdImageStruct, ptr %24, i32 0, i32 20
  %26 = load i32, ptr %25, align 8, !tbaa !14
  %27 = icmp slt i32 %23, %26
  br i1 %27, label %34, label %28

28:                                               ; preds = %22
  %29 = load i32, ptr %7, align 4, !tbaa !9
  %30 = load ptr, ptr %5, align 8, !tbaa !5
  %31 = getelementptr inbounds %struct.gdImageStruct, ptr %30, i32 0, i32 22
  %32 = load i32, ptr %31, align 8, !tbaa !15
  %33 = icmp sgt i32 %29, %32
  br i1 %33, label %34, label %35

34:                                               ; preds = %28, %22, %16, %4
  store i32 1, ptr %10, align 4
  br label %106

35:                                               ; preds = %28
  %36 = load i32, ptr %8, align 4, !tbaa !9
  switch i32 %36, label %85 [
    i32 -2, label %37
    i32 -4, label %56
    i32 -3, label %77
    i32 -5, label %81
  ]

37:                                               ; preds = %35
  %38 = load ptr, ptr %5, align 8, !tbaa !5
  %39 = getelementptr inbounds %struct.gdImageStruct, ptr %38, i32 0, i32 17
  %40 = load ptr, ptr %39, align 8, !tbaa !16
  %41 = icmp ne ptr %40, null
  br i1 %41, label %43, label %42

42:                                               ; preds = %37
  store i32 1, ptr %10, align 4
  br label %106

43:                                               ; preds = %37
  %44 = load ptr, ptr %5, align 8, !tbaa !5
  %45 = load i32, ptr %6, align 4, !tbaa !9
  %46 = load i32, ptr %7, align 4, !tbaa !9
  %47 = call i32 @getStylePixel(ptr noundef %44, i32 noundef %45, i32 noundef %46)
  store i32 %47, ptr %9, align 4, !tbaa !9
  %48 = load i32, ptr %9, align 4, !tbaa !9
  %49 = icmp ne i32 %48, -6
  br i1 %49, label %50, label %55

50:                                               ; preds = %43
  %51 = load ptr, ptr %5, align 8, !tbaa !5
  %52 = load i32, ptr %6, align 4, !tbaa !9
  %53 = load i32, ptr %7, align 4, !tbaa !9
  %54 = load i32, ptr %9, align 4, !tbaa !9
  call void @gdImageSetPixel(ptr noundef %51, i32 noundef %52, i32 noundef %53, i32 noundef %54)
  br label %55

55:                                               ; preds = %50, %43
  br label %105

56:                                               ; preds = %35
  %57 = load ptr, ptr %5, align 8, !tbaa !5
  %58 = getelementptr inbounds %struct.gdImageStruct, ptr %57, i32 0, i32 17
  %59 = load ptr, ptr %58, align 8, !tbaa !16
  %60 = icmp ne ptr %59, null
  br i1 %60, label %62, label %61

61:                                               ; preds = %56
  store i32 1, ptr %10, align 4
  br label %106

62:                                               ; preds = %56
  %63 = load ptr, ptr %5, align 8, !tbaa !5
  %64 = load i32, ptr %6, align 4, !tbaa !9
  %65 = load i32, ptr %7, align 4, !tbaa !9
  %66 = call i32 @getStylePixel(ptr noundef %63, i32 noundef %64, i32 noundef %65)
  store i32 %66, ptr %9, align 4, !tbaa !9
  %67 = load i32, ptr %9, align 4, !tbaa !9
  %68 = icmp ne i32 %67, -6
  br i1 %68, label %69, label %76

69:                                               ; preds = %62
  %70 = load i32, ptr %9, align 4, !tbaa !9
  %71 = icmp ne i32 %70, 0
  br i1 %71, label %72, label %76

72:                                               ; preds = %69
  %73 = load ptr, ptr %5, align 8, !tbaa !5
  %74 = load i32, ptr %6, align 4, !tbaa !9
  %75 = load i32, ptr %7, align 4, !tbaa !9
  call void @gdImageSetPixel(ptr noundef %73, i32 noundef %74, i32 noundef %75, i32 noundef -3)
  br label %76

76:                                               ; preds = %72, %69, %62
  br label %105

77:                                               ; preds = %35
  %78 = load ptr, ptr %5, align 8, !tbaa !5
  %79 = load i32, ptr %6, align 4, !tbaa !9
  %80 = load i32, ptr %7, align 4, !tbaa !9
  call void @gdImageBrushApply(ptr noundef %78, i32 noundef %79, i32 noundef %80)
  br label %105

81:                                               ; preds = %35
  %82 = load ptr, ptr %5, align 8, !tbaa !5
  %83 = load i32, ptr %6, align 4, !tbaa !9
  %84 = load i32, ptr %7, align 4, !tbaa !9
  call void @gdImageTileApply(ptr noundef %82, i32 noundef %83, i32 noundef %84)
  br label %105

85:                                               ; preds = %35
  %86 = load ptr, ptr %5, align 8, !tbaa !5
  %87 = load i32, ptr %6, align 4, !tbaa !9
  %88 = load i32, ptr %7, align 4, !tbaa !9
  %89 = call i32 @gdImageBoundsSafe(ptr noundef %86, i32 noundef %87, i32 noundef %88)
  %90 = icmp ne i32 %89, 0
  br i1 %90, label %91, label %104

91:                                               ; preds = %85
  %92 = load i32, ptr %8, align 4, !tbaa !9
  %93 = trunc i32 %92 to i8
  %94 = load ptr, ptr %5, align 8, !tbaa !5
  %95 = getelementptr inbounds %struct.gdImageStruct, ptr %94, i32 0, i32 0
  %96 = load ptr, ptr %95, align 8, !tbaa !17
  %97 = load i32, ptr %6, align 4, !tbaa !9
  %98 = sext i32 %97 to i64
  %99 = getelementptr inbounds ptr, ptr %96, i64 %98
  %100 = load ptr, ptr %99, align 8, !tbaa !5
  %101 = load i32, ptr %7, align 4, !tbaa !9
  %102 = sext i32 %101 to i64
  %103 = getelementptr inbounds i8, ptr %100, i64 %102
  store i8 %93, ptr %103, align 1, !tbaa !18
  br label %104

104:                                              ; preds = %91, %85
  br label %105

105:                                              ; preds = %104, %81, %77, %76, %55
  store i32 0, ptr %10, align 4
  br label %106

106:                                              ; preds = %105, %61, %42, %34
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #2
  %107 = load i32, ptr %10, align 4
  switch i32 %107, label %109 [
    i32 0, label %108
    i32 1, label %108
  ]

108:                                              ; preds = %106, %106
  ret void

109:                                              ; preds = %106
  unreachable
}

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

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

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

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

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 = { 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 6220}
!12 = !{!"gdImageStruct", !6, i64 0, !10, i64 8, !10, i64 12, !10, i64 16, !7, i64 20, !7, i64 1044, !7, i64 2068, !7, i64 3092, !10, i64 4116, !6, i64 4120, !10, i64 4128, !6, i64 4136, !6, i64 4144, !7, i64 4152, !7, i64 5176, !10, i64 6200, !10, i64 6204, !6, i64 6208, !10, i64 6216, !10, i64 6220, !10, i64 6224, !10, i64 6228, !10, i64 6232}
!13 = !{!12, !10, i64 6228}
!14 = !{!12, !10, i64 6224}
!15 = !{!12, !10, i64 6232}
!16 = !{!12, !6, i64 6208}
!17 = !{!12, !6, i64 0}
!18 = !{!7, !7, i64 0}


; 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"

; Function Attrs: nounwind uwtable
define dso_local void @gdImageSetPixel(ptr noundef %0, i32 noundef %1, i32 noundef %2, i32 noundef %3) local_unnamed_addr #0 {
  %5 = getelementptr inbounds i8, ptr %0, i64 6220
  %6 = load i32, ptr %5, align 4, !tbaa !5
  %7 = icmp sgt i32 %6, %1
  br i1 %7, label %.loopexit, label %.lr.ph

.lr.ph:                                           ; preds = %4
  %8 = getelementptr inbounds i8, ptr %0, i64 6228
  %9 = getelementptr inbounds i8, ptr %0, i64 6224
  %10 = getelementptr inbounds i8, ptr %0, i64 6232
  %11 = getelementptr inbounds i8, ptr %0, i64 6208
  br label %12

12:                                               ; preds = %.lr.ph, %tailrecurse.backedge
  %.tr4751 = phi i32 [ %3, %.lr.ph ], [ %.tr47.be, %tailrecurse.backedge ]
  %13 = load i32, ptr %8, align 4, !tbaa !11
  %14 = icmp slt i32 %13, %1
  br i1 %14, label %.loopexit, label %15

15:                                               ; preds = %12
  %16 = load i32, ptr %9, align 8, !tbaa !12
  %17 = icmp sgt i32 %16, %2
  br i1 %17, label %.loopexit, label %18

18:                                               ; preds = %15
  %19 = load i32, ptr %10, align 8, !tbaa !13
  %20 = icmp slt i32 %19, %2
  br i1 %20, label %.loopexit, label %21

21:                                               ; preds = %18
  switch i32 %.tr4751, label %34 [
    i32 -2, label %22
    i32 -4, label %28
    i32 -3, label %32
    i32 -5, label %33
  ]

22:                                               ; preds = %21
  %23 = load ptr, ptr %11, align 8, !tbaa !14
  %.not42 = icmp eq ptr %23, null
  br i1 %.not42, label %.loopexit, label %24

24:                                               ; preds = %22
  %25 = tail call i32 @getStylePixel(ptr noundef nonnull %0, i32 noundef %1, i32 noundef %2)
  %.not43 = icmp eq i32 %25, -6
  br i1 %.not43, label %.loopexit, label %tailrecurse.backedge

tailrecurse.backedge:                             ; preds = %24, %30
  %.tr47.be = phi i32 [ %25, %24 ], [ -3, %30 ]
  %26 = load i32, ptr %5, align 4, !tbaa !5
  %27 = icmp sgt i32 %26, %1
  br i1 %27, label %.loopexit, label %12

28:                                               ; preds = %21
  %29 = load ptr, ptr %11, align 8, !tbaa !14
  %.not = icmp eq ptr %29, null
  br i1 %.not, label %.loopexit, label %30

30:                                               ; preds = %28
  %31 = tail call i32 @getStylePixel(ptr noundef nonnull %0, i32 noundef %1, i32 noundef %2)
  switch i32 %31, label %tailrecurse.backedge [
    i32 -6, label %.loopexit
    i32 0, label %.loopexit
  ]

32:                                               ; preds = %21
  tail call void @gdImageBrushApply(ptr noundef nonnull %0, i32 noundef %1, i32 noundef %2)
  br label %.loopexit

33:                                               ; preds = %21
  tail call void @gdImageTileApply(ptr noundef nonnull %0, i32 noundef %1, i32 noundef %2)
  br label %.loopexit

34:                                               ; preds = %21
  %35 = tail call i32 @gdImageBoundsSafe(ptr noundef nonnull %0, i32 noundef %1, i32 noundef %2)
  %.not44 = icmp eq i32 %35, 0
  br i1 %.not44, label %.loopexit, label %36

36:                                               ; preds = %34
  %37 = trunc i32 %.tr4751 to i8
  %38 = load ptr, ptr %0, align 8, !tbaa !15
  %39 = sext i32 %1 to i64
  %40 = getelementptr inbounds ptr, ptr %38, i64 %39
  %41 = load ptr, ptr %40, align 8, !tbaa !16
  %42 = sext i32 %2 to i64
  %43 = getelementptr inbounds i8, ptr %41, i64 %42
  store i8 %37, ptr %43, align 1, !tbaa !17
  br label %.loopexit

.loopexit:                                        ; preds = %18, %15, %12, %tailrecurse.backedge, %22, %28, %30, %30, %24, %4, %32, %33, %36, %34
  ret void
}

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

; Function Attrs: nounwind uwtable
declare hidden void @gdImageBrushApply(ptr noundef, i32 noundef, i32 noundef) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
declare hidden void @gdImageTileApply(ptr noundef, i32 noundef, i32 noundef) local_unnamed_addr #0

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

attributes #0 = { 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" }

!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, !10, i64 6220}
!6 = !{!"gdImageStruct", !7, i64 0, !10, i64 8, !10, i64 12, !10, i64 16, !8, i64 20, !8, i64 1044, !8, i64 2068, !8, i64 3092, !10, i64 4116, !7, i64 4120, !10, i64 4128, !7, i64 4136, !7, i64 4144, !8, i64 4152, !8, i64 5176, !10, i64 6200, !10, i64 6204, !7, i64 6208, !10, i64 6216, !10, i64 6220, !10, i64 6224, !10, i64 6228, !10, i64 6232}
!7 = !{!"any pointer", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"int", !8, i64 0}
!11 = !{!6, !10, i64 6228}
!12 = !{!6, !10, i64 6224}
!13 = !{!6, !10, i64 6232}
!14 = !{!6, !7, i64 6208}
!15 = !{!6, !7, i64 0}
!16 = !{!7, !7, i64 0}
!17 = !{!8, !8, i64 0}


; Effective O3 passes: CorrelatedValuePropagationPass,EarlyCSEPass,GVNPass,GlobalOptPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,JumpThreadingPass,LCSSAPass,LICMPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,SROAPass,SimplifyCFGPass,TailCallElimPass