; LLVM IR from ljm941004/HYPERCV_PUBLIC :: modules/core/src/c_src (simplemat)

; 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.BmpInfoHeader = type { i32, i32, i32, i16, i16, i32, i32, i32, i32, i32, i32 }
%struct.SIMPLE_MAT = type { i32, i32, i32, i32, i32, ptr }

@.str = external hidden unnamed_addr constant [8 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [2 x i8], align 1
@.str.7 = external hidden unnamed_addr constant [35 x i8], align 1
@.str.8 = external hidden unnamed_addr constant [3 x i8], align 1
@.str.9 = external hidden unnamed_addr constant [20 x i8], align 1

; Function Attrs: nounwind uwtable
declare dso_local ptr @create_simple_mat(i32 noundef, i32 noundef, i32 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

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

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

; Function Attrs: noreturn nounwind
declare void @exit(i32 noundef) #3

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

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

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

declare i32 @fclose(ptr noundef) #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) #5

; Function Attrs: nounwind uwtable
define dso_local ptr @smread_bmp(ptr noundef %0) #0 {
  %2 = alloca ptr, align 8
  %3 = alloca ptr, align 8
  %4 = alloca %struct.BmpInfoHeader, align 1
  %5 = alloca i32, align 4
  %6 = alloca i32, align 4
  %7 = alloca i32, align 4
  %8 = alloca i32, align 4
  %9 = alloca i32, align 4
  %10 = alloca ptr, align 8
  %11 = alloca ptr, align 8
  %12 = alloca i32, align 4
  %13 = alloca i32, align 4
  %14 = alloca i32, align 4
  %15 = alloca i32, align 4
  %16 = alloca i32, align 4
  %17 = alloca ptr, align 8
  %18 = alloca ptr, align 8
  %19 = alloca i32, align 4
  %20 = alloca ptr, align 8
  %21 = alloca ptr, align 8
  store ptr %0, ptr %2, align 8, !tbaa !5
  %22 = load ptr, ptr %2, align 8, !tbaa !5
  %23 = icmp ne ptr %22, null
  br i1 %23, label %24, label %25

24:                                               ; preds = %1
  br label %29

25:                                               ; preds = %1
  %26 = call i32 (ptr, ...) @printf(ptr noundef @.str)
  %27 = call i32 (ptr, ...) @printf(ptr noundef @.str.7)
  %28 = call i32 (ptr, ...) @printf(ptr noundef @.str.2)
  call void @exit(i32 noundef 1) #7
  unreachable

29:                                               ; preds = %24
  call void @llvm.lifetime.start.p0(i64 8, ptr %3) #8
  %30 = load ptr, ptr %2, align 8, !tbaa !5
  %31 = call noalias ptr @fopen(ptr noundef %30, ptr noundef @.str.8)
  store ptr %31, ptr %3, align 8, !tbaa !5
  %32 = load ptr, ptr %3, align 8, !tbaa !5
  %33 = icmp ne ptr %32, null
  br i1 %33, label %34, label %35

34:                                               ; preds = %29
  br label %39

35:                                               ; preds = %29
  %36 = call i32 (ptr, ...) @printf(ptr noundef @.str)
  %37 = call i32 (ptr, ...) @printf(ptr noundef @.str.9)
  %38 = call i32 (ptr, ...) @printf(ptr noundef @.str.2)
  call void @exit(i32 noundef 1) #7
  unreachable

39:                                               ; preds = %34
  %40 = load ptr, ptr %3, align 8, !tbaa !5
  %41 = call i32 @fseek(ptr noundef %40, i64 noundef 14, i32 noundef 0)
  call void @llvm.lifetime.start.p0(i64 40, ptr %4) #8
  %42 = load ptr, ptr %3, align 8, !tbaa !5
  %43 = call i64 @fread(ptr noundef %4, i64 noundef 40, i64 noundef 1, ptr noundef %42)
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #8
  store i32 3, ptr %5, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #8
  %44 = getelementptr inbounds %struct.BmpInfoHeader, ptr %4, i32 0, i32 1
  %45 = load i32, ptr %44, align 1, !tbaa !11
  store i32 %45, ptr %6, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #8
  %46 = getelementptr inbounds %struct.BmpInfoHeader, ptr %4, i32 0, i32 2
  %47 = load i32, ptr %46, align 1, !tbaa !14
  store i32 %47, ptr %7, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #8
  %48 = getelementptr inbounds %struct.BmpInfoHeader, ptr %4, i32 0, i32 4
  %49 = load i16, ptr %48, align 1, !tbaa !15
  %50 = zext i16 %49 to i32
  store i32 %50, ptr %8, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #8
  %51 = load i32, ptr %6, align 4, !tbaa !9
  %52 = load i32, ptr %8, align 4, !tbaa !9
  %53 = mul nsw i32 %51, %52
  %54 = sdiv i32 %53, 8
  %55 = add nsw i32 %54, 3
  %56 = sdiv i32 %55, 4
  %57 = mul nsw i32 %56, 4
  store i32 %57, ptr %9, align 4, !tbaa !9
  %58 = load i32, ptr %8, align 4, !tbaa !9
  %59 = icmp eq i32 %58, 8
  br i1 %59, label %60, label %65

60:                                               ; preds = %39
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #8
  %61 = call noalias ptr @malloc(i64 noundef 4096) #9
  store ptr %61, ptr %10, align 8, !tbaa !5
  %62 = load ptr, ptr %10, align 8, !tbaa !5
  %63 = load ptr, ptr %3, align 8, !tbaa !5
  %64 = call i64 @fread(ptr noundef %62, i64 noundef 4, i64 noundef 256, ptr noundef %63)
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #8
  br label %65

65:                                               ; preds = %60, %39
  call void @llvm.lifetime.start.p0(i64 8, ptr %11) #8
  %66 = load i32, ptr %9, align 4, !tbaa !9
  %67 = sext i32 %66 to i64
  %68 = mul i64 1, %67
  %69 = load i32, ptr %7, align 4, !tbaa !9
  %70 = sext i32 %69 to i64
  %71 = mul i64 %68, %70
  %72 = call noalias ptr @malloc(i64 noundef %71) #9
  store ptr %72, ptr %11, align 8, !tbaa !5
  %73 = load ptr, ptr %11, align 8, !tbaa !5
  %74 = load i32, ptr %9, align 4, !tbaa !9
  %75 = load i32, ptr %7, align 4, !tbaa !9
  %76 = mul nsw i32 %74, %75
  %77 = sext i32 %76 to i64
  %78 = load ptr, ptr %3, align 8, !tbaa !5
  %79 = call i64 @fread(ptr noundef %73, i64 noundef 1, i64 noundef %77, ptr noundef %78)
  %80 = load ptr, ptr %3, align 8, !tbaa !5
  %81 = call i32 @fclose(ptr noundef %80)
  call void @llvm.lifetime.start.p0(i64 4, ptr %12) #8
  store i32 0, ptr %12, align 4, !tbaa !9
  br label %82

82:                                               ; preds = %170, %65
  %83 = load i32, ptr %12, align 4, !tbaa !9
  %84 = load i32, ptr %7, align 4, !tbaa !9
  %85 = sdiv i32 %84, 2
  %86 = icmp slt i32 %83, %85
  br i1 %86, label %88, label %87

87:                                               ; preds = %82
  store i32 2, ptr %13, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %12) #8
  br label %173

88:                                               ; preds = %82
  call void @llvm.lifetime.start.p0(i64 4, ptr %14) #8
  store i32 0, ptr %14, align 4, !tbaa !9
  br label %89

89:                                               ; preds = %166, %88
  %90 = load i32, ptr %14, align 4, !tbaa !9
  %91 = load i32, ptr %6, align 4, !tbaa !9
  %92 = icmp slt i32 %90, %91
  br i1 %92, label %94, label %93

93:                                               ; preds = %89
  store i32 5, ptr %13, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %14) #8
  br label %169

94:                                               ; preds = %89
  call void @llvm.lifetime.start.p0(i64 4, ptr %15) #8
  store i32 0, ptr %15, align 4, !tbaa !9
  br label %95

95:                                               ; preds = %162, %94
  %96 = load i32, ptr %15, align 4, !tbaa !9
  %97 = load i32, ptr %5, align 4, !tbaa !9
  %98 = icmp slt i32 %96, %97
  br i1 %98, label %100, label %99

99:                                               ; preds = %95
  store i32 8, ptr %13, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %15) #8
  br label %165

100:                                              ; preds = %95
  call void @llvm.lifetime.start.p0(i64 4, ptr %16) #8
  %101 = load ptr, ptr %11, align 8, !tbaa !5
  %102 = load i32, ptr %12, align 4, !tbaa !9
  %103 = load i32, ptr %9, align 4, !tbaa !9
  %104 = mul nsw i32 %102, %103
  %105 = load i32, ptr %14, align 4, !tbaa !9
  %106 = load i32, ptr %5, align 4, !tbaa !9
  %107 = mul nsw i32 %105, %106
  %108 = add nsw i32 %104, %107
  %109 = load i32, ptr %15, align 4, !tbaa !9
  %110 = add nsw i32 %108, %109
  %111 = sext i32 %110 to i64
  %112 = getelementptr inbounds i8, ptr %101, i64 %111
  %113 = load i8, ptr %112, align 1, !tbaa !16
  %114 = zext i8 %113 to i32
  store i32 %114, ptr %16, align 4, !tbaa !9
  %115 = load ptr, ptr %11, align 8, !tbaa !5
  %116 = load i32, ptr %7, align 4, !tbaa !9
  %117 = load i32, ptr %12, align 4, !tbaa !9
  %118 = sub nsw i32 %116, %117
  %119 = sub nsw i32 %118, 1
  %120 = load i32, ptr %9, align 4, !tbaa !9
  %121 = mul nsw i32 %119, %120
  %122 = load i32, ptr %14, align 4, !tbaa !9
  %123 = load i32, ptr %5, align 4, !tbaa !9
  %124 = mul nsw i32 %122, %123
  %125 = add nsw i32 %121, %124
  %126 = add nsw i32 %125, 2
  %127 = load i32, ptr %15, align 4, !tbaa !9
  %128 = sub nsw i32 %126, %127
  %129 = sext i32 %128 to i64
  %130 = getelementptr inbounds i8, ptr %115, i64 %129
  %131 = load i8, ptr %130, align 1, !tbaa !16
  %132 = load ptr, ptr %11, align 8, !tbaa !5
  %133 = load i32, ptr %12, align 4, !tbaa !9
  %134 = load i32, ptr %9, align 4, !tbaa !9
  %135 = mul nsw i32 %133, %134
  %136 = load i32, ptr %14, align 4, !tbaa !9
  %137 = load i32, ptr %5, align 4, !tbaa !9
  %138 = mul nsw i32 %136, %137
  %139 = add nsw i32 %135, %138
  %140 = load i32, ptr %15, align 4, !tbaa !9
  %141 = add nsw i32 %139, %140
  %142 = sext i32 %141 to i64
  %143 = getelementptr inbounds i8, ptr %132, i64 %142
  store i8 %131, ptr %143, align 1, !tbaa !16
  %144 = load i32, ptr %16, align 4, !tbaa !9
  %145 = trunc i32 %144 to i8
  %146 = load ptr, ptr %11, align 8, !tbaa !5
  %147 = load i32, ptr %7, align 4, !tbaa !9
  %148 = load i32, ptr %12, align 4, !tbaa !9
  %149 = sub nsw i32 %147, %148
  %150 = sub nsw i32 %149, 1
  %151 = load i32, ptr %9, align 4, !tbaa !9
  %152 = mul nsw i32 %150, %151
  %153 = load i32, ptr %14, align 4, !tbaa !9
  %154 = load i32, ptr %5, align 4, !tbaa !9
  %155 = mul nsw i32 %153, %154
  %156 = add nsw i32 %152, %155
  %157 = add nsw i32 %156, 2
  %158 = load i32, ptr %15, align 4, !tbaa !9
  %159 = sub nsw i32 %157, %158
  %160 = sext i32 %159 to i64
  %161 = getelementptr inbounds i8, ptr %146, i64 %160
  store i8 %145, ptr %161, align 1, !tbaa !16
  call void @llvm.lifetime.end.p0(i64 4, ptr %16) #8
  br label %162

162:                                              ; preds = %100
  %163 = load i32, ptr %15, align 4, !tbaa !9
  %164 = add nsw i32 %163, 1
  store i32 %164, ptr %15, align 4, !tbaa !9
  br label %95, !llvm.loop !17

165:                                              ; preds = %99
  br label %166

166:                                              ; preds = %165
  %167 = load i32, ptr %14, align 4, !tbaa !9
  %168 = add nsw i32 %167, 1
  store i32 %168, ptr %14, align 4, !tbaa !9
  br label %89, !llvm.loop !19

169:                                              ; preds = %93
  br label %170

170:                                              ; preds = %169
  %171 = load i32, ptr %12, align 4, !tbaa !9
  %172 = add nsw i32 %171, 1
  store i32 %172, ptr %12, align 4, !tbaa !9
  br label %82, !llvm.loop !20

173:                                              ; preds = %87
  call void @llvm.lifetime.start.p0(i64 8, ptr %17) #8
  %174 = load i32, ptr %7, align 4, !tbaa !9
  %175 = load i32, ptr %6, align 4, !tbaa !9
  %176 = call ptr @create_simple_mat(i32 noundef %174, i32 noundef %175, i32 noundef 1, i32 noundef 3)
  store ptr %176, ptr %17, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %18) #8
  %177 = load ptr, ptr %17, align 8, !tbaa !5
  %178 = getelementptr inbounds %struct.SIMPLE_MAT, ptr %177, i32 0, i32 5
  %179 = load ptr, ptr %178, align 8, !tbaa !21
  store ptr %179, ptr %18, align 8, !tbaa !5
  %180 = load i32, ptr %9, align 4, !tbaa !9
  %181 = load i32, ptr %6, align 4, !tbaa !9
  %182 = load i32, ptr %8, align 4, !tbaa !9
  %183 = mul nsw i32 %181, %182
  %184 = sdiv i32 %183, 8
  %185 = icmp eq i32 %180, %184
  br i1 %185, label %186, label %193

186:                                              ; preds = %173
  %187 = load ptr, ptr %18, align 8, !tbaa !5
  %188 = load ptr, ptr %11, align 8, !tbaa !5
  %189 = load i32, ptr %9, align 4, !tbaa !9
  %190 = load i32, ptr %7, align 4, !tbaa !9
  %191 = mul nsw i32 %189, %190
  %192 = sext i32 %191 to i64
  call void @llvm.memcpy.p0.p0.i64(ptr align 1 %187, ptr align 1 %188, i64 %192, i1 false)
  br label %224

193:                                              ; preds = %173
  call void @llvm.lifetime.start.p0(i64 4, ptr %19) #8
  store i32 0, ptr %19, align 4, !tbaa !9
  br label %194

194:                                              ; preds = %220, %193
  %195 = load i32, ptr %19, align 4, !tbaa !9
  %196 = load i32, ptr %7, align 4, !tbaa !9
  %197 = icmp slt i32 %195, %196
  br i1 %197, label %199, label %198

198:                                              ; preds = %194
  store i32 11, ptr %13, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %19) #8
  br label %223

199:                                              ; preds = %194
  call void @llvm.lifetime.start.p0(i64 8, ptr %20) #8
  %200 = load ptr, ptr %18, align 8, !tbaa !5
  %201 = load i32, ptr %19, align 4, !tbaa !9
  %202 = load i32, ptr %6, align 4, !tbaa !9
  %203 = mul nsw i32 %201, %202
  %204 = load i32, ptr %5, align 4, !tbaa !9
  %205 = mul nsw i32 %203, %204
  %206 = sext i32 %205 to i64
  %207 = getelementptr inbounds i8, ptr %200, i64 %206
  store ptr %207, ptr %20, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %21) #8
  %208 = load ptr, ptr %11, align 8, !tbaa !5
  %209 = load i32, ptr %19, align 4, !tbaa !9
  %210 = load i32, ptr %9, align 4, !tbaa !9
  %211 = mul nsw i32 %209, %210
  %212 = sext i32 %211 to i64
  %213 = getelementptr inbounds i8, ptr %208, i64 %212
  store ptr %213, ptr %21, align 8, !tbaa !5
  %214 = load ptr, ptr %20, align 8, !tbaa !5
  %215 = load ptr, ptr %21, align 8, !tbaa !5
  %216 = load i32, ptr %6, align 4, !tbaa !9
  %217 = load i32, ptr %5, align 4, !tbaa !9
  %218 = mul nsw i32 %216, %217
  %219 = sext i32 %218 to i64
  call void @llvm.memcpy.p0.p0.i64(ptr align 1 %214, ptr align 1 %215, i64 %219, i1 false)
  call void @llvm.lifetime.end.p0(i64 8, ptr %21) #8
  call void @llvm.lifetime.end.p0(i64 8, ptr %20) #8
  br label %220

220:                                              ; preds = %199
  %221 = load i32, ptr %19, align 4, !tbaa !9
  %222 = add nsw i32 %221, 1
  store i32 %222, ptr %19, align 4, !tbaa !9
  br label %194, !llvm.loop !23

223:                                              ; preds = %198
  br label %224

224:                                              ; preds = %223, %186
  %225 = load ptr, ptr %11, align 8, !tbaa !5
  call void @free(ptr noundef %225) #8
  %226 = load ptr, ptr %17, align 8, !tbaa !5
  store i32 1, ptr %13, align 4
  call void @llvm.lifetime.end.p0(i64 8, ptr %18) #8
  call void @llvm.lifetime.end.p0(i64 8, ptr %17) #8
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #8
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #8
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #8
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #8
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #8
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #8
  call void @llvm.lifetime.end.p0(i64 40, ptr %4) #8
  call void @llvm.lifetime.end.p0(i64 8, ptr %3) #8
  ret ptr %226
}

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

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

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

!llvm.module.flags = !{!0, !1, !2, !3}
!llvm.ident = !{!4}

!0 = !{i32 1, !"wchar_size", i32 4}
!1 = !{i32 8, !"PIC Level", i32 2}
!2 = !{i32 7, !"PIE Level", i32 2}
!3 = !{i32 7, !"uwtable", i32 2}
!4 = !{!"clang version 19.1.0 (git@github.com:llvm/llvm-project.git a4bf6cd7cfb1a1421ba92bca9d017b49936c55e4)"}
!5 = !{!6, !6, i64 0}
!6 = !{!"any pointer", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"int", !7, i64 0}
!11 = !{!12, !10, i64 4}
!12 = !{!"BmpInfoHeader", !10, i64 0, !10, i64 4, !10, i64 8, !13, i64 12, !13, i64 14, !10, i64 16, !10, i64 20, !10, i64 24, !10, i64 28, !10, i64 32, !10, i64 36}
!13 = !{!"short", !7, i64 0}
!14 = !{!12, !10, i64 8}
!15 = !{!12, !13, i64 14}
!16 = !{!7, !7, i64 0}
!17 = distinct !{!17, !18}
!18 = !{!"llvm.loop.mustprogress"}
!19 = distinct !{!19, !18}
!20 = distinct !{!20, !18}
!21 = !{!22, !6, i64 24}
!22 = !{!"", !10, i64 0, !10, i64 4, !10, i64 8, !10, i64 12, !10, i64 16, !6, i64 24}
!23 = distinct !{!23, !18}


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

@.str = external hidden unnamed_addr constant [8 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [2 x i8], align 1
@.str.7 = external hidden unnamed_addr constant [35 x i8], align 1
@.str.8 = external hidden unnamed_addr constant [3 x i8], align 1
@.str.9 = external hidden unnamed_addr constant [20 x i8], align 1

; Function Attrs: nounwind uwtable
declare dso_local ptr @create_simple_mat(i32 noundef, i32 noundef, i32 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: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #1

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

; Function Attrs: noreturn nounwind
declare void @exit(i32 noundef) local_unnamed_addr #3

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

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

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

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

; Function Attrs: mustprogress 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: nounwind uwtable
define dso_local ptr @smread_bmp(ptr noundef readonly %0) local_unnamed_addr #0 {
  %2 = alloca %struct.BmpInfoHeader, align 1
  %.not = icmp eq ptr %0, null
  br i1 %.not, label %3, label %7

3:                                                ; preds = %1
  %4 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str)
  %5 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.7)
  %6 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.2)
  tail call void @exit(i32 noundef 1) #7
  unreachable

7:                                                ; preds = %1
  %8 = tail call noalias ptr @fopen(ptr noundef nonnull %0, ptr noundef nonnull @.str.8)
  %.not84 = icmp eq ptr %8, null
  br i1 %.not84, label %9, label %13

9:                                                ; preds = %7
  %10 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str)
  %11 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.9)
  %12 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.2)
  tail call void @exit(i32 noundef 1) #7
  unreachable

13:                                               ; preds = %7
  %14 = tail call i32 @fseek(ptr noundef nonnull %8, i64 noundef 14, i32 noundef 0)
  call void @llvm.lifetime.start.p0(i64 40, ptr nonnull %2) #8
  %15 = call i64 @fread(ptr noundef nonnull %2, i64 noundef 40, i64 noundef 1, ptr noundef nonnull %8)
  %16 = getelementptr inbounds i8, ptr %2, i64 4
  %17 = load i32, ptr %16, align 1, !tbaa !5
  %18 = getelementptr inbounds i8, ptr %2, i64 8
  %19 = load i32, ptr %18, align 1, !tbaa !11
  %20 = getelementptr inbounds i8, ptr %2, i64 14
  %21 = load i16, ptr %20, align 1, !tbaa !12
  %22 = zext i16 %21 to i32
  %23 = mul nsw i32 %17, %22
  %24 = sdiv i32 %23, 8
  %25 = add nsw i32 %24, 3
  %26 = sdiv i32 %25, 4
  %27 = shl nsw i32 %26, 2
  %28 = icmp eq i16 %21, 8
  br i1 %28, label %29, label %32

29:                                               ; preds = %13
  %30 = tail call noalias dereferenceable_or_null(4096) ptr @malloc(i64 noundef 4096) #9
  %31 = tail call i64 @fread(ptr noundef %30, i64 noundef 4, i64 noundef 256, ptr noundef nonnull %8)
  br label %32

32:                                               ; preds = %29, %13
  %33 = sext i32 %27 to i64
  %34 = sext i32 %19 to i64
  %35 = mul nsw i64 %33, %34
  %36 = tail call noalias ptr @malloc(i64 noundef %35) #9
  %37 = mul nsw i32 %27, %19
  %38 = sext i32 %37 to i64
  %39 = tail call i64 @fread(ptr noundef %36, i64 noundef 1, i64 noundef %38, ptr noundef nonnull %8)
  %40 = tail call i32 @fclose(ptr noundef nonnull %8)
  %41 = icmp sgt i32 %19, 1
  %42 = icmp sgt i32 %17, 0
  %or.cond = select i1 %41, i1 %42, i1 false
  br i1 %or.cond, label %.preheader86.us.preheader, label %._crit_edge90

.preheader86.us.preheader:                        ; preds = %32
  %43 = lshr i32 %19, 1
  %wide.trip.count98 = zext nneg i32 %43 to i64
  %wide.trip.count = zext nneg i32 %17 to i64
  %invariant.gep = getelementptr i8, ptr %36, i64 1
  %invariant.gep105 = getelementptr i8, ptr %36, i64 2
  br label %.preheader86.us

.preheader86.us:                                  ; preds = %.preheader86.us.preheader, %._crit_edge.us
  %indvars.iv95 = phi i64 [ 0, %.preheader86.us.preheader ], [ %indvars.iv.next96, %._crit_edge.us ]
  %44 = mul nuw nsw i64 %indvars.iv95, %33
  %45 = trunc i64 %indvars.iv95 to i32
  %46 = xor i32 %45, -1
  %47 = add i32 %19, %46
  %48 = mul i32 %47, %27
  %49 = or disjoint i32 %48, 2
  br label %.preheader85.us

.preheader85.us:                                  ; preds = %.preheader86.us, %.preheader85.us
  %indvars.iv = phi i64 [ 0, %.preheader86.us ], [ %indvars.iv.next, %.preheader85.us ]
  %50 = mul nuw nsw i64 %indvars.iv, 3
  %51 = add nsw i64 %50, %44
  %52 = trunc nuw nsw i64 %50 to i32
  %53 = add i32 %49, %52
  %54 = getelementptr inbounds i8, ptr %36, i64 %51
  %55 = load i8, ptr %54, align 1, !tbaa !13
  %56 = sext i32 %53 to i64
  %57 = getelementptr inbounds i8, ptr %36, i64 %56
  %58 = load i8, ptr %57, align 1, !tbaa !13
  store i8 %58, ptr %54, align 1, !tbaa !13
  store i8 %55, ptr %57, align 1, !tbaa !13
  %gep = getelementptr i8, ptr %invariant.gep, i64 %51
  %59 = load i8, ptr %gep, align 1, !tbaa !13
  %60 = add i32 %53, -1
  %61 = sext i32 %60 to i64
  %62 = getelementptr inbounds i8, ptr %36, i64 %61
  %63 = load i8, ptr %62, align 1, !tbaa !13
  store i8 %63, ptr %gep, align 1, !tbaa !13
  store i8 %59, ptr %62, align 1, !tbaa !13
  %gep106 = getelementptr i8, ptr %invariant.gep105, i64 %51
  %64 = load i8, ptr %gep106, align 1, !tbaa !13
  %65 = add i32 %53, -2
  %66 = sext i32 %65 to i64
  %67 = getelementptr inbounds i8, ptr %36, i64 %66
  %68 = load i8, ptr %67, align 1, !tbaa !13
  store i8 %68, ptr %gep106, align 1, !tbaa !13
  store i8 %64, ptr %67, align 1, !tbaa !13
  %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 %._crit_edge.us, label %.preheader85.us, !llvm.loop !14

._crit_edge.us:                                   ; preds = %.preheader85.us
  %indvars.iv.next96 = add nuw nsw i64 %indvars.iv95, 1
  %exitcond99.not = icmp eq i64 %indvars.iv.next96, %wide.trip.count98
  br i1 %exitcond99.not, label %._crit_edge90, label %.preheader86.us, !llvm.loop !16

._crit_edge90:                                    ; preds = %._crit_edge.us, %32
  %69 = tail call ptr @create_simple_mat(i32 noundef %19, i32 noundef %17, i32 noundef 1, i32 noundef 3)
  %70 = getelementptr inbounds i8, ptr %69, i64 24
  %71 = load ptr, ptr %70, align 8, !tbaa !17
  %72 = icmp eq i32 %27, %24
  br i1 %72, label %77, label %.preheader

.preheader:                                       ; preds = %._crit_edge90
  %73 = icmp sgt i32 %19, 0
  br i1 %73, label %.lr.ph, label %.loopexit

.lr.ph:                                           ; preds = %.preheader
  %74 = mul i32 %17, 3
  %75 = sext i32 %74 to i64
  %wide.trip.count103 = zext nneg i32 %19 to i64
  %xtraiter = and i64 %wide.trip.count103, 1
  %76 = icmp eq i32 %19, 1
  br i1 %76, label %.loopexit.loopexit.unr-lcssa, label %.lr.ph.new

.lr.ph.new:                                       ; preds = %.lr.ph
  %unroll_iter = and i64 %wide.trip.count103, 2147483646
  br label %78

77:                                               ; preds = %._crit_edge90
  tail call void @llvm.memcpy.p0.p0.i64(ptr align 1 %71, ptr align 1 %36, i64 %38, i1 false)
  br label %.loopexit

78:                                               ; preds = %78, %.lr.ph.new
  %indvars.iv100 = phi i64 [ 0, %.lr.ph.new ], [ %indvars.iv.next101.1, %78 ]
  %niter = phi i64 [ 0, %.lr.ph.new ], [ %niter.next.1, %78 ]
  %79 = trunc nuw nsw i64 %indvars.iv100 to i32
  %80 = mul i32 %74, %79
  %81 = sext i32 %80 to i64
  %82 = getelementptr inbounds i8, ptr %71, i64 %81
  %83 = mul nsw i64 %indvars.iv100, %33
  %84 = getelementptr inbounds i8, ptr %36, i64 %83
  tail call void @llvm.memcpy.p0.p0.i64(ptr align 1 %82, ptr align 1 %84, i64 %75, i1 false)
  %indvars.iv.next101 = or disjoint i64 %indvars.iv100, 1
  %85 = trunc nuw nsw i64 %indvars.iv.next101 to i32
  %86 = mul i32 %74, %85
  %87 = sext i32 %86 to i64
  %88 = getelementptr inbounds i8, ptr %71, i64 %87
  %89 = mul nsw i64 %indvars.iv.next101, %33
  %90 = getelementptr inbounds i8, ptr %36, i64 %89
  tail call void @llvm.memcpy.p0.p0.i64(ptr align 1 %88, ptr align 1 %90, i64 %75, i1 false)
  %indvars.iv.next101.1 = add nuw nsw i64 %indvars.iv100, 2
  %niter.next.1 = add i64 %niter, 2
  %niter.ncmp.1 = icmp eq i64 %niter.next.1, %unroll_iter
  br i1 %niter.ncmp.1, label %.loopexit.loopexit.unr-lcssa, label %78, !llvm.loop !20

.loopexit.loopexit.unr-lcssa:                     ; preds = %78, %.lr.ph
  %indvars.iv100.unr = phi i64 [ 0, %.lr.ph ], [ %indvars.iv.next101.1, %78 ]
  %lcmp.mod.not = icmp eq i64 %xtraiter, 0
  br i1 %lcmp.mod.not, label %.loopexit, label %.loopexit.loopexit.epilog-lcssa

.loopexit.loopexit.epilog-lcssa:                  ; preds = %.loopexit.loopexit.unr-lcssa
  %91 = trunc nuw nsw i64 %indvars.iv100.unr to i32
  %92 = mul i32 %74, %91
  %93 = sext i32 %92 to i64
  %94 = getelementptr inbounds i8, ptr %71, i64 %93
  %95 = mul nsw i64 %indvars.iv100.unr, %33
  %96 = getelementptr inbounds i8, ptr %36, i64 %95
  tail call void @llvm.memcpy.p0.p0.i64(ptr align 1 %94, ptr align 1 %96, i64 %75, i1 false)
  br label %.loopexit

.loopexit:                                        ; preds = %.loopexit.loopexit.epilog-lcssa, %.loopexit.loopexit.unr-lcssa, %.preheader, %77
  tail call void @free(ptr noundef %36) #8
  call void @llvm.lifetime.end.p0(i64 40, ptr nonnull %2) #8
  ret ptr %69
}

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

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

attributes #0 = { nounwind uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #1 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { 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 #3 = { noreturn nounwind "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #4 = { mustprogress nofree nounwind willreturn allockind("alloc,uninitialized") allocsize(0) memory(inaccessiblemem: readwrite) "alloc-family"="malloc" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #5 = { mustprogress nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #6 = { mustprogress nounwind willreturn allockind("free") memory(argmem: readwrite, inaccessiblemem: readwrite) "alloc-family"="malloc" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #7 = { noreturn nounwind }
attributes #8 = { nounwind }
attributes #9 = { nounwind allocsize(0) }

!llvm.module.flags = !{!0, !1, !2, !3}
!llvm.ident = !{!4}

!0 = !{i32 1, !"wchar_size", i32 4}
!1 = !{i32 8, !"PIC Level", i32 2}
!2 = !{i32 7, !"PIE Level", i32 2}
!3 = !{i32 7, !"uwtable", i32 2}
!4 = !{!"clang version 19.1.0 (git@github.com:llvm/llvm-project.git a4bf6cd7cfb1a1421ba92bca9d017b49936c55e4)"}
!5 = !{!6, !7, i64 4}
!6 = !{!"BmpInfoHeader", !7, i64 0, !7, i64 4, !7, i64 8, !10, i64 12, !10, i64 14, !7, i64 16, !7, i64 20, !7, i64 24, !7, i64 28, !7, i64 32, !7, i64 36}
!7 = !{!"int", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"short", !8, i64 0}
!11 = !{!6, !7, i64 8}
!12 = !{!6, !10, i64 14}
!13 = !{!8, !8, i64 0}
!14 = distinct !{!14, !15}
!15 = !{!"llvm.loop.mustprogress"}
!16 = distinct !{!16, !15}
!17 = !{!18, !19, i64 24}
!18 = !{!"", !7, i64 0, !7, i64 4, !7, i64 8, !7, i64 12, !7, i64 16, !19, i64 24}
!19 = !{!"any pointer", !8, i64 0}
!20 = distinct !{!20, !15}


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