; LLVM IR from jingweizhanghuai/Morn :: src/util (morn_file)

; 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.Chunk = type { i32, i32, i32 }
%struct.HandleMORNFile = type { ptr, ptr, i32 }

@.str = external hidden unnamed_addr constant [76 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [17 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [14 x i8], align 1
@__FUNCTION__.mMORNWrite = external hidden unnamed_addr constant [11 x i8], align 1

declare i32 @fseek(ptr noundef, i64 noundef, i32 noundef) #0

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

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

declare void @m_Exception(i32 noundef, i32 noundef, ptr noundef, i32 noundef, ptr noundef, ptr noundef, ...) #0

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

; Function Attrs: nounwind uwtable
declare dso_local ptr @MORNInit(ptr noundef) #2

declare ptr @mListWrite(ptr noundef, i32 noundef, ptr noundef, i32 noundef) #0

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

; Function Attrs: nounwind uwtable
define dso_local i32 @mMORNWrite(ptr noundef %0, i32 noundef %1, ptr noundef %2, i32 noundef %3, i32 noundef %4) #2 {
  %6 = alloca i32, align 4
  %7 = alloca ptr, align 8
  %8 = alloca i32, align 4
  %9 = alloca ptr, align 8
  %10 = alloca i32, align 4
  %11 = alloca i32, align 4
  %12 = alloca ptr, align 8
  %13 = alloca ptr, align 8
  %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
  %19 = alloca i32, align 4
  %20 = alloca i32, align 4
  %21 = alloca i32, align 4
  %22 = alloca i32, align 4
  %23 = alloca %struct.Chunk, align 4
  %24 = alloca i32, align 4
  %25 = alloca i32, align 4
  store ptr %0, ptr %7, align 8, !tbaa !5
  store i32 %1, ptr %8, align 4, !tbaa !9
  store ptr %2, ptr %9, align 8, !tbaa !5
  store i32 %3, ptr %10, align 4, !tbaa !9
  store i32 %4, ptr %11, align 4, !tbaa !9
  %26 = load i32, ptr %10, align 4, !tbaa !9
  %27 = icmp sle i32 %26, 0
  br i1 %27, label %28, label %29

28:                                               ; preds = %5
  store i32 1, ptr %10, align 4, !tbaa !9
  br label %29

29:                                               ; preds = %28, %5
  call void @llvm.lifetime.start.p0(i64 8, ptr %12) #3
  %30 = load ptr, ptr %7, align 8, !tbaa !5
  %31 = call ptr @MORNInit(ptr noundef %30)
  store ptr %31, ptr %12, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %13) #3
  %32 = load ptr, ptr %12, align 8, !tbaa !5
  %33 = load i32, ptr %8, align 4, !tbaa !9
  %34 = call ptr @MornChunk(ptr noundef %32, i32 noundef %33)
  store ptr %34, ptr %13, align 8, !tbaa !5
  %35 = load ptr, ptr %13, align 8, !tbaa !5
  %36 = icmp ne ptr %35, null
  br i1 %36, label %37, label %122

37:                                               ; preds = %29
  %38 = load i32, ptr %11, align 4, !tbaa !9
  %39 = icmp sle i32 %38, 0
  br i1 %39, label %40, label %61

40:                                               ; preds = %37
  br label %41

41:                                               ; preds = %40
  call void @llvm.lifetime.start.p0(i64 4, ptr %14) #3
  %42 = load ptr, ptr %13, align 8, !tbaa !5
  %43 = getelementptr inbounds %struct.Chunk, ptr %42, i32 0, i32 1
  %44 = load i32, ptr %43, align 4, !tbaa !11
  %45 = load i32, ptr %10, align 4, !tbaa !9
  %46 = srem i32 %44, %45
  %47 = icmp ne i32 %46, 0
  %48 = zext i1 %47 to i32
  store i32 %48, ptr %14, align 4, !tbaa !9
  %49 = load i32, ptr %14, align 4, !tbaa !9
  %50 = icmp ne i32 %49, 0
  br i1 %50, label %51, label %53

51:                                               ; preds = %41
  %52 = load i32, ptr %14, align 4, !tbaa !9
  call void (i32, i32, ptr, i32, ptr, ptr, ...) @m_Exception(i32 noundef %52, i32 noundef -1, ptr noundef @.str, i32 noundef 144, ptr noundef @__FUNCTION__.mMORNWrite, ptr noundef @.str.2)
  br label %53

53:                                               ; preds = %51, %41
  call void @llvm.lifetime.end.p0(i64 4, ptr %14) #3
  br label %54

54:                                               ; preds = %53
  br label %55

55:                                               ; preds = %54
  %56 = load ptr, ptr %13, align 8, !tbaa !5
  %57 = getelementptr inbounds %struct.Chunk, ptr %56, i32 0, i32 1
  %58 = load i32, ptr %57, align 4, !tbaa !11
  %59 = load i32, ptr %10, align 4, !tbaa !9
  %60 = sdiv i32 %58, %59
  store i32 %60, ptr %11, align 4, !tbaa !9
  br label %61

61:                                               ; preds = %55, %37
  br label %62

62:                                               ; preds = %61
  call void @llvm.lifetime.start.p0(i64 4, ptr %15) #3
  %63 = load ptr, ptr %13, align 8, !tbaa !5
  %64 = getelementptr inbounds %struct.Chunk, ptr %63, i32 0, i32 1
  %65 = load i32, ptr %64, align 4, !tbaa !11
  %66 = load i32, ptr %10, align 4, !tbaa !9
  %67 = load i32, ptr %11, align 4, !tbaa !9
  %68 = mul nsw i32 %66, %67
  %69 = icmp ne i32 %65, %68
  %70 = zext i1 %69 to i32
  store i32 %70, ptr %15, align 4, !tbaa !9
  %71 = load i32, ptr %15, align 4, !tbaa !9
  %72 = icmp ne i32 %71, 0
  br i1 %72, label %73, label %75

73:                                               ; preds = %62
  %74 = load i32, ptr %15, align 4, !tbaa !9
  call void (i32, i32, ptr, i32, ptr, ptr, ...) @m_Exception(i32 noundef %74, i32 noundef -1, ptr noundef @.str, i32 noundef 145, ptr noundef @__FUNCTION__.mMORNWrite, ptr noundef @.str.2)
  br label %75

75:                                               ; preds = %73, %62
  call void @llvm.lifetime.end.p0(i64 4, ptr %15) #3
  br label %76

76:                                               ; preds = %75
  br label %77

77:                                               ; preds = %76
  %78 = load ptr, ptr %12, align 8, !tbaa !5
  %79 = getelementptr inbounds %struct.HandleMORNFile, ptr %78, i32 0, i32 0
  %80 = load ptr, ptr %79, align 8, !tbaa !13
  %81 = load ptr, ptr %13, align 8, !tbaa !5
  %82 = getelementptr inbounds %struct.Chunk, ptr %81, i32 0, i32 2
  %83 = load i32, ptr %82, align 4, !tbaa !15
  %84 = sext i32 %83 to i64
  %85 = call i32 @fseek(ptr noundef %80, i64 noundef %84, i32 noundef 0)
  call void @llvm.lifetime.start.p0(i64 4, ptr %16) #3
  store i32 0, ptr %16, align 4, !tbaa !9
  br label %86

86:                                               ; preds = %115, %77
  %87 = load i32, ptr %16, align 4, !tbaa !9
  %88 = load i32, ptr %10, align 4, !tbaa !9
  %89 = icmp slt i32 %87, %88
  br i1 %89, label %91, label %90

90:                                               ; preds = %86
  call void @llvm.lifetime.end.p0(i64 4, ptr %16) #3
  br label %118

91:                                               ; preds = %86
  br label %92

92:                                               ; preds = %91
  call void @llvm.lifetime.start.p0(i64 4, ptr %17) #3
  %93 = load ptr, ptr %9, align 8, !tbaa !5
  %94 = load i32, ptr %16, align 4, !tbaa !9
  %95 = sext i32 %94 to i64
  %96 = getelementptr inbounds ptr, ptr %93, i64 %95
  %97 = load ptr, ptr %96, align 8, !tbaa !5
  %98 = load i32, ptr %11, align 4, !tbaa !9
  %99 = sext i32 %98 to i64
  %100 = load ptr, ptr %12, align 8, !tbaa !5
  %101 = getelementptr inbounds %struct.HandleMORNFile, ptr %100, i32 0, i32 0
  %102 = load ptr, ptr %101, align 8, !tbaa !13
  %103 = call i64 @fwrite(ptr noundef %97, i64 noundef 1, i64 noundef %99, ptr noundef %102)
  %104 = trunc i64 %103 to i32
  %105 = load i32, ptr %11, align 4, !tbaa !9
  %106 = icmp ne i32 %104, %105
  %107 = zext i1 %106 to i32
  store i32 %107, ptr %17, align 4, !tbaa !9
  %108 = load i32, ptr %17, align 4, !tbaa !9
  %109 = icmp ne i32 %108, 0
  br i1 %109, label %110, label %112

110:                                              ; preds = %92
  %111 = load i32, ptr %17, align 4, !tbaa !9
  call void (i32, i32, ptr, i32, ptr, ptr, ...) @m_Exception(i32 noundef %111, i32 noundef -1, ptr noundef @.str, i32 noundef 148, ptr noundef @__FUNCTION__.mMORNWrite, ptr noundef @.str.1)
  br label %112

112:                                              ; preds = %110, %92
  call void @llvm.lifetime.end.p0(i64 4, ptr %17) #3
  br label %113

113:                                              ; preds = %112
  br label %114

114:                                              ; preds = %113
  br label %115

115:                                              ; preds = %114
  %116 = load i32, ptr %16, align 4, !tbaa !9
  %117 = add nsw i32 %116, 1
  store i32 %117, ptr %16, align 4, !tbaa !9
  br label %86, !llvm.loop !16

118:                                              ; preds = %90
  %119 = load ptr, ptr %13, align 8, !tbaa !5
  %120 = getelementptr inbounds %struct.Chunk, ptr %119, i32 0, i32 1
  %121 = load i32, ptr %120, align 4, !tbaa !11
  store i32 %121, ptr %6, align 4
  store i32 1, ptr %18, align 4
  br label %228

122:                                              ; preds = %29
  br label %123

123:                                              ; preds = %122
  call void @llvm.lifetime.start.p0(i64 4, ptr %19) #3
  %124 = load i32, ptr %11, align 4, !tbaa !9
  %125 = icmp sle i32 %124, 0
  %126 = zext i1 %125 to i32
  store i32 %126, ptr %19, align 4, !tbaa !9
  %127 = load i32, ptr %19, align 4, !tbaa !9
  %128 = icmp ne i32 %127, 0
  br i1 %128, label %129, label %131

129:                                              ; preds = %123
  %130 = load i32, ptr %19, align 4, !tbaa !9
  call void (i32, i32, ptr, i32, ptr, ptr, ...) @m_Exception(i32 noundef %130, i32 noundef -1, ptr noundef @.str, i32 noundef 152, ptr noundef @__FUNCTION__.mMORNWrite, ptr noundef @.str.2)
  br label %131

131:                                              ; preds = %129, %123
  call void @llvm.lifetime.end.p0(i64 4, ptr %19) #3
  br label %132

132:                                              ; preds = %131
  br label %133

133:                                              ; preds = %132
  %134 = load ptr, ptr %12, align 8, !tbaa !5
  %135 = getelementptr inbounds %struct.HandleMORNFile, ptr %134, i32 0, i32 0
  %136 = load ptr, ptr %135, align 8, !tbaa !13
  %137 = call i32 @fseek(ptr noundef %136, i64 noundef 0, i32 noundef 2)
  br label %138

138:                                              ; preds = %133
  call void @llvm.lifetime.start.p0(i64 4, ptr %20) #3
  %139 = load ptr, ptr %12, align 8, !tbaa !5
  %140 = getelementptr inbounds %struct.HandleMORNFile, ptr %139, i32 0, i32 0
  %141 = load ptr, ptr %140, align 8, !tbaa !13
  %142 = call i64 @fwrite(ptr noundef %8, i64 noundef 1, i64 noundef 4, ptr noundef %141)
  %143 = trunc i64 %142 to i32
  %144 = icmp ne i32 %143, 4
  %145 = zext i1 %144 to i32
  store i32 %145, ptr %20, align 4, !tbaa !9
  %146 = load i32, ptr %20, align 4, !tbaa !9
  %147 = icmp ne i32 %146, 0
  br i1 %147, label %148, label %150

148:                                              ; preds = %138
  %149 = load i32, ptr %20, align 4, !tbaa !9
  call void (i32, i32, ptr, i32, ptr, ptr, ...) @m_Exception(i32 noundef %149, i32 noundef -1, ptr noundef @.str, i32 noundef 155, ptr noundef @__FUNCTION__.mMORNWrite, ptr noundef @.str.1)
  br label %150

150:                                              ; preds = %148, %138
  call void @llvm.lifetime.end.p0(i64 4, ptr %20) #3
  br label %151

151:                                              ; preds = %150
  br label %152

152:                                              ; preds = %151
  call void @llvm.lifetime.start.p0(i64 4, ptr %21) #3
  %153 = load i32, ptr %11, align 4, !tbaa !9
  %154 = load i32, ptr %10, align 4, !tbaa !9
  %155 = mul nsw i32 %153, %154
  store i32 %155, ptr %21, align 4, !tbaa !9
  br label %156

156:                                              ; preds = %152
  call void @llvm.lifetime.start.p0(i64 4, ptr %22) #3
  %157 = load ptr, ptr %12, align 8, !tbaa !5
  %158 = getelementptr inbounds %struct.HandleMORNFile, ptr %157, i32 0, i32 0
  %159 = load ptr, ptr %158, align 8, !tbaa !13
  %160 = call i64 @fwrite(ptr noundef %21, i64 noundef 4, i64 noundef 1, ptr noundef %159)
  %161 = trunc i64 %160 to i32
  %162 = icmp ne i32 %161, 1
  %163 = zext i1 %162 to i32
  store i32 %163, ptr %22, align 4, !tbaa !9
  %164 = load i32, ptr %22, align 4, !tbaa !9
  %165 = icmp ne i32 %164, 0
  br i1 %165, label %166, label %168

166:                                              ; preds = %156
  %167 = load i32, ptr %22, align 4, !tbaa !9
  call void (i32, i32, ptr, i32, ptr, ptr, ...) @m_Exception(i32 noundef %167, i32 noundef -1, ptr noundef @.str, i32 noundef 156, ptr noundef @__FUNCTION__.mMORNWrite, ptr noundef @.str.1)
  br label %168

168:                                              ; preds = %166, %156
  call void @llvm.lifetime.end.p0(i64 4, ptr %22) #3
  br label %169

169:                                              ; preds = %168
  br label %170

170:                                              ; preds = %169
  %171 = load ptr, ptr %12, align 8, !tbaa !5
  %172 = getelementptr inbounds %struct.HandleMORNFile, ptr %171, i32 0, i32 2
  %173 = load i32, ptr %172, align 8, !tbaa !18
  %174 = load i32, ptr %21, align 4, !tbaa !9
  %175 = add nsw i32 %173, %174
  %176 = add nsw i32 %175, 4
  %177 = add nsw i32 %176, 4
  %178 = load ptr, ptr %12, align 8, !tbaa !5
  %179 = getelementptr inbounds %struct.HandleMORNFile, ptr %178, i32 0, i32 2
  store i32 %177, ptr %179, align 8, !tbaa !18
  call void @llvm.lifetime.start.p0(i64 12, ptr %23) #3
  %180 = load i32, ptr %21, align 4, !tbaa !9
  %181 = getelementptr inbounds %struct.Chunk, ptr %23, i32 0, i32 1
  store i32 %180, ptr %181, align 4, !tbaa !11
  %182 = load i32, ptr %8, align 4, !tbaa !9
  %183 = getelementptr inbounds %struct.Chunk, ptr %23, i32 0, i32 0
  store i32 %182, ptr %183, align 4, !tbaa !19
  %184 = load ptr, ptr %12, align 8, !tbaa !5
  %185 = getelementptr inbounds %struct.HandleMORNFile, ptr %184, i32 0, i32 0
  %186 = load ptr, ptr %185, align 8, !tbaa !13
  %187 = call i64 @ftell(ptr noundef %186)
  %188 = trunc i64 %187 to i32
  %189 = getelementptr inbounds %struct.Chunk, ptr %23, i32 0, i32 2
  store i32 %188, ptr %189, align 4, !tbaa !15
  %190 = load ptr, ptr %12, align 8, !tbaa !5
  %191 = getelementptr inbounds %struct.HandleMORNFile, ptr %190, i32 0, i32 1
  %192 = load ptr, ptr %191, align 8, !tbaa !20
  %193 = call ptr @mListWrite(ptr noundef %192, i32 noundef -1, ptr noundef %23, i32 noundef 12)
  call void @llvm.lifetime.start.p0(i64 4, ptr %24) #3
  store i32 0, ptr %24, align 4, !tbaa !9
  br label %194

194:                                              ; preds = %223, %170
  %195 = load i32, ptr %24, align 4, !tbaa !9
  %196 = load i32, ptr %10, align 4, !tbaa !9
  %197 = icmp slt i32 %195, %196
  br i1 %197, label %199, label %198

198:                                              ; preds = %194
  store i32 17, ptr %18, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %24) #3
  br label %226

199:                                              ; preds = %194
  br label %200

200:                                              ; preds = %199
  call void @llvm.lifetime.start.p0(i64 4, ptr %25) #3
  %201 = load ptr, ptr %9, align 8, !tbaa !5
  %202 = load i32, ptr %24, align 4, !tbaa !9
  %203 = sext i32 %202 to i64
  %204 = getelementptr inbounds ptr, ptr %201, i64 %203
  %205 = load ptr, ptr %204, align 8, !tbaa !5
  %206 = load i32, ptr %11, align 4, !tbaa !9
  %207 = sext i32 %206 to i64
  %208 = load ptr, ptr %12, align 8, !tbaa !5
  %209 = getelementptr inbounds %struct.HandleMORNFile, ptr %208, i32 0, i32 0
  %210 = load ptr, ptr %209, align 8, !tbaa !13
  %211 = call i64 @fwrite(ptr noundef %205, i64 noundef 1, i64 noundef %207, ptr noundef %210)
  %212 = trunc i64 %211 to i32
  %213 = load i32, ptr %11, align 4, !tbaa !9
  %214 = icmp ne i32 %212, %213
  %215 = zext i1 %214 to i32
  store i32 %215, ptr %25, align 4, !tbaa !9
  %216 = load i32, ptr %25, align 4, !tbaa !9
  %217 = icmp ne i32 %216, 0
  br i1 %217, label %218, label %220

218:                                              ; preds = %200
  %219 = load i32, ptr %25, align 4, !tbaa !9
  call void (i32, i32, ptr, i32, ptr, ptr, ...) @m_Exception(i32 noundef %219, i32 noundef -1, ptr noundef @.str, i32 noundef 165, ptr noundef @__FUNCTION__.mMORNWrite, ptr noundef @.str.1)
  br label %220

220:                                              ; preds = %218, %200
  call void @llvm.lifetime.end.p0(i64 4, ptr %25) #3
  br label %221

221:                                              ; preds = %220
  br label %222

222:                                              ; preds = %221
  br label %223

223:                                              ; preds = %222
  %224 = load i32, ptr %24, align 4, !tbaa !9
  %225 = add nsw i32 %224, 1
  store i32 %225, ptr %24, align 4, !tbaa !9
  br label %194, !llvm.loop !21

226:                                              ; preds = %198
  %227 = load i32, ptr %21, align 4, !tbaa !9
  store i32 %227, ptr %6, align 4
  store i32 1, ptr %18, align 4
  call void @llvm.lifetime.end.p0(i64 12, ptr %23) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %21) #3
  br label %228

228:                                              ; preds = %226, %118
  call void @llvm.lifetime.end.p0(i64 8, ptr %13) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %12) #3
  %229 = load i32, ptr %6, align 4
  ret i32 %229
}

declare i64 @ftell(ptr noundef) #0

attributes #0 = { "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #1 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { 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 = { 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 = !{!10, !10, i64 0}
!10 = !{!"int", !7, i64 0}
!11 = !{!12, !10, i64 4}
!12 = !{!"Chunk", !10, i64 0, !10, i64 4, !10, i64 8}
!13 = !{!14, !6, i64 0}
!14 = !{!"HandleMORNFile", !6, i64 0, !6, i64 8, !10, i64 16}
!15 = !{!12, !10, i64 8}
!16 = distinct !{!16, !17}
!17 = !{!"llvm.loop.mustprogress"}
!18 = !{!14, !10, i64 16}
!19 = !{!12, !10, i64 0}
!20 = !{!14, !6, i64 8}
!21 = distinct !{!21, !17}


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

@.str = external hidden unnamed_addr constant [76 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [17 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [14 x i8], align 1
@__FUNCTION__.mMORNWrite = external hidden unnamed_addr constant [11 x i8], align 1

; Function Attrs: nofree nounwind
declare noundef i32 @fseek(ptr nocapture noundef, i64 noundef, i32 noundef) local_unnamed_addr #0

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

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

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

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

; Function Attrs: nounwind uwtable
declare dso_local ptr @MORNInit(ptr noundef) local_unnamed_addr #3

declare ptr @mListWrite(ptr noundef, i32 noundef, ptr noundef, i32 noundef) local_unnamed_addr #2

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

; Function Attrs: nounwind uwtable
define dso_local i32 @mMORNWrite(ptr noundef %0, i32 noundef %1, ptr nocapture noundef readonly %2, i32 noundef %3, i32 noundef %4) local_unnamed_addr #3 {
  %6 = alloca i32, align 4
  %7 = alloca i32, align 4
  %8 = alloca %struct.Chunk, align 4
  store i32 %1, ptr %6, align 4, !tbaa !5
  %spec.store.select = tail call i32 @llvm.smax.i32(i32 %3, i32 1)
  %9 = tail call ptr @MORNInit(ptr noundef %0)
  %10 = tail call ptr @MornChunk(ptr noundef %9, i32 noundef %1)
  %.not = icmp eq ptr %10, null
  %11 = icmp slt i32 %4, 1
  br i1 %.not, label %42, label %12

12:                                               ; preds = %5
  %13 = getelementptr inbounds i8, ptr %10, i64 4
  %14 = load i32, ptr %13, align 4, !tbaa !9
  br i1 %11, label %15, label %._crit_edge

15:                                               ; preds = %12
  %16 = srem i32 %14, %spec.store.select
  %.not60 = icmp eq i32 %16, 0
  br i1 %.not60, label %18, label %17

17:                                               ; preds = %15
  tail call void (i32, i32, ptr, i32, ptr, ptr, ...) @m_Exception(i32 noundef 1, i32 noundef -1, ptr noundef nonnull @.str, i32 noundef 144, ptr noundef nonnull @__FUNCTION__.mMORNWrite, ptr noundef nonnull @.str.2) #5
  %.pre = load i32, ptr %13, align 4, !tbaa !9
  br label %18

18:                                               ; preds = %17, %15
  %19 = phi i32 [ %.pre, %17 ], [ %14, %15 ]
  %20 = sdiv i32 %19, %spec.store.select
  br label %._crit_edge

._crit_edge:                                      ; preds = %12, %18
  %21 = phi i32 [ %19, %18 ], [ %14, %12 ]
  %.056 = phi i32 [ %20, %18 ], [ %4, %12 ]
  %22 = getelementptr inbounds i8, ptr %10, i64 4
  %23 = mul nsw i32 %.056, %spec.store.select
  %.not61 = icmp eq i32 %21, %23
  br i1 %.not61, label %25, label %24

24:                                               ; preds = %._crit_edge
  tail call void (i32, i32, ptr, i32, ptr, ptr, ...) @m_Exception(i32 noundef 1, i32 noundef -1, ptr noundef nonnull @.str, i32 noundef 145, ptr noundef nonnull @__FUNCTION__.mMORNWrite, ptr noundef nonnull @.str.2) #5
  br label %25

25:                                               ; preds = %24, %._crit_edge
  %26 = load ptr, ptr %9, align 8, !tbaa !11
  %27 = getelementptr inbounds i8, ptr %10, i64 8
  %28 = load i32, ptr %27, align 4, !tbaa !14
  %29 = sext i32 %28 to i64
  %30 = tail call i32 @fseek(ptr noundef %26, i64 noundef %29, i32 noundef 0)
  %31 = sext i32 %.056 to i64
  %wide.trip.count = zext nneg i32 %spec.store.select to i64
  br label %34

32:                                               ; preds = %41
  %33 = load i32, ptr %22, align 4, !tbaa !9
  br label %82

34:                                               ; preds = %25, %41
  %indvars.iv = phi i64 [ 0, %25 ], [ %indvars.iv.next, %41 ]
  %35 = getelementptr inbounds ptr, ptr %2, i64 %indvars.iv
  %36 = load ptr, ptr %35, align 8, !tbaa !15
  %37 = load ptr, ptr %9, align 8, !tbaa !11
  %38 = tail call i64 @fwrite(ptr noundef %36, i64 noundef 1, i64 noundef %31, ptr noundef %37)
  %39 = trunc i64 %38 to i32
  %.not62 = icmp eq i32 %.056, %39
  br i1 %.not62, label %41, label %40

40:                                               ; preds = %34
  tail call void (i32, i32, ptr, i32, ptr, ptr, ...) @m_Exception(i32 noundef 1, i32 noundef -1, ptr noundef nonnull @.str, i32 noundef 148, ptr noundef nonnull @__FUNCTION__.mMORNWrite, ptr noundef nonnull @.str.1) #5
  br label %41

41:                                               ; preds = %40, %34
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %exitcond.not = icmp eq i64 %indvars.iv.next, %wide.trip.count
  br i1 %exitcond.not, label %32, label %34, !llvm.loop !16

42:                                               ; preds = %5
  br i1 %11, label %43, label %44

43:                                               ; preds = %42
  tail call void (i32, i32, ptr, i32, ptr, ptr, ...) @m_Exception(i32 noundef 1, i32 noundef -1, ptr noundef nonnull @.str, i32 noundef 152, ptr noundef nonnull @__FUNCTION__.mMORNWrite, ptr noundef nonnull @.str.2) #5
  br label %44

44:                                               ; preds = %43, %42
  %45 = load ptr, ptr %9, align 8, !tbaa !11
  %46 = tail call i32 @fseek(ptr noundef %45, i64 noundef 0, i32 noundef 2)
  %47 = load ptr, ptr %9, align 8, !tbaa !11
  %48 = call i64 @fwrite(ptr noundef nonnull %6, i64 noundef 1, i64 noundef 4, ptr noundef %47)
  %49 = and i64 %48, 4294967295
  %.not63 = icmp eq i64 %49, 4
  br i1 %.not63, label %51, label %50

50:                                               ; preds = %44
  tail call void (i32, i32, ptr, i32, ptr, ptr, ...) @m_Exception(i32 noundef 1, i32 noundef -1, ptr noundef nonnull @.str, i32 noundef 155, ptr noundef nonnull @__FUNCTION__.mMORNWrite, ptr noundef nonnull @.str.1) #5
  br label %51

51:                                               ; preds = %50, %44
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %7) #5
  %52 = mul nsw i32 %spec.store.select, %4
  store i32 %52, ptr %7, align 4, !tbaa !5
  %53 = load ptr, ptr %9, align 8, !tbaa !11
  %54 = call i64 @fwrite(ptr noundef nonnull %7, i64 noundef 4, i64 noundef 1, ptr noundef %53)
  %55 = and i64 %54, 4294967295
  %.not64 = icmp eq i64 %55, 1
  br i1 %.not64, label %57, label %56

56:                                               ; preds = %51
  tail call void (i32, i32, ptr, i32, ptr, ptr, ...) @m_Exception(i32 noundef 1, i32 noundef -1, ptr noundef nonnull @.str, i32 noundef 156, ptr noundef nonnull @__FUNCTION__.mMORNWrite, ptr noundef nonnull @.str.1) #5
  br label %57

57:                                               ; preds = %56, %51
  %58 = getelementptr inbounds i8, ptr %9, i64 16
  %59 = load i32, ptr %58, align 8, !tbaa !18
  %60 = load i32, ptr %7, align 4, !tbaa !5
  %61 = add i32 %59, 8
  %62 = add i32 %61, %60
  store i32 %62, ptr %58, align 8, !tbaa !18
  call void @llvm.lifetime.start.p0(i64 12, ptr nonnull %8) #5
  %63 = getelementptr inbounds i8, ptr %8, i64 4
  store i32 %60, ptr %63, align 4, !tbaa !9
  %64 = load i32, ptr %6, align 4, !tbaa !5
  store i32 %64, ptr %8, align 4, !tbaa !19
  %65 = load ptr, ptr %9, align 8, !tbaa !11
  %66 = tail call i64 @ftell(ptr noundef %65)
  %67 = trunc i64 %66 to i32
  %68 = getelementptr inbounds i8, ptr %8, i64 8
  store i32 %67, ptr %68, align 4, !tbaa !14
  %69 = getelementptr inbounds i8, ptr %9, i64 8
  %70 = load ptr, ptr %69, align 8, !tbaa !20
  %71 = call ptr @mListWrite(ptr noundef %70, i32 noundef -1, ptr noundef nonnull %8, i32 noundef 12) #5
  %72 = sext i32 %4 to i64
  %wide.trip.count72 = zext nneg i32 %spec.store.select to i64
  br label %74

73:                                               ; preds = %81
  call void @llvm.lifetime.end.p0(i64 12, ptr nonnull %8) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %7) #5
  br label %82

74:                                               ; preds = %57, %81
  %indvars.iv69 = phi i64 [ 0, %57 ], [ %indvars.iv.next70, %81 ]
  %75 = getelementptr inbounds ptr, ptr %2, i64 %indvars.iv69
  %76 = load ptr, ptr %75, align 8, !tbaa !15
  %77 = load ptr, ptr %9, align 8, !tbaa !11
  %78 = call i64 @fwrite(ptr noundef %76, i64 noundef 1, i64 noundef %72, ptr noundef %77)
  %79 = trunc i64 %78 to i32
  %.not65 = icmp eq i32 %79, %4
  br i1 %.not65, label %81, label %80

80:                                               ; preds = %74
  call void (i32, i32, ptr, i32, ptr, ptr, ...) @m_Exception(i32 noundef 1, i32 noundef -1, ptr noundef nonnull @.str, i32 noundef 165, ptr noundef nonnull @__FUNCTION__.mMORNWrite, ptr noundef nonnull @.str.1) #5
  br label %81

81:                                               ; preds = %80, %74
  %indvars.iv.next70 = add nuw nsw i64 %indvars.iv69, 1
  %exitcond73.not = icmp eq i64 %indvars.iv.next70, %wide.trip.count72
  br i1 %exitcond73.not, label %73, label %74, !llvm.loop !21

82:                                               ; preds = %73, %32
  %.0 = phi i32 [ %33, %32 ], [ %60, %73 ]
  ret i32 %.0
}

; Function Attrs: nofree nounwind
declare noundef i64 @ftell(ptr nocapture noundef) local_unnamed_addr #0

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

attributes #0 = { 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 #1 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 = { 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 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
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 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !6, i64 4}
!10 = !{!"Chunk", !6, i64 0, !6, i64 4, !6, i64 8}
!11 = !{!12, !13, i64 0}
!12 = !{!"HandleMORNFile", !13, i64 0, !13, i64 8, !6, i64 16}
!13 = !{!"any pointer", !7, i64 0}
!14 = !{!10, !6, i64 8}
!15 = !{!13, !13, i64 0}
!16 = distinct !{!16, !17}
!17 = !{!"llvm.loop.mustprogress"}
!18 = !{!12, !6, i64 16}
!19 = !{!10, !6, i64 0}
!20 = !{!12, !13, i64 8}
!21 = distinct !{!21, !17}


; Effective O3 passes: EarlyCSEPass,GVNPass,GlobalOptPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,LICMPass,LoopRotatePass,PostOrderFunctionAttrsPass,ReassociatePass,SCCPPass,SROAPass,SimplifyCFGPass,TailCallElimPass