; LLVM IR from tangjz/acm-icpc :: self_training/2016-06-18 (T)

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

@t = external dso_local global i32, align 4
@n = external dso_local global i32, align 4
@x = external dso_local global [1001 x i32], align 16
@y = external dso_local global [1001 x i32], align 16
@r = external dso_local global [1001 x i32], align 16
@fa = external dso_local global [1001 x i32], align 16
@dis = external dso_local global [1001 x i32], align 16
@vis = external dso_local global [1001 x i8], align 16
@.str = external hidden unnamed_addr constant [3 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [7 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [10 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [10 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [17 x i8], align 1
@.str.5 = external hidden unnamed_addr constant [16 x i8], align 1

; Function Attrs: mustprogress uwtable
declare dso_local noundef i32 @_Z4findi(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

; Function Attrs: mustprogress uwtable
declare dso_local void @_Z3dfsi(i32 noundef) #0

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef i64 @_Z3sqri(i32 noundef) #2

; Function Attrs: mustprogress norecurse uwtable
define dso_local noundef i32 @main() #3 {
  %1 = alloca i32, align 4
  %2 = alloca i32, align 4
  %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 i32, align 4
  %11 = alloca i32, align 4
  store i32 0, ptr %1, align 4
  %12 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str, ptr noundef @t)
  br label %13

13:                                               ; preds = %210, %0
  %14 = load i32, ptr @t, align 4, !tbaa !5
  %15 = add nsw i32 %14, -1
  store i32 %15, ptr @t, align 4, !tbaa !5
  %16 = icmp ne i32 %14, 0
  br i1 %16, label %17, label %211

17:                                               ; preds = %13
  %18 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str, ptr noundef @n)
  call void @llvm.lifetime.start.p0(i64 4, ptr %2) #6
  store i32 1, ptr %2, align 4, !tbaa !5
  br label %19

19:                                               ; preds = %45, %17
  %20 = load i32, ptr %2, align 4, !tbaa !5
  %21 = load i32, ptr @n, align 4, !tbaa !5
  %22 = icmp sle i32 %20, %21
  br i1 %22, label %24, label %23

23:                                               ; preds = %19
  call void @llvm.lifetime.end.p0(i64 4, ptr %2) #6
  br label %48

24:                                               ; preds = %19
  %25 = load i32, ptr %2, align 4, !tbaa !5
  %26 = sext i32 %25 to i64
  %27 = getelementptr inbounds i32, ptr @x, i64 %26
  %28 = load i32, ptr %2, align 4, !tbaa !5
  %29 = sext i32 %28 to i64
  %30 = getelementptr inbounds i32, ptr @y, i64 %29
  %31 = load i32, ptr %2, align 4, !tbaa !5
  %32 = sext i32 %31 to i64
  %33 = getelementptr inbounds i32, ptr @r, i64 %32
  %34 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str.1, ptr noundef %27, ptr noundef %30, ptr noundef %33)
  %35 = load i32, ptr %2, align 4, !tbaa !5
  %36 = load i32, ptr %2, align 4, !tbaa !5
  %37 = sext i32 %36 to i64
  %38 = getelementptr inbounds [1001 x i32], ptr @fa, i64 0, i64 %37
  store i32 %35, ptr %38, align 4, !tbaa !5
  %39 = load i32, ptr %2, align 4, !tbaa !5
  %40 = sext i32 %39 to i64
  %41 = getelementptr inbounds [1001 x i32], ptr @dis, i64 0, i64 %40
  store i32 0, ptr %41, align 4, !tbaa !5
  %42 = load i32, ptr %2, align 4, !tbaa !5
  %43 = sext i32 %42 to i64
  %44 = getelementptr inbounds [1001 x i8], ptr @vis, i64 0, i64 %43
  store i8 0, ptr %44, align 1, !tbaa !9
  br label %45

45:                                               ; preds = %24
  %46 = load i32, ptr %2, align 4, !tbaa !5
  %47 = add nsw i32 %46, 1
  store i32 %47, ptr %2, align 4, !tbaa !5
  br label %19, !llvm.loop !11

48:                                               ; preds = %23
  call void @_Z3dfsi(i32 noundef 1)
  call void @llvm.lifetime.start.p0(i64 1, ptr %3) #6
  %49 = load i32, ptr @n, align 4, !tbaa !5
  %50 = sext i32 %49 to i64
  %51 = getelementptr inbounds [1001 x i8], ptr @vis, i64 0, i64 %50
  %52 = load i8, ptr %51, align 1, !tbaa !9, !range !13, !noundef !14
  %53 = trunc i8 %52 to i1
  %54 = zext i1 %53 to i8
  store i8 %54, ptr %3, align 1, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #6
  store i32 1, ptr %4, align 4, !tbaa !5
  br label %55

55:                                               ; preds = %173, %48
  %56 = load i32, ptr %4, align 4, !tbaa !5
  %57 = load i32, ptr @n, align 4, !tbaa !5
  %58 = icmp sle i32 %56, %57
  br i1 %58, label %59, label %62

59:                                               ; preds = %55
  %60 = load i8, ptr %3, align 1, !tbaa !9, !range !13, !noundef !14
  %61 = trunc i8 %60 to i1
  br label %62

62:                                               ; preds = %59, %55
  %63 = phi i1 [ false, %55 ], [ %61, %59 ]
  br i1 %63, label %65, label %64

64:                                               ; preds = %62
  store i32 7, ptr %5, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #6
  br label %176

65:                                               ; preds = %62
  %66 = load i32, ptr %4, align 4, !tbaa !5
  %67 = sext i32 %66 to i64
  %68 = getelementptr inbounds [1001 x i8], ptr @vis, i64 0, i64 %67
  %69 = load i8, ptr %68, align 1, !tbaa !9, !range !13, !noundef !14
  %70 = trunc i8 %69 to i1
  br i1 %70, label %72, label %71

71:                                               ; preds = %65
  br label %173

72:                                               ; preds = %65
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #6
  %73 = load i32, ptr %4, align 4, !tbaa !5
  %74 = add nsw i32 %73, 1
  store i32 %74, ptr %6, align 4, !tbaa !5
  br label %75

75:                                               ; preds = %169, %72
  %76 = load i32, ptr %6, align 4, !tbaa !5
  %77 = load i32, ptr @n, align 4, !tbaa !5
  %78 = icmp sle i32 %76, %77
  br i1 %78, label %79, label %82

79:                                               ; preds = %75
  %80 = load i8, ptr %3, align 1, !tbaa !9, !range !13, !noundef !14
  %81 = trunc i8 %80 to i1
  br label %82

82:                                               ; preds = %79, %75
  %83 = phi i1 [ false, %75 ], [ %81, %79 ]
  br i1 %83, label %85, label %84

84:                                               ; preds = %82
  store i32 10, ptr %5, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #6
  br label %172

85:                                               ; preds = %82
  %86 = load i32, ptr %6, align 4, !tbaa !5
  %87 = sext i32 %86 to i64
  %88 = getelementptr inbounds [1001 x i8], ptr @vis, i64 0, i64 %87
  %89 = load i8, ptr %88, align 1, !tbaa !9, !range !13, !noundef !14
  %90 = trunc i8 %89 to i1
  br i1 %90, label %91, label %124

91:                                               ; preds = %85
  %92 = load i32, ptr %4, align 4, !tbaa !5
  %93 = sext i32 %92 to i64
  %94 = getelementptr inbounds [1001 x i32], ptr @x, i64 0, i64 %93
  %95 = load i32, ptr %94, align 4, !tbaa !5
  %96 = load i32, ptr %6, align 4, !tbaa !5
  %97 = sext i32 %96 to i64
  %98 = getelementptr inbounds [1001 x i32], ptr @x, i64 0, i64 %97
  %99 = load i32, ptr %98, align 4, !tbaa !5
  %100 = sub nsw i32 %95, %99
  %101 = call noundef i64 @_Z3sqri(i32 noundef %100)
  %102 = load i32, ptr %4, align 4, !tbaa !5
  %103 = sext i32 %102 to i64
  %104 = getelementptr inbounds [1001 x i32], ptr @y, i64 0, i64 %103
  %105 = load i32, ptr %104, align 4, !tbaa !5
  %106 = load i32, ptr %6, align 4, !tbaa !5
  %107 = sext i32 %106 to i64
  %108 = getelementptr inbounds [1001 x i32], ptr @y, i64 0, i64 %107
  %109 = load i32, ptr %108, align 4, !tbaa !5
  %110 = sub nsw i32 %105, %109
  %111 = call noundef i64 @_Z3sqri(i32 noundef %110)
  %112 = add nsw i64 %101, %111
  %113 = load i32, ptr %4, align 4, !tbaa !5
  %114 = sext i32 %113 to i64
  %115 = getelementptr inbounds [1001 x i32], ptr @r, i64 0, i64 %114
  %116 = load i32, ptr %115, align 4, !tbaa !5
  %117 = load i32, ptr %6, align 4, !tbaa !5
  %118 = sext i32 %117 to i64
  %119 = getelementptr inbounds [1001 x i32], ptr @r, i64 0, i64 %118
  %120 = load i32, ptr %119, align 4, !tbaa !5
  %121 = add nsw i32 %116, %120
  %122 = call noundef i64 @_Z3sqri(i32 noundef %121)
  %123 = icmp sgt i64 %112, %122
  br i1 %123, label %124, label %125

124:                                              ; preds = %91, %85
  br label %169

125:                                              ; preds = %91
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #6
  %126 = load i32, ptr %4, align 4, !tbaa !5
  %127 = call noundef i32 @_Z4findi(i32 noundef %126)
  store i32 %127, ptr %7, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #6
  %128 = load i32, ptr %6, align 4, !tbaa !5
  %129 = call noundef i32 @_Z4findi(i32 noundef %128)
  store i32 %129, ptr %8, align 4, !tbaa !5
  %130 = load i32, ptr %7, align 4, !tbaa !5
  %131 = load i32, ptr %8, align 4, !tbaa !5
  %132 = icmp eq i32 %130, %131
  br i1 %132, label %133, label %150

133:                                              ; preds = %125
  %134 = load i32, ptr %4, align 4, !tbaa !5
  %135 = sext i32 %134 to i64
  %136 = getelementptr inbounds [1001 x i32], ptr @dis, i64 0, i64 %135
  %137 = load i32, ptr %136, align 4, !tbaa !5
  %138 = load i32, ptr %6, align 4, !tbaa !5
  %139 = sext i32 %138 to i64
  %140 = getelementptr inbounds [1001 x i32], ptr @dis, i64 0, i64 %139
  %141 = load i32, ptr %140, align 4, !tbaa !5
  %142 = icmp ne i32 %137, %141
  %143 = zext i1 %142 to i32
  %144 = load i8, ptr %3, align 1, !tbaa !9, !range !13, !noundef !14
  %145 = trunc i8 %144 to i1
  %146 = zext i1 %145 to i32
  %147 = and i32 %146, %143
  %148 = icmp ne i32 %147, 0
  %149 = zext i1 %148 to i8
  store i8 %149, ptr %3, align 1, !tbaa !9
  br label %168

150:                                              ; preds = %125
  %151 = load i32, ptr %8, align 4, !tbaa !5
  %152 = load i32, ptr %7, align 4, !tbaa !5
  %153 = sext i32 %152 to i64
  %154 = getelementptr inbounds [1001 x i32], ptr @fa, i64 0, i64 %153
  store i32 %151, ptr %154, align 4, !tbaa !5
  %155 = load i32, ptr %4, align 4, !tbaa !5
  %156 = sext i32 %155 to i64
  %157 = getelementptr inbounds [1001 x i32], ptr @dis, i64 0, i64 %156
  %158 = load i32, ptr %157, align 4, !tbaa !5
  %159 = load i32, ptr %6, align 4, !tbaa !5
  %160 = sext i32 %159 to i64
  %161 = getelementptr inbounds [1001 x i32], ptr @dis, i64 0, i64 %160
  %162 = load i32, ptr %161, align 4, !tbaa !5
  %163 = xor i32 %158, %162
  %164 = xor i32 %163, 1
  %165 = load i32, ptr %7, align 4, !tbaa !5
  %166 = sext i32 %165 to i64
  %167 = getelementptr inbounds [1001 x i32], ptr @dis, i64 0, i64 %166
  store i32 %164, ptr %167, align 4, !tbaa !5
  br label %168

168:                                              ; preds = %150, %133
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #6
  br label %169

169:                                              ; preds = %168, %124
  %170 = load i32, ptr %6, align 4, !tbaa !5
  %171 = add nsw i32 %170, 1
  store i32 %171, ptr %6, align 4, !tbaa !5
  br label %75, !llvm.loop !15

172:                                              ; preds = %84
  br label %173

173:                                              ; preds = %172, %71
  %174 = load i32, ptr %4, align 4, !tbaa !5
  %175 = add nsw i32 %174, 1
  store i32 %175, ptr %4, align 4, !tbaa !5
  br label %55, !llvm.loop !16

176:                                              ; preds = %64
  %177 = load i8, ptr %3, align 1, !tbaa !9, !range !13, !noundef !14
  %178 = trunc i8 %177 to i1
  br i1 %178, label %179, label %208

179:                                              ; preds = %176
  %180 = call noundef i32 @_Z4findi(i32 noundef 1)
  %181 = load i32, ptr @n, align 4, !tbaa !5
  %182 = call noundef i32 @_Z4findi(i32 noundef %181)
  %183 = icmp eq i32 %180, %182
  br i1 %183, label %184, label %208

184:                                              ; preds = %179
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #6
  %185 = load i32, ptr getelementptr inbounds ([1001 x i32], ptr @r, i64 0, i64 1), align 4, !tbaa !5
  store i32 %185, ptr %9, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #6
  %186 = load i32, ptr @n, align 4, !tbaa !5
  %187 = sext i32 %186 to i64
  %188 = getelementptr inbounds [1001 x i32], ptr @r, i64 0, i64 %187
  %189 = load i32, ptr %188, align 4, !tbaa !5
  store i32 %189, ptr %10, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %11) #6
  %190 = load i32, ptr %9, align 4, !tbaa !5
  %191 = load i32, ptr %10, align 4, !tbaa !5
  %192 = call noundef i32 @_ZSt5__gcdIiET_S0_S0_(i32 noundef %190, i32 noundef %191)
  store i32 %192, ptr %11, align 4, !tbaa !5
  %193 = load i32, ptr %9, align 4, !tbaa !5
  %194 = load i32, ptr %11, align 4, !tbaa !5
  %195 = sdiv i32 %193, %194
  %196 = load i32, ptr %10, align 4, !tbaa !5
  %197 = load i32, ptr %11, align 4, !tbaa !5
  %198 = sdiv i32 %196, %197
  %199 = load i32, ptr getelementptr inbounds ([1001 x i32], ptr @dis, i64 0, i64 1), align 4, !tbaa !5
  %200 = load i32, ptr @n, align 4, !tbaa !5
  %201 = sext i32 %200 to i64
  %202 = getelementptr inbounds [1001 x i32], ptr @dis, i64 0, i64 %201
  %203 = load i32, ptr %202, align 4, !tbaa !5
  %204 = icmp eq i32 %199, %203
  %205 = zext i1 %204 to i64
  %206 = select i1 %204, ptr @.str.3, ptr @.str.4
  %207 = call i32 (ptr, ...) @printf(ptr noundef @.str.2, i32 noundef %195, i32 noundef %198, ptr noundef %206)
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #6
  br label %210

208:                                              ; preds = %179, %176
  %209 = call i32 @puts(ptr noundef @.str.5)
  br label %210

210:                                              ; preds = %208, %184
  call void @llvm.lifetime.end.p0(i64 1, ptr %3) #6
  br label %13, !llvm.loop !17

211:                                              ; preds = %13
  ret i32 0
}

declare i32 @__isoc99_scanf(ptr noundef, ...) #4

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef i32 @_ZSt5__gcdIiET_S0_S0_(i32 noundef, i32 noundef) #5

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

declare i32 @puts(ptr noundef) #4

attributes #0 = { mustprogress uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #1 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { inlinehint mustprogress nounwind uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #3 = { mustprogress norecurse 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 = { "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 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 #6 = { 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++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"bool", !7, i64 0}
!11 = distinct !{!11, !12}
!12 = !{!"llvm.loop.mustprogress"}
!13 = !{i8 0, i8 2}
!14 = !{}
!15 = distinct !{!15, !12}
!16 = distinct !{!16, !12}
!17 = distinct !{!17, !12}


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

@t = external dso_local global i32, align 4
@n = external dso_local global i32, align 4
@x = external dso_local global [1001 x i32], align 16
@y = external dso_local global [1001 x i32], align 16
@r = external dso_local global [1001 x i32], align 16
@fa = external dso_local local_unnamed_addr global [1001 x i32], align 16
@dis = external dso_local local_unnamed_addr global [1001 x i32], align 16
@vis = external dso_local local_unnamed_addr global [1001 x i8], align 16
@.str = external hidden unnamed_addr constant [3 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [7 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [10 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [10 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [17 x i8], align 1
@.str.5 = external hidden unnamed_addr constant [16 x i8], align 1

; Function Attrs: mustprogress uwtable
declare dso_local noundef i32 @_Z4findi(i32 noundef) local_unnamed_addr #0

; Function Attrs: mustprogress uwtable
declare dso_local void @_Z3dfsi(i32 noundef) local_unnamed_addr #0

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef i64 @_Z3sqri(i32 noundef) local_unnamed_addr #1

; Function Attrs: mustprogress norecurse uwtable
define dso_local noundef i32 @main() local_unnamed_addr #2 {
  %1 = tail call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull @t)
  %2 = load i32, ptr @t, align 4, !tbaa !5
  %3 = add nsw i32 %2, -1
  store i32 %3, ptr @t, align 4, !tbaa !5
  %.not62 = icmp eq i32 %2, 0
  br i1 %.not62, label %._crit_edge65, label %.lr.ph64

.lr.ph64:                                         ; preds = %0, %112
  %4 = tail call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull @n)
  %5 = load i32, ptr @n, align 4, !tbaa !5
  %.not4849 = icmp slt i32 %5, 1
  br i1 %.not4849, label %._crit_edge, label %.lr.ph

._crit_edge:                                      ; preds = %.lr.ph, %.lr.ph64
  tail call void @_Z3dfsi(i32 noundef 1)
  %6 = load i32, ptr @n, align 4, !tbaa !5
  %7 = sext i32 %6 to i64
  %8 = getelementptr inbounds [1001 x i8], ptr @vis, i64 0, i64 %7
  %9 = load i8, ptr %8, align 1, !tbaa !9, !range !11, !noundef !12
  %10 = icmp sgt i32 %6, 0
  %11 = trunc nuw i8 %9 to i1
  %12 = select i1 %10, i1 %11, i1 false
  br i1 %12, label %.lr.ph59, label %._crit_edge60

.lr.ph:                                           ; preds = %.lr.ph64, %.lr.ph
  %indvars.iv = phi i64 [ %indvars.iv.next, %.lr.ph ], [ 1, %.lr.ph64 ]
  %13 = getelementptr inbounds i32, ptr @x, i64 %indvars.iv
  %14 = getelementptr inbounds i32, ptr @y, i64 %indvars.iv
  %15 = getelementptr inbounds i32, ptr @r, i64 %indvars.iv
  %16 = tail call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str.1, ptr noundef nonnull %13, ptr noundef nonnull %14, ptr noundef nonnull %15)
  %17 = getelementptr inbounds [1001 x i32], ptr @fa, i64 0, i64 %indvars.iv
  %18 = trunc nuw nsw i64 %indvars.iv to i32
  store i32 %18, ptr %17, align 4, !tbaa !5
  %19 = getelementptr inbounds [1001 x i32], ptr @dis, i64 0, i64 %indvars.iv
  store i32 0, ptr %19, align 4, !tbaa !5
  %20 = getelementptr inbounds [1001 x i8], ptr @vis, i64 0, i64 %indvars.iv
  store i8 0, ptr %20, align 1, !tbaa !9
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %21 = load i32, ptr @n, align 4, !tbaa !5
  %22 = sext i32 %21 to i64
  %.not48.not = icmp slt i64 %indvars.iv, %22
  br i1 %.not48.not, label %.lr.ph, label %._crit_edge, !llvm.loop !13

._crit_edge60:                                    ; preds = %.loopexit, %._crit_edge
  %.lcssa = phi i1 [ %11, %._crit_edge ], [ %.pre-phi, %.loopexit ]
  br i1 %.lcssa, label %88, label %110

.lr.ph59:                                         ; preds = %._crit_edge, %.loopexit
  %23 = phi i32 [ %84, %.loopexit ], [ %6, %._crit_edge ]
  %indvars.iv68 = phi i64 [ %indvars.iv.next69, %.loopexit ], [ 1, %._crit_edge ]
  %.04357 = phi i8 [ %.4, %.loopexit ], [ %9, %._crit_edge ]
  %24 = getelementptr inbounds [1001 x i8], ptr @vis, i64 0, i64 %indvars.iv68
  %25 = load i8, ptr %24, align 1, !tbaa !9, !range !11, !noundef !12
  %26 = trunc nuw i8 %25 to i1
  br i1 %26, label %.preheader, label %.lr.ph59..loopexit_crit_edge

.lr.ph59..loopexit_crit_edge:                     ; preds = %.lr.ph59
  %.pre = trunc nuw i8 %.04357 to i1
  br label %.loopexit

.preheader:                                       ; preds = %.lr.ph59
  %27 = sext i32 %23 to i64
  %28 = icmp slt i64 %indvars.iv68, %27
  %29 = trunc nuw i8 %.04357 to i1
  %30 = select i1 %28, i1 %29, i1 false
  br i1 %30, label %.lr.ph54, label %.loopexit

.lr.ph54:                                         ; preds = %.preheader
  %31 = getelementptr inbounds [1001 x i32], ptr @x, i64 0, i64 %indvars.iv68
  %32 = getelementptr inbounds [1001 x i32], ptr @y, i64 0, i64 %indvars.iv68
  %33 = getelementptr inbounds [1001 x i32], ptr @r, i64 0, i64 %indvars.iv68
  %34 = getelementptr inbounds [1001 x i32], ptr @dis, i64 0, i64 %indvars.iv68
  %35 = trunc nuw nsw i64 %indvars.iv68 to i32
  br label %36

36:                                               ; preds = %.lr.ph54, %78
  %indvars.iv70 = phi i64 [ %indvars.iv68, %.lr.ph54 ], [ %indvars.iv.next71, %78 ]
  %.152 = phi i8 [ %.04357, %.lr.ph54 ], [ %.3, %78 ]
  %indvars.iv.next71 = add nuw nsw i64 %indvars.iv70, 1
  %37 = getelementptr inbounds [1001 x i8], ptr @vis, i64 0, i64 %indvars.iv.next71
  %38 = load i8, ptr %37, align 1, !tbaa !9, !range !11, !noundef !12
  %39 = trunc nuw i8 %38 to i1
  br i1 %39, label %40, label %78

40:                                               ; preds = %36
  %41 = load i32, ptr %31, align 4, !tbaa !5
  %42 = getelementptr inbounds [1001 x i32], ptr @x, i64 0, i64 %indvars.iv.next71
  %43 = load i32, ptr %42, align 4, !tbaa !5
  %44 = sub nsw i32 %41, %43
  %45 = tail call noundef i64 @_Z3sqri(i32 noundef %44)
  %46 = load i32, ptr %32, align 4, !tbaa !5
  %47 = getelementptr inbounds [1001 x i32], ptr @y, i64 0, i64 %indvars.iv.next71
  %48 = load i32, ptr %47, align 4, !tbaa !5
  %49 = sub nsw i32 %46, %48
  %50 = tail call noundef i64 @_Z3sqri(i32 noundef %49)
  %51 = add nsw i64 %50, %45
  %52 = load i32, ptr %33, align 4, !tbaa !5
  %53 = getelementptr inbounds [1001 x i32], ptr @r, i64 0, i64 %indvars.iv.next71
  %54 = load i32, ptr %53, align 4, !tbaa !5
  %55 = add nsw i32 %54, %52
  %56 = tail call noundef i64 @_Z3sqri(i32 noundef %55)
  %57 = icmp sgt i64 %51, %56
  br i1 %57, label %78, label %58

58:                                               ; preds = %40
  %59 = tail call noundef i32 @_Z4findi(i32 noundef %35)
  %60 = trunc nuw i64 %indvars.iv.next71 to i32
  %61 = tail call noundef i32 @_Z4findi(i32 noundef %60)
  %62 = icmp eq i32 %59, %61
  br i1 %62, label %63, label %69

63:                                               ; preds = %58
  %64 = load i32, ptr %34, align 4, !tbaa !5
  %65 = getelementptr inbounds [1001 x i32], ptr @dis, i64 0, i64 %indvars.iv.next71
  %66 = load i32, ptr %65, align 4, !tbaa !5
  %67 = icmp ne i32 %64, %66
  %68 = zext i1 %67 to i8
  br label %78

69:                                               ; preds = %58
  %70 = sext i32 %59 to i64
  %71 = getelementptr inbounds [1001 x i32], ptr @fa, i64 0, i64 %70
  store i32 %61, ptr %71, align 4, !tbaa !5
  %72 = load i32, ptr %34, align 4, !tbaa !5
  %73 = getelementptr inbounds [1001 x i32], ptr @dis, i64 0, i64 %indvars.iv.next71
  %74 = load i32, ptr %73, align 4, !tbaa !5
  %75 = xor i32 %72, %74
  %76 = xor i32 %75, 1
  %77 = getelementptr inbounds [1001 x i32], ptr @dis, i64 0, i64 %70
  store i32 %76, ptr %77, align 4, !tbaa !5
  br label %78

78:                                               ; preds = %63, %69, %36, %40
  %.3 = phi i8 [ %.152, %40 ], [ %.152, %36 ], [ %68, %63 ], [ %.152, %69 ]
  %79 = load i32, ptr @n, align 4, !tbaa !5
  %80 = trunc nuw i64 %indvars.iv.next71 to i32
  %81 = icmp sgt i32 %79, %80
  %82 = trunc nuw i8 %.3 to i1
  %83 = select i1 %81, i1 %82, i1 false
  br i1 %83, label %36, label %.loopexit, !llvm.loop !15

.loopexit:                                        ; preds = %78, %.lr.ph59..loopexit_crit_edge, %.preheader
  %.pre-phi = phi i1 [ %.pre, %.lr.ph59..loopexit_crit_edge ], [ %29, %.preheader ], [ %82, %78 ]
  %84 = phi i32 [ %23, %.lr.ph59..loopexit_crit_edge ], [ %23, %.preheader ], [ %79, %78 ]
  %.4 = phi i8 [ %.04357, %.lr.ph59..loopexit_crit_edge ], [ %.04357, %.preheader ], [ %.3, %78 ]
  %indvars.iv.next69 = add nuw nsw i64 %indvars.iv68, 1
  %85 = sext i32 %84 to i64
  %86 = icmp slt i64 %indvars.iv68, %85
  %87 = select i1 %86, i1 %.pre-phi, i1 false
  br i1 %87, label %.lr.ph59, label %._crit_edge60, !llvm.loop !16

88:                                               ; preds = %._crit_edge60
  %89 = tail call noundef i32 @_Z4findi(i32 noundef 1)
  %90 = load i32, ptr @n, align 4, !tbaa !5
  %91 = tail call noundef i32 @_Z4findi(i32 noundef %90)
  %92 = icmp eq i32 %89, %91
  br i1 %92, label %93, label %110

93:                                               ; preds = %88
  %94 = load i32, ptr getelementptr inbounds (i8, ptr @r, i64 4), align 4, !tbaa !5
  %95 = load i32, ptr @n, align 4, !tbaa !5
  %96 = sext i32 %95 to i64
  %97 = getelementptr inbounds [1001 x i32], ptr @r, i64 0, i64 %96
  %98 = load i32, ptr %97, align 4, !tbaa !5
  %99 = tail call noundef i32 @_ZSt5__gcdIiET_S0_S0_(i32 noundef %94, i32 noundef %98)
  %100 = sdiv i32 %94, %99
  %101 = sdiv i32 %98, %99
  %102 = load i32, ptr getelementptr inbounds (i8, ptr @dis, i64 4), align 4, !tbaa !5
  %103 = load i32, ptr @n, align 4, !tbaa !5
  %104 = sext i32 %103 to i64
  %105 = getelementptr inbounds [1001 x i32], ptr @dis, i64 0, i64 %104
  %106 = load i32, ptr %105, align 4, !tbaa !5
  %107 = icmp eq i32 %102, %106
  %108 = select i1 %107, ptr @.str.3, ptr @.str.4
  %109 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.2, i32 noundef %100, i32 noundef %101, ptr noundef nonnull %108)
  br label %112

110:                                              ; preds = %88, %._crit_edge60
  %111 = tail call i32 @puts(ptr noundef nonnull dereferenceable(1) @.str.5)
  br label %112

112:                                              ; preds = %110, %93
  %113 = load i32, ptr @t, align 4, !tbaa !5
  %114 = add nsw i32 %113, -1
  store i32 %114, ptr @t, align 4, !tbaa !5
  %.not = icmp eq i32 %113, 0
  br i1 %.not, label %._crit_edge65, label %.lr.ph64, !llvm.loop !17

._crit_edge65:                                    ; preds = %112, %0
  ret i32 0
}

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef i32 @_ZSt5__gcdIiET_S0_S0_(i32 noundef, i32 noundef) local_unnamed_addr #4

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

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

attributes #0 = { mustprogress uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #1 = { inlinehint mustprogress nounwind uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #2 = { mustprogress norecurse 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 = { 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 = { mustprogress nounwind uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }

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

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


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