; LLVM IR from steps3d/graphics-book :: Code/Libs/SOIL (SOIL)

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

@result_string_pointer = external dso_local global ptr, align 8
@.str.19 = external hidden unnamed_addr constant [30 x i8], align 1
@.str.20 = external hidden unnamed_addr constant [28 x i8], align 1
@.str.21 = external hidden unnamed_addr constant [28 x i8], align 1

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

; Function Attrs: nounwind uwtable
declare dso_local void @SOIL_free_image_data(ptr noundef) #1

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

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

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

24:                                               ; preds = %6
  %25 = load i32, ptr %13, align 4, !tbaa !9
  %26 = icmp slt i32 %25, 1
  br i1 %26, label %27, label %28

27:                                               ; preds = %24, %6
  store ptr @.str.19, ptr @result_string_pointer, align 8, !tbaa !5
  store i32 0, ptr %7, align 4
  store i32 1, ptr %18, align 4
  br label %113

28:                                               ; preds = %24
  %29 = load i32, ptr %10, align 4, !tbaa !9
  %30 = icmp slt i32 %29, 0
  br i1 %30, label %34, label %31

31:                                               ; preds = %28
  %32 = load i32, ptr %11, align 4, !tbaa !9
  %33 = icmp slt i32 %32, 0
  br i1 %33, label %34, label %35

34:                                               ; preds = %31, %28
  store ptr @.str.20, ptr @result_string_pointer, align 8, !tbaa !5
  store i32 0, ptr %7, align 4
  store i32 1, ptr %18, align 4
  br label %113

35:                                               ; preds = %31
  %36 = load ptr, ptr %8, align 8, !tbaa !5
  %37 = icmp eq ptr %36, null
  br i1 %37, label %38, label %39

38:                                               ; preds = %35
  store ptr @.str.21, ptr @result_string_pointer, align 8, !tbaa !5
  store i32 0, ptr %7, align 4
  store i32 1, ptr %18, align 4
  br label %113

39:                                               ; preds = %35
  %40 = load i32, ptr %12, align 4, !tbaa !9
  %41 = mul nsw i32 3, %40
  %42 = load i32, ptr %13, align 4, !tbaa !9
  %43 = mul nsw i32 %41, %42
  %44 = sext i32 %43 to i64
  %45 = call noalias ptr @malloc(i64 noundef %44) #5
  store ptr %45, ptr %14, align 8, !tbaa !5
  %46 = load i32, ptr %10, align 4, !tbaa !9
  %47 = load i32, ptr %11, align 4, !tbaa !9
  %48 = load i32, ptr %12, align 4, !tbaa !9
  %49 = load i32, ptr %13, align 4, !tbaa !9
  %50 = load ptr, ptr %14, align 8, !tbaa !5
  call void @glReadPixels(i32 noundef %46, i32 noundef %47, i32 noundef %48, i32 noundef %49, i32 noundef 6407, i32 noundef 5121, ptr noundef %50)
  store i32 0, ptr %16, align 4, !tbaa !9
  br label %51

51:                                               ; preds = %101, %39
  %52 = load i32, ptr %16, align 4, !tbaa !9
  %53 = mul nsw i32 %52, 2
  %54 = load i32, ptr %13, align 4, !tbaa !9
  %55 = icmp slt i32 %53, %54
  br i1 %55, label %56, label %104

56:                                               ; preds = %51
  call void @llvm.lifetime.start.p0(i64 4, ptr %19) #4
  %57 = load i32, ptr %16, align 4, !tbaa !9
  %58 = load i32, ptr %12, align 4, !tbaa !9
  %59 = mul nsw i32 %57, %58
  %60 = mul nsw i32 %59, 3
  store i32 %60, ptr %19, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %20) #4
  %61 = load i32, ptr %13, align 4, !tbaa !9
  %62 = sub nsw i32 %61, 1
  %63 = load i32, ptr %16, align 4, !tbaa !9
  %64 = sub nsw i32 %62, %63
  %65 = load i32, ptr %12, align 4, !tbaa !9
  %66 = mul nsw i32 %64, %65
  %67 = mul nsw i32 %66, 3
  store i32 %67, ptr %20, align 4, !tbaa !9
  %68 = load i32, ptr %12, align 4, !tbaa !9
  %69 = mul nsw i32 %68, 3
  store i32 %69, ptr %15, align 4, !tbaa !9
  br label %70

70:                                               ; preds = %97, %56
  %71 = load i32, ptr %15, align 4, !tbaa !9
  %72 = icmp sgt i32 %71, 0
  br i1 %72, label %73, label %100

73:                                               ; preds = %70
  call void @llvm.lifetime.start.p0(i64 1, ptr %21) #4
  %74 = load ptr, ptr %14, align 8, !tbaa !5
  %75 = load i32, ptr %19, align 4, !tbaa !9
  %76 = sext i32 %75 to i64
  %77 = getelementptr inbounds i8, ptr %74, i64 %76
  %78 = load i8, ptr %77, align 1, !tbaa !11
  store i8 %78, ptr %21, align 1, !tbaa !11
  %79 = load ptr, ptr %14, align 8, !tbaa !5
  %80 = load i32, ptr %20, align 4, !tbaa !9
  %81 = sext i32 %80 to i64
  %82 = getelementptr inbounds i8, ptr %79, i64 %81
  %83 = load i8, ptr %82, align 1, !tbaa !11
  %84 = load ptr, ptr %14, align 8, !tbaa !5
  %85 = load i32, ptr %19, align 4, !tbaa !9
  %86 = sext i32 %85 to i64
  %87 = getelementptr inbounds i8, ptr %84, i64 %86
  store i8 %83, ptr %87, align 1, !tbaa !11
  %88 = load i8, ptr %21, align 1, !tbaa !11
  %89 = load ptr, ptr %14, align 8, !tbaa !5
  %90 = load i32, ptr %20, align 4, !tbaa !9
  %91 = sext i32 %90 to i64
  %92 = getelementptr inbounds i8, ptr %89, i64 %91
  store i8 %88, ptr %92, align 1, !tbaa !11
  %93 = load i32, ptr %19, align 4, !tbaa !9
  %94 = add nsw i32 %93, 1
  store i32 %94, ptr %19, align 4, !tbaa !9
  %95 = load i32, ptr %20, align 4, !tbaa !9
  %96 = add nsw i32 %95, 1
  store i32 %96, ptr %20, align 4, !tbaa !9
  call void @llvm.lifetime.end.p0(i64 1, ptr %21) #4
  br label %97

97:                                               ; preds = %73
  %98 = load i32, ptr %15, align 4, !tbaa !9
  %99 = add nsw i32 %98, -1
  store i32 %99, ptr %15, align 4, !tbaa !9
  br label %70, !llvm.loop !12

100:                                              ; preds = %70
  call void @llvm.lifetime.end.p0(i64 4, ptr %20) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %19) #4
  br label %101

101:                                              ; preds = %100
  %102 = load i32, ptr %16, align 4, !tbaa !9
  %103 = add nsw i32 %102, 1
  store i32 %103, ptr %16, align 4, !tbaa !9
  br label %51, !llvm.loop !14

104:                                              ; preds = %51
  %105 = load ptr, ptr %8, align 8, !tbaa !5
  %106 = load i32, ptr %9, align 4, !tbaa !9
  %107 = load i32, ptr %12, align 4, !tbaa !9
  %108 = load i32, ptr %13, align 4, !tbaa !9
  %109 = load ptr, ptr %14, align 8, !tbaa !5
  %110 = call i32 @SOIL_save_image(ptr noundef %105, i32 noundef %106, i32 noundef %107, i32 noundef %108, i32 noundef 3, ptr noundef %109)
  store i32 %110, ptr %17, align 4, !tbaa !9
  %111 = load ptr, ptr %14, align 8, !tbaa !5
  call void @SOIL_free_image_data(ptr noundef %111)
  %112 = load i32, ptr %17, align 4, !tbaa !9
  store i32 %112, ptr %7, align 4
  store i32 1, ptr %18, align 4
  br label %113

113:                                              ; preds = %104, %38, %34, %27
  call void @llvm.lifetime.end.p0(i64 4, ptr %17) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %16) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %15) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %14) #4
  %114 = load i32, ptr %7, align 4
  ret i32 %114
}

declare void @glReadPixels(i32 noundef, i32 noundef, i32 noundef, i32 noundef, i32 noundef, i32 noundef, ptr noundef) #3

; Function Attrs: nounwind uwtable
declare dso_local i32 @SOIL_save_image(ptr noundef, i32 noundef, i32 noundef, i32 noundef, i32 noundef, ptr 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 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 = { "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 }
attributes #5 = { 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 = !{!7, !7, i64 0}
!12 = distinct !{!12, !13}
!13 = !{!"llvm.loop.mustprogress"}
!14 = distinct !{!14, !13}


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

@result_string_pointer = external dso_local local_unnamed_addr global ptr, align 8
@.str.19 = external hidden unnamed_addr constant [30 x i8], align 1
@.str.20 = external hidden unnamed_addr constant [28 x i8], align 1
@.str.21 = external hidden unnamed_addr constant [28 x i8], align 1

; Function Attrs: nounwind uwtable
declare dso_local void @SOIL_free_image_data(ptr 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
define dso_local i32 @SOIL_save_screenshot(ptr noundef %0, i32 noundef %1, i32 noundef %2, i32 noundef %3, i32 noundef %4, i32 noundef %5) local_unnamed_addr #0 {
  %7 = icmp slt i32 %4, 1
  %8 = icmp slt i32 %5, 1
  %or.cond = or i1 %7, %8
  br i1 %or.cond, label %9, label %10

9:                                                ; preds = %6
  store ptr @.str.19, ptr @result_string_pointer, align 8, !tbaa !5
  br label %46

10:                                               ; preds = %6
  %11 = or i32 %3, %2
  %or.cond3.not = icmp sgt i32 %11, -1
  br i1 %or.cond3.not, label %13, label %12

12:                                               ; preds = %10
  store ptr @.str.20, ptr @result_string_pointer, align 8, !tbaa !5
  br label %46

13:                                               ; preds = %10
  %14 = icmp eq ptr %0, null
  br i1 %14, label %15, label %.lr.ph.us.preheader

15:                                               ; preds = %13
  store ptr @.str.21, ptr @result_string_pointer, align 8, !tbaa !5
  br label %46

.lr.ph.us.preheader:                              ; preds = %13
  %16 = mul nuw nsw i32 %4, 3
  %17 = mul nuw nsw i32 %16, %5
  %18 = zext nneg i32 %17 to i64
  %19 = tail call noalias ptr @malloc(i64 noundef %18) #4
  tail call void @glReadPixels(i32 noundef %2, i32 noundef %3, i32 noundef %4, i32 noundef %5, i32 noundef 6407, i32 noundef 5121, ptr noundef %19) #5
  %20 = add nsw i32 %5, -1
  %21 = mul i32 %20, %4
  %22 = mul i32 %21, 3
  %23 = lshr i32 %20, 1
  %smin = tail call i32 @llvm.smin.i32(i32 %16, i32 1)
  %24 = sub nsw i32 %16, %smin
  %25 = zext i32 %24 to i64
  %26 = add nuw nsw i64 %25, 1
  %scevgep70 = getelementptr i8, ptr %19, i64 %26
  %scevgep73 = getelementptr i8, ptr %19, i64 %26
  %smin75 = tail call i32 @llvm.smin.i32(i32 %16, i32 1)
  %27 = sub nsw i32 %16, %smin75
  %28 = zext i32 %27 to i64
  %29 = add nuw nsw i64 %28, 1
  %min.iters.check = icmp ult i32 %27, 7
  %min.iters.check76 = icmp ult i32 %27, 31
  %n.vec = and i64 %29, 8589934560
  %cmp.n = icmp eq i64 %29, %n.vec
  %.cast88 = trunc i64 %n.vec to i32
  %ind.end89 = sub i32 %16, %.cast88
  %n.vec.remaining = and i64 %29, 24
  %min.epilog.iters.check = icmp eq i64 %n.vec.remaining, 0
  %n.vec82 = and i64 %29, 8589934584
  %.cast = trunc i64 %n.vec82 to i32
  %ind.end87 = sub i32 %16, %.cast
  %cmp.n97 = icmp eq i64 %29, %n.vec82
  br label %iter.check

iter.check:                                       ; preds = %.lr.ph.us.preheader, %._crit_edge.us
  %indvars.iv63 = phi i32 [ 0, %.lr.ph.us.preheader ], [ %indvars.iv.next64, %._crit_edge.us ]
  %indvars.iv = phi i32 [ %22, %.lr.ph.us.preheader ], [ %indvars.iv.next, %._crit_edge.us ]
  %.04756.us = phi i32 [ 0, %.lr.ph.us.preheader ], [ %44, %._crit_edge.us ]
  %30 = sext i32 %indvars.iv to i64
  %31 = zext i32 %indvars.iv63 to i64
  br i1 %min.iters.check, label %vec.epilog.scalar.ph.preheader, label %vector.memcheck

vector.memcheck:                                  ; preds = %iter.check
  %32 = sext i32 %indvars.iv to i64
  %scevgep74 = getelementptr i8, ptr %scevgep73, i64 %32
  %scevgep72 = getelementptr i8, ptr %19, i64 %32
  %33 = zext i32 %indvars.iv63 to i64
  %scevgep71 = getelementptr i8, ptr %scevgep70, i64 %33
  %scevgep = getelementptr i8, ptr %19, i64 %33
  %bound0 = icmp ult ptr %scevgep, %scevgep74
  %bound1 = icmp ult ptr %scevgep72, %scevgep71
  %found.conflict = and i1 %bound0, %bound1
  br i1 %found.conflict, label %vec.epilog.scalar.ph.preheader, label %vector.main.loop.iter.check

vector.main.loop.iter.check:                      ; preds = %vector.memcheck
  br i1 %min.iters.check76, label %vec.epilog.ph, label %vector.ph

vector.ph:                                        ; preds = %vector.main.loop.iter.check
  %invariant.gep = getelementptr i8, ptr %19, i64 %31
  %invariant.gep98 = getelementptr i8, ptr %19, i64 %30
  br label %vector.body

vector.body:                                      ; preds = %vector.body, %vector.ph
  %index = phi i64 [ 0, %vector.ph ], [ %index.next, %vector.body ]
  %gep = getelementptr i8, ptr %invariant.gep, i64 %index
  %34 = getelementptr inbounds i8, ptr %gep, i64 16
  %wide.load = load <16 x i8>, ptr %gep, align 1, !tbaa !9, !alias.scope !10, !noalias !13
  %wide.load78 = load <16 x i8>, ptr %34, align 1, !tbaa !9, !alias.scope !10, !noalias !13
  %gep99 = getelementptr i8, ptr %invariant.gep98, i64 %index
  %35 = getelementptr inbounds i8, ptr %gep99, i64 16
  %wide.load79 = load <16 x i8>, ptr %gep99, align 1, !tbaa !9, !alias.scope !13
  %wide.load80 = load <16 x i8>, ptr %35, align 1, !tbaa !9, !alias.scope !13
  store <16 x i8> %wide.load79, ptr %gep, align 1, !tbaa !9, !alias.scope !10, !noalias !13
  store <16 x i8> %wide.load80, ptr %34, align 1, !tbaa !9, !alias.scope !10, !noalias !13
  store <16 x i8> %wide.load, ptr %gep99, align 1, !tbaa !9, !alias.scope !13
  store <16 x i8> %wide.load78, ptr %35, align 1, !tbaa !9, !alias.scope !13
  %index.next = add nuw i64 %index, 32
  %36 = icmp eq i64 %index.next, %n.vec
  br i1 %36, label %middle.block, label %vector.body, !llvm.loop !15

middle.block:                                     ; preds = %vector.body
  br i1 %cmp.n, label %._crit_edge.us, label %vec.epilog.iter.check

vec.epilog.iter.check:                            ; preds = %middle.block
  %ind.end85 = add nsw i64 %n.vec, %30
  %ind.end83 = add nuw nsw i64 %n.vec, %31
  br i1 %min.epilog.iters.check, label %vec.epilog.scalar.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 ]
  %ind.end = add nuw nsw i64 %n.vec82, %31
  %ind.end84 = add nsw i64 %n.vec82, %30
  %invariant.gep100 = getelementptr i8, ptr %19, i64 %31
  %invariant.gep102 = getelementptr i8, ptr %19, i64 %30
  br label %vec.epilog.vector.body

vec.epilog.vector.body:                           ; preds = %vec.epilog.vector.body, %vec.epilog.ph
  %index91 = phi i64 [ %vec.epilog.resume.val, %vec.epilog.ph ], [ %index.next96, %vec.epilog.vector.body ]
  %gep101 = getelementptr i8, ptr %invariant.gep100, i64 %index91
  %wide.load94 = load <8 x i8>, ptr %gep101, align 1, !tbaa !9, !alias.scope !19, !noalias !22
  %gep103 = getelementptr i8, ptr %invariant.gep102, i64 %index91
  %wide.load95 = load <8 x i8>, ptr %gep103, align 1, !tbaa !9, !alias.scope !22
  store <8 x i8> %wide.load95, ptr %gep101, align 1, !tbaa !9, !alias.scope !19, !noalias !22
  store <8 x i8> %wide.load94, ptr %gep103, align 1, !tbaa !9, !alias.scope !22
  %index.next96 = add nuw i64 %index91, 8
  %37 = icmp eq i64 %index.next96, %n.vec82
  br i1 %37, label %vec.epilog.middle.block, label %vec.epilog.vector.body, !llvm.loop !24

vec.epilog.middle.block:                          ; preds = %vec.epilog.vector.body
  br i1 %cmp.n97, label %._crit_edge.us, label %vec.epilog.scalar.ph.preheader

vec.epilog.scalar.ph.preheader:                   ; preds = %vec.epilog.middle.block, %vector.memcheck, %iter.check, %vec.epilog.iter.check
  %indvars.iv65.ph = phi i64 [ %31, %iter.check ], [ %31, %vector.memcheck ], [ %ind.end83, %vec.epilog.iter.check ], [ %ind.end, %vec.epilog.middle.block ]
  %indvars.iv61.ph = phi i64 [ %30, %iter.check ], [ %30, %vector.memcheck ], [ %ind.end85, %vec.epilog.iter.check ], [ %ind.end84, %vec.epilog.middle.block ]
  %.04653.us.ph = phi i32 [ %16, %iter.check ], [ %16, %vector.memcheck ], [ %ind.end89, %vec.epilog.iter.check ], [ %ind.end87, %vec.epilog.middle.block ]
  br label %vec.epilog.scalar.ph

vec.epilog.scalar.ph:                             ; preds = %vec.epilog.scalar.ph.preheader, %vec.epilog.scalar.ph
  %indvars.iv65 = phi i64 [ %indvars.iv.next66, %vec.epilog.scalar.ph ], [ %indvars.iv65.ph, %vec.epilog.scalar.ph.preheader ]
  %indvars.iv61 = phi i64 [ %indvars.iv.next62, %vec.epilog.scalar.ph ], [ %indvars.iv61.ph, %vec.epilog.scalar.ph.preheader ]
  %.04653.us = phi i32 [ %42, %vec.epilog.scalar.ph ], [ %.04653.us.ph, %vec.epilog.scalar.ph.preheader ]
  %38 = getelementptr inbounds i8, ptr %19, i64 %indvars.iv65
  %39 = load i8, ptr %38, align 1, !tbaa !9
  %40 = getelementptr inbounds i8, ptr %19, i64 %indvars.iv61
  %41 = load i8, ptr %40, align 1, !tbaa !9
  store i8 %41, ptr %38, align 1, !tbaa !9
  store i8 %39, ptr %40, align 1, !tbaa !9
  %indvars.iv.next66 = add nuw nsw i64 %indvars.iv65, 1
  %indvars.iv.next62 = add nsw i64 %indvars.iv61, 1
  %42 = add nsw i32 %.04653.us, -1
  %43 = icmp sgt i32 %.04653.us, 1
  br i1 %43, label %vec.epilog.scalar.ph, label %._crit_edge.us, !llvm.loop !25

._crit_edge.us:                                   ; preds = %vec.epilog.scalar.ph, %vec.epilog.middle.block, %middle.block
  %44 = add nuw nsw i32 %.04756.us, 1
  %indvars.iv.next = sub i32 %indvars.iv, %16
  %indvars.iv.next64 = add i32 %indvars.iv63, %16
  %exitcond.not = icmp eq i32 %.04756.us, %23
  br i1 %exitcond.not, label %._crit_edge59, label %iter.check, !llvm.loop !26

._crit_edge59:                                    ; preds = %._crit_edge.us
  %45 = tail call i32 @SOIL_save_image(ptr noundef nonnull %0, i32 noundef %1, i32 noundef %4, i32 noundef %5, i32 noundef 3, ptr noundef nonnull %19)
  tail call void @SOIL_free_image_data(ptr noundef nonnull %19)
  br label %46

46:                                               ; preds = %._crit_edge59, %15, %12, %9
  %.0 = phi i32 [ 0, %9 ], [ 0, %12 ], [ 0, %15 ], [ %45, %._crit_edge59 ]
  ret i32 %.0
}

declare void @glReadPixels(i32 noundef, i32 noundef, i32 noundef, i32 noundef, i32 noundef, i32 noundef, ptr noundef) local_unnamed_addr #2

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

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

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" }
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 = { "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 allocsize(0) }
attributes #5 = { 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 = !{!7, !7, i64 0}
!10 = !{!11}
!11 = distinct !{!11, !12}
!12 = distinct !{!12, !"LVerDomain"}
!13 = !{!14}
!14 = distinct !{!14, !12}
!15 = distinct !{!15, !16, !17, !18}
!16 = !{!"llvm.loop.mustprogress"}
!17 = !{!"llvm.loop.isvectorized", i32 1}
!18 = !{!"llvm.loop.unroll.runtime.disable"}
!19 = !{!20}
!20 = distinct !{!20, !21}
!21 = distinct !{!21, !"LVerDomain"}
!22 = !{!23}
!23 = distinct !{!23, !21}
!24 = distinct !{!24, !16, !17, !18}
!25 = distinct !{!25, !16, !17}
!26 = distinct !{!26, !16}


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