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

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

@.str = external hidden unnamed_addr constant [29 x i8], align 1
@_ZTI6CError = external dso_local constant { ptr, ptr, ptr }, align 8
@.str.1 = external hidden unnamed_addr constant [5 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [43 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [3 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [32 x i8], align 1
@.str.5 = external hidden unnamed_addr constant [38 x i8], align 1
@.str.6 = external hidden unnamed_addr constant [66 x i8], align 1
@.str.7 = external hidden unnamed_addr constant [35 x i8], align 1
@.str.8 = external hidden unnamed_addr constant [36 x i8], align 1
@.str.9 = external hidden unnamed_addr constant [36 x i8], align 1
@.str.10 = external hidden unnamed_addr constant [35 x i8], align 1

; Function Attrs: mustprogress uwtable
define dso_local void @_Z12ReadFlowFileR8CImageOfIfEPKc(ptr noundef nonnull align 8 dereferenceable(76) %0, ptr noundef %1) #0 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 ptr, align 8
  %9 = alloca i32, align 4
  %10 = alloca i32, align 4
  %11 = alloca float, align 4
  %12 = alloca i32, align 4
  %13 = alloca %struct.CShape, align 4
  %14 = alloca %struct.CShape, align 4
  %15 = alloca { i64, i32 }, align 4
  %16 = alloca i32, align 4
  %17 = alloca i32, align 4
  %18 = alloca ptr, align 8
  store ptr %0, ptr %3, align 8, !tbaa !5
  store ptr %1, ptr %4, align 8, !tbaa !5
  %19 = load ptr, ptr %4, align 8, !tbaa !5
  %20 = icmp eq ptr %19, null
  br i1 %20, label %21, label %28

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

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

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

28:                                               ; preds = %2
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #8
  %29 = load ptr, ptr %4, align 8, !tbaa !5
  %30 = call noundef ptr @strrchr(ptr noundef %29, i32 noundef 46) #10
  store ptr %30, ptr %7, align 8, !tbaa !5
  %31 = load ptr, ptr %7, align 8, !tbaa !5
  %32 = call i32 @strcmp(ptr noundef %31, ptr noundef @.str.1) #10
  %33 = icmp ne i32 %32, 0
  br i1 %33, label %34, label %42

34:                                               ; preds = %28
  %35 = call ptr @__cxa_allocate_exception(i64 1032) #8
  %36 = load ptr, ptr %4, align 8, !tbaa !5
  invoke void @_ZN6CErrorC2EPKcS1_(ptr noundef nonnull align 8 dereferenceable(1032) %35, ptr noundef @.str.2, ptr noundef %36)
          to label %37 unwind label %38

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

38:                                               ; preds = %34
  %39 = landingpad { ptr, i32 }
          cleanup
  %40 = extractvalue { ptr, i32 } %39, 0
  store ptr %40, ptr %5, align 8
  %41 = extractvalue { ptr, i32 } %39, 1
  store i32 %41, ptr %6, align 4
  call void @__cxa_free_exception(ptr %35) #8
  br label %179

42:                                               ; preds = %28
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #8
  %43 = load ptr, ptr %4, align 8, !tbaa !5
  %44 = call noalias ptr @fopen(ptr noundef %43, ptr noundef @.str.3)
  store ptr %44, ptr %8, align 8, !tbaa !5
  %45 = load ptr, ptr %8, align 8, !tbaa !5
  %46 = icmp eq ptr %45, null
  br i1 %46, label %47, label %55

47:                                               ; preds = %42
  %48 = call ptr @__cxa_allocate_exception(i64 1032) #8
  %49 = load ptr, ptr %4, align 8, !tbaa !5
  invoke void @_ZN6CErrorC2EPKcS1_(ptr noundef nonnull align 8 dereferenceable(1032) %48, ptr noundef @.str.4, ptr noundef %49)
          to label %50 unwind label %51

50:                                               ; preds = %47
  call void @__cxa_throw(ptr %48, ptr @_ZTI6CError, ptr @_ZNSt9exceptionD2Ev) #9
  unreachable

51:                                               ; preds = %47
  %52 = landingpad { ptr, i32 }
          cleanup
  %53 = extractvalue { ptr, i32 } %52, 0
  store ptr %53, ptr %5, align 8
  %54 = extractvalue { ptr, i32 } %52, 1
  store i32 %54, ptr %6, align 4
  call void @__cxa_free_exception(ptr %48) #8
  br label %178

55:                                               ; preds = %42
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #8
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #8
  call void @llvm.lifetime.start.p0(i64 4, ptr %11) #8
  %56 = load ptr, ptr %8, align 8, !tbaa !5
  %57 = call i64 @fread(ptr noundef %11, i64 noundef 4, i64 noundef 1, ptr noundef %56)
  %58 = trunc i64 %57 to i32
  %59 = icmp ne i32 %58, 1
  br i1 %59, label %70, label %60

60:                                               ; preds = %55
  %61 = load ptr, ptr %8, align 8, !tbaa !5
  %62 = call i64 @fread(ptr noundef %9, i64 noundef 4, i64 noundef 1, ptr noundef %61)
  %63 = trunc i64 %62 to i32
  %64 = icmp ne i32 %63, 1
  br i1 %64, label %70, label %65

65:                                               ; preds = %60
  %66 = load ptr, ptr %8, align 8, !tbaa !5
  %67 = call i64 @fread(ptr noundef %10, i64 noundef 4, i64 noundef 1, ptr noundef %66)
  %68 = trunc i64 %67 to i32
  %69 = icmp ne i32 %68, 1
  br i1 %69, label %70, label %78

70:                                               ; preds = %65, %60, %55
  %71 = call ptr @__cxa_allocate_exception(i64 1032) #8
  %72 = load ptr, ptr %4, align 8, !tbaa !5
  invoke void @_ZN6CErrorC2EPKcS1_(ptr noundef nonnull align 8 dereferenceable(1032) %71, ptr noundef @.str.5, ptr noundef %72)
          to label %73 unwind label %74

73:                                               ; preds = %70
  call void @__cxa_throw(ptr %71, ptr @_ZTI6CError, ptr @_ZNSt9exceptionD2Ev) #9
  unreachable

74:                                               ; preds = %70
  %75 = landingpad { ptr, i32 }
          cleanup
  %76 = extractvalue { ptr, i32 } %75, 0
  store ptr %76, ptr %5, align 8
  %77 = extractvalue { ptr, i32 } %75, 1
  store i32 %77, ptr %6, align 4
  call void @__cxa_free_exception(ptr %71) #8
  br label %177

78:                                               ; preds = %65
  %79 = load float, ptr %11, align 4, !tbaa !9
  %80 = fpext float %79 to double
  %81 = fcmp une double %80, 0x4108A92A00000000
  br i1 %81, label %82, label %90

82:                                               ; preds = %78
  %83 = call ptr @__cxa_allocate_exception(i64 1032) #8
  %84 = load ptr, ptr %4, align 8, !tbaa !5
  invoke void @_ZN6CErrorC2EPKcS1_(ptr noundef nonnull align 8 dereferenceable(1032) %83, ptr noundef @.str.6, ptr noundef %84)
          to label %85 unwind label %86

85:                                               ; preds = %82
  call void @__cxa_throw(ptr %83, ptr @_ZTI6CError, ptr @_ZNSt9exceptionD2Ev) #9
  unreachable

86:                                               ; preds = %82
  %87 = landingpad { ptr, i32 }
          cleanup
  %88 = extractvalue { ptr, i32 } %87, 0
  store ptr %88, ptr %5, align 8
  %89 = extractvalue { ptr, i32 } %87, 1
  store i32 %89, ptr %6, align 4
  call void @__cxa_free_exception(ptr %83) #8
  br label %177

90:                                               ; preds = %78
  %91 = load i32, ptr %9, align 4, !tbaa !11
  %92 = icmp slt i32 %91, 1
  br i1 %92, label %96, label %93

93:                                               ; preds = %90
  %94 = load i32, ptr %9, align 4, !tbaa !11
  %95 = icmp sgt i32 %94, 99999
  br i1 %95, label %96, label %105

96:                                               ; preds = %93, %90
  %97 = call ptr @__cxa_allocate_exception(i64 1032) #8
  %98 = load ptr, ptr %4, align 8, !tbaa !5
  %99 = load i32, ptr %9, align 4, !tbaa !11
  invoke void @_ZN6CErrorC2EPKcS1_i(ptr noundef nonnull align 8 dereferenceable(1032) %97, ptr noundef @.str.7, ptr noundef %98, i32 noundef %99)
          to label %100 unwind label %101

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

101:                                              ; preds = %96
  %102 = landingpad { ptr, i32 }
          cleanup
  %103 = extractvalue { ptr, i32 } %102, 0
  store ptr %103, ptr %5, align 8
  %104 = extractvalue { ptr, i32 } %102, 1
  store i32 %104, ptr %6, align 4
  call void @__cxa_free_exception(ptr %97) #8
  br label %177

105:                                              ; preds = %93
  %106 = load i32, ptr %10, align 4, !tbaa !11
  %107 = icmp slt i32 %106, 1
  br i1 %107, label %111, label %108

108:                                              ; preds = %105
  %109 = load i32, ptr %10, align 4, !tbaa !11
  %110 = icmp sgt i32 %109, 99999
  br i1 %110, label %111, label %120

111:                                              ; preds = %108, %105
  %112 = call ptr @__cxa_allocate_exception(i64 1032) #8
  %113 = load ptr, ptr %4, align 8, !tbaa !5
  %114 = load i32, ptr %10, align 4, !tbaa !11
  invoke void @_ZN6CErrorC2EPKcS1_i(ptr noundef nonnull align 8 dereferenceable(1032) %112, ptr noundef @.str.8, ptr noundef %113, i32 noundef %114)
          to label %115 unwind label %116

115:                                              ; preds = %111
  call void @__cxa_throw(ptr %112, ptr @_ZTI6CError, ptr @_ZNSt9exceptionD2Ev) #9
  unreachable

116:                                              ; preds = %111
  %117 = landingpad { ptr, i32 }
          cleanup
  %118 = extractvalue { ptr, i32 } %117, 0
  store ptr %118, ptr %5, align 8
  %119 = extractvalue { ptr, i32 } %117, 1
  store i32 %119, ptr %6, align 4
  call void @__cxa_free_exception(ptr %112) #8
  br label %177

120:                                              ; preds = %108
  call void @llvm.lifetime.start.p0(i64 4, ptr %12) #8
  store i32 2, ptr %12, align 4, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 12, ptr %13) #8
  %121 = load i32, ptr %9, align 4, !tbaa !11
  %122 = load i32, ptr %10, align 4, !tbaa !11
  %123 = load i32, ptr %12, align 4, !tbaa !11
  call void @_ZN6CShapeC2Eiii(ptr noundef nonnull align 4 dereferenceable(12) %13, i32 noundef %121, i32 noundef %122, i32 noundef %123)
  %124 = load ptr, ptr %3, align 8, !tbaa !5
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %14, ptr align 4 %13, i64 12, i1 false), !tbaa.struct !13
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %15, ptr align 4 %14, i64 12, i1 false)
  %125 = getelementptr inbounds { i64, i32 }, ptr %15, i32 0, i32 0
  %126 = load i64, ptr %125, align 4
  %127 = getelementptr inbounds { i64, i32 }, ptr %15, i32 0, i32 1
  %128 = load i32, ptr %127, align 4
  call void @_ZN8CImageOfIfE10ReAllocateE6CShapeb(ptr noundef nonnull align 8 dereferenceable(76) %124, i64 %126, i32 %128, i1 noundef zeroext false)
  call void @llvm.lifetime.start.p0(i64 4, ptr %16) #8
  %129 = load i32, ptr %12, align 4, !tbaa !11
  %130 = load i32, ptr %9, align 4, !tbaa !11
  %131 = mul nsw i32 %129, %130
  store i32 %131, ptr %16, align 4, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 4, ptr %17) #8
  store i32 0, ptr %17, align 4, !tbaa !11
  br label %132

132:                                              ; preds = %158, %120
  %133 = load i32, ptr %17, align 4, !tbaa !11
  %134 = load i32, ptr %10, align 4, !tbaa !11
  %135 = icmp slt i32 %133, %134
  br i1 %135, label %137, label %136

136:                                              ; preds = %132
  call void @llvm.lifetime.end.p0(i64 4, ptr %17) #8
  br label %161

137:                                              ; preds = %132
  call void @llvm.lifetime.start.p0(i64 8, ptr %18) #8
  %138 = load ptr, ptr %3, align 8, !tbaa !5
  %139 = load i32, ptr %17, align 4, !tbaa !11
  %140 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZN8CImageOfIfE5PixelEiii(ptr noundef nonnull align 8 dereferenceable(76) %138, i32 noundef 0, i32 noundef %139, i32 noundef 0)
  store ptr %140, ptr %18, align 8, !tbaa !5
  %141 = load ptr, ptr %18, align 8, !tbaa !5
  %142 = load i32, ptr %16, align 4, !tbaa !11
  %143 = sext i32 %142 to i64
  %144 = load ptr, ptr %8, align 8, !tbaa !5
  %145 = call i64 @fread(ptr noundef %141, i64 noundef 4, i64 noundef %143, ptr noundef %144)
  %146 = trunc i64 %145 to i32
  %147 = load i32, ptr %16, align 4, !tbaa !11
  %148 = icmp ne i32 %146, %147
  br i1 %148, label %149, label %157

149:                                              ; preds = %137
  %150 = call ptr @__cxa_allocate_exception(i64 1032) #8
  %151 = load ptr, ptr %4, align 8, !tbaa !5
  invoke void @_ZN6CErrorC2EPKcS1_(ptr noundef nonnull align 8 dereferenceable(1032) %150, ptr noundef @.str.9, ptr noundef %151)
          to label %152 unwind label %153

152:                                              ; preds = %149
  call void @__cxa_throw(ptr %150, ptr @_ZTI6CError, ptr @_ZNSt9exceptionD2Ev) #9
  unreachable

153:                                              ; preds = %149
  %154 = landingpad { ptr, i32 }
          cleanup
  %155 = extractvalue { ptr, i32 } %154, 0
  store ptr %155, ptr %5, align 8
  %156 = extractvalue { ptr, i32 } %154, 1
  store i32 %156, ptr %6, align 4
  call void @__cxa_free_exception(ptr %150) #8
  call void @llvm.lifetime.end.p0(i64 8, ptr %18) #8
  call void @llvm.lifetime.end.p0(i64 4, ptr %17) #8
  br label %176

157:                                              ; preds = %137
  call void @llvm.lifetime.end.p0(i64 8, ptr %18) #8
  br label %158

158:                                              ; preds = %157
  %159 = load i32, ptr %17, align 4, !tbaa !11
  %160 = add nsw i32 %159, 1
  store i32 %160, ptr %17, align 4, !tbaa !11
  br label %132, !llvm.loop !14

161:                                              ; preds = %136
  %162 = load ptr, ptr %8, align 8, !tbaa !5
  %163 = call i32 @fgetc(ptr noundef %162)
  %164 = icmp ne i32 %163, -1
  br i1 %164, label %165, label %173

165:                                              ; preds = %161
  %166 = call ptr @__cxa_allocate_exception(i64 1032) #8
  %167 = load ptr, ptr %4, align 8, !tbaa !5
  invoke void @_ZN6CErrorC2EPKcS1_(ptr noundef nonnull align 8 dereferenceable(1032) %166, ptr noundef @.str.10, ptr noundef %167)
          to label %168 unwind label %169

168:                                              ; preds = %165
  call void @__cxa_throw(ptr %166, ptr @_ZTI6CError, ptr @_ZNSt9exceptionD2Ev) #9
  unreachable

169:                                              ; preds = %165
  %170 = landingpad { ptr, i32 }
          cleanup
  %171 = extractvalue { ptr, i32 } %170, 0
  store ptr %171, ptr %5, align 8
  %172 = extractvalue { ptr, i32 } %170, 1
  store i32 %172, ptr %6, align 4
  call void @__cxa_free_exception(ptr %166) #8
  br label %176

173:                                              ; preds = %161
  %174 = load ptr, ptr %8, align 8, !tbaa !5
  %175 = call i32 @fclose(ptr noundef %174)
  call void @llvm.lifetime.end.p0(i64 4, ptr %16) #8
  call void @llvm.lifetime.end.p0(i64 12, 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 4, ptr %9) #8
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #8
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #8
  ret void

176:                                              ; preds = %169, %153
  call void @llvm.lifetime.end.p0(i64 4, ptr %16) #8
  call void @llvm.lifetime.end.p0(i64 12, ptr %13) #8
  call void @llvm.lifetime.end.p0(i64 4, ptr %12) #8
  br label %177

177:                                              ; preds = %176, %116, %101, %86, %74
  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 4, ptr %9) #8
  br label %178

178:                                              ; preds = %177, %51
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #8
  br label %179

179:                                              ; preds = %178, %38
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #8
  br label %180

180:                                              ; preds = %179, %24
  %181 = load ptr, ptr %5, align 8
  %182 = load i32, ptr %6, align 4
  %183 = insertvalue { ptr, i32 } poison, ptr %181, 0
  %184 = insertvalue { ptr, i32 } %183, i32 %182, 1
  resume { ptr, i32 } %184
}

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 #1 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 #2

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) #3

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

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

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

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

declare i64 @fread(ptr noundef, i64 noundef, i64 noundef, ptr noundef) #5

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZN6CShapeC2Eiii(ptr noundef nonnull align 4 dereferenceable(12), i32 noundef, i32 noundef, i32 noundef) unnamed_addr #1 align 2

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local void @_ZN8CImageOfIfE10ReAllocateE6CShapeb(ptr noundef nonnull align 8 dereferenceable(76), i64, i32, i1 noundef zeroext) #6 align 2

; 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) #7

; 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) #3

declare i32 @fgetc(ptr noundef) #5

declare i32 @fclose(ptr noundef) #5

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 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 "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 willreturn memory(argmem: readwrite) }
attributes #4 = { 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 #5 = { "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 = { 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 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
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, !10, i64 0}
!10 = !{!"float", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"int", !7, i64 0}
!13 = !{i64 0, i64 4, !11, i64 4, i64 4, !11, i64 8, i64 4, !11}
!14 = distinct !{!14, !15}
!15 = !{!"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"

%struct.CShape = type { i32, i32, i32 }

@.str = external hidden unnamed_addr constant [29 x i8], align 1
@_ZTI6CError = external dso_local constant { ptr, ptr, ptr }, align 8
@.str.1 = external hidden unnamed_addr constant [5 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [43 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [3 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [32 x i8], align 1
@.str.5 = external hidden unnamed_addr constant [38 x i8], align 1
@.str.6 = external hidden unnamed_addr constant [66 x i8], align 1
@.str.7 = external hidden unnamed_addr constant [35 x i8], align 1
@.str.8 = external hidden unnamed_addr constant [36 x i8], align 1
@.str.9 = external hidden unnamed_addr constant [36 x i8], align 1
@.str.10 = external hidden unnamed_addr constant [35 x i8], align 1

; Function Attrs: mustprogress uwtable
define dso_local void @_Z12ReadFlowFileR8CImageOfIfEPKc(ptr noundef nonnull align 8 dereferenceable(76) %0, ptr noundef %1) local_unnamed_addr #0 personality ptr @__gxx_personality_v0 {
  %3 = alloca i32, align 4
  %4 = alloca i32, align 4
  %5 = alloca float, align 4
  %6 = alloca %struct.CShape, align 8
  %7 = icmp eq ptr %1, null
  br i1 %7, label %8, label %10

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

10:                                               ; preds = %2
  %11 = tail call noundef ptr @strrchr(ptr noundef nonnull dereferenceable(1) %1, i32 noundef 46) #9
  %12 = tail call i32 @strcmp(ptr noundef nonnull dereferenceable(1) %11, ptr noundef nonnull dereferenceable(1) @.str.1) #9
  %.not = icmp eq i32 %12, 0
  br i1 %.not, label %15, label %13

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

15:                                               ; preds = %10
  %16 = tail call noalias ptr @fopen(ptr noundef nonnull %1, ptr noundef nonnull @.str.3)
  %17 = icmp eq ptr %16, null
  br i1 %17, label %18, label %20

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

20:                                               ; preds = %15
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %3) #7
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %4) #7
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %5) #7
  %21 = call i64 @fread(ptr noundef nonnull %5, i64 noundef 4, i64 noundef 1, ptr noundef nonnull %16)
  %22 = and i64 %21, 4294967295
  %.not35 = icmp eq i64 %22, 1
  br i1 %.not35, label %23, label %29

23:                                               ; preds = %20
  %24 = call i64 @fread(ptr noundef nonnull %3, i64 noundef 4, i64 noundef 1, ptr noundef nonnull %16)
  %25 = and i64 %24, 4294967295
  %.not36 = icmp eq i64 %25, 1
  br i1 %.not36, label %26, label %29

26:                                               ; preds = %23
  %27 = call i64 @fread(ptr noundef nonnull %4, i64 noundef 4, i64 noundef 1, ptr noundef nonnull %16)
  %28 = and i64 %27, 4294967295
  %.not37 = icmp eq i64 %28, 1
  br i1 %.not37, label %31, label %29

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

31:                                               ; preds = %26
  %32 = load float, ptr %5, align 4, !tbaa !5
  %33 = fcmp une float %32, 0x4108A92A00000000
  br i1 %33, label %34, label %36

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

36:                                               ; preds = %31
  %37 = load i32, ptr %3, align 4
  %38 = add i32 %37, -100000
  %or.cond = icmp ult i32 %38, -99999
  br i1 %or.cond, label %39, label %41

39:                                               ; preds = %36
  %40 = tail call ptr @__cxa_allocate_exception(i64 1032) #7
  tail call void @_ZN6CErrorC2EPKcS1_i(ptr noundef nonnull align 8 dereferenceable(1032) %40, ptr noundef nonnull @.str.7, ptr noundef nonnull %1, i32 noundef %37)
  tail call void @__cxa_throw(ptr nonnull %40, ptr nonnull @_ZTI6CError, ptr nonnull @_ZNSt9exceptionD2Ev) #8
  unreachable

41:                                               ; preds = %36
  %42 = load i32, ptr %4, align 4
  %43 = add i32 %42, -100000
  %or.cond3 = icmp ult i32 %43, -99999
  br i1 %or.cond3, label %44, label %.lr.ph

44:                                               ; preds = %41
  %45 = tail call ptr @__cxa_allocate_exception(i64 1032) #7
  tail call void @_ZN6CErrorC2EPKcS1_i(ptr noundef nonnull align 8 dereferenceable(1032) %45, ptr noundef nonnull @.str.8, ptr noundef nonnull %1, i32 noundef %42)
  tail call void @__cxa_throw(ptr nonnull %45, ptr nonnull @_ZTI6CError, ptr nonnull @_ZNSt9exceptionD2Ev) #8
  unreachable

.lr.ph:                                           ; preds = %41
  call void @llvm.lifetime.start.p0(i64 12, ptr nonnull %6) #7
  call void @_ZN6CShapeC2Eiii(ptr noundef nonnull align 4 dereferenceable(12) %6, i32 noundef %37, i32 noundef %42, i32 noundef 2)
  %.sroa.08.0.copyload = load i64, ptr %6, align 8
  %.sroa.29.0..sroa_idx = getelementptr inbounds i8, ptr %6, i64 8
  %.sroa.29.0.copyload = load i32, ptr %.sroa.29.0..sroa_idx, align 8, !tbaa !9
  call void @_ZN8CImageOfIfE10ReAllocateE6CShapeb(ptr noundef nonnull align 8 dereferenceable(76) %0, i64 %.sroa.08.0.copyload, i32 %.sroa.29.0.copyload, i1 noundef zeroext false)
  %46 = shl nuw nsw i32 %37, 1
  %47 = zext nneg i32 %46 to i64
  br label %51

48:                                               ; preds = %51
  %49 = add nuw nsw i32 %.040, 1
  %exitcond.not = icmp eq i32 %49, %42
  br i1 %exitcond.not, label %._crit_edge, label %51, !llvm.loop !11

._crit_edge:                                      ; preds = %48
  %50 = call i32 @fgetc(ptr noundef nonnull %16)
  %.not38 = icmp eq i32 %50, -1
  br i1 %.not38, label %59, label %57

51:                                               ; preds = %.lr.ph, %48
  %.040 = phi i32 [ 0, %.lr.ph ], [ %49, %48 ]
  %52 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZN8CImageOfIfE5PixelEiii(ptr noundef nonnull align 8 dereferenceable(76) %0, i32 noundef 0, i32 noundef %.040, i32 noundef 0)
  %53 = call i64 @fread(ptr noundef nonnull %52, i64 noundef 4, i64 noundef %47, ptr noundef nonnull %16)
  %54 = trunc i64 %53 to i32
  %.not39 = icmp eq i32 %46, %54
  br i1 %.not39, label %48, label %55

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

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

59:                                               ; preds = %._crit_edge
  %60 = call i32 @fclose(ptr noundef nonnull %16)
  call void @llvm.lifetime.end.p0(i64 12, ptr nonnull %6) #7
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %5) #7
  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
}

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 #1 align 2

declare i32 @__gxx_personality_v0(...)

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

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) #3

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

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

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

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

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

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZN6CShapeC2Eiii(ptr noundef nonnull align 4 dereferenceable(12), i32 noundef, i32 noundef, i32 noundef) unnamed_addr #1 align 2

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local void @_ZN8CImageOfIfE10ReAllocateE6CShapeb(ptr noundef nonnull align 8 dereferenceable(76), i64, i32, i1 noundef zeroext) local_unnamed_addr #6 align 2

; 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 #6 align 2

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

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

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

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 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 "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 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #4 = { 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 #5 = { 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 #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 = { 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 = !{!"float", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"int", !7, i64 0}
!11 = distinct !{!11, !12}
!12 = !{!"llvm.loop.mustprogress"}


; Effective O3 passes: CorrelatedValuePropagationPass,EarlyCSEPass,GlobalOptPass,IndVarSimplifyPass,InferAlignmentPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,LICMPass,LoopRotatePass,LoopSimplifyPass,SROAPass,SimplifyCFGPass,TailCallElimPass