; LLVM IR from cornell-zhang/rosetta :: optical-flow/imageLib/flowIO.ll (Z13WriteFlowFile8CImageOfIfEPKc)

; 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.CShape = type { i32, i32, i32 }

@_ZTI6CError = external dso_local constant { ptr, ptr, ptr }, align 8
@.str.1 = external hidden unnamed_addr constant [5 x i8], align 1
@.str.11 = external hidden unnamed_addr constant [30 x i8], align 1
@.str.12 = external hidden unnamed_addr constant [51 x i8], align 1
@.str.13 = external hidden unnamed_addr constant [58 x i8], align 1
@.str.14 = external hidden unnamed_addr constant [43 x i8], align 1
@.str.15 = external hidden unnamed_addr constant [3 x i8], align 1
@.str.16 = external hidden unnamed_addr constant [33 x i8], align 1
@.str.17 = external hidden unnamed_addr constant [5 x i8], align 1
@.str.18 = external hidden unnamed_addr constant [42 x i8], align 1
@.str.19 = external hidden unnamed_addr constant [40 x i8], align 1

declare ptr @__cxa_allocate_exception(i64)

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZN6CErrorC2EPKc(ptr noundef nonnull align 8 dereferenceable(1032), ptr noundef) unnamed_addr #0 align 2

declare i32 @__gxx_personality_v0(...)

declare void @__cxa_free_exception(ptr)

; Function Attrs: nounwind
declare void @_ZNSt9exceptionD2Ev(ptr noundef nonnull align 8 dereferenceable(8)) unnamed_addr #1

declare void @__cxa_throw(ptr, ptr, ptr)

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

; Function Attrs: nounwind willreturn memory(read)
declare noundef ptr @strrchr(ptr noundef, i32 noundef) #3

; Function Attrs: nounwind willreturn memory(read)
declare i32 @strcmp(ptr noundef, ptr noundef) #3

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZN6CErrorC2EPKcS1_(ptr noundef nonnull align 8 dereferenceable(1032), ptr noundef, ptr noundef) unnamed_addr #0 align 2

declare noalias ptr @fopen(ptr noundef, ptr noundef) #4

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: readwrite)
declare void @llvm.memcpy.p0.p0.i64(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i64, i1 immarg) #5

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local noundef nonnull align 4 dereferenceable(4) ptr @_ZN8CImageOfIfE5PixelEiii(ptr noundef nonnull align 8 dereferenceable(76), i32 noundef, i32 noundef, i32 noundef) #6 align 2

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

declare i32 @fclose(ptr noundef) #4

; Function Attrs: mustprogress uwtable
define dso_local void @_Z13WriteFlowFile8CImageOfIfEPKc(ptr noundef %0, ptr noundef %1) #7 personality ptr @__gxx_personality_v0 {
  %3 = alloca ptr, align 8
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca i32, align 4
  %7 = alloca ptr, align 8
  %8 = alloca %struct.CShape, align 4
  %9 = alloca { i64, i32 }, align 8
  %10 = alloca i32, align 4
  %11 = alloca i32, align 4
  %12 = alloca i32, align 4
  %13 = alloca ptr, align 8
  %14 = alloca i32, align 4
  %15 = alloca i32, align 4
  %16 = alloca ptr, align 8
  store ptr %0, ptr %3, align 8, !tbaa !5
  store ptr %1, ptr %4, align 8, !tbaa !5
  %17 = load ptr, ptr %4, align 8, !tbaa !5
  %18 = icmp eq ptr %17, null
  br i1 %18, label %19, label %26

19:                                               ; preds = %2
  %20 = call ptr @__cxa_allocate_exception(i64 1032) #8
  invoke void @_ZN6CErrorC2EPKc(ptr noundef nonnull align 8 dereferenceable(1032) %20, ptr noundef @.str.11)
          to label %21 unwind label %22

21:                                               ; preds = %19
  call void @__cxa_throw(ptr %20, ptr @_ZTI6CError, ptr @_ZNSt9exceptionD2Ev) #9
  unreachable

22:                                               ; preds = %19
  %23 = landingpad { ptr, i32 }
          cleanup
  %24 = extractvalue { ptr, i32 } %23, 0
  store ptr %24, ptr %5, align 8
  %25 = extractvalue { ptr, i32 } %23, 1
  store i32 %25, ptr %6, align 4
  call void @__cxa_free_exception(ptr %20) #8
  br label %140

26:                                               ; preds = %2
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #8
  %27 = load ptr, ptr %4, align 8, !tbaa !5
  %28 = call noundef ptr @strrchr(ptr noundef %27, i32 noundef 46) #10
  store ptr %28, ptr %7, align 8, !tbaa !5
  %29 = load ptr, ptr %7, align 8, !tbaa !5
  %30 = icmp eq ptr %29, null
  br i1 %30, label %31, label %39

31:                                               ; preds = %26
  %32 = call ptr @__cxa_allocate_exception(i64 1032) #8
  %33 = load ptr, ptr %4, align 8, !tbaa !5
  invoke void @_ZN6CErrorC2EPKcS1_(ptr noundef nonnull align 8 dereferenceable(1032) %32, ptr noundef @.str.12, ptr noundef %33)
          to label %34 unwind label %35

34:                                               ; preds = %31
  call void @__cxa_throw(ptr %32, ptr @_ZTI6CError, ptr @_ZNSt9exceptionD2Ev) #9
  unreachable

35:                                               ; preds = %31
  %36 = landingpad { ptr, i32 }
          cleanup
  %37 = extractvalue { ptr, i32 } %36, 0
  store ptr %37, ptr %5, align 8
  %38 = extractvalue { ptr, i32 } %36, 1
  store i32 %38, ptr %6, align 4
  call void @__cxa_free_exception(ptr %32) #8
  br label %139

39:                                               ; preds = %26
  %40 = load ptr, ptr %7, align 8, !tbaa !5
  %41 = call i32 @strcmp(ptr noundef %40, ptr noundef @.str.1) #10
  %42 = icmp ne i32 %41, 0
  br i1 %42, label %43, label %51

43:                                               ; preds = %39
  %44 = call ptr @__cxa_allocate_exception(i64 1032) #8
  %45 = load ptr, ptr %4, align 8, !tbaa !5
  invoke void @_ZN6CErrorC2EPKcS1_(ptr noundef nonnull align 8 dereferenceable(1032) %44, ptr noundef @.str.13, ptr noundef %45)
          to label %46 unwind label %47

46:                                               ; preds = %43
  call void @__cxa_throw(ptr %44, ptr @_ZTI6CError, ptr @_ZNSt9exceptionD2Ev) #9
  unreachable

47:                                               ; preds = %43
  %48 = landingpad { ptr, i32 }
          cleanup
  %49 = extractvalue { ptr, i32 } %48, 0
  store ptr %49, ptr %5, align 8
  %50 = extractvalue { ptr, i32 } %48, 1
  store i32 %50, ptr %6, align 4
  call void @__cxa_free_exception(ptr %44) #8
  br label %139

51:                                               ; preds = %39
  call void @llvm.lifetime.start.p0(i64 12, ptr %8) #8
  %52 = call { i64, i32 } @_ZN6CImage5ShapeEv(ptr noundef nonnull align 8 dereferenceable(76) %0)
  store { i64, i32 } %52, ptr %9, align 8
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %8, ptr align 8 %9, i64 12, i1 false)
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #8
  %53 = getelementptr inbounds %struct.CShape, ptr %8, i32 0, i32 0
  %54 = load i32, ptr %53, align 4, !tbaa !9
  store i32 %54, ptr %10, align 4, !tbaa !12
  call void @llvm.lifetime.start.p0(i64 4, ptr %11) #8
  %55 = getelementptr inbounds %struct.CShape, ptr %8, i32 0, i32 1
  %56 = load i32, ptr %55, align 4, !tbaa !13
  store i32 %56, ptr %11, align 4, !tbaa !12
  call void @llvm.lifetime.start.p0(i64 4, ptr %12) #8
  %57 = getelementptr inbounds %struct.CShape, ptr %8, i32 0, i32 2
  %58 = load i32, ptr %57, align 4, !tbaa !14
  store i32 %58, ptr %12, align 4, !tbaa !12
  %59 = load i32, ptr %12, align 4, !tbaa !12
  %60 = icmp ne i32 %59, 2
  br i1 %60, label %61, label %69

61:                                               ; preds = %51
  %62 = call ptr @__cxa_allocate_exception(i64 1032) #8
  %63 = load ptr, ptr %4, align 8, !tbaa !5
  invoke void @_ZN6CErrorC2EPKcS1_(ptr noundef nonnull align 8 dereferenceable(1032) %62, ptr noundef @.str.14, ptr noundef %63)
          to label %64 unwind label %65

64:                                               ; preds = %61
  call void @__cxa_throw(ptr %62, ptr @_ZTI6CError, ptr @_ZNSt9exceptionD2Ev) #9
  unreachable

65:                                               ; preds = %61
  %66 = landingpad { ptr, i32 }
          cleanup
  %67 = extractvalue { ptr, i32 } %66, 0
  store ptr %67, ptr %5, align 8
  %68 = extractvalue { ptr, i32 } %66, 1
  store i32 %68, ptr %6, align 4
  call void @__cxa_free_exception(ptr %62) #8
  br label %138

69:                                               ; preds = %51
  call void @llvm.lifetime.start.p0(i64 8, ptr %13) #8
  %70 = load ptr, ptr %4, align 8, !tbaa !5
  %71 = call noalias ptr @fopen(ptr noundef %70, ptr noundef @.str.15)
  store ptr %71, ptr %13, align 8, !tbaa !5
  %72 = load ptr, ptr %13, align 8, !tbaa !5
  %73 = icmp eq ptr %72, null
  br i1 %73, label %74, label %82

74:                                               ; preds = %69
  %75 = call ptr @__cxa_allocate_exception(i64 1032) #8
  %76 = load ptr, ptr %4, align 8, !tbaa !5
  invoke void @_ZN6CErrorC2EPKcS1_(ptr noundef nonnull align 8 dereferenceable(1032) %75, ptr noundef @.str.16, ptr noundef %76)
          to label %77 unwind label %78

77:                                               ; preds = %74
  call void @__cxa_throw(ptr %75, ptr @_ZTI6CError, ptr @_ZNSt9exceptionD2Ev) #9
  unreachable

78:                                               ; preds = %74
  %79 = landingpad { ptr, i32 }
          cleanup
  %80 = extractvalue { ptr, i32 } %79, 0
  store ptr %80, ptr %5, align 8
  %81 = extractvalue { ptr, i32 } %79, 1
  store i32 %81, ptr %6, align 4
  call void @__cxa_free_exception(ptr %75) #8
  br label %137

82:                                               ; preds = %69
  %83 = load ptr, ptr %13, align 8, !tbaa !5
  %84 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %83, ptr noundef @.str.17) #8
  %85 = load ptr, ptr %13, align 8, !tbaa !5
  %86 = call i64 @fwrite(ptr noundef %10, i64 noundef 4, i64 noundef 1, ptr noundef %85)
  %87 = trunc i64 %86 to i32
  %88 = icmp ne i32 %87, 1
  br i1 %88, label %94, label %89

89:                                               ; preds = %82
  %90 = load ptr, ptr %13, align 8, !tbaa !5
  %91 = call i64 @fwrite(ptr noundef %11, i64 noundef 4, i64 noundef 1, ptr noundef %90)
  %92 = trunc i64 %91 to i32
  %93 = icmp ne i32 %92, 1
  br i1 %93, label %94, label %102

94:                                               ; preds = %89, %82
  %95 = call ptr @__cxa_allocate_exception(i64 1032) #8
  %96 = load ptr, ptr %4, align 8, !tbaa !5
  invoke void @_ZN6CErrorC2EPKcS1_(ptr noundef nonnull align 8 dereferenceable(1032) %95, ptr noundef @.str.18, ptr noundef %96)
          to label %97 unwind label %98

97:                                               ; preds = %94
  call void @__cxa_throw(ptr %95, ptr @_ZTI6CError, ptr @_ZNSt9exceptionD2Ev) #9
  unreachable

98:                                               ; preds = %94
  %99 = landingpad { ptr, i32 }
          cleanup
  %100 = extractvalue { ptr, i32 } %99, 0
  store ptr %100, ptr %5, align 8
  %101 = extractvalue { ptr, i32 } %99, 1
  store i32 %101, ptr %6, align 4
  call void @__cxa_free_exception(ptr %95) #8
  br label %137

102:                                              ; preds = %89
  call void @llvm.lifetime.start.p0(i64 4, ptr %14) #8
  %103 = load i32, ptr %12, align 4, !tbaa !12
  %104 = load i32, ptr %10, align 4, !tbaa !12
  %105 = mul nsw i32 %103, %104
  store i32 %105, ptr %14, align 4, !tbaa !12
  call void @llvm.lifetime.start.p0(i64 4, ptr %15) #8
  store i32 0, ptr %15, align 4, !tbaa !12
  br label %106

106:                                              ; preds = %131, %102
  %107 = load i32, ptr %15, align 4, !tbaa !12
  %108 = load i32, ptr %11, align 4, !tbaa !12
  %109 = icmp slt i32 %107, %108
  br i1 %109, label %111, label %110

110:                                              ; preds = %106
  call void @llvm.lifetime.end.p0(i64 4, ptr %15) #8
  br label %134

111:                                              ; preds = %106
  call void @llvm.lifetime.start.p0(i64 8, ptr %16) #8
  %112 = load i32, ptr %15, align 4, !tbaa !12
  %113 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZN8CImageOfIfE5PixelEiii(ptr noundef nonnull align 8 dereferenceable(76) %0, i32 noundef 0, i32 noundef %112, i32 noundef 0)
  store ptr %113, ptr %16, align 8, !tbaa !5
  %114 = load ptr, ptr %16, align 8, !tbaa !5
  %115 = load i32, ptr %14, align 4, !tbaa !12
  %116 = sext i32 %115 to i64
  %117 = load ptr, ptr %13, align 8, !tbaa !5
  %118 = call i64 @fwrite(ptr noundef %114, i64 noundef 4, i64 noundef %116, ptr noundef %117)
  %119 = trunc i64 %118 to i32
  %120 = load i32, ptr %14, align 4, !tbaa !12
  %121 = icmp ne i32 %119, %120
  br i1 %121, label %122, label %130

122:                                              ; preds = %111
  %123 = call ptr @__cxa_allocate_exception(i64 1032) #8
  %124 = load ptr, ptr %4, align 8, !tbaa !5
  invoke void @_ZN6CErrorC2EPKcS1_(ptr noundef nonnull align 8 dereferenceable(1032) %123, ptr noundef @.str.19, ptr noundef %124)
          to label %125 unwind label %126

125:                                              ; preds = %122
  call void @__cxa_throw(ptr %123, ptr @_ZTI6CError, ptr @_ZNSt9exceptionD2Ev) #9
  unreachable

126:                                              ; preds = %122
  %127 = landingpad { ptr, i32 }
          cleanup
  %128 = extractvalue { ptr, i32 } %127, 0
  store ptr %128, ptr %5, align 8
  %129 = extractvalue { ptr, i32 } %127, 1
  store i32 %129, ptr %6, align 4
  call void @__cxa_free_exception(ptr %123) #8
  call void @llvm.lifetime.end.p0(i64 8, ptr %16) #8
  call void @llvm.lifetime.end.p0(i64 4, ptr %15) #8
  call void @llvm.lifetime.end.p0(i64 4, ptr %14) #8
  br label %137

130:                                              ; preds = %111
  call void @llvm.lifetime.end.p0(i64 8, ptr %16) #8
  br label %131

131:                                              ; preds = %130
  %132 = load i32, ptr %15, align 4, !tbaa !12
  %133 = add nsw i32 %132, 1
  store i32 %133, ptr %15, align 4, !tbaa !12
  br label %106, !llvm.loop !15

134:                                              ; preds = %110
  %135 = load ptr, ptr %13, align 8, !tbaa !5
  %136 = call i32 @fclose(ptr noundef %135)
  call void @llvm.lifetime.end.p0(i64 4, ptr %14) #8
  call void @llvm.lifetime.end.p0(i64 8, ptr %13) #8
  call void @llvm.lifetime.end.p0(i64 4, ptr %12) #8
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #8
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #8
  call void @llvm.lifetime.end.p0(i64 12, ptr %8) #8
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #8
  ret void

137:                                              ; preds = %126, %98, %78
  call void @llvm.lifetime.end.p0(i64 8, ptr %13) #8
  br label %138

138:                                              ; preds = %137, %65
  call void @llvm.lifetime.end.p0(i64 4, ptr %12) #8
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #8
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #8
  call void @llvm.lifetime.end.p0(i64 12, ptr %8) #8
  br label %139

139:                                              ; preds = %138, %47, %35
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #8
  br label %140

140:                                              ; preds = %139, %22
  %141 = load ptr, ptr %5, align 8
  %142 = load i32, ptr %6, align 4
  %143 = insertvalue { ptr, i32 } poison, ptr %141, 0
  %144 = insertvalue { ptr, i32 } %143, i32 %142, 1
  resume { ptr, i32 } %144
}

; Function Attrs: mustprogress nounwind uwtable
declare dso_local { i64, i32 } @_ZN6CImage5ShapeEv(ptr noundef nonnull align 8 dereferenceable(76)) #0 align 2

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

declare i64 @fwrite(ptr noundef, i64 noundef, i64 noundef, ptr noundef) #4

attributes #0 = { 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 #1 = { 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 #2 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #3 = { nounwind willreturn memory(read) "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 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #6 = { inlinehint 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 #7 = { 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 #8 = { nounwind }
attributes #9 = { noreturn }
attributes #10 = { nounwind willreturn memory(read) }

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


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

@_ZTI6CError = external dso_local constant { ptr, ptr, ptr }, align 8
@.str.1 = external hidden unnamed_addr constant [5 x i8], align 1
@.str.11 = external hidden unnamed_addr constant [30 x i8], align 1
@.str.12 = external hidden unnamed_addr constant [51 x i8], align 1
@.str.13 = external hidden unnamed_addr constant [58 x i8], align 1
@.str.14 = external hidden unnamed_addr constant [43 x i8], align 1
@.str.15 = external hidden unnamed_addr constant [3 x i8], align 1
@.str.16 = external hidden unnamed_addr constant [33 x i8], align 1
@.str.17 = external hidden unnamed_addr constant [5 x i8], align 1
@.str.18 = external hidden unnamed_addr constant [42 x i8], align 1
@.str.19 = external hidden unnamed_addr constant [40 x i8], align 1

declare ptr @__cxa_allocate_exception(i64) local_unnamed_addr

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZN6CErrorC2EPKc(ptr noundef nonnull align 8 dereferenceable(1032), ptr noundef) unnamed_addr #0 align 2

declare i32 @__gxx_personality_v0(...)

; Function Attrs: nounwind
declare void @_ZNSt9exceptionD2Ev(ptr noundef nonnull align 8 dereferenceable(8)) unnamed_addr #1

declare void @__cxa_throw(ptr, ptr, ptr) local_unnamed_addr

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

; Function Attrs: mustprogress nofree nounwind willreturn memory(argmem: read)
declare noundef ptr @strrchr(ptr noundef, i32 noundef) local_unnamed_addr #3

; Function Attrs: mustprogress nofree nounwind willreturn memory(argmem: read)
declare i32 @strcmp(ptr nocapture noundef, ptr nocapture noundef) local_unnamed_addr #3

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZN6CErrorC2EPKcS1_(ptr noundef nonnull align 8 dereferenceable(1032), ptr noundef, ptr noundef) unnamed_addr #0 align 2

; Function Attrs: nofree nounwind
declare noalias noundef ptr @fopen(ptr nocapture noundef readonly, ptr nocapture noundef readonly) local_unnamed_addr #4

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local noundef nonnull align 4 dereferenceable(4) ptr @_ZN8CImageOfIfE5PixelEiii(ptr noundef nonnull align 8 dereferenceable(76), i32 noundef, i32 noundef, i32 noundef) local_unnamed_addr #5 align 2

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

; Function Attrs: nofree nounwind
declare noundef i32 @fclose(ptr nocapture noundef) local_unnamed_addr #4

; Function Attrs: mustprogress uwtable
define dso_local void @_Z13WriteFlowFile8CImageOfIfEPKc(ptr noundef %0, ptr noundef %1) local_unnamed_addr #6 personality ptr @__gxx_personality_v0 {
  %3 = alloca i32, align 4
  %4 = alloca i32, align 4
  %5 = icmp eq ptr %1, null
  br i1 %5, label %6, label %8

6:                                                ; preds = %2
  %7 = tail call ptr @__cxa_allocate_exception(i64 1032) #7
  tail call void @_ZN6CErrorC2EPKc(ptr noundef nonnull align 8 dereferenceable(1032) %7, ptr noundef nonnull @.str.11)
  tail call void @__cxa_throw(ptr nonnull %7, ptr nonnull @_ZTI6CError, ptr nonnull @_ZNSt9exceptionD2Ev) #8
  unreachable

8:                                                ; preds = %2
  %9 = tail call noundef ptr @strrchr(ptr noundef nonnull dereferenceable(1) %1, i32 noundef 46) #9
  %10 = icmp eq ptr %9, null
  br i1 %10, label %11, label %13

11:                                               ; preds = %8
  %12 = tail call ptr @__cxa_allocate_exception(i64 1032) #7
  tail call void @_ZN6CErrorC2EPKcS1_(ptr noundef nonnull align 8 dereferenceable(1032) %12, ptr noundef nonnull @.str.12, ptr noundef nonnull %1)
  tail call void @__cxa_throw(ptr nonnull %12, ptr nonnull @_ZTI6CError, ptr nonnull @_ZNSt9exceptionD2Ev) #8
  unreachable

13:                                               ; preds = %8
  %14 = tail call i32 @strcmp(ptr noundef nonnull dereferenceable(1) %9, ptr noundef nonnull dereferenceable(1) @.str.1) #9
  %.not = icmp eq i32 %14, 0
  br i1 %.not, label %17, label %15

15:                                               ; preds = %13
  %16 = tail call ptr @__cxa_allocate_exception(i64 1032) #7
  tail call void @_ZN6CErrorC2EPKcS1_(ptr noundef nonnull align 8 dereferenceable(1032) %16, ptr noundef nonnull @.str.13, ptr noundef nonnull %1)
  tail call void @__cxa_throw(ptr nonnull %16, ptr nonnull @_ZTI6CError, ptr nonnull @_ZNSt9exceptionD2Ev) #8
  unreachable

17:                                               ; preds = %13
  %18 = tail call { i64, i32 } @_ZN6CImage5ShapeEv(ptr noundef nonnull align 8 dereferenceable(76) %0)
  %.fca.0.extract = extractvalue { i64, i32 } %18, 0
  %.fca.1.extract = extractvalue { i64, i32 } %18, 1
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %3) #7
  %.sroa.013.0.extract.trunc = trunc i64 %.fca.0.extract to i32
  store i32 %.sroa.013.0.extract.trunc, ptr %3, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %4) #7
  %.sroa.013.4.extract.shift = lshr i64 %.fca.0.extract, 32
  %.sroa.013.4.extract.trunc = trunc nuw i64 %.sroa.013.4.extract.shift to i32
  store i32 %.sroa.013.4.extract.trunc, ptr %4, align 4, !tbaa !5
  %.not28 = icmp eq i32 %.fca.1.extract, 2
  br i1 %.not28, label %21, label %19

19:                                               ; preds = %17
  %20 = tail call ptr @__cxa_allocate_exception(i64 1032) #7
  tail call void @_ZN6CErrorC2EPKcS1_(ptr noundef nonnull align 8 dereferenceable(1032) %20, ptr noundef nonnull @.str.14, ptr noundef nonnull %1)
  tail call void @__cxa_throw(ptr nonnull %20, ptr nonnull @_ZTI6CError, ptr nonnull @_ZNSt9exceptionD2Ev) #8
  unreachable

21:                                               ; preds = %17
  %22 = tail call noalias ptr @fopen(ptr noundef nonnull %1, ptr noundef nonnull @.str.15)
  %23 = icmp eq ptr %22, null
  br i1 %23, label %24, label %26

24:                                               ; preds = %21
  %25 = tail call ptr @__cxa_allocate_exception(i64 1032) #7
  tail call void @_ZN6CErrorC2EPKcS1_(ptr noundef nonnull align 8 dereferenceable(1032) %25, ptr noundef nonnull @.str.16, ptr noundef nonnull %1)
  tail call void @__cxa_throw(ptr nonnull %25, ptr nonnull @_ZTI6CError, ptr nonnull @_ZNSt9exceptionD2Ev) #8
  unreachable

26:                                               ; preds = %21
  %27 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef nonnull %22, ptr noundef nonnull @.str.17) #7
  %28 = call i64 @fwrite(ptr noundef nonnull %3, i64 noundef 4, i64 noundef 1, ptr noundef nonnull %22)
  %29 = and i64 %28, 4294967295
  %.not29 = icmp eq i64 %29, 1
  br i1 %.not29, label %30, label %33

30:                                               ; preds = %26
  %31 = call i64 @fwrite(ptr noundef nonnull %4, i64 noundef 4, i64 noundef 1, ptr noundef nonnull %22)
  %32 = and i64 %31, 4294967295
  %.not30 = icmp eq i64 %32, 1
  br i1 %.not30, label %35, label %33

33:                                               ; preds = %30, %26
  %34 = tail call ptr @__cxa_allocate_exception(i64 1032) #7
  tail call void @_ZN6CErrorC2EPKcS1_(ptr noundef nonnull align 8 dereferenceable(1032) %34, ptr noundef nonnull @.str.18, ptr noundef nonnull %1)
  tail call void @__cxa_throw(ptr nonnull %34, ptr nonnull @_ZTI6CError, ptr nonnull @_ZNSt9exceptionD2Ev) #8
  unreachable

35:                                               ; preds = %30
  %36 = load i32, ptr %3, align 4, !tbaa !5
  %37 = shl nsw i32 %36, 1
  %38 = load i32, ptr %4, align 4, !tbaa !5
  %39 = icmp sgt i32 %38, 0
  br i1 %39, label %.lr.ph, label %._crit_edge

.lr.ph:                                           ; preds = %35
  %40 = sext i32 %37 to i64
  br label %44

41:                                               ; preds = %44
  %42 = add nuw nsw i32 %.032, 1
  %exitcond.not = icmp eq i32 %42, %38
  br i1 %exitcond.not, label %._crit_edge, label %44, !llvm.loop !9

._crit_edge:                                      ; preds = %41, %35
  %43 = tail call i32 @fclose(ptr noundef nonnull %22)
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %4) #7
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %3) #7
  ret void

44:                                               ; preds = %.lr.ph, %41
  %.032 = phi i32 [ 0, %.lr.ph ], [ %42, %41 ]
  %45 = tail call noundef nonnull align 4 dereferenceable(4) ptr @_ZN8CImageOfIfE5PixelEiii(ptr noundef nonnull align 8 dereferenceable(76) %0, i32 noundef 0, i32 noundef %.032, i32 noundef 0)
  %46 = tail call i64 @fwrite(ptr noundef nonnull %45, i64 noundef 4, i64 noundef %40, ptr noundef nonnull %22)
  %47 = trunc i64 %46 to i32
  %.not31 = icmp eq i32 %37, %47
  br i1 %.not31, label %41, label %48

48:                                               ; preds = %44
  %49 = tail call ptr @__cxa_allocate_exception(i64 1032) #7
  tail call void @_ZN6CErrorC2EPKcS1_(ptr noundef nonnull align 8 dereferenceable(1032) %49, ptr noundef nonnull @.str.19, ptr noundef nonnull %1)
  tail call void @__cxa_throw(ptr nonnull %49, ptr nonnull @_ZTI6CError, ptr nonnull @_ZNSt9exceptionD2Ev) #8
  unreachable
}

; Function Attrs: mustprogress nounwind uwtable
declare dso_local { i64, i32 } @_ZN6CImage5ShapeEv(ptr noundef nonnull align 8 dereferenceable(76)) local_unnamed_addr #0 align 2

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

; Function Attrs: nofree nounwind
declare noundef i64 @fwrite(ptr nocapture noundef, i64 noundef, i64 noundef, ptr nocapture noundef) local_unnamed_addr #4

attributes #0 = { 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 #1 = { 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 #2 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #3 = { mustprogress nofree nounwind willreturn memory(argmem: read) "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 = { 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 #5 = { inlinehint 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 #6 = { 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 #7 = { nounwind }
attributes #8 = { noreturn }
attributes #9 = { nounwind willreturn memory(read) }

!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++ TBAA"}
!9 = distinct !{!9, !10}
!10 = !{!"llvm.loop.mustprogress"}


; Effective O3 passes: GlobalOptPass,IPSCCPPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,LICMPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,SROAPass,SimplifyCFGPass,TailCallElimPass