; LLVM IR from ermig1979/Simd :: src/Simd/SimdBaseImageSavePpm.ll (ZN4Simd4Base16ImagePpmTxtSaver8ToStreamEPKhm)

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

%"class.Simd::ImageSaver" = type { ptr, %"struct.Simd::ImageSaverParam", %"class.Simd::OutputMemoryStream" }
%"struct.Simd::ImageSaverParam" = type { i64, i64, i32, i32, i32, i32 }
%"class.Simd::OutputMemoryStream" = type { i64, ptr, i64, i64, i64, i64, i64 }
%"class.Simd::Base::ImagePxmSaver" = type { %"class.Simd::ImageSaver", ptr, %"struct.Simd::Array", i64, i64 }
%"struct.Simd::Array" = type { ptr, i64 }

@_ZN4Simd4Base10g_pxmPrintE = external dso_local global [256 x [4 x i8]], align 16

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN4Simd4Base13ImagePxmSaver11WriteHeaderEm(ptr noundef nonnull align 8 dereferenceable(136), i64 noundef) #0 align 2

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

; Function Attrs: alwaysinline mustprogress uwtable
declare dso_local void @_ZN4Simd18OutputMemoryStream5WriteEPKvm(ptr noundef nonnull align 8 dereferenceable(56), ptr noundef, i64 noundef) #2 align 2

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

; Function Attrs: alwaysinline mustprogress uwtable
declare dso_local void @_ZN4Simd18OutputMemoryStream7ReserveEm(ptr noundef nonnull align 8 dereferenceable(56), i64 noundef) #2 align 2

; Function Attrs: alwaysinline mustprogress nounwind uwtable
declare dso_local noundef i64 @_ZN4Simd5DivHiEmm(i64 noundef, i64 noundef) #3

; Function Attrs: alwaysinline mustprogress nounwind uwtable
declare dso_local noundef i64 @_ZN4Simd3MinImEET_S1_S1_(i64 noundef, i64 noundef) #3

; Function Attrs: mustprogress uwtable
define dso_local noundef zeroext i1 @_ZN4Simd4Base16ImagePpmTxtSaver8ToStreamEPKhm(ptr noundef nonnull align 8 dereferenceable(136) %0, ptr noundef %1, i64 noundef %2) unnamed_addr #0 align 2 {
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca i64, align 8
  %7 = alloca i64, align 8
  %8 = alloca i64, align 8
  %9 = alloca i32, align 4
  %10 = alloca i64, align 8
  %11 = alloca ptr, align 8
  %12 = alloca i64, align 8
  %13 = alloca [70 x i8], align 16
  %14 = alloca i64, align 8
  %15 = alloca i64, align 8
  store ptr %0, ptr %4, align 8, !tbaa !5
  store ptr %1, ptr %5, align 8, !tbaa !5
  store i64 %2, ptr %6, align 8, !tbaa !9
  %16 = load ptr, ptr %4, align 8
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #4
  %17 = getelementptr inbounds %"class.Simd::ImageSaver", ptr %16, i32 0, i32 1
  %18 = getelementptr inbounds %"struct.Simd::ImageSaverParam", ptr %17, i32 0, i32 2
  %19 = load i32, ptr %18, align 8, !tbaa !11
  %20 = icmp eq i32 %19, 16
  br i1 %20, label %21, label %23

21:                                               ; preds = %3
  %22 = load i64, ptr %6, align 8, !tbaa !9
  br label %26

23:                                               ; preds = %3
  %24 = getelementptr inbounds %"class.Simd::Base::ImagePxmSaver", ptr %16, i32 0, i32 4
  %25 = load i64, ptr %24, align 8, !tbaa !19
  br label %26

26:                                               ; preds = %23, %21
  %27 = phi i64 [ %22, %21 ], [ %25, %23 ]
  store i64 %27, ptr %7, align 8, !tbaa !9
  %28 = getelementptr inbounds %"class.Simd::ImageSaver", ptr %16, i32 0, i32 2
  %29 = getelementptr inbounds %"class.Simd::ImageSaver", ptr %16, i32 0, i32 1
  %30 = getelementptr inbounds %"struct.Simd::ImageSaverParam", ptr %29, i32 0, i32 1
  %31 = load i64, ptr %30, align 8, !tbaa !22
  %32 = getelementptr inbounds %"class.Simd::ImageSaver", ptr %16, i32 0, i32 1
  %33 = getelementptr inbounds %"struct.Simd::ImageSaverParam", ptr %32, i32 0, i32 0
  %34 = load i64, ptr %33, align 8, !tbaa !23
  %35 = mul i64 %34, 13
  %36 = getelementptr inbounds %"class.Simd::ImageSaver", ptr %16, i32 0, i32 1
  %37 = getelementptr inbounds %"struct.Simd::ImageSaverParam", ptr %36, i32 0, i32 0
  %38 = load i64, ptr %37, align 8, !tbaa !23
  %39 = call noundef i64 @_ZN4Simd5DivHiEmm(i64 noundef %38, i64 noundef 5)
  %40 = add i64 %35, %39
  %41 = mul i64 %31, %40
  %42 = add i64 32, %41
  call void @_ZN4Simd18OutputMemoryStream7ReserveEm(ptr noundef nonnull align 8 dereferenceable(56) %28, i64 noundef %42)
  call void @_ZN4Simd4Base13ImagePxmSaver11WriteHeaderEm(ptr noundef nonnull align 8 dereferenceable(136) %16, i64 noundef 3)
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #4
  store i64 0, ptr %8, align 8, !tbaa !9
  br label %43

43:                                               ; preds = %170, %26
  %44 = load i64, ptr %8, align 8, !tbaa !9
  %45 = getelementptr inbounds %"class.Simd::ImageSaver", ptr %16, i32 0, i32 1
  %46 = getelementptr inbounds %"struct.Simd::ImageSaverParam", ptr %45, i32 0, i32 1
  %47 = load i64, ptr %46, align 8, !tbaa !22
  %48 = icmp ult i64 %44, %47
  br i1 %48, label %50, label %49

49:                                               ; preds = %43
  store i32 2, ptr %9, align 4
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #4
  br label %179

50:                                               ; preds = %43
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #4
  %51 = load i64, ptr %8, align 8, !tbaa !9
  %52 = getelementptr inbounds %"class.Simd::Base::ImagePxmSaver", ptr %16, i32 0, i32 3
  %53 = load i64, ptr %52, align 8, !tbaa !24
  %54 = add i64 %51, %53
  %55 = getelementptr inbounds %"class.Simd::ImageSaver", ptr %16, i32 0, i32 1
  %56 = getelementptr inbounds %"struct.Simd::ImageSaverParam", ptr %55, i32 0, i32 1
  %57 = load i64, ptr %56, align 8, !tbaa !22
  %58 = call noundef i64 @_ZN4Simd3MinImEET_S1_S1_(i64 noundef %54, i64 noundef %57)
  %59 = load i64, ptr %8, align 8, !tbaa !9
  %60 = sub i64 %58, %59
  store i64 %60, ptr %10, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %11) #4
  %61 = load ptr, ptr %5, align 8, !tbaa !5
  store ptr %61, ptr %11, align 8, !tbaa !5
  %62 = getelementptr inbounds %"class.Simd::ImageSaver", ptr %16, i32 0, i32 1
  %63 = getelementptr inbounds %"struct.Simd::ImageSaverParam", ptr %62, i32 0, i32 2
  %64 = load i32, ptr %63, align 8, !tbaa !11
  %65 = icmp ne i32 %64, 16
  br i1 %65, label %66, label %82

66:                                               ; preds = %50
  %67 = getelementptr inbounds %"class.Simd::Base::ImagePxmSaver", ptr %16, i32 0, i32 1
  %68 = load ptr, ptr %67, align 8, !tbaa !25
  %69 = load ptr, ptr %5, align 8, !tbaa !5
  %70 = getelementptr inbounds %"class.Simd::ImageSaver", ptr %16, i32 0, i32 1
  %71 = getelementptr inbounds %"struct.Simd::ImageSaverParam", ptr %70, i32 0, i32 0
  %72 = load i64, ptr %71, align 8, !tbaa !23
  %73 = load i64, ptr %10, align 8, !tbaa !9
  %74 = load i64, ptr %6, align 8, !tbaa !9
  %75 = getelementptr inbounds %"class.Simd::Base::ImagePxmSaver", ptr %16, i32 0, i32 2
  %76 = getelementptr inbounds %"struct.Simd::Array", ptr %75, i32 0, i32 0
  %77 = load ptr, ptr %76, align 8, !tbaa !26
  %78 = load i64, ptr %7, align 8, !tbaa !9
  call void %68(ptr noundef %69, i64 noundef %72, i64 noundef %73, i64 noundef %74, ptr noundef %77, i64 noundef %78)
  %79 = getelementptr inbounds %"class.Simd::Base::ImagePxmSaver", ptr %16, i32 0, i32 2
  %80 = getelementptr inbounds %"struct.Simd::Array", ptr %79, i32 0, i32 0
  %81 = load ptr, ptr %80, align 8, !tbaa !26
  store ptr %81, ptr %11, align 8, !tbaa !5
  br label %82

82:                                               ; preds = %66, %50
  call void @llvm.lifetime.start.p0(i64 8, ptr %12) #4
  store i64 0, ptr %12, align 8, !tbaa !9
  br label %83

83:                                               ; preds = %167, %82
  %84 = load i64, ptr %12, align 8, !tbaa !9
  %85 = load i64, ptr %10, align 8, !tbaa !9
  %86 = icmp ult i64 %84, %85
  br i1 %86, label %88, label %87

87:                                               ; preds = %83
  store i32 4, ptr %9, align 4
  call void @llvm.lifetime.end.p0(i64 8, ptr %12) #4
  br label %170

88:                                               ; preds = %83
  call void @llvm.lifetime.start.p0(i64 70, ptr %13) #4
  call void @llvm.lifetime.start.p0(i64 8, ptr %14) #4
  store i64 0, ptr %14, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %15) #4
  store i64 0, ptr %15, align 8, !tbaa !9
  br label %89

89:                                               ; preds = %160, %88
  %90 = load i64, ptr %14, align 8, !tbaa !9
  %91 = getelementptr inbounds %"class.Simd::Base::ImagePxmSaver", ptr %16, i32 0, i32 4
  %92 = load i64, ptr %91, align 8, !tbaa !19
  %93 = icmp ult i64 %90, %92
  br i1 %93, label %95, label %94

94:                                               ; preds = %89
  store i32 7, ptr %9, align 4
  call void @llvm.lifetime.end.p0(i64 8, ptr %15) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %14) #4
  br label %163

95:                                               ; preds = %89
  %96 = load ptr, ptr %11, align 8, !tbaa !5
  %97 = load i64, ptr %14, align 8, !tbaa !9
  %98 = add i64 %97, 0
  %99 = getelementptr inbounds i8, ptr %96, i64 %98
  %100 = load i8, ptr %99, align 1, !tbaa !27
  %101 = zext i8 %100 to i64
  %102 = getelementptr inbounds [256 x [4 x i8]], ptr @_ZN4Simd4Base10g_pxmPrintE, i64 0, i64 %101
  %103 = getelementptr inbounds [4 x i8], ptr %102, i64 0, i64 0
  %104 = load i32, ptr %103, align 4, !tbaa !28
  %105 = getelementptr inbounds [70 x i8], ptr %13, i64 0, i64 0
  %106 = load i64, ptr %15, align 8, !tbaa !9
  %107 = getelementptr inbounds i8, ptr %105, i64 %106
  %108 = getelementptr inbounds i32, ptr %107, i64 0
  store i32 %104, ptr %108, align 4, !tbaa !28
  %109 = load ptr, ptr %11, align 8, !tbaa !5
  %110 = load i64, ptr %14, align 8, !tbaa !9
  %111 = add i64 %110, 1
  %112 = getelementptr inbounds i8, ptr %109, i64 %111
  %113 = load i8, ptr %112, align 1, !tbaa !27
  %114 = zext i8 %113 to i64
  %115 = getelementptr inbounds [256 x [4 x i8]], ptr @_ZN4Simd4Base10g_pxmPrintE, i64 0, i64 %114
  %116 = getelementptr inbounds [4 x i8], ptr %115, i64 0, i64 0
  %117 = load i32, ptr %116, align 4, !tbaa !28
  %118 = getelementptr inbounds [70 x i8], ptr %13, i64 0, i64 0
  %119 = load i64, ptr %15, align 8, !tbaa !9
  %120 = getelementptr inbounds i8, ptr %118, i64 %119
  %121 = getelementptr inbounds i32, ptr %120, i64 1
  store i32 %117, ptr %121, align 4, !tbaa !28
  %122 = load ptr, ptr %11, align 8, !tbaa !5
  %123 = load i64, ptr %14, align 8, !tbaa !9
  %124 = add i64 %123, 2
  %125 = getelementptr inbounds i8, ptr %122, i64 %124
  %126 = load i8, ptr %125, align 1, !tbaa !27
  %127 = zext i8 %126 to i64
  %128 = getelementptr inbounds [256 x [4 x i8]], ptr @_ZN4Simd4Base10g_pxmPrintE, i64 0, i64 %127
  %129 = getelementptr inbounds [4 x i8], ptr %128, i64 0, i64 0
  %130 = load i32, ptr %129, align 4, !tbaa !28
  %131 = getelementptr inbounds [70 x i8], ptr %13, i64 0, i64 0
  %132 = load i64, ptr %15, align 8, !tbaa !9
  %133 = getelementptr inbounds i8, ptr %131, i64 %132
  %134 = getelementptr inbounds i32, ptr %133, i64 2
  store i32 %130, ptr %134, align 4, !tbaa !28
  %135 = load i64, ptr %15, align 8, !tbaa !9
  %136 = add i64 %135, 12
  store i64 %136, ptr %15, align 8, !tbaa !9
  %137 = load i64, ptr %15, align 8, !tbaa !9
  %138 = icmp uge i64 %137, 68
  br i1 %138, label %145, label %139

139:                                              ; preds = %95
  %140 = load i64, ptr %14, align 8, !tbaa !9
  %141 = getelementptr inbounds %"class.Simd::Base::ImagePxmSaver", ptr %16, i32 0, i32 4
  %142 = load i64, ptr %141, align 8, !tbaa !19
  %143 = sub i64 %142, 3
  %144 = icmp eq i64 %140, %143
  br i1 %144, label %145, label %152

145:                                              ; preds = %139, %95
  %146 = load i64, ptr %15, align 8, !tbaa !9
  %147 = add i64 %146, 1
  store i64 %147, ptr %15, align 8, !tbaa !9
  %148 = getelementptr inbounds [70 x i8], ptr %13, i64 0, i64 %146
  store i8 10, ptr %148, align 1, !tbaa !27
  %149 = getelementptr inbounds %"class.Simd::ImageSaver", ptr %16, i32 0, i32 2
  %150 = getelementptr inbounds [70 x i8], ptr %13, i64 0, i64 0
  %151 = load i64, ptr %15, align 8, !tbaa !9
  call void @_ZN4Simd18OutputMemoryStream5WriteEPKvm(ptr noundef nonnull align 8 dereferenceable(56) %149, ptr noundef %150, i64 noundef %151)
  store i64 0, ptr %15, align 8, !tbaa !9
  br label %159

152:                                              ; preds = %139
  %153 = load i64, ptr %15, align 8, !tbaa !9
  %154 = add i64 %153, 1
  store i64 %154, ptr %15, align 8, !tbaa !9
  %155 = getelementptr inbounds [70 x i8], ptr %13, i64 0, i64 %153
  store i8 32, ptr %155, align 1, !tbaa !27
  %156 = load i64, ptr %15, align 8, !tbaa !9
  %157 = add i64 %156, 1
  store i64 %157, ptr %15, align 8, !tbaa !9
  %158 = getelementptr inbounds [70 x i8], ptr %13, i64 0, i64 %156
  store i8 32, ptr %158, align 1, !tbaa !27
  br label %159

159:                                              ; preds = %152, %145
  br label %160

160:                                              ; preds = %159
  %161 = load i64, ptr %14, align 8, !tbaa !9
  %162 = add i64 %161, 3
  store i64 %162, ptr %14, align 8, !tbaa !9
  br label %89, !llvm.loop !29

163:                                              ; preds = %94
  %164 = load i64, ptr %7, align 8, !tbaa !9
  %165 = load ptr, ptr %11, align 8, !tbaa !5
  %166 = getelementptr inbounds i8, ptr %165, i64 %164
  store ptr %166, ptr %11, align 8, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 70, ptr %13) #4
  br label %167

167:                                              ; preds = %163
  %168 = load i64, ptr %12, align 8, !tbaa !9
  %169 = add i64 %168, 1
  store i64 %169, ptr %12, align 8, !tbaa !9
  br label %83, !llvm.loop !31

170:                                              ; preds = %87
  %171 = load i64, ptr %6, align 8, !tbaa !9
  %172 = load i64, ptr %10, align 8, !tbaa !9
  %173 = mul i64 %171, %172
  %174 = load ptr, ptr %5, align 8, !tbaa !5
  %175 = getelementptr inbounds i8, ptr %174, i64 %173
  store ptr %175, ptr %5, align 8, !tbaa !5
  %176 = load i64, ptr %10, align 8, !tbaa !9
  %177 = load i64, ptr %8, align 8, !tbaa !9
  %178 = add i64 %177, %176
  store i64 %178, ptr %8, align 8, !tbaa !9
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #4
  br label %43, !llvm.loop !32

179:                                              ; preds = %49
  store i32 1, ptr %9, align 4
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #4
  ret i1 true
}

attributes #0 = { 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 #1 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { alwaysinline 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 #3 = { alwaysinline 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 #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 = !{!"any pointer", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"long", !7, i64 0}
!11 = !{!12, !14, i64 24}
!12 = !{!"_ZTSN4Simd10ImageSaverE", !13, i64 8, !18, i64 40}
!13 = !{!"_ZTSN4Simd15ImageSaverParamE", !10, i64 0, !10, i64 8, !14, i64 16, !15, i64 20, !16, i64 24, !17, i64 28}
!14 = !{!"_ZTS19SimdPixelFormatType", !7, i64 0}
!15 = !{!"_ZTS17SimdImageFileType", !7, i64 0}
!16 = !{!"int", !7, i64 0}
!17 = !{!"_ZTS11SimdYuvType", !7, i64 0}
!18 = !{!"_ZTSN4Simd18OutputMemoryStreamE", !10, i64 0, !6, i64 8, !10, i64 16, !10, i64 24, !10, i64 32, !10, i64 40, !10, i64 48}
!19 = !{!20, !10, i64 128}
!20 = !{!"_ZTSN4Simd4Base13ImagePxmSaverE", !12, i64 0, !6, i64 96, !21, i64 104, !10, i64 120, !10, i64 128}
!21 = !{!"_ZTSN4Simd5ArrayIhEE", !6, i64 0, !10, i64 8}
!22 = !{!12, !10, i64 16}
!23 = !{!12, !10, i64 8}
!24 = !{!20, !10, i64 120}
!25 = !{!20, !6, i64 96}
!26 = !{!20, !6, i64 104}
!27 = !{!7, !7, i64 0}
!28 = !{!16, !16, i64 0}
!29 = distinct !{!29, !30}
!30 = !{!"llvm.loop.mustprogress"}
!31 = distinct !{!31, !30}
!32 = distinct !{!32, !30}


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

@_ZN4Simd4Base10g_pxmPrintE = external dso_local local_unnamed_addr global [256 x [4 x i8]], align 16

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN4Simd4Base13ImagePxmSaver11WriteHeaderEm(ptr noundef nonnull align 8 dereferenceable(136), i64 noundef) local_unnamed_addr #0 align 2

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

; Function Attrs: alwaysinline mustprogress uwtable
declare dso_local void @_ZN4Simd18OutputMemoryStream5WriteEPKvm(ptr noundef nonnull align 8 dereferenceable(56), ptr noundef, i64 noundef) local_unnamed_addr #2 align 2

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

; Function Attrs: alwaysinline mustprogress uwtable
declare dso_local void @_ZN4Simd18OutputMemoryStream7ReserveEm(ptr noundef nonnull align 8 dereferenceable(56), i64 noundef) local_unnamed_addr #2 align 2

; Function Attrs: alwaysinline mustprogress nounwind uwtable
declare dso_local noundef i64 @_ZN4Simd5DivHiEmm(i64 noundef, i64 noundef) local_unnamed_addr #3

; Function Attrs: alwaysinline mustprogress nounwind uwtable
declare dso_local noundef i64 @_ZN4Simd3MinImEET_S1_S1_(i64 noundef, i64 noundef) local_unnamed_addr #3

; Function Attrs: mustprogress uwtable
define dso_local noundef zeroext i1 @_ZN4Simd4Base16ImagePpmTxtSaver8ToStreamEPKhm(ptr noundef nonnull align 8 dereferenceable(136) %0, ptr noundef %1, i64 noundef %2) unnamed_addr #0 align 2 {
  %4 = alloca [70 x i8], align 16
  %5 = getelementptr inbounds i8, ptr %0, i64 8
  %6 = getelementptr inbounds i8, ptr %0, i64 24
  %7 = load i32, ptr %6, align 8, !tbaa !5
  %8 = icmp eq i32 %7, 16
  %9 = getelementptr inbounds i8, ptr %0, i64 128
  %10 = load i64, ptr %9, align 8
  %11 = select i1 %8, i64 %2, i64 %10
  %12 = getelementptr inbounds i8, ptr %0, i64 40
  %13 = getelementptr inbounds i8, ptr %0, i64 16
  %14 = load i64, ptr %13, align 8, !tbaa !17
  %15 = load i64, ptr %5, align 8, !tbaa !18
  %16 = mul i64 %15, 13
  %17 = tail call noundef i64 @_ZN4Simd5DivHiEmm(i64 noundef %15, i64 noundef 5)
  %18 = add i64 %16, %17
  %19 = mul i64 %18, %14
  %20 = add i64 %19, 32
  tail call void @_ZN4Simd18OutputMemoryStream7ReserveEm(ptr noundef nonnull align 8 dereferenceable(56) %12, i64 noundef %20)
  tail call void @_ZN4Simd4Base13ImagePxmSaver11WriteHeaderEm(ptr noundef nonnull align 8 dereferenceable(136) %0, i64 noundef 3)
  %21 = load i64, ptr %13, align 8, !tbaa !17
  %.not59 = icmp eq i64 %21, 0
  br i1 %.not59, label %._crit_edge58, label %.lr.ph57

.lr.ph57:                                         ; preds = %3
  %22 = getelementptr inbounds i8, ptr %0, i64 120
  %23 = getelementptr inbounds i8, ptr %0, i64 96
  %24 = getelementptr inbounds i8, ptr %0, i64 104
  br label %25

._crit_edge58:                                    ; preds = %._crit_edge53, %3
  ret i1 true

25:                                               ; preds = %.lr.ph57, %._crit_edge53
  %26 = phi i64 [ %21, %.lr.ph57 ], [ %41, %._crit_edge53 ]
  %.04155 = phi ptr [ %1, %.lr.ph57 ], [ %40, %._crit_edge53 ]
  %.04254 = phi i64 [ 0, %.lr.ph57 ], [ %29, %._crit_edge53 ]
  %27 = load i64, ptr %22, align 8, !tbaa !19
  %28 = add i64 %27, %.04254
  %29 = call noundef i64 @_ZN4Simd3MinImEET_S1_S1_(i64 noundef %28, i64 noundef %26)
  %30 = sub i64 %29, %.04254
  %31 = load i32, ptr %6, align 8, !tbaa !5
  %.not = icmp eq i32 %31, 16
  br i1 %.not, label %37, label %32

32:                                               ; preds = %25
  %33 = load ptr, ptr %23, align 8, !tbaa !22
  %34 = load i64, ptr %5, align 8, !tbaa !18
  %35 = load ptr, ptr %24, align 8, !tbaa !23
  call void %33(ptr noundef %.04155, i64 noundef %34, i64 noundef %30, i64 noundef %2, ptr noundef %35, i64 noundef %11)
  %36 = load ptr, ptr %24, align 8, !tbaa !23
  br label %37

37:                                               ; preds = %32, %25
  %.039 = phi ptr [ %36, %32 ], [ %.04155, %25 ]
  %.not60 = icmp eq i64 %29, %.04254
  %38 = load i64, ptr %9, align 8
  %.not61 = icmp eq i64 %38, 0
  %or.cond64 = select i1 %.not60, i1 true, i1 %.not61
  br i1 %or.cond64, label %._crit_edge53, label %.lr.ph52.split

._crit_edge53:                                    ; preds = %._crit_edge, %37
  %39 = mul i64 %30, %2
  %40 = getelementptr inbounds i8, ptr %.04155, i64 %39
  %41 = load i64, ptr %13, align 8, !tbaa !17
  %42 = icmp ult i64 %29, %41
  br i1 %42, label %25, label %._crit_edge58, !llvm.loop !24

.lr.ph52.split:                                   ; preds = %37, %._crit_edge
  %43 = phi i64 [ %45, %._crit_edge ], [ %38, %37 ]
  %44 = phi i64 [ %46, %._crit_edge ], [ %38, %37 ]
  %.03850 = phi i64 [ %48, %._crit_edge ], [ 0, %37 ]
  %.14049 = phi ptr [ %47, %._crit_edge ], [ %.039, %37 ]
  call void @llvm.lifetime.start.p0(i64 70, ptr nonnull %4) #4
  %.not62 = icmp eq i64 %44, 0
  br i1 %.not62, label %._crit_edge, label %.lr.ph

._crit_edge:                                      ; preds = %81, %.lr.ph52.split
  %45 = phi i64 [ %43, %.lr.ph52.split ], [ %82, %81 ]
  %46 = phi i64 [ 0, %.lr.ph52.split ], [ %82, %81 ]
  %47 = getelementptr inbounds i8, ptr %.14049, i64 %11
  call void @llvm.lifetime.end.p0(i64 70, ptr nonnull %4) #4
  %48 = add nuw i64 %.03850, 1
  %exitcond.not = icmp eq i64 %48, %30
  br i1 %exitcond.not, label %._crit_edge53, label %.lr.ph52.split, !llvm.loop !26

.lr.ph:                                           ; preds = %.lr.ph52.split, %81
  %49 = phi i64 [ %82, %81 ], [ %43, %.lr.ph52.split ]
  %50 = phi i64 [ %82, %81 ], [ %44, %.lr.ph52.split ]
  %.048 = phi i64 [ %.1, %81 ], [ 0, %.lr.ph52.split ]
  %.03747 = phi i64 [ %83, %81 ], [ 0, %.lr.ph52.split ]
  %51 = getelementptr inbounds i8, ptr %.14049, i64 %.03747
  %52 = load i8, ptr %51, align 1, !tbaa !28
  %53 = zext i8 %52 to i64
  %54 = getelementptr inbounds [256 x [4 x i8]], ptr @_ZN4Simd4Base10g_pxmPrintE, i64 0, i64 %53
  %55 = load i32, ptr %54, align 4, !tbaa !29
  %56 = getelementptr inbounds i8, ptr %4, i64 %.048
  store i32 %55, ptr %56, align 4, !tbaa !29
  %57 = add nuw i64 %.03747, 1
  %58 = getelementptr inbounds i8, ptr %.14049, i64 %57
  %59 = load i8, ptr %58, align 1, !tbaa !28
  %60 = zext i8 %59 to i64
  %61 = getelementptr inbounds [256 x [4 x i8]], ptr @_ZN4Simd4Base10g_pxmPrintE, i64 0, i64 %60
  %62 = load i32, ptr %61, align 4, !tbaa !29
  %63 = getelementptr inbounds i8, ptr %56, i64 4
  store i32 %62, ptr %63, align 4, !tbaa !29
  %64 = add i64 %.03747, 2
  %65 = getelementptr inbounds i8, ptr %.14049, i64 %64
  %66 = load i8, ptr %65, align 1, !tbaa !28
  %67 = zext i8 %66 to i64
  %68 = getelementptr inbounds [256 x [4 x i8]], ptr @_ZN4Simd4Base10g_pxmPrintE, i64 0, i64 %67
  %69 = load i32, ptr %68, align 4, !tbaa !29
  %70 = getelementptr inbounds i8, ptr %56, i64 8
  store i32 %69, ptr %70, align 4, !tbaa !29
  %71 = add i64 %.048, 12
  %72 = icmp ugt i64 %71, 67
  %73 = add i64 %50, -3
  %74 = icmp eq i64 %.03747, %73
  %or.cond = or i1 %72, %74
  %75 = add i64 %.048, 13
  %76 = getelementptr inbounds [70 x i8], ptr %4, i64 0, i64 %71
  br i1 %or.cond, label %77, label %78

77:                                               ; preds = %.lr.ph
  store i8 10, ptr %76, align 1, !tbaa !28
  call void @_ZN4Simd18OutputMemoryStream5WriteEPKvm(ptr noundef nonnull align 8 dereferenceable(56) %12, ptr noundef nonnull %4, i64 noundef %75)
  %.pre = load i64, ptr %9, align 8, !tbaa !30
  br label %81

78:                                               ; preds = %.lr.ph
  store i8 32, ptr %76, align 1, !tbaa !28
  %79 = add nsw i64 %.048, 14
  %80 = getelementptr inbounds [70 x i8], ptr %4, i64 0, i64 %75
  store i8 32, ptr %80, align 1, !tbaa !28
  br label %81

81:                                               ; preds = %77, %78
  %82 = phi i64 [ %.pre, %77 ], [ %49, %78 ]
  %.1 = phi i64 [ 0, %77 ], [ %79, %78 ]
  %83 = add i64 %.03747, 3
  %84 = icmp ult i64 %83, %82
  br i1 %84, label %.lr.ph, label %._crit_edge, !llvm.loop !31
}

attributes #0 = { 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 #1 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { alwaysinline 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 #3 = { alwaysinline 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 #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, !11, i64 24}
!6 = !{!"_ZTSN4Simd10ImageSaverE", !7, i64 8, !15, i64 40}
!7 = !{!"_ZTSN4Simd15ImageSaverParamE", !8, i64 0, !8, i64 8, !11, i64 16, !12, i64 20, !13, i64 24, !14, i64 28}
!8 = !{!"long", !9, i64 0}
!9 = !{!"omnipotent char", !10, i64 0}
!10 = !{!"Simple C++ TBAA"}
!11 = !{!"_ZTS19SimdPixelFormatType", !9, i64 0}
!12 = !{!"_ZTS17SimdImageFileType", !9, i64 0}
!13 = !{!"int", !9, i64 0}
!14 = !{!"_ZTS11SimdYuvType", !9, i64 0}
!15 = !{!"_ZTSN4Simd18OutputMemoryStreamE", !8, i64 0, !16, i64 8, !8, i64 16, !8, i64 24, !8, i64 32, !8, i64 40, !8, i64 48}
!16 = !{!"any pointer", !9, i64 0}
!17 = !{!6, !8, i64 16}
!18 = !{!6, !8, i64 8}
!19 = !{!20, !8, i64 120}
!20 = !{!"_ZTSN4Simd4Base13ImagePxmSaverE", !6, i64 0, !16, i64 96, !21, i64 104, !8, i64 120, !8, i64 128}
!21 = !{!"_ZTSN4Simd5ArrayIhEE", !16, i64 0, !8, i64 8}
!22 = !{!20, !16, i64 96}
!23 = !{!20, !16, i64 104}
!24 = distinct !{!24, !25}
!25 = !{!"llvm.loop.mustprogress"}
!26 = distinct !{!26, !25, !27}
!27 = !{!"llvm.loop.unswitch.partial.disable"}
!28 = !{!9, !9, i64 0}
!29 = !{!13, !13, i64 0}
!30 = !{!20, !8, i64 128}
!31 = distinct !{!31, !25}


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