; LLVM IR from avik-das/seam-carver :: seam-carver (write_energy)

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

@stderr = external global ptr, align 8
@.str.9 = external hidden unnamed_addr constant [32 x i8], align 1
@.str.10 = external hidden unnamed_addr constant [17 x i8], align 1
@.str.11 = external hidden unnamed_addr constant [29 x i8], align 1

; Function Attrs: nounwind
declare void @free(ptr noundef) #0

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

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

; Function Attrs: nounwind allocsize(0)
declare noalias ptr @malloc(i64 noundef) #2

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

; Function Attrs: nounwind
declare i32 @fprintf(ptr noundef, ptr noundef, ...) #0

; Function Attrs: nounwind uwtable
define dso_local i32 @write_energy(ptr noundef %0, i32 noundef %1, i32 noundef %2, ptr noundef %3) #3 {
  %5 = alloca ptr, align 8
  %6 = alloca i32, align 4
  %7 = alloca i32, align 4
  %8 = alloca ptr, align 8
  %9 = alloca i32, align 4
  %10 = alloca ptr, align 8
  %11 = alloca i32, align 4
  %12 = alloca i32, align 4
  %13 = alloca i32, align 4
  %14 = alloca i32, align 4
  %15 = alloca i32, align 4
  %16 = alloca i32, align 4
  %17 = alloca i32, align 4
  %18 = 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 ptr %3, ptr %8, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #5
  store i32 0, ptr %9, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #5
  %19 = load i32, ptr %6, align 4, !tbaa !9
  %20 = load i32, ptr %7, align 4, !tbaa !9
  %21 = mul nsw i32 %19, %20
  %22 = sext i32 %21 to i64
  %23 = call noalias ptr @malloc(i64 noundef %22) #6
  store ptr %23, ptr %10, align 8, !tbaa !5
  %24 = load ptr, ptr %10, align 8, !tbaa !5
  %25 = icmp ne ptr %24, null
  br i1 %25, label %29, label %26

26:                                               ; preds = %4
  %27 = load ptr, ptr @stderr, align 8, !tbaa !5
  %28 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %27, ptr noundef @.str.9, i32 noundef 191) #5
  store i32 1, ptr %9, align 4, !tbaa !9
  br label %124

29:                                               ; preds = %4
  store i32 1, ptr %11, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %12) #5
  store i32 0, ptr %12, align 4, !tbaa !9
  br label %30

30:                                               ; preds = %68, %29
  %31 = load i32, ptr %12, align 4, !tbaa !9
  %32 = load i32, ptr %7, align 4, !tbaa !9
  %33 = icmp slt i32 %31, %32
  br i1 %33, label %35, label %34

34:                                               ; preds = %30
  store i32 3, ptr %13, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %12) #5
  br label %71

35:                                               ; preds = %30
  call void @llvm.lifetime.start.p0(i64 4, ptr %14) #5
  store i32 0, ptr %14, align 4, !tbaa !9
  br label %36

36:                                               ; preds = %64, %35
  %37 = load i32, ptr %14, align 4, !tbaa !9
  %38 = load i32, ptr %6, align 4, !tbaa !9
  %39 = icmp slt i32 %37, %38
  br i1 %39, label %41, label %40

40:                                               ; preds = %36
  store i32 6, ptr %13, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %14) #5
  br label %67

41:                                               ; preds = %36
  call void @llvm.lifetime.start.p0(i64 4, ptr %15) #5
  %42 = load i32, ptr %12, align 4, !tbaa !9
  %43 = load i32, ptr %6, align 4, !tbaa !9
  %44 = mul nsw i32 %42, %43
  %45 = load i32, ptr %14, align 4, !tbaa !9
  %46 = add nsw i32 %44, %45
  store i32 %46, ptr %15, align 4, !tbaa !9
  %47 = load ptr, ptr %5, align 8, !tbaa !5
  %48 = load i32, ptr %15, align 4, !tbaa !9
  %49 = sext i32 %48 to i64
  %50 = getelementptr inbounds i32, ptr %47, i64 %49
  %51 = load i32, ptr %50, align 4, !tbaa !9
  %52 = load i32, ptr %11, align 4, !tbaa !9
  %53 = icmp ugt i32 %51, %52
  br i1 %53, label %54, label %60

54:                                               ; preds = %41
  %55 = load ptr, ptr %5, align 8, !tbaa !5
  %56 = load i32, ptr %15, align 4, !tbaa !9
  %57 = sext i32 %56 to i64
  %58 = getelementptr inbounds i32, ptr %55, i64 %57
  %59 = load i32, ptr %58, align 4, !tbaa !9
  br label %62

60:                                               ; preds = %41
  %61 = load i32, ptr %11, align 4, !tbaa !9
  br label %62

62:                                               ; preds = %60, %54
  %63 = phi i32 [ %59, %54 ], [ %61, %60 ]
  store i32 %63, ptr %11, align 4, !tbaa !9
  call void @llvm.lifetime.end.p0(i64 4, ptr %15) #5
  br label %64

64:                                               ; preds = %62
  %65 = load i32, ptr %14, align 4, !tbaa !9
  %66 = add nsw i32 %65, 1
  store i32 %66, ptr %14, align 4, !tbaa !9
  br label %36, !llvm.loop !11

67:                                               ; preds = %40
  br label %68

68:                                               ; preds = %67
  %69 = load i32, ptr %12, align 4, !tbaa !9
  %70 = add nsw i32 %69, 1
  store i32 %70, ptr %12, align 4, !tbaa !9
  br label %30, !llvm.loop !13

71:                                               ; preds = %34
  call void @llvm.lifetime.start.p0(i64 4, ptr %16) #5
  store i32 0, ptr %16, align 4, !tbaa !9
  br label %72

72:                                               ; preds = %108, %71
  %73 = load i32, ptr %16, align 4, !tbaa !9
  %74 = load i32, ptr %7, align 4, !tbaa !9
  %75 = icmp slt i32 %73, %74
  br i1 %75, label %77, label %76

76:                                               ; preds = %72
  store i32 9, ptr %13, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %16) #5
  br label %111

77:                                               ; preds = %72
  call void @llvm.lifetime.start.p0(i64 4, ptr %17) #5
  store i32 0, ptr %17, align 4, !tbaa !9
  br label %78

78:                                               ; preds = %104, %77
  %79 = load i32, ptr %17, align 4, !tbaa !9
  %80 = load i32, ptr %6, align 4, !tbaa !9
  %81 = icmp slt i32 %79, %80
  br i1 %81, label %83, label %82

82:                                               ; preds = %78
  store i32 12, ptr %13, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %17) #5
  br label %107

83:                                               ; preds = %78
  call void @llvm.lifetime.start.p0(i64 4, ptr %18) #5
  %84 = load i32, ptr %16, align 4, !tbaa !9
  %85 = load i32, ptr %6, align 4, !tbaa !9
  %86 = mul nsw i32 %84, %85
  %87 = load i32, ptr %17, align 4, !tbaa !9
  %88 = add nsw i32 %86, %87
  store i32 %88, ptr %18, align 4, !tbaa !9
  %89 = load ptr, ptr %5, align 8, !tbaa !5
  %90 = load i32, ptr %18, align 4, !tbaa !9
  %91 = sext i32 %90 to i64
  %92 = getelementptr inbounds i32, ptr %89, i64 %91
  %93 = load i32, ptr %92, align 4, !tbaa !9
  %94 = uitofp i32 %93 to double
  %95 = load i32, ptr %11, align 4, !tbaa !9
  %96 = sitofp i32 %95 to double
  %97 = fdiv double %94, %96
  %98 = fmul double %97, 2.550000e+02
  %99 = fptosi double %98 to i8
  %100 = load ptr, ptr %10, align 8, !tbaa !5
  %101 = load i32, ptr %18, align 4, !tbaa !9
  %102 = sext i32 %101 to i64
  %103 = getelementptr inbounds i8, ptr %100, i64 %102
  store i8 %99, ptr %103, align 1, !tbaa !14
  call void @llvm.lifetime.end.p0(i64 4, ptr %18) #5
  br label %104

104:                                              ; preds = %83
  %105 = load i32, ptr %17, align 4, !tbaa !9
  %106 = add nsw i32 %105, 1
  store i32 %106, ptr %17, align 4, !tbaa !9
  br label %78, !llvm.loop !15

107:                                              ; preds = %82
  br label %108

108:                                              ; preds = %107
  %109 = load i32, ptr %16, align 4, !tbaa !9
  %110 = add nsw i32 %109, 1
  store i32 %110, ptr %16, align 4, !tbaa !9
  br label %72, !llvm.loop !16

111:                                              ; preds = %76
  %112 = load ptr, ptr %8, align 8, !tbaa !5
  %113 = call i32 (ptr, ...) @printf(ptr noundef @.str.10, ptr noundef %112)
  %114 = load ptr, ptr %8, align 8, !tbaa !5
  %115 = load i32, ptr %6, align 4, !tbaa !9
  %116 = load i32, ptr %7, align 4, !tbaa !9
  %117 = load ptr, ptr %10, align 8, !tbaa !5
  %118 = call i32 @stbi_write_jpg(ptr noundef %114, i32 noundef %115, i32 noundef %116, i32 noundef 1, ptr noundef %117, i32 noundef 80)
  %119 = icmp ne i32 %118, 0
  br i1 %119, label %123, label %120

120:                                              ; preds = %111
  %121 = load ptr, ptr @stderr, align 8, !tbaa !5
  %122 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %121, ptr noundef @.str.11, i32 noundef 212) #5
  store i32 1, ptr %9, align 4, !tbaa !9
  br label %124

123:                                              ; preds = %111
  br label %124

124:                                              ; preds = %123, %120, %26
  %125 = load ptr, ptr %10, align 8, !tbaa !5
  %126 = icmp ne ptr %125, null
  br i1 %126, label %127, label %129

127:                                              ; preds = %124
  %128 = load ptr, ptr %10, align 8, !tbaa !5
  call void @free(ptr noundef %128) #5
  br label %129

129:                                              ; preds = %127, %124
  %130 = load i32, ptr %9, align 4, !tbaa !9
  store i32 1, ptr %13, align 4
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #5
  ret i32 %130
}

declare i32 @printf(ptr noundef, ...) #4

attributes #0 = { nounwind "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #1 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { nounwind allocsize(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"="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 = { "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 = { nounwind allocsize(0) }

!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 = distinct !{!11, !12}
!12 = !{!"llvm.loop.mustprogress"}
!13 = distinct !{!13, !12}
!14 = !{!7, !7, i64 0}
!15 = distinct !{!15, !12}
!16 = distinct !{!16, !12}


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

@stderr = external local_unnamed_addr global ptr, align 8
@.str.9 = external hidden unnamed_addr constant [32 x i8], align 1
@.str.10 = external hidden unnamed_addr constant [17 x i8], align 1
@.str.11 = external hidden unnamed_addr constant [29 x i8], align 1

; Function Attrs: mustprogress nounwind willreturn allockind("free") memory(argmem: readwrite, inaccessiblemem: readwrite)
declare void @free(ptr allocptr nocapture noundef) local_unnamed_addr #0

; Function Attrs: mustprogress nofree nounwind willreturn allockind("alloc,uninitialized") allocsize(0) memory(inaccessiblemem: readwrite)
declare noalias noundef ptr @malloc(i64 noundef) local_unnamed_addr #1

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

; Function Attrs: nofree nounwind
declare noundef i32 @fprintf(ptr nocapture noundef, ptr nocapture noundef readonly, ...) local_unnamed_addr #3

; Function Attrs: nounwind uwtable
define dso_local range(i32 0, 2) i32 @write_energy(ptr nocapture noundef readonly %0, i32 noundef %1, i32 noundef %2, ptr noundef %3) local_unnamed_addr #2 {
  %5 = mul nsw i32 %2, %1
  %6 = sext i32 %5 to i64
  %7 = tail call noalias ptr @malloc(i64 noundef %6) #5
  %.not = icmp eq ptr %7, null
  br i1 %.not, label %.thread, label %.preheader55

.preheader55:                                     ; preds = %4
  %8 = icmp sgt i32 %2, 0
  %9 = icmp sgt i32 %1, 0
  %or.cond = and i1 %8, %9
  br i1 %or.cond, label %.preheader54.us.preheader, label %._crit_edge63

.preheader54.us.preheader:                        ; preds = %.preheader55
  %10 = zext nneg i32 %1 to i64
  %wide.trip.count71 = zext nneg i32 %2 to i64
  %min.iters.check = icmp ult i32 %1, 8
  %n.vec = and i64 %10, 2147483640
  %cmp.n = icmp eq i64 %n.vec, %10
  br label %.preheader54.us

.preheader54.us:                                  ; preds = %.preheader54.us.preheader, %._crit_edge.us
  %indvars.iv68 = phi i64 [ 0, %.preheader54.us.preheader ], [ %indvars.iv.next69, %._crit_edge.us ]
  %.04159.us = phi i32 [ 1, %.preheader54.us.preheader ], [ %..1.us.lcssa, %._crit_edge.us ]
  %11 = mul nuw nsw i64 %indvars.iv68, %10
  %invariant.gep = getelementptr inbounds i32, ptr %0, i64 %11
  br i1 %min.iters.check, label %scalar.ph.preheader, label %vector.ph

vector.ph:                                        ; preds = %.preheader54.us
  %minmax.ident.splatinsert = insertelement <4 x i32> poison, i32 %.04159.us, i64 0
  %minmax.ident.splat = shufflevector <4 x i32> %minmax.ident.splatinsert, <4 x i32> poison, <4 x i32> zeroinitializer
  br label %vector.body

vector.body:                                      ; preds = %vector.body, %vector.ph
  %index = phi i64 [ 0, %vector.ph ], [ %index.next, %vector.body ]
  %vec.phi = phi <4 x i32> [ %minmax.ident.splat, %vector.ph ], [ %14, %vector.body ]
  %vec.phi89 = phi <4 x i32> [ %minmax.ident.splat, %vector.ph ], [ %15, %vector.body ]
  %12 = getelementptr inbounds i32, ptr %invariant.gep, i64 %index
  %13 = getelementptr inbounds i8, ptr %12, i64 16
  %wide.load = load <4 x i32>, ptr %12, align 4, !tbaa !5
  %wide.load90 = load <4 x i32>, ptr %13, align 4, !tbaa !5
  %14 = tail call <4 x i32> @llvm.umax.v4i32(<4 x i32> %wide.load, <4 x i32> %vec.phi)
  %15 = tail call <4 x i32> @llvm.umax.v4i32(<4 x i32> %wide.load90, <4 x i32> %vec.phi89)
  %index.next = add nuw i64 %index, 8
  %16 = icmp eq i64 %index.next, %n.vec
  br i1 %16, label %middle.block, label %vector.body, !llvm.loop !9

middle.block:                                     ; preds = %vector.body
  %rdx.minmax = tail call <4 x i32> @llvm.umax.v4i32(<4 x i32> %14, <4 x i32> %15)
  %17 = tail call i32 @llvm.vector.reduce.umax.v4i32(<4 x i32> %rdx.minmax)
  br i1 %cmp.n, label %._crit_edge.us, label %scalar.ph.preheader

scalar.ph.preheader:                              ; preds = %middle.block, %.preheader54.us
  %indvars.iv.ph = phi i64 [ 0, %.preheader54.us ], [ %n.vec, %middle.block ]
  %.157.us.ph = phi i32 [ %.04159.us, %.preheader54.us ], [ %17, %middle.block ]
  br label %scalar.ph

scalar.ph:                                        ; preds = %scalar.ph.preheader, %scalar.ph
  %indvars.iv = phi i64 [ %indvars.iv.next, %scalar.ph ], [ %indvars.iv.ph, %scalar.ph.preheader ]
  %.157.us = phi i32 [ %..1.us, %scalar.ph ], [ %.157.us.ph, %scalar.ph.preheader ]
  %gep = getelementptr inbounds i32, ptr %invariant.gep, i64 %indvars.iv
  %18 = load i32, ptr %gep, align 4, !tbaa !5
  %..1.us = tail call i32 @llvm.umax.i32(i32 %18, i32 %.157.us)
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %exitcond.not = icmp eq i64 %indvars.iv.next, %10
  br i1 %exitcond.not, label %._crit_edge.us, label %scalar.ph, !llvm.loop !13

._crit_edge.us:                                   ; preds = %scalar.ph, %middle.block
  %..1.us.lcssa = phi i32 [ %17, %middle.block ], [ %..1.us, %scalar.ph ]
  %indvars.iv.next69 = add nuw nsw i64 %indvars.iv68, 1
  %exitcond72.not = icmp eq i64 %indvars.iv.next69, %wide.trip.count71
  br i1 %exitcond72.not, label %.preheader53, label %.preheader54.us, !llvm.loop !14

.thread:                                          ; preds = %4
  %19 = load ptr, ptr @stderr, align 8, !tbaa !15
  %20 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %19, ptr noundef nonnull @.str.9, i32 noundef 191) #6
  br label %46

.preheader53:                                     ; preds = %._crit_edge.us
  %21 = sitofp i32 %..1.us.lcssa to double
  br i1 %8, label %.preheader.us.preheader, label %._crit_edge63

.preheader.us.preheader:                          ; preds = %.preheader53
  %22 = zext nneg i32 %1 to i64
  %wide.trip.count81 = zext nneg i32 %2 to i64
  %min.iters.check93 = icmp ult i32 %1, 4
  %n.vec96 = and i64 %10, 2147483644
  %broadcast.splatinsert = insertelement <4 x double> poison, double %21, i64 0
  %broadcast.splat = shufflevector <4 x double> %broadcast.splatinsert, <4 x double> poison, <4 x i32> zeroinitializer
  %cmp.n102 = icmp eq i64 %n.vec96, %10
  br label %.preheader.us

.preheader.us:                                    ; preds = %.preheader.us.preheader, %._crit_edge.us64
  %indvars.iv78 = phi i64 [ 0, %.preheader.us.preheader ], [ %indvars.iv.next79, %._crit_edge.us64 ]
  %23 = mul nuw nsw i64 %indvars.iv78, %22
  br i1 %min.iters.check93, label %scalar.ph92.preheader, label %vector.body98

vector.body98:                                    ; preds = %.preheader.us, %vector.body98
  %index99 = phi i64 [ %index.next101, %vector.body98 ], [ 0, %.preheader.us ]
  %24 = add nuw nsw i64 %index99, %23
  %25 = getelementptr inbounds i32, ptr %0, i64 %24
  %wide.load100 = load <4 x i32>, ptr %25, align 4, !tbaa !5
  %26 = uitofp <4 x i32> %wide.load100 to <4 x double>
  %27 = fdiv <4 x double> %26, %broadcast.splat
  %28 = fmul <4 x double> %27, <double 2.550000e+02, double 2.550000e+02, double 2.550000e+02, double 2.550000e+02>
  %29 = fptosi <4 x double> %28 to <4 x i8>
  %30 = getelementptr inbounds i8, ptr %7, i64 %24
  store <4 x i8> %29, ptr %30, align 1, !tbaa !17
  %index.next101 = add nuw i64 %index99, 4
  %31 = icmp eq i64 %index.next101, %n.vec96
  br i1 %31, label %middle.block91, label %vector.body98, !llvm.loop !18

middle.block91:                                   ; preds = %vector.body98
  br i1 %cmp.n102, label %._crit_edge.us64, label %scalar.ph92.preheader

scalar.ph92.preheader:                            ; preds = %middle.block91, %.preheader.us
  %indvars.iv73.ph = phi i64 [ 0, %.preheader.us ], [ %n.vec96, %middle.block91 ]
  br label %scalar.ph92

scalar.ph92:                                      ; preds = %scalar.ph92.preheader, %scalar.ph92
  %indvars.iv73 = phi i64 [ %indvars.iv.next74, %scalar.ph92 ], [ %indvars.iv73.ph, %scalar.ph92.preheader ]
  %32 = add nuw nsw i64 %indvars.iv73, %23
  %33 = getelementptr inbounds i32, ptr %0, i64 %32
  %34 = load i32, ptr %33, align 4, !tbaa !5
  %35 = uitofp i32 %34 to double
  %36 = fdiv double %35, %21
  %37 = fmul double %36, 2.550000e+02
  %38 = fptosi double %37 to i8
  %39 = getelementptr inbounds i8, ptr %7, i64 %32
  store i8 %38, ptr %39, align 1, !tbaa !17
  %indvars.iv.next74 = add nuw nsw i64 %indvars.iv73, 1
  %exitcond77.not = icmp eq i64 %indvars.iv.next74, %22
  br i1 %exitcond77.not, label %._crit_edge.us64, label %scalar.ph92, !llvm.loop !19

._crit_edge.us64:                                 ; preds = %scalar.ph92, %middle.block91
  %indvars.iv.next79 = add nuw nsw i64 %indvars.iv78, 1
  %exitcond82.not = icmp eq i64 %indvars.iv.next79, %wide.trip.count81
  br i1 %exitcond82.not, label %._crit_edge63, label %.preheader.us, !llvm.loop !20

._crit_edge63:                                    ; preds = %._crit_edge.us64, %.preheader55, %.preheader53
  %40 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.10, ptr noundef %3)
  %41 = tail call i32 @stbi_write_jpg(ptr noundef %3, i32 noundef %1, i32 noundef %2, i32 noundef 1, ptr noundef nonnull %7, i32 noundef 80)
  %.not50 = icmp eq i32 %41, 0
  br i1 %.not50, label %42, label %45

42:                                               ; preds = %._crit_edge63
  %43 = load ptr, ptr @stderr, align 8, !tbaa !15
  %44 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %43, ptr noundef nonnull @.str.11, i32 noundef 212) #6
  br label %45

45:                                               ; preds = %42, %._crit_edge63
  %.0 = phi i32 [ 0, %._crit_edge63 ], [ 1, %42 ]
  tail call void @free(ptr noundef nonnull %7) #7
  br label %46

46:                                               ; preds = %.thread, %45
  %.052 = phi i32 [ 1, %.thread ], [ %.0, %45 ]
  ret i32 %.052
}

; Function Attrs: nofree nounwind
declare noundef i32 @printf(ptr nocapture noundef readonly, ...) local_unnamed_addr #3

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare i32 @llvm.umax.i32(i32, i32) #4

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare <4 x i32> @llvm.umax.v4i32(<4 x i32>, <4 x i32>) #4

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare i32 @llvm.vector.reduce.umax.v4i32(<4 x i32>) #4

attributes #0 = { mustprogress nounwind willreturn allockind("free") memory(argmem: readwrite, inaccessiblemem: readwrite) "alloc-family"="malloc" "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 nofree nounwind willreturn allockind("alloc,uninitialized") allocsize(0) memory(inaccessiblemem: readwrite) "alloc-family"="malloc" "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 = { nofree 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 #4 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #5 = { nounwind allocsize(0) }
attributes #6 = { cold nounwind }
attributes #7 = { 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 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = distinct !{!9, !10, !11, !12}
!10 = !{!"llvm.loop.mustprogress"}
!11 = !{!"llvm.loop.isvectorized", i32 1}
!12 = !{!"llvm.loop.unroll.runtime.disable"}
!13 = distinct !{!13, !10, !12, !11}
!14 = distinct !{!14, !10}
!15 = !{!16, !16, i64 0}
!16 = !{!"any pointer", !7, i64 0}
!17 = !{!7, !7, i64 0}
!18 = distinct !{!18, !10, !11, !12}
!19 = distinct !{!19, !10, !12, !11}
!20 = distinct !{!20, !10}


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