; LLVM IR from Wilson-ZheLin/Introduction-to-Digital-Image-Processing :: 1. Average Filter and Median Filter/src/main.ll (Z12ReadPNMImagePc)

; 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.Image = type { i32, i32, i32, ptr, [15 x [100 x i8]], i32 }

@.str.6 = external hidden unnamed_addr constant [3 x i8], align 1
@.str.7 = external hidden unnamed_addr constant [16 x i8], align 1
@.str.8 = external hidden unnamed_addr constant [15 x i8], align 1
@.str.9 = external hidden unnamed_addr constant [5 x i8], align 1
@.str.10 = external hidden unnamed_addr constant [48 x i8], align 1
@.str.11 = external hidden unnamed_addr constant [45 x i8], align 1
@.str.12 = external hidden unnamed_addr constant [8 x i8], align 1
@.str.13 = external hidden unnamed_addr constant [37 x i8], align 1
@.str.14 = external hidden unnamed_addr constant [33 x i8], align 1
@.str.15 = external hidden unnamed_addr constant [18 x i8], align 1
@.str.16 = external hidden unnamed_addr constant [24 x i8], align 1

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

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

; Function Attrs: mustprogress uwtable
define dso_local noundef ptr @_Z12ReadPNMImagePc(ptr noundef %0) #1 {
  %2 = alloca ptr, align 8
  %3 = alloca i8, align 1
  %4 = alloca i32, align 4
  %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
  store ptr %0, ptr %2, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 1, ptr %3) #6
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #6
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #6
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #6
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #6
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #6
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #6
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #6
  call void @llvm.lifetime.start.p0(i64 8, ptr %11) #6
  call void @llvm.lifetime.start.p0(i64 4, ptr %12) #6
  store i32 0, ptr %12, align 4, !tbaa !9
  %13 = call noalias ptr @malloc(i64 noundef 1528) #7
  store ptr %13, ptr %11, align 8, !tbaa !5
  %14 = load ptr, ptr %2, align 8, !tbaa !5
  %15 = call noalias ptr @fopen(ptr noundef %14, ptr noundef @.str.6)
  store ptr %15, ptr %10, align 8, !tbaa !5
  %16 = icmp eq ptr %15, null
  br i1 %16, label %17, label %20

17:                                               ; preds = %1
  %18 = load ptr, ptr %2, align 8, !tbaa !5
  %19 = call i32 (ptr, ...) @printf(ptr noundef @.str.7, ptr noundef %18)
  call void @exit(i32 noundef 0) #8
  unreachable

20:                                               ; preds = %1
  %21 = load ptr, ptr %2, align 8, !tbaa !5
  %22 = call i32 (ptr, ...) @printf(ptr noundef @.str.8, ptr noundef %21)
  %23 = load ptr, ptr %10, align 8, !tbaa !5
  %24 = call i32 (ptr, ptr, ...) @__isoc99_fscanf(ptr noundef %23, ptr noundef @.str.9, ptr noundef %3)
  %25 = icmp ne i32 %24, 1
  br i1 %25, label %26, label %28

26:                                               ; preds = %20
  %27 = call i32 (ptr, ...) @printf(ptr noundef @.str.10)
  call void @exit(i32 noundef 0) #8
  unreachable

28:                                               ; preds = %20
  %29 = load i8, ptr %3, align 1, !tbaa !11
  %30 = sext i8 %29 to i32
  %31 = icmp ne i32 %30, 54
  br i1 %31, label %32, label %38

32:                                               ; preds = %28
  %33 = load i8, ptr %3, align 1, !tbaa !11
  %34 = sext i8 %33 to i32
  %35 = icmp ne i32 %34, 53
  br i1 %35, label %36, label %38

36:                                               ; preds = %32
  %37 = call i32 (ptr, ...) @printf(ptr noundef @.str.10)
  call void @exit(i32 noundef 0) #8
  unreachable

38:                                               ; preds = %32, %28
  %39 = load i8, ptr %3, align 1, !tbaa !11
  %40 = sext i8 %39 to i32
  %41 = icmp eq i32 %40, 53
  br i1 %41, label %42, label %45

42:                                               ; preds = %38
  %43 = load ptr, ptr %11, align 8, !tbaa !5
  %44 = getelementptr inbounds %struct.Image, ptr %43, i32 0, i32 2
  store i32 1, ptr %44, align 8, !tbaa !12
  br label %53

45:                                               ; preds = %38
  %46 = load i8, ptr %3, align 1, !tbaa !11
  %47 = sext i8 %46 to i32
  %48 = icmp eq i32 %47, 54
  br i1 %48, label %49, label %52

49:                                               ; preds = %45
  %50 = load ptr, ptr %11, align 8, !tbaa !5
  %51 = getelementptr inbounds %struct.Image, ptr %50, i32 0, i32 2
  store i32 2, ptr %51, align 8, !tbaa !12
  br label %52

52:                                               ; preds = %49, %45
  br label %53

53:                                               ; preds = %52, %42
  %54 = load ptr, ptr %10, align 8, !tbaa !5
  %55 = call i32 @getc(ptr noundef %54)
  %56 = trunc i32 %55 to i8
  store i8 %56, ptr %3, align 1, !tbaa !11
  store i32 0, ptr %9, align 4, !tbaa !9
  br label %57

57:                                               ; preds = %92, %53
  %58 = load i8, ptr %3, align 1, !tbaa !11
  %59 = sext i8 %58 to i32
  %60 = icmp eq i32 %59, 35
  br i1 %60, label %61, label %107

61:                                               ; preds = %57
  %62 = load i8, ptr %3, align 1, !tbaa !11
  %63 = load ptr, ptr %11, align 8, !tbaa !5
  %64 = getelementptr inbounds %struct.Image, ptr %63, i32 0, i32 4
  %65 = load i32, ptr %12, align 4, !tbaa !9
  %66 = sext i32 %65 to i64
  %67 = getelementptr inbounds [15 x [100 x i8]], ptr %64, i64 0, i64 %66
  %68 = load i32, ptr %9, align 4, !tbaa !9
  %69 = sext i32 %68 to i64
  %70 = getelementptr inbounds [100 x i8], ptr %67, i64 0, i64 %69
  store i8 %62, ptr %70, align 1, !tbaa !11
  %71 = load i32, ptr %9, align 4, !tbaa !9
  %72 = add nsw i32 %71, 1
  store i32 %72, ptr %9, align 4, !tbaa !9
  br label %73

73:                                               ; preds = %88, %61
  %74 = load ptr, ptr %10, align 8, !tbaa !5
  %75 = call i32 @getc(ptr noundef %74)
  %76 = trunc i32 %75 to i8
  store i8 %76, ptr %3, align 1, !tbaa !11
  %77 = load i8, ptr %3, align 1, !tbaa !11
  %78 = load ptr, ptr %11, align 8, !tbaa !5
  %79 = getelementptr inbounds %struct.Image, ptr %78, i32 0, i32 4
  %80 = load i32, ptr %12, align 4, !tbaa !9
  %81 = sext i32 %80 to i64
  %82 = getelementptr inbounds [15 x [100 x i8]], ptr %79, i64 0, i64 %81
  %83 = load i32, ptr %9, align 4, !tbaa !9
  %84 = sext i32 %83 to i64
  %85 = getelementptr inbounds [100 x i8], ptr %82, i64 0, i64 %84
  store i8 %77, ptr %85, align 1, !tbaa !11
  %86 = load i32, ptr %9, align 4, !tbaa !9
  %87 = add nsw i32 %86, 1
  store i32 %87, ptr %9, align 4, !tbaa !9
  br label %88

88:                                               ; preds = %73
  %89 = load i8, ptr %3, align 1, !tbaa !11
  %90 = sext i8 %89 to i32
  %91 = icmp ne i32 %90, 10
  br i1 %91, label %73, label %92, !llvm.loop !14

92:                                               ; preds = %88
  %93 = load ptr, ptr %11, align 8, !tbaa !5
  %94 = getelementptr inbounds %struct.Image, ptr %93, i32 0, i32 4
  %95 = load i32, ptr %12, align 4, !tbaa !9
  %96 = sext i32 %95 to i64
  %97 = getelementptr inbounds [15 x [100 x i8]], ptr %94, i64 0, i64 %96
  %98 = load i32, ptr %9, align 4, !tbaa !9
  %99 = sub nsw i32 %98, 1
  %100 = sext i32 %99 to i64
  %101 = getelementptr inbounds [100 x i8], ptr %97, i64 0, i64 %100
  store i8 0, ptr %101, align 1, !tbaa !11
  store i32 0, ptr %9, align 4, !tbaa !9
  %102 = load i32, ptr %12, align 4, !tbaa !9
  %103 = add nsw i32 %102, 1
  store i32 %103, ptr %12, align 4, !tbaa !9
  %104 = load ptr, ptr %10, align 8, !tbaa !5
  %105 = call i32 @getc(ptr noundef %104)
  %106 = trunc i32 %105 to i8
  store i8 %106, ptr %3, align 1, !tbaa !11
  br label %57, !llvm.loop !16

107:                                              ; preds = %57
  %108 = load i8, ptr %3, align 1, !tbaa !11
  %109 = sext i8 %108 to i32
  %110 = call i32 @isdigit(i32 noundef %109) #9
  %111 = icmp ne i32 %110, 0
  br i1 %111, label %114, label %112

112:                                              ; preds = %107
  %113 = call i32 (ptr, ...) @printf(ptr noundef @.str.11)
  call void @exit(i32 noundef 0) #8
  unreachable

114:                                              ; preds = %107
  %115 = load i8, ptr %3, align 1, !tbaa !11
  %116 = sext i8 %115 to i32
  %117 = load ptr, ptr %10, align 8, !tbaa !5
  %118 = call i32 @ungetc(i32 noundef %116, ptr noundef %117)
  %119 = load ptr, ptr %10, align 8, !tbaa !5
  %120 = call i32 (ptr, ptr, ...) @__isoc99_fscanf(ptr noundef %119, ptr noundef @.str.12, ptr noundef %5, ptr noundef %6, ptr noundef %4)
  %121 = load ptr, ptr %11, align 8, !tbaa !5
  %122 = getelementptr inbounds %struct.Image, ptr %121, i32 0, i32 2
  %123 = load i32, ptr %122, align 8, !tbaa !12
  %124 = icmp eq i32 %123, 1
  br i1 %124, label %125, label %129

125:                                              ; preds = %114
  %126 = load i32, ptr %5, align 4, !tbaa !9
  %127 = load i32, ptr %6, align 4, !tbaa !9
  %128 = mul nsw i32 %126, %127
  store i32 %128, ptr %7, align 4, !tbaa !9
  br label %140

129:                                              ; preds = %114
  %130 = load ptr, ptr %11, align 8, !tbaa !5
  %131 = getelementptr inbounds %struct.Image, ptr %130, i32 0, i32 2
  %132 = load i32, ptr %131, align 8, !tbaa !12
  %133 = icmp eq i32 %132, 2
  br i1 %133, label %134, label %139

134:                                              ; preds = %129
  %135 = load i32, ptr %5, align 4, !tbaa !9
  %136 = load i32, ptr %6, align 4, !tbaa !9
  %137 = mul nsw i32 %135, %136
  %138 = mul nsw i32 %137, 3
  store i32 %138, ptr %7, align 4, !tbaa !9
  br label %139

139:                                              ; preds = %134, %129
  br label %140

140:                                              ; preds = %139, %125
  %141 = load i32, ptr %7, align 4, !tbaa !9
  %142 = sext i32 %141 to i64
  %143 = call noalias ptr @malloc(i64 noundef %142) #7
  %144 = load ptr, ptr %11, align 8, !tbaa !5
  %145 = getelementptr inbounds %struct.Image, ptr %144, i32 0, i32 3
  store ptr %143, ptr %145, align 8, !tbaa !17
  %146 = load i32, ptr %5, align 4, !tbaa !9
  %147 = load ptr, ptr %11, align 8, !tbaa !5
  %148 = getelementptr inbounds %struct.Image, ptr %147, i32 0, i32 0
  store i32 %146, ptr %148, align 8, !tbaa !18
  %149 = load i32, ptr %6, align 4, !tbaa !9
  %150 = load ptr, ptr %11, align 8, !tbaa !5
  %151 = getelementptr inbounds %struct.Image, ptr %150, i32 0, i32 1
  store i32 %149, ptr %151, align 4, !tbaa !19
  %152 = load i32, ptr %12, align 4, !tbaa !9
  %153 = load ptr, ptr %11, align 8, !tbaa !5
  %154 = getelementptr inbounds %struct.Image, ptr %153, i32 0, i32 5
  store i32 %152, ptr %154, align 4, !tbaa !20
  %155 = load ptr, ptr %11, align 8, !tbaa !5
  %156 = getelementptr inbounds %struct.Image, ptr %155, i32 0, i32 3
  %157 = load ptr, ptr %156, align 8, !tbaa !17
  %158 = icmp ne ptr %157, null
  br i1 %158, label %161, label %159

159:                                              ; preds = %140
  %160 = call i32 (ptr, ...) @printf(ptr noundef @.str.13)
  call void @exit(i32 noundef 0) #8
  unreachable

161:                                              ; preds = %140
  %162 = load ptr, ptr %11, align 8, !tbaa !5
  %163 = getelementptr inbounds %struct.Image, ptr %162, i32 0, i32 3
  %164 = load ptr, ptr %163, align 8, !tbaa !17
  %165 = load i32, ptr %7, align 4, !tbaa !9
  %166 = sext i32 %165 to i64
  %167 = load ptr, ptr %10, align 8, !tbaa !5
  %168 = call i64 @fread(ptr noundef %164, i64 noundef 1, i64 noundef %166, ptr noundef %167)
  %169 = trunc i64 %168 to i32
  store i32 %169, ptr %8, align 4, !tbaa !9
  %170 = load i32, ptr %8, align 4, !tbaa !9
  %171 = load i32, ptr %7, align 4, !tbaa !9
  %172 = icmp ne i32 %170, %171
  br i1 %172, label %173, label %175

173:                                              ; preds = %161
  %174 = call i32 (ptr, ...) @printf(ptr noundef @.str.14)
  call void @exit(i32 noundef 0) #8
  unreachable

175:                                              ; preds = %161
  %176 = load ptr, ptr %10, align 8, !tbaa !5
  %177 = call i32 @fclose(ptr noundef %176)
  %178 = load ptr, ptr %11, align 8, !tbaa !5
  %179 = getelementptr inbounds %struct.Image, ptr %178, i32 0, i32 2
  %180 = load i32, ptr %179, align 8, !tbaa !12
  %181 = icmp eq i32 %180, 1
  br i1 %181, label %182, label %184

182:                                              ; preds = %175
  %183 = call i32 (ptr, ...) @printf(ptr noundef @.str.15)
  br label %186

184:                                              ; preds = %175
  %185 = call i32 (ptr, ...) @printf(ptr noundef @.str.16)
  br label %186

186:                                              ; preds = %184, %182
  %187 = load ptr, ptr %11, align 8, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 4, ptr %12) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #6
  call void @llvm.lifetime.end.p0(i64 1, ptr %3) #6
  ret ptr %187
}

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

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

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

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

declare i32 @__isoc99_fscanf(ptr noundef, ptr noundef, ...) #3

declare i32 @getc(ptr noundef) #3

; Function Attrs: nounwind willreturn memory(read)
declare i32 @isdigit(i32 noundef) #5

declare i32 @ungetc(i32 noundef, ptr noundef) #3

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

declare i32 @fclose(ptr noundef) #3

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


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

@.str.6 = external hidden unnamed_addr constant [3 x i8], align 1
@.str.7 = external hidden unnamed_addr constant [16 x i8], align 1
@.str.8 = external hidden unnamed_addr constant [15 x i8], align 1
@.str.9 = external hidden unnamed_addr constant [5 x i8], align 1
@.str.10 = external hidden unnamed_addr constant [48 x i8], align 1
@.str.11 = external hidden unnamed_addr constant [45 x i8], align 1
@.str.12 = external hidden unnamed_addr constant [8 x i8], align 1
@.str.13 = external hidden unnamed_addr constant [37 x i8], align 1
@.str.14 = external hidden unnamed_addr constant [33 x i8], align 1
@.str.15 = external hidden unnamed_addr constant [18 x i8], align 1
@.str.16 = external hidden unnamed_addr constant [24 x i8], align 1

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

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

; Function Attrs: mustprogress uwtable
define dso_local noalias noundef ptr @_Z12ReadPNMImagePc(ptr noundef %0) local_unnamed_addr #1 {
  %2 = alloca i8, align 1
  %3 = alloca i32, align 4
  %4 = alloca i32, align 4
  %5 = alloca i32, align 4
  call void @llvm.lifetime.start.p0(i64 1, ptr nonnull %2) #6
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %3) #6
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %4) #6
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %5) #6
  %6 = tail call noalias dereferenceable_or_null(1528) ptr @malloc(i64 noundef 1528) #7
  %7 = tail call noalias ptr @fopen(ptr noundef %0, ptr noundef nonnull @.str.6)
  %8 = icmp eq ptr %7, null
  br i1 %8, label %9, label %11

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

11:                                               ; preds = %1
  %12 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.8, ptr noundef %0)
  %13 = call i32 (ptr, ptr, ...) @__isoc99_fscanf(ptr noundef nonnull %7, ptr noundef nonnull @.str.9, ptr noundef nonnull %2)
  %.not = icmp eq i32 %13, 1
  br i1 %.not, label %16, label %14

14:                                               ; preds = %11
  %15 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.10)
  call void @exit(i32 noundef 0) #8
  unreachable

16:                                               ; preds = %11
  %17 = load i8, ptr %2, align 1
  %18 = add i8 %17, -55
  %or.cond = icmp ult i8 %18, -2
  br i1 %or.cond, label %19, label %21

19:                                               ; preds = %16
  %20 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.10)
  call void @exit(i32 noundef 0) #8
  unreachable

21:                                               ; preds = %16
  %switch = icmp eq i8 %17, 53
  %spec.select = select i1 %switch, i32 1, i32 2
  %22 = getelementptr inbounds i8, ptr %6, i64 8
  store i32 %spec.select, ptr %22, align 8
  %23 = call i32 @getc(ptr noundef nonnull %7)
  %storemerge53 = trunc i32 %23 to i8
  store i8 %storemerge53, ptr %2, align 1, !tbaa !5
  %sext54 = shl i32 %23, 24
  %24 = icmp eq i32 %sext54, 587202560
  br i1 %24, label %.lr.ph, label %._crit_edge

.lr.ph:                                           ; preds = %21
  %25 = getelementptr inbounds i8, ptr %6, i64 24
  br label %26

26:                                               ; preds = %.lr.ph, %32
  %indvars.iv61 = phi i64 [ 0, %.lr.ph ], [ %indvars.iv.next62, %32 ]
  %storemerge56 = phi i8 [ %storemerge53, %.lr.ph ], [ %storemerge, %32 ]
  %27 = getelementptr inbounds [15 x [100 x i8]], ptr %25, i64 0, i64 %indvars.iv61
  store i8 %storemerge56, ptr %27, align 1, !tbaa !5
  br label %28

28:                                               ; preds = %28, %26
  %indvars.iv = phi i64 [ %indvars.iv.next, %28 ], [ 1, %26 ]
  %29 = call i32 @getc(ptr noundef nonnull %7)
  %30 = trunc i32 %29 to i8
  store i8 %30, ptr %2, align 1, !tbaa !5
  %31 = getelementptr inbounds [15 x [100 x i8]], ptr %25, i64 0, i64 %indvars.iv61, i64 %indvars.iv
  store i8 %30, ptr %31, align 1, !tbaa !5
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %sext50.mask = and i32 %29, 255
  %.not51 = icmp eq i32 %sext50.mask, 10
  br i1 %.not51, label %32, label %28, !llvm.loop !8

32:                                               ; preds = %28
  store i8 0, ptr %31, align 1, !tbaa !5
  %indvars.iv.next62 = add nuw nsw i64 %indvars.iv61, 1
  %33 = call i32 @getc(ptr noundef nonnull %7)
  %storemerge = trunc i32 %33 to i8
  store i8 %storemerge, ptr %2, align 1, !tbaa !5
  %sext = shl i32 %33, 24
  %34 = icmp eq i32 %sext, 587202560
  br i1 %34, label %26, label %._crit_edge.loopexit, !llvm.loop !10

._crit_edge.loopexit:                             ; preds = %32
  %35 = trunc nuw i64 %indvars.iv.next62 to i32
  br label %._crit_edge

._crit_edge:                                      ; preds = %._crit_edge.loopexit, %21
  %sext.lcssa = phi i32 [ %sext54, %21 ], [ %sext, %._crit_edge.loopexit ]
  %.0.lcssa = phi i32 [ 0, %21 ], [ %35, %._crit_edge.loopexit ]
  %36 = ashr exact i32 %sext.lcssa, 24
  %isdigittmp = add nsw i32 %36, -48
  %isdigit = icmp ult i32 %isdigittmp, 10
  br i1 %isdigit, label %39, label %37

37:                                               ; preds = %._crit_edge
  %38 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.11)
  call void @exit(i32 noundef 0) #8
  unreachable

39:                                               ; preds = %._crit_edge
  %40 = call i32 @ungetc(i32 noundef %36, ptr noundef nonnull %7)
  %41 = call i32 (ptr, ptr, ...) @__isoc99_fscanf(ptr noundef nonnull %7, ptr noundef nonnull @.str.12, ptr noundef nonnull %4, ptr noundef nonnull %5, ptr noundef nonnull %3)
  %42 = load i32, ptr %22, align 8, !tbaa !11
  %.pre = load i32, ptr %4, align 4, !tbaa !15
  %.pre64 = load i32, ptr %5, align 4, !tbaa !15
  switch i32 %42, label %._crit_edge63 [
    i32 1, label %43
    i32 2, label %45
  ]

43:                                               ; preds = %39
  %44 = mul nsw i32 %.pre64, %.pre
  br label %._crit_edge63

45:                                               ; preds = %39
  %46 = mul i32 %.pre, 3
  %47 = mul i32 %46, %.pre64
  br label %._crit_edge63

._crit_edge63:                                    ; preds = %39, %45, %43
  %.041 = phi i32 [ %44, %43 ], [ %47, %45 ], [ undef, %39 ]
  %48 = sext i32 %.041 to i64
  %49 = call noalias ptr @malloc(i64 noundef %48) #7
  %50 = getelementptr inbounds i8, ptr %6, i64 16
  store ptr %49, ptr %50, align 8, !tbaa !16
  store i32 %.pre, ptr %6, align 8, !tbaa !17
  %51 = getelementptr inbounds i8, ptr %6, i64 4
  store i32 %.pre64, ptr %51, align 4, !tbaa !18
  %52 = getelementptr inbounds i8, ptr %6, i64 1524
  store i32 %.0.lcssa, ptr %52, align 4, !tbaa !19
  %.not48 = icmp eq ptr %49, null
  br i1 %.not48, label %53, label %55

53:                                               ; preds = %._crit_edge63
  %54 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.13)
  call void @exit(i32 noundef 0) #8
  unreachable

55:                                               ; preds = %._crit_edge63
  %56 = call i64 @fread(ptr noundef nonnull %49, i64 noundef 1, i64 noundef %48, ptr noundef nonnull %7)
  %57 = trunc i64 %56 to i32
  %.not49 = icmp eq i32 %.041, %57
  br i1 %.not49, label %60, label %58

58:                                               ; preds = %55
  %59 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.14)
  call void @exit(i32 noundef 0) #8
  unreachable

60:                                               ; preds = %55
  %61 = call i32 @fclose(ptr noundef nonnull %7)
  %62 = icmp eq i32 %42, 1
  %.str.15..str.16 = select i1 %62, ptr @.str.15, ptr @.str.16
  %63 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) %.str.15..str.16)
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %5) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %4) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %3) #6
  call void @llvm.lifetime.end.p0(i64 1, ptr nonnull %2) #6
  ret ptr %6
}

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

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

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

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

declare i32 @__isoc99_fscanf(ptr noundef, ptr noundef, ...) local_unnamed_addr #5

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

; Function Attrs: nofree nounwind
declare noundef i32 @ungetc(i32 noundef, ptr nocapture noundef) local_unnamed_addr #3

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

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

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


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