; LLVM IR from SourangshuGhosh/Fluid-Simulation-for-Computer-Graphics :: src/render/brick_texture_packer/lodepng (lodepng)

; 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.ColorTree = type { [16 x ptr], i32 }
%struct.LodePNGColorMode = type { i32, i32, ptr, i64, 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: mustprogress uwtable
declare dso_local noundef i64 @_Z20lodepng_get_raw_sizejjPK16LodePNGColorMode(i32 noundef, i32 noundef, ptr noundef) #1

; Function Attrs: mustprogress uwtable
define dso_local noundef i32 @_Z15lodepng_convertPhPKhP16LodePNGColorModePKS2_jj(ptr noundef %0, ptr noundef %1, ptr noundef %2, ptr noundef %3, i32 noundef %4, i32 noundef %5) #1 {
  %7 = alloca i32, align 4
  %8 = alloca ptr, align 8
  %9 = alloca ptr, align 8
  %10 = alloca ptr, align 8
  %11 = alloca ptr, align 8
  %12 = alloca i32, align 4
  %13 = alloca i32, align 4
  %14 = alloca i64, align 8
  %15 = alloca %struct.ColorTree, align 8
  %16 = alloca i64, align 8
  %17 = alloca i64, align 8
  %18 = alloca i32, align 4
  %19 = alloca i64, align 8
  %20 = alloca ptr, align 8
  %21 = alloca i16, align 2
  %22 = alloca i16, align 2
  %23 = alloca i16, align 2
  %24 = alloca i16, align 2
  %25 = alloca i8, align 1
  %26 = alloca i8, align 1
  %27 = alloca i8, align 1
  %28 = alloca i8, align 1
  store ptr %0, ptr %8, align 8, !tbaa !5
  store ptr %1, ptr %9, align 8, !tbaa !5
  store ptr %2, ptr %10, align 8, !tbaa !5
  store ptr %3, ptr %11, align 8, !tbaa !5
  store i32 %4, ptr %12, align 4, !tbaa !9
  store i32 %5, ptr %13, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %14) #3
  call void @llvm.lifetime.start.p0(i64 136, ptr %15) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr %16) #3
  %29 = load i32, ptr %12, align 4, !tbaa !9
  %30 = load i32, ptr %13, align 4, !tbaa !9
  %31 = mul i32 %29, %30
  %32 = zext i32 %31 to i64
  store i64 %32, ptr %16, align 8, !tbaa !11
  %33 = load ptr, ptr %10, align 8, !tbaa !5
  %34 = load ptr, ptr %11, align 8, !tbaa !5
  %35 = call noundef i32 @_ZL24lodepng_color_mode_equalPK16LodePNGColorModeS1_(ptr noundef %33, ptr noundef %34)
  %36 = icmp ne i32 %35, 0
  br i1 %36, label %37, label %58

37:                                               ; preds = %6
  call void @llvm.lifetime.start.p0(i64 8, ptr %17) #3
  %38 = load i32, ptr %12, align 4, !tbaa !9
  %39 = load i32, ptr %13, align 4, !tbaa !9
  %40 = load ptr, ptr %11, align 8, !tbaa !5
  %41 = call noundef i64 @_Z20lodepng_get_raw_sizejjPK16LodePNGColorMode(i32 noundef %38, i32 noundef %39, ptr noundef %40)
  store i64 %41, ptr %17, align 8, !tbaa !11
  store i64 0, ptr %14, align 8, !tbaa !11
  br label %42

42:                                               ; preds = %54, %37
  %43 = load i64, ptr %14, align 8, !tbaa !11
  %44 = load i64, ptr %17, align 8, !tbaa !11
  %45 = icmp ne i64 %43, %44
  br i1 %45, label %46, label %57

46:                                               ; preds = %42
  %47 = load ptr, ptr %9, align 8, !tbaa !5
  %48 = load i64, ptr %14, align 8, !tbaa !11
  %49 = getelementptr inbounds i8, ptr %47, i64 %48
  %50 = load i8, ptr %49, align 1, !tbaa !13
  %51 = load ptr, ptr %8, align 8, !tbaa !5
  %52 = load i64, ptr %14, align 8, !tbaa !11
  %53 = getelementptr inbounds i8, ptr %51, i64 %52
  store i8 %50, ptr %53, align 1, !tbaa !13
  br label %54

54:                                               ; preds = %46
  %55 = load i64, ptr %14, align 8, !tbaa !11
  %56 = add i64 %55, 1
  store i64 %56, ptr %14, align 8, !tbaa !11
  br label %42, !llvm.loop !14

57:                                               ; preds = %42
  store i32 0, ptr %7, align 4
  store i32 1, ptr %18, align 4
  call void @llvm.lifetime.end.p0(i64 8, ptr %17) #3
  br label %198

58:                                               ; preds = %6
  %59 = load ptr, ptr %10, align 8, !tbaa !5
  %60 = getelementptr inbounds %struct.LodePNGColorMode, ptr %59, i32 0, i32 0
  %61 = load i32, ptr %60, align 8, !tbaa !16
  %62 = icmp eq i32 %61, 3
  br i1 %62, label %63, label %108

63:                                               ; preds = %58
  call void @llvm.lifetime.start.p0(i64 8, ptr %19) #3
  %64 = load ptr, ptr %10, align 8, !tbaa !5
  %65 = getelementptr inbounds %struct.LodePNGColorMode, ptr %64, i32 0, i32 1
  %66 = load i32, ptr %65, align 4, !tbaa !19
  %67 = shl i32 1, %66
  %68 = zext i32 %67 to i64
  store i64 %68, ptr %19, align 8, !tbaa !11
  %69 = load ptr, ptr %10, align 8, !tbaa !5
  %70 = getelementptr inbounds %struct.LodePNGColorMode, ptr %69, i32 0, i32 3
  %71 = load i64, ptr %70, align 8, !tbaa !20
  %72 = load i64, ptr %19, align 8, !tbaa !11
  %73 = icmp ult i64 %71, %72
  br i1 %73, label %74, label %78

74:                                               ; preds = %63
  %75 = load ptr, ptr %10, align 8, !tbaa !5
  %76 = getelementptr inbounds %struct.LodePNGColorMode, ptr %75, i32 0, i32 3
  %77 = load i64, ptr %76, align 8, !tbaa !20
  store i64 %77, ptr %19, align 8, !tbaa !11
  br label %78

78:                                               ; preds = %74, %63
  call void @_ZL15color_tree_initP9ColorTree(ptr noundef %15)
  store i64 0, ptr %14, align 8, !tbaa !11
  br label %79

79:                                               ; preds = %104, %78
  %80 = load i64, ptr %14, align 8, !tbaa !11
  %81 = load i64, ptr %19, align 8, !tbaa !11
  %82 = icmp ne i64 %80, %81
  br i1 %82, label %83, label %107

83:                                               ; preds = %79
  call void @llvm.lifetime.start.p0(i64 8, ptr %20) #3
  %84 = load ptr, ptr %10, align 8, !tbaa !5
  %85 = getelementptr inbounds %struct.LodePNGColorMode, ptr %84, i32 0, i32 2
  %86 = load ptr, ptr %85, align 8, !tbaa !21
  %87 = load i64, ptr %14, align 8, !tbaa !11
  %88 = mul i64 %87, 4
  %89 = getelementptr inbounds i8, ptr %86, i64 %88
  store ptr %89, ptr %20, align 8, !tbaa !5
  %90 = load ptr, ptr %20, align 8, !tbaa !5
  %91 = getelementptr inbounds i8, ptr %90, i64 0
  %92 = load i8, ptr %91, align 1, !tbaa !13
  %93 = load ptr, ptr %20, align 8, !tbaa !5
  %94 = getelementptr inbounds i8, ptr %93, i64 1
  %95 = load i8, ptr %94, align 1, !tbaa !13
  %96 = load ptr, ptr %20, align 8, !tbaa !5
  %97 = getelementptr inbounds i8, ptr %96, i64 2
  %98 = load i8, ptr %97, align 1, !tbaa !13
  %99 = load ptr, ptr %20, align 8, !tbaa !5
  %100 = getelementptr inbounds i8, ptr %99, i64 3
  %101 = load i8, ptr %100, align 1, !tbaa !13
  %102 = load i64, ptr %14, align 8, !tbaa !11
  %103 = trunc i64 %102 to i32
  call void @_ZL14color_tree_addP9ColorTreehhhhj(ptr noundef %15, i8 noundef zeroext %92, i8 noundef zeroext %95, i8 noundef zeroext %98, i8 noundef zeroext %101, i32 noundef %103)
  call void @llvm.lifetime.end.p0(i64 8, ptr %20) #3
  br label %104

104:                                              ; preds = %83
  %105 = load i64, ptr %14, align 8, !tbaa !11
  %106 = add i64 %105, 1
  store i64 %106, ptr %14, align 8, !tbaa !11
  br label %79, !llvm.loop !22

107:                                              ; preds = %79
  call void @llvm.lifetime.end.p0(i64 8, ptr %19) #3
  br label %108

108:                                              ; preds = %107, %58
  %109 = load ptr, ptr %11, align 8, !tbaa !5
  %110 = getelementptr inbounds %struct.LodePNGColorMode, ptr %109, i32 0, i32 1
  %111 = load i32, ptr %110, align 4, !tbaa !19
  %112 = icmp eq i32 %111, 16
  br i1 %112, label %113, label %138

113:                                              ; preds = %108
  %114 = load ptr, ptr %10, align 8, !tbaa !5
  %115 = getelementptr inbounds %struct.LodePNGColorMode, ptr %114, i32 0, i32 1
  %116 = load i32, ptr %115, align 4, !tbaa !19
  %117 = icmp eq i32 %116, 16
  br i1 %117, label %118, label %138

118:                                              ; preds = %113
  store i64 0, ptr %14, align 8, !tbaa !11
  br label %119

119:                                              ; preds = %134, %118
  %120 = load i64, ptr %14, align 8, !tbaa !11
  %121 = load i64, ptr %16, align 8, !tbaa !11
  %122 = icmp ne i64 %120, %121
  br i1 %122, label %123, label %137

123:                                              ; preds = %119
  call void @llvm.lifetime.start.p0(i64 2, ptr %21) #3
  store i16 0, ptr %21, align 2, !tbaa !23
  call void @llvm.lifetime.start.p0(i64 2, ptr %22) #3
  store i16 0, ptr %22, align 2, !tbaa !23
  call void @llvm.lifetime.start.p0(i64 2, ptr %23) #3
  store i16 0, ptr %23, align 2, !tbaa !23
  call void @llvm.lifetime.start.p0(i64 2, ptr %24) #3
  store i16 0, ptr %24, align 2, !tbaa !23
  %124 = load ptr, ptr %9, align 8, !tbaa !5
  %125 = load i64, ptr %14, align 8, !tbaa !11
  %126 = load ptr, ptr %11, align 8, !tbaa !5
  call void @_ZL19getPixelColorRGBA16PtS_S_S_PKhmPK16LodePNGColorMode(ptr noundef %21, ptr noundef %22, ptr noundef %23, ptr noundef %24, ptr noundef %124, i64 noundef %125, ptr noundef %126)
  %127 = load ptr, ptr %8, align 8, !tbaa !5
  %128 = load i64, ptr %14, align 8, !tbaa !11
  %129 = load ptr, ptr %10, align 8, !tbaa !5
  %130 = load i16, ptr %21, align 2, !tbaa !23
  %131 = load i16, ptr %22, align 2, !tbaa !23
  %132 = load i16, ptr %23, align 2, !tbaa !23
  %133 = load i16, ptr %24, align 2, !tbaa !23
  call void @_ZL13rgba16ToPixelPhmPK16LodePNGColorModetttt(ptr noundef %127, i64 noundef %128, ptr noundef %129, i16 noundef zeroext %130, i16 noundef zeroext %131, i16 noundef zeroext %132, i16 noundef zeroext %133)
  call void @llvm.lifetime.end.p0(i64 2, ptr %24) #3
  call void @llvm.lifetime.end.p0(i64 2, ptr %23) #3
  call void @llvm.lifetime.end.p0(i64 2, ptr %22) #3
  call void @llvm.lifetime.end.p0(i64 2, ptr %21) #3
  br label %134

134:                                              ; preds = %123
  %135 = load i64, ptr %14, align 8, !tbaa !11
  %136 = add i64 %135, 1
  store i64 %136, ptr %14, align 8, !tbaa !11
  br label %119, !llvm.loop !25

137:                                              ; preds = %119
  br label %191

138:                                              ; preds = %113, %108
  %139 = load ptr, ptr %10, align 8, !tbaa !5
  %140 = getelementptr inbounds %struct.LodePNGColorMode, ptr %139, i32 0, i32 1
  %141 = load i32, ptr %140, align 4, !tbaa !19
  %142 = icmp eq i32 %141, 8
  br i1 %142, label %143, label %153

143:                                              ; preds = %138
  %144 = load ptr, ptr %10, align 8, !tbaa !5
  %145 = getelementptr inbounds %struct.LodePNGColorMode, ptr %144, i32 0, i32 0
  %146 = load i32, ptr %145, align 8, !tbaa !16
  %147 = icmp eq i32 %146, 6
  br i1 %147, label %148, label %153

148:                                              ; preds = %143
  %149 = load ptr, ptr %8, align 8, !tbaa !5
  %150 = load i64, ptr %16, align 8, !tbaa !11
  %151 = load ptr, ptr %9, align 8, !tbaa !5
  %152 = load ptr, ptr %11, align 8, !tbaa !5
  call void @_ZL19getPixelColorsRGBA8PhmjPKhPK16LodePNGColorMode(ptr noundef %149, i64 noundef %150, i32 noundef 1, ptr noundef %151, ptr noundef %152)
  br label %190

153:                                              ; preds = %143, %138
  %154 = load ptr, ptr %10, align 8, !tbaa !5
  %155 = getelementptr inbounds %struct.LodePNGColorMode, ptr %154, i32 0, i32 1
  %156 = load i32, ptr %155, align 4, !tbaa !19
  %157 = icmp eq i32 %156, 8
  br i1 %157, label %158, label %168

158:                                              ; preds = %153
  %159 = load ptr, ptr %10, align 8, !tbaa !5
  %160 = getelementptr inbounds %struct.LodePNGColorMode, ptr %159, i32 0, i32 0
  %161 = load i32, ptr %160, align 8, !tbaa !16
  %162 = icmp eq i32 %161, 2
  br i1 %162, label %163, label %168

163:                                              ; preds = %158
  %164 = load ptr, ptr %8, align 8, !tbaa !5
  %165 = load i64, ptr %16, align 8, !tbaa !11
  %166 = load ptr, ptr %9, align 8, !tbaa !5
  %167 = load ptr, ptr %11, align 8, !tbaa !5
  call void @_ZL19getPixelColorsRGBA8PhmjPKhPK16LodePNGColorMode(ptr noundef %164, i64 noundef %165, i32 noundef 0, ptr noundef %166, ptr noundef %167)
  br label %189

168:                                              ; preds = %158, %153
  call void @llvm.lifetime.start.p0(i64 1, ptr %25) #3
  store i8 0, ptr %25, align 1, !tbaa !13
  call void @llvm.lifetime.start.p0(i64 1, ptr %26) #3
  store i8 0, ptr %26, align 1, !tbaa !13
  call void @llvm.lifetime.start.p0(i64 1, ptr %27) #3
  store i8 0, ptr %27, align 1, !tbaa !13
  call void @llvm.lifetime.start.p0(i64 1, ptr %28) #3
  store i8 0, ptr %28, align 1, !tbaa !13
  store i64 0, ptr %14, align 8, !tbaa !11
  br label %169

169:                                              ; preds = %185, %168
  %170 = load i64, ptr %14, align 8, !tbaa !11
  %171 = load i64, ptr %16, align 8, !tbaa !11
  %172 = icmp ne i64 %170, %171
  br i1 %172, label %173, label %188

173:                                              ; preds = %169
  %174 = load ptr, ptr %9, align 8, !tbaa !5
  %175 = load i64, ptr %14, align 8, !tbaa !11
  %176 = load ptr, ptr %11, align 8, !tbaa !5
  call void @_ZL18getPixelColorRGBA8PhS_S_S_PKhmPK16LodePNGColorMode(ptr noundef %25, ptr noundef %26, ptr noundef %27, ptr noundef %28, ptr noundef %174, i64 noundef %175, ptr noundef %176)
  %177 = load ptr, ptr %8, align 8, !tbaa !5
  %178 = load i64, ptr %14, align 8, !tbaa !11
  %179 = load ptr, ptr %10, align 8, !tbaa !5
  %180 = load i8, ptr %25, align 1, !tbaa !13
  %181 = load i8, ptr %26, align 1, !tbaa !13
  %182 = load i8, ptr %27, align 1, !tbaa !13
  %183 = load i8, ptr %28, align 1, !tbaa !13
  %184 = call noundef i32 @_ZL12rgba8ToPixelPhmPK16LodePNGColorModeP9ColorTreehhhh(ptr noundef %177, i64 noundef %178, ptr noundef %179, ptr noundef %15, i8 noundef zeroext %180, i8 noundef zeroext %181, i8 noundef zeroext %182, i8 noundef zeroext %183)
  br label %185

185:                                              ; preds = %173
  %186 = load i64, ptr %14, align 8, !tbaa !11
  %187 = add i64 %186, 1
  store i64 %187, ptr %14, align 8, !tbaa !11
  br label %169, !llvm.loop !26

188:                                              ; preds = %169
  call void @llvm.lifetime.end.p0(i64 1, ptr %28) #3
  call void @llvm.lifetime.end.p0(i64 1, ptr %27) #3
  call void @llvm.lifetime.end.p0(i64 1, ptr %26) #3
  call void @llvm.lifetime.end.p0(i64 1, ptr %25) #3
  br label %189

189:                                              ; preds = %188, %163
  br label %190

190:                                              ; preds = %189, %148
  br label %191

191:                                              ; preds = %190, %137
  %192 = load ptr, ptr %10, align 8, !tbaa !5
  %193 = getelementptr inbounds %struct.LodePNGColorMode, ptr %192, i32 0, i32 0
  %194 = load i32, ptr %193, align 8, !tbaa !16
  %195 = icmp eq i32 %194, 3
  br i1 %195, label %196, label %197

196:                                              ; preds = %191
  call void @_ZL18color_tree_cleanupP9ColorTree(ptr noundef %15)
  br label %197

197:                                              ; preds = %196, %191
  store i32 0, ptr %7, align 4
  store i32 1, ptr %18, align 4
  br label %198

198:                                              ; preds = %197, %57
  call void @llvm.lifetime.end.p0(i64 8, ptr %16) #3
  call void @llvm.lifetime.end.p0(i64 136, ptr %15) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %14) #3
  %199 = load i32, ptr %7, align 4
  ret i32 %199
}

; Function Attrs: mustprogress nounwind uwtable
declare hidden noundef i32 @_ZL24lodepng_color_mode_equalPK16LodePNGColorModeS1_(ptr noundef, ptr noundef) #2

; Function Attrs: mustprogress nounwind uwtable
declare hidden void @_ZL15color_tree_initP9ColorTree(ptr noundef) #2

; Function Attrs: mustprogress nounwind uwtable
declare hidden void @_ZL14color_tree_addP9ColorTreehhhhj(ptr noundef, i8 noundef zeroext, i8 noundef zeroext, i8 noundef zeroext, i8 noundef zeroext, i32 noundef) #2

; Function Attrs: mustprogress nounwind uwtable
declare hidden void @_ZL19getPixelColorRGBA16PtS_S_S_PKhmPK16LodePNGColorMode(ptr noundef, ptr noundef, ptr noundef, ptr noundef, ptr noundef, i64 noundef, ptr noundef) #2

; Function Attrs: mustprogress nounwind uwtable
declare hidden void @_ZL13rgba16ToPixelPhmPK16LodePNGColorModetttt(ptr noundef, i64 noundef, ptr noundef, i16 noundef zeroext, i16 noundef zeroext, i16 noundef zeroext, i16 noundef zeroext) #2

; Function Attrs: mustprogress uwtable
declare hidden void @_ZL19getPixelColorsRGBA8PhmjPKhPK16LodePNGColorMode(ptr noundef, i64 noundef, i32 noundef, ptr noundef, ptr noundef) #1

; Function Attrs: mustprogress uwtable
declare hidden void @_ZL18getPixelColorRGBA8PhS_S_S_PKhmPK16LodePNGColorMode(ptr noundef, ptr noundef, ptr noundef, ptr noundef, ptr noundef, i64 noundef, ptr noundef) #1

; Function Attrs: mustprogress uwtable
declare hidden noundef i32 @_ZL12rgba8ToPixelPhmPK16LodePNGColorModeP9ColorTreehhhh(ptr noundef, i64 noundef, ptr noundef, ptr noundef, i8 noundef zeroext, i8 noundef zeroext, i8 noundef zeroext, i8 noundef zeroext) #1

; Function Attrs: mustprogress uwtable
declare hidden void @_ZL18color_tree_cleanupP9ColorTree(ptr noundef) #1

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { mustprogress 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 = { mustprogress 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 }

!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++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"int", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"long", !7, i64 0}
!13 = !{!7, !7, i64 0}
!14 = distinct !{!14, !15}
!15 = !{!"llvm.loop.mustprogress"}
!16 = !{!17, !18, i64 0}
!17 = !{!"_ZTS16LodePNGColorMode", !18, i64 0, !10, i64 4, !6, i64 8, !12, i64 16, !10, i64 24, !10, i64 28, !10, i64 32, !10, i64 36}
!18 = !{!"_ZTS16LodePNGColorType", !7, i64 0}
!19 = !{!17, !10, i64 4}
!20 = !{!17, !12, i64 16}
!21 = !{!17, !6, i64 8}
!22 = distinct !{!22, !15}
!23 = !{!24, !24, i64 0}
!24 = !{!"short", !7, i64 0}
!25 = distinct !{!25, !15}
!26 = distinct !{!26, !15}


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

; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture) #0

; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #0

; Function Attrs: mustprogress uwtable
declare dso_local noundef i64 @_Z20lodepng_get_raw_sizejjPK16LodePNGColorMode(i32 noundef, i32 noundef, ptr noundef) local_unnamed_addr #1

; Function Attrs: mustprogress uwtable
define dso_local noundef i32 @_Z15lodepng_convertPhPKhP16LodePNGColorModePKS2_jj(ptr noundef %0, ptr noundef %1, ptr noundef %2, ptr noundef %3, i32 noundef %4, i32 noundef %5) local_unnamed_addr #1 {
  %7 = ptrtoint ptr %1 to i64
  %8 = ptrtoint ptr %0 to i64
  %9 = alloca %struct.ColorTree, align 8
  %10 = alloca i16, align 2
  %11 = alloca i16, align 2
  %12 = alloca i16, align 2
  %13 = alloca i16, align 2
  %14 = alloca i8, align 1
  %15 = alloca i8, align 1
  %16 = alloca i8, align 1
  %17 = alloca i8, align 1
  call void @llvm.lifetime.start.p0(i64 136, ptr nonnull %9) #4
  %18 = mul i32 %5, %4
  %19 = zext i32 %18 to i64
  %20 = tail call noundef i32 @_ZL24lodepng_color_mode_equalPK16LodePNGColorModeS1_(ptr noundef %2, ptr noundef %3)
  %.not = icmp eq i32 %20, 0
  br i1 %.not, label %54, label %21

21:                                               ; preds = %6
  %22 = tail call noundef i64 @_Z20lodepng_get_raw_sizejjPK16LodePNGColorMode(i32 noundef %4, i32 noundef %5, ptr noundef %3)
  %.not6871 = icmp eq i64 %22, 0
  br i1 %.not6871, label %.loopexit70, label %iter.check

iter.check:                                       ; preds = %21
  %min.iters.check = icmp ult i64 %22, 8
  %23 = sub i64 %8, %7
  %diff.check = icmp ult i64 %23, 32
  %or.cond90 = or i1 %min.iters.check, %diff.check
  br i1 %or.cond90, label %.lr.ph.preheader, label %vector.main.loop.iter.check

vector.main.loop.iter.check:                      ; preds = %iter.check
  %min.iters.check82 = icmp ult i64 %22, 32
  br i1 %min.iters.check82, label %vec.epilog.ph, label %vector.ph

vector.ph:                                        ; preds = %vector.main.loop.iter.check
  %n.vec = and i64 %22, -32
  br label %vector.body

vector.body:                                      ; preds = %vector.body, %vector.ph
  %index = phi i64 [ 0, %vector.ph ], [ %index.next, %vector.body ]
  %24 = getelementptr inbounds i8, ptr %1, i64 %index
  %25 = getelementptr inbounds i8, ptr %24, i64 16
  %wide.load = load <16 x i8>, ptr %24, align 1, !tbaa !5
  %wide.load83 = load <16 x i8>, ptr %25, align 1, !tbaa !5
  %26 = getelementptr inbounds i8, ptr %0, i64 %index
  %27 = getelementptr inbounds i8, ptr %26, i64 16
  store <16 x i8> %wide.load, ptr %26, align 1, !tbaa !5
  store <16 x i8> %wide.load83, ptr %27, align 1, !tbaa !5
  %index.next = add nuw i64 %index, 32
  %28 = icmp eq i64 %index.next, %n.vec
  br i1 %28, label %middle.block, label %vector.body, !llvm.loop !8

middle.block:                                     ; preds = %vector.body
  %cmp.n = icmp eq i64 %22, %n.vec
  br i1 %cmp.n, label %.loopexit70, label %vec.epilog.iter.check

vec.epilog.iter.check:                            ; preds = %middle.block
  %n.vec.remaining = and i64 %22, 24
  %min.epilog.iters.check = icmp eq i64 %n.vec.remaining, 0
  br i1 %min.epilog.iters.check, label %.lr.ph.preheader, label %vec.epilog.ph

vec.epilog.ph:                                    ; preds = %vector.main.loop.iter.check, %vec.epilog.iter.check
  %vec.epilog.resume.val = phi i64 [ %n.vec, %vec.epilog.iter.check ], [ 0, %vector.main.loop.iter.check ]
  %n.vec85 = and i64 %22, -8
  br label %vec.epilog.vector.body

vec.epilog.vector.body:                           ; preds = %vec.epilog.vector.body, %vec.epilog.ph
  %index86 = phi i64 [ %vec.epilog.resume.val, %vec.epilog.ph ], [ %index.next88, %vec.epilog.vector.body ]
  %29 = getelementptr inbounds i8, ptr %1, i64 %index86
  %wide.load87 = load <8 x i8>, ptr %29, align 1, !tbaa !5
  %30 = getelementptr inbounds i8, ptr %0, i64 %index86
  store <8 x i8> %wide.load87, ptr %30, align 1, !tbaa !5
  %index.next88 = add nuw i64 %index86, 8
  %31 = icmp eq i64 %index.next88, %n.vec85
  br i1 %31, label %vec.epilog.middle.block, label %vec.epilog.vector.body, !llvm.loop !12

vec.epilog.middle.block:                          ; preds = %vec.epilog.vector.body
  %cmp.n89 = icmp eq i64 %22, %n.vec85
  br i1 %cmp.n89, label %.loopexit70, label %.lr.ph.preheader

.lr.ph.preheader:                                 ; preds = %vec.epilog.middle.block, %iter.check, %vec.epilog.iter.check
  %.06372.ph = phi i64 [ 0, %iter.check ], [ %n.vec, %vec.epilog.iter.check ], [ %n.vec85, %vec.epilog.middle.block ]
  %xtraiter = and i64 %22, 3
  %lcmp.mod.not = icmp eq i64 %xtraiter, 0
  br i1 %lcmp.mod.not, label %.lr.ph.prol.loopexit, label %.lr.ph.prol

.lr.ph.prol:                                      ; preds = %.lr.ph.preheader, %.lr.ph.prol
  %.06372.prol = phi i64 [ %35, %.lr.ph.prol ], [ %.06372.ph, %.lr.ph.preheader ]
  %prol.iter = phi i64 [ %prol.iter.next, %.lr.ph.prol ], [ 0, %.lr.ph.preheader ]
  %32 = getelementptr inbounds i8, ptr %1, i64 %.06372.prol
  %33 = load i8, ptr %32, align 1, !tbaa !5
  %34 = getelementptr inbounds i8, ptr %0, i64 %.06372.prol
  store i8 %33, ptr %34, align 1, !tbaa !5
  %35 = add nuw i64 %.06372.prol, 1
  %prol.iter.next = add i64 %prol.iter, 1
  %prol.iter.cmp.not = icmp eq i64 %prol.iter.next, %xtraiter
  br i1 %prol.iter.cmp.not, label %.lr.ph.prol.loopexit, label %.lr.ph.prol, !llvm.loop !13

.lr.ph.prol.loopexit:                             ; preds = %.lr.ph.prol, %.lr.ph.preheader
  %.06372.unr = phi i64 [ %.06372.ph, %.lr.ph.preheader ], [ %35, %.lr.ph.prol ]
  %36 = sub i64 %.06372.ph, %22
  %37 = icmp ugt i64 %36, -4
  br i1 %37, label %.loopexit70, label %.lr.ph

.lr.ph:                                           ; preds = %.lr.ph.prol.loopexit, %.lr.ph
  %.06372 = phi i64 [ %53, %.lr.ph ], [ %.06372.unr, %.lr.ph.prol.loopexit ]
  %38 = getelementptr inbounds i8, ptr %1, i64 %.06372
  %39 = load i8, ptr %38, align 1, !tbaa !5
  %40 = getelementptr inbounds i8, ptr %0, i64 %.06372
  store i8 %39, ptr %40, align 1, !tbaa !5
  %41 = add nuw i64 %.06372, 1
  %42 = getelementptr inbounds i8, ptr %1, i64 %41
  %43 = load i8, ptr %42, align 1, !tbaa !5
  %44 = getelementptr inbounds i8, ptr %0, i64 %41
  store i8 %43, ptr %44, align 1, !tbaa !5
  %45 = add nuw i64 %.06372, 2
  %46 = getelementptr inbounds i8, ptr %1, i64 %45
  %47 = load i8, ptr %46, align 1, !tbaa !5
  %48 = getelementptr inbounds i8, ptr %0, i64 %45
  store i8 %47, ptr %48, align 1, !tbaa !5
  %49 = add nuw i64 %.06372, 3
  %50 = getelementptr inbounds i8, ptr %1, i64 %49
  %51 = load i8, ptr %50, align 1, !tbaa !5
  %52 = getelementptr inbounds i8, ptr %0, i64 %49
  store i8 %51, ptr %52, align 1, !tbaa !5
  %53 = add nuw i64 %.06372, 4
  %.not68.3 = icmp eq i64 %53, %22
  br i1 %.not68.3, label %.loopexit70, label %.lr.ph, !llvm.loop !15

54:                                               ; preds = %6
  %55 = load i32, ptr %2, align 8, !tbaa !16
  %56 = icmp eq i32 %55, 3
  br i1 %56, label %57, label %.loopexit69

57:                                               ; preds = %54
  %58 = getelementptr inbounds i8, ptr %2, i64 4
  %59 = load i32, ptr %58, align 4, !tbaa !22
  %60 = shl nuw i32 1, %59
  %61 = zext i32 %60 to i64
  %62 = getelementptr inbounds i8, ptr %2, i64 16
  %63 = load i64, ptr %62, align 8, !tbaa !23
  %spec.select = tail call i64 @llvm.umin.i64(i64 %63, i64 %61)
  call void @_ZL15color_tree_initP9ColorTree(ptr noundef nonnull %9)
  %.not6573 = icmp eq i64 %63, 0
  br i1 %.not6573, label %.loopexit69, label %.lr.ph75

.lr.ph75:                                         ; preds = %57
  %64 = getelementptr inbounds i8, ptr %2, i64 8
  br label %65

65:                                               ; preds = %.lr.ph75, %65
  %.174 = phi i64 [ 0, %.lr.ph75 ], [ %77, %65 ]
  %66 = load ptr, ptr %64, align 8, !tbaa !24
  %67 = shl i64 %.174, 2
  %68 = getelementptr inbounds i8, ptr %66, i64 %67
  %69 = load i8, ptr %68, align 1, !tbaa !5
  %70 = getelementptr inbounds i8, ptr %68, i64 1
  %71 = load i8, ptr %70, align 1, !tbaa !5
  %72 = getelementptr inbounds i8, ptr %68, i64 2
  %73 = load i8, ptr %72, align 1, !tbaa !5
  %74 = getelementptr inbounds i8, ptr %68, i64 3
  %75 = load i8, ptr %74, align 1, !tbaa !5
  %76 = trunc i64 %.174 to i32
  call void @_ZL14color_tree_addP9ColorTreehhhhj(ptr noundef nonnull %9, i8 noundef zeroext %69, i8 noundef zeroext %71, i8 noundef zeroext %73, i8 noundef zeroext %75, i32 noundef %76)
  %77 = add i64 %.174, 1
  %.not65 = icmp eq i64 %77, %spec.select
  br i1 %.not65, label %.loopexit69, label %65, !llvm.loop !25

.loopexit69:                                      ; preds = %65, %57, %54
  %78 = getelementptr inbounds i8, ptr %3, i64 4
  %79 = load i32, ptr %78, align 4, !tbaa !22
  %80 = icmp eq i32 %79, 16
  %81 = getelementptr inbounds i8, ptr %2, i64 4
  %82 = load i32, ptr %81, align 4, !tbaa !22
  %83 = icmp eq i32 %82, 16
  %or.cond = select i1 %80, i1 %83, i1 false
  br i1 %or.cond, label %.preheader, label %.loopexit69._crit_edge

.preheader:                                       ; preds = %.loopexit69
  %.not6779 = icmp eq i32 %18, 0
  br i1 %.not6779, label %.loopexit, label %.lr.ph81

.lr.ph81:                                         ; preds = %.preheader, %.lr.ph81
  %.280 = phi i64 [ %88, %.lr.ph81 ], [ 0, %.preheader ]
  call void @llvm.lifetime.start.p0(i64 2, ptr nonnull %10) #4
  store i16 0, ptr %10, align 2, !tbaa !26
  call void @llvm.lifetime.start.p0(i64 2, ptr nonnull %11) #4
  store i16 0, ptr %11, align 2, !tbaa !26
  call void @llvm.lifetime.start.p0(i64 2, ptr nonnull %12) #4
  store i16 0, ptr %12, align 2, !tbaa !26
  call void @llvm.lifetime.start.p0(i64 2, ptr nonnull %13) #4
  store i16 0, ptr %13, align 2, !tbaa !26
  call void @_ZL19getPixelColorRGBA16PtS_S_S_PKhmPK16LodePNGColorMode(ptr noundef nonnull %10, ptr noundef nonnull %11, ptr noundef nonnull %12, ptr noundef nonnull %13, ptr noundef %1, i64 noundef %.280, ptr noundef %3)
  %84 = load i16, ptr %10, align 2, !tbaa !26
  %85 = load i16, ptr %11, align 2, !tbaa !26
  %86 = load i16, ptr %12, align 2, !tbaa !26
  %87 = load i16, ptr %13, align 2, !tbaa !26
  call void @_ZL13rgba16ToPixelPhmPK16LodePNGColorModetttt(ptr noundef %0, i64 noundef %.280, ptr noundef nonnull %2, i16 noundef zeroext %84, i16 noundef zeroext %85, i16 noundef zeroext %86, i16 noundef zeroext %87)
  call void @llvm.lifetime.end.p0(i64 2, ptr nonnull %13) #4
  call void @llvm.lifetime.end.p0(i64 2, ptr nonnull %12) #4
  call void @llvm.lifetime.end.p0(i64 2, ptr nonnull %11) #4
  call void @llvm.lifetime.end.p0(i64 2, ptr nonnull %10) #4
  %88 = add nuw nsw i64 %.280, 1
  %.not67 = icmp eq i64 %88, %19
  br i1 %.not67, label %.loopexit, label %.lr.ph81, !llvm.loop !28

.loopexit69._crit_edge:                           ; preds = %.loopexit69
  %89 = icmp eq i32 %82, 8
  br i1 %89, label %90, label %94

90:                                               ; preds = %.loopexit69._crit_edge
  %91 = load i32, ptr %2, align 8, !tbaa !16
  switch i32 %91, label %94 [
    i32 6, label %92
    i32 2, label %93
  ]

92:                                               ; preds = %90
  call void @_ZL19getPixelColorsRGBA8PhmjPKhPK16LodePNGColorMode(ptr noundef %0, i64 noundef %19, i32 noundef 1, ptr noundef %1, ptr noundef nonnull %3)
  br label %.loopexit

93:                                               ; preds = %90
  call void @_ZL19getPixelColorsRGBA8PhmjPKhPK16LodePNGColorMode(ptr noundef %0, i64 noundef %19, i32 noundef 0, ptr noundef %1, ptr noundef nonnull %3)
  br label %.loopexit

94:                                               ; preds = %90, %.loopexit69._crit_edge
  call void @llvm.lifetime.start.p0(i64 1, ptr nonnull %14) #4
  store i8 0, ptr %14, align 1, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 1, ptr nonnull %15) #4
  store i8 0, ptr %15, align 1, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 1, ptr nonnull %16) #4
  store i8 0, ptr %16, align 1, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 1, ptr nonnull %17) #4
  store i8 0, ptr %17, align 1, !tbaa !5
  %.not6676 = icmp eq i32 %18, 0
  br i1 %.not6676, label %._crit_edge, label %.lr.ph78

.lr.ph78:                                         ; preds = %94, %.lr.ph78
  %.377 = phi i64 [ %100, %.lr.ph78 ], [ 0, %94 ]
  call void @_ZL18getPixelColorRGBA8PhS_S_S_PKhmPK16LodePNGColorMode(ptr noundef nonnull %14, ptr noundef nonnull %15, ptr noundef nonnull %16, ptr noundef nonnull %17, ptr noundef %1, i64 noundef %.377, ptr noundef %3)
  %95 = load i8, ptr %14, align 1, !tbaa !5
  %96 = load i8, ptr %15, align 1, !tbaa !5
  %97 = load i8, ptr %16, align 1, !tbaa !5
  %98 = load i8, ptr %17, align 1, !tbaa !5
  %99 = call noundef i32 @_ZL12rgba8ToPixelPhmPK16LodePNGColorModeP9ColorTreehhhh(ptr noundef %0, i64 noundef %.377, ptr noundef nonnull %2, ptr noundef nonnull %9, i8 noundef zeroext %95, i8 noundef zeroext %96, i8 noundef zeroext %97, i8 noundef zeroext %98)
  %100 = add nuw nsw i64 %.377, 1
  %.not66 = icmp eq i64 %100, %19
  br i1 %.not66, label %._crit_edge, label %.lr.ph78, !llvm.loop !29

._crit_edge:                                      ; preds = %.lr.ph78, %94
  call void @llvm.lifetime.end.p0(i64 1, ptr nonnull %17) #4
  call void @llvm.lifetime.end.p0(i64 1, ptr nonnull %16) #4
  call void @llvm.lifetime.end.p0(i64 1, ptr nonnull %15) #4
  call void @llvm.lifetime.end.p0(i64 1, ptr nonnull %14) #4
  br label %.loopexit

.loopexit:                                        ; preds = %.lr.ph81, %.preheader, %92, %._crit_edge, %93
  %101 = load i32, ptr %2, align 8, !tbaa !16
  %102 = icmp eq i32 %101, 3
  br i1 %102, label %103, label %.loopexit70

103:                                              ; preds = %.loopexit
  call void @_ZL18color_tree_cleanupP9ColorTree(ptr noundef nonnull %9)
  br label %.loopexit70

.loopexit70:                                      ; preds = %.lr.ph.prol.loopexit, %.lr.ph, %middle.block, %vec.epilog.middle.block, %21, %.loopexit, %103
  call void @llvm.lifetime.end.p0(i64 136, ptr nonnull %9) #4
  ret i32 0
}

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

; Function Attrs: mustprogress nounwind uwtable
declare hidden void @_ZL15color_tree_initP9ColorTree(ptr noundef) local_unnamed_addr #2

; Function Attrs: mustprogress nounwind uwtable
declare hidden void @_ZL14color_tree_addP9ColorTreehhhhj(ptr noundef, i8 noundef zeroext, i8 noundef zeroext, i8 noundef zeroext, i8 noundef zeroext, i32 noundef) local_unnamed_addr #2

; Function Attrs: mustprogress nounwind uwtable
declare hidden void @_ZL19getPixelColorRGBA16PtS_S_S_PKhmPK16LodePNGColorMode(ptr noundef, ptr noundef, ptr noundef, ptr noundef, ptr noundef, i64 noundef, ptr noundef) local_unnamed_addr #2

; Function Attrs: mustprogress nounwind uwtable
declare hidden void @_ZL13rgba16ToPixelPhmPK16LodePNGColorModetttt(ptr noundef, i64 noundef, ptr noundef, i16 noundef zeroext, i16 noundef zeroext, i16 noundef zeroext, i16 noundef zeroext) local_unnamed_addr #2

; Function Attrs: mustprogress uwtable
declare hidden void @_ZL19getPixelColorsRGBA8PhmjPKhPK16LodePNGColorMode(ptr noundef, i64 noundef, i32 noundef, ptr noundef, ptr noundef) local_unnamed_addr #1

; Function Attrs: mustprogress uwtable
declare hidden void @_ZL18getPixelColorRGBA8PhS_S_S_PKhmPK16LodePNGColorMode(ptr noundef, ptr noundef, ptr noundef, ptr noundef, ptr noundef, i64 noundef, ptr noundef) local_unnamed_addr #1

; Function Attrs: mustprogress uwtable
declare hidden noundef i32 @_ZL12rgba8ToPixelPhmPK16LodePNGColorModeP9ColorTreehhhh(ptr noundef, i64 noundef, ptr noundef, ptr noundef, i8 noundef zeroext, i8 noundef zeroext, i8 noundef zeroext, i8 noundef zeroext) local_unnamed_addr #1

; Function Attrs: mustprogress uwtable
declare hidden void @_ZL18color_tree_cleanupP9ColorTree(ptr noundef) local_unnamed_addr #1

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare i64 @llvm.umin.i64(i64, i64) #3

attributes #0 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { mustprogress 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 = { mustprogress 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 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #4 = { 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++ TBAA"}
!8 = distinct !{!8, !9, !10, !11}
!9 = !{!"llvm.loop.mustprogress"}
!10 = !{!"llvm.loop.isvectorized", i32 1}
!11 = !{!"llvm.loop.unroll.runtime.disable"}
!12 = distinct !{!12, !9, !10, !11}
!13 = distinct !{!13, !14}
!14 = !{!"llvm.loop.unroll.disable"}
!15 = distinct !{!15, !9, !10}
!16 = !{!17, !18, i64 0}
!17 = !{!"_ZTS16LodePNGColorMode", !18, i64 0, !19, i64 4, !20, i64 8, !21, i64 16, !19, i64 24, !19, i64 28, !19, i64 32, !19, i64 36}
!18 = !{!"_ZTS16LodePNGColorType", !6, i64 0}
!19 = !{!"int", !6, i64 0}
!20 = !{!"any pointer", !6, i64 0}
!21 = !{!"long", !6, i64 0}
!22 = !{!17, !19, i64 4}
!23 = !{!17, !21, i64 16}
!24 = !{!17, !20, i64 8}
!25 = distinct !{!25, !9}
!26 = !{!27, !27, i64 0}
!27 = !{!"short", !6, i64 0}
!28 = distinct !{!28, !9}
!29 = distinct !{!29, !9}


; Effective O3 passes: BDCEPass,CorrelatedValuePropagationPass,EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,JumpThreadingPass,LCSSAPass,LICMPass,LoopLoadEliminationPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,LoopVectorizePass,ReassociatePass,SROAPass,SimplifyCFGPass,TailCallElimPass