; LLVM IR from VastoLorde95/Competitive-Programming :: Hackerrank/101 Hacks/101 Hack 2017/101 Hack Jan/Problem C (C)

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

%"class.std::basic_istream" = type { ptr, i64, %"class.std::basic_ios" }
%"class.std::basic_ios" = type { %"class.std::ios_base", ptr, i8, i8, ptr, ptr, ptr, ptr }
%"class.std::ios_base" = type { ptr, i64, i64, i32, i32, i32, ptr, %"struct.std::ios_base::_Words", [8 x %"struct.std::ios_base::_Words"], i32, ptr, %"class.std::locale" }
%"struct.std::ios_base::_Words" = type { ptr, i64 }
%"class.std::locale" = type { ptr }
%"class.std::basic_ostream" = type { ptr, %"class.std::basic_ios" }

@n = external dso_local global i32, align 4
@a = external dso_local global [100100 x i64], align 16
@l = external dso_local global [100100 x i64], align 16
@r = external dso_local global [100100 x i64], align 16
@_ZSt3cin = external global %"class.std::basic_istream", align 8
@_ZSt4cout = external global %"class.std::basic_ostream", align 8

; Function Attrs: mustprogress norecurse uwtable
define dso_local noundef i32 @main() #0 {
  %1 = alloca i32, align 4
  %2 = alloca i32, align 4
  %3 = alloca i32, align 4
  %4 = alloca i32, align 4
  %5 = alloca i64, align 8
  %6 = alloca i32, align 4
  %7 = alloca i32, align 4
  %8 = alloca i64, align 8
  store i32 0, ptr %1, align 4
  %9 = call noundef zeroext i1 @_ZNSt8ios_base15sync_with_stdioEb(i1 noundef zeroext false)
  %10 = load ptr, ptr @_ZSt3cin, align 8, !tbaa !5
  %11 = getelementptr i8, ptr %10, i64 -24
  %12 = load i64, ptr %11, align 8
  %13 = getelementptr inbounds i8, ptr @_ZSt3cin, i64 %12
  %14 = call noundef ptr @_ZNSt9basic_iosIcSt11char_traitsIcEE3tieEPSo(ptr noundef nonnull align 8 dereferenceable(264) %13, ptr noundef null)
  %15 = load ptr, ptr @_ZSt4cout, align 8, !tbaa !5
  %16 = getelementptr i8, ptr %15, i64 -24
  %17 = load i64, ptr %16, align 8
  %18 = getelementptr inbounds i8, ptr @_ZSt4cout, i64 %17
  %19 = call noundef ptr @_ZNSt9basic_iosIcSt11char_traitsIcEE3tieEPSo(ptr noundef nonnull align 8 dereferenceable(264) %18, ptr noundef null)
  %20 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERi(ptr noundef nonnull align 8 dereferenceable(16) @_ZSt3cin, ptr noundef nonnull align 4 dereferenceable(4) @n)
  call void @llvm.lifetime.start.p0(i64 4, ptr %2) #7
  store i32 0, ptr %2, align 4, !tbaa !8
  br label %21

21:                                               ; preds = %31, %0
  %22 = load i32, ptr %2, align 4, !tbaa !8
  %23 = load i32, ptr @n, align 4, !tbaa !8
  %24 = icmp slt i32 %22, %23
  br i1 %24, label %26, label %25

25:                                               ; preds = %21
  call void @llvm.lifetime.end.p0(i64 4, ptr %2) #7
  br label %34

26:                                               ; preds = %21
  %27 = load i32, ptr %2, align 4, !tbaa !8
  %28 = sext i32 %27 to i64
  %29 = getelementptr inbounds [100100 x i64], ptr @a, i64 0, i64 %28
  %30 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERx(ptr noundef nonnull align 8 dereferenceable(16) @_ZSt3cin, ptr noundef nonnull align 8 dereferenceable(8) %29)
  br label %31

31:                                               ; preds = %26
  %32 = load i32, ptr %2, align 4, !tbaa !8
  %33 = add nsw i32 %32, 1
  store i32 %33, ptr %2, align 4, !tbaa !8
  br label %21, !llvm.loop !11

34:                                               ; preds = %25
  %35 = load i32, ptr @n, align 4, !tbaa !8
  %36 = icmp eq i32 %35, 1
  br i1 %36, label %37, label %42

37:                                               ; preds = %34
  %38 = load i64, ptr @a, align 16, !tbaa !13
  %39 = add nsw i64 %38, 1
  %40 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEx(ptr noundef nonnull align 8 dereferenceable(8) @_ZSt4cout, i64 noundef %39)
  %41 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEPFRSoS_E(ptr noundef nonnull align 8 dereferenceable(8) %40, ptr noundef @_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_)
  store i32 0, ptr %1, align 4
  br label %185

42:                                               ; preds = %34
  %43 = load i32, ptr @n, align 4, !tbaa !8
  %44 = icmp eq i32 %43, 2
  br i1 %44, label %45, label %50

45:                                               ; preds = %42
  %46 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZSt3maxIxERKT_S2_S2_(ptr noundef nonnull align 8 dereferenceable(8) @a, ptr noundef nonnull align 8 dereferenceable(8) getelementptr inbounds ([100100 x i64], ptr @a, i64 0, i64 1))
  %47 = load i64, ptr %46, align 8, !tbaa !13
  %48 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEx(ptr noundef nonnull align 8 dereferenceable(8) @_ZSt4cout, i64 noundef %47)
  %49 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEPFRSoS_E(ptr noundef nonnull align 8 dereferenceable(8) %48, ptr noundef @_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_)
  store i32 0, ptr %1, align 4
  br label %185

50:                                               ; preds = %42
  %51 = load i64, ptr @a, align 16, !tbaa !13
  store i64 %51, ptr @l, align 16, !tbaa !13
  call void @llvm.lifetime.start.p0(i64 4, ptr %3) #7
  store i32 1, ptr %3, align 4, !tbaa !8
  br label %52

52:                                               ; preds = %71, %50
  %53 = load i32, ptr %3, align 4, !tbaa !8
  %54 = load i32, ptr @n, align 4, !tbaa !8
  %55 = icmp slt i32 %53, %54
  br i1 %55, label %57, label %56

56:                                               ; preds = %52
  call void @llvm.lifetime.end.p0(i64 4, ptr %3) #7
  br label %74

57:                                               ; preds = %52
  %58 = load i32, ptr %3, align 4, !tbaa !8
  %59 = sub nsw i32 %58, 1
  %60 = sext i32 %59 to i64
  %61 = getelementptr inbounds [100100 x i64], ptr @l, i64 0, i64 %60
  %62 = load i64, ptr %61, align 8, !tbaa !13
  %63 = load i32, ptr %3, align 4, !tbaa !8
  %64 = sext i32 %63 to i64
  %65 = getelementptr inbounds [100100 x i64], ptr @a, i64 0, i64 %64
  %66 = load i64, ptr %65, align 8, !tbaa !13
  %67 = call noundef i64 @_ZSt5__gcdIxET_S0_S0_(i64 noundef %62, i64 noundef %66)
  %68 = load i32, ptr %3, align 4, !tbaa !8
  %69 = sext i32 %68 to i64
  %70 = getelementptr inbounds [100100 x i64], ptr @l, i64 0, i64 %69
  store i64 %67, ptr %70, align 8, !tbaa !13
  br label %71

71:                                               ; preds = %57
  %72 = load i32, ptr %3, align 4, !tbaa !8
  %73 = add nsw i32 %72, 1
  store i32 %73, ptr %3, align 4, !tbaa !8
  br label %52, !llvm.loop !15

74:                                               ; preds = %56
  %75 = load i32, ptr @n, align 4, !tbaa !8
  %76 = sub nsw i32 %75, 1
  %77 = sext i32 %76 to i64
  %78 = getelementptr inbounds [100100 x i64], ptr @a, i64 0, i64 %77
  %79 = load i64, ptr %78, align 8, !tbaa !13
  %80 = load i32, ptr @n, align 4, !tbaa !8
  %81 = sub nsw i32 %80, 1
  %82 = sext i32 %81 to i64
  %83 = getelementptr inbounds [100100 x i64], ptr @r, i64 0, i64 %82
  store i64 %79, ptr %83, align 8, !tbaa !13
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #7
  %84 = load i32, ptr @n, align 4, !tbaa !8
  %85 = sub nsw i32 %84, 2
  store i32 %85, ptr %4, align 4, !tbaa !8
  br label %86

86:                                               ; preds = %104, %74
  %87 = load i32, ptr %4, align 4, !tbaa !8
  %88 = icmp sge i32 %87, 0
  br i1 %88, label %90, label %89

89:                                               ; preds = %86
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #7
  br label %107

90:                                               ; preds = %86
  %91 = load i32, ptr %4, align 4, !tbaa !8
  %92 = add nsw i32 %91, 1
  %93 = sext i32 %92 to i64
  %94 = getelementptr inbounds [100100 x i64], ptr @r, i64 0, i64 %93
  %95 = load i64, ptr %94, align 8, !tbaa !13
  %96 = load i32, ptr %4, align 4, !tbaa !8
  %97 = sext i32 %96 to i64
  %98 = getelementptr inbounds [100100 x i64], ptr @a, i64 0, i64 %97
  %99 = load i64, ptr %98, align 8, !tbaa !13
  %100 = call noundef i64 @_ZSt5__gcdIxET_S0_S0_(i64 noundef %95, i64 noundef %99)
  %101 = load i32, ptr %4, align 4, !tbaa !8
  %102 = sext i32 %101 to i64
  %103 = getelementptr inbounds [100100 x i64], ptr @r, i64 0, i64 %102
  store i64 %100, ptr %103, align 8, !tbaa !13
  br label %104

104:                                              ; preds = %90
  %105 = load i32, ptr %4, align 4, !tbaa !8
  %106 = add nsw i32 %105, -1
  store i32 %106, ptr %4, align 4, !tbaa !8
  br label %86, !llvm.loop !16

107:                                              ; preds = %89
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #7
  %108 = load i32, ptr @n, align 4, !tbaa !8
  %109 = sub nsw i32 %108, 2
  %110 = sext i32 %109 to i64
  %111 = getelementptr inbounds [100100 x i64], ptr @l, i64 0, i64 %110
  %112 = load i64, ptr %111, align 8, !tbaa !13
  store i64 %112, ptr %5, align 8, !tbaa !13
  %113 = load i64, ptr %5, align 8, !tbaa !13
  %114 = icmp sgt i64 %113, 1
  br i1 %114, label %115, label %128

115:                                              ; preds = %107
  %116 = load i32, ptr @n, align 4, !tbaa !8
  %117 = sub nsw i32 %116, 1
  %118 = sext i32 %117 to i64
  %119 = getelementptr inbounds [100100 x i64], ptr @a, i64 0, i64 %118
  %120 = load i64, ptr %119, align 8, !tbaa !13
  %121 = load i64, ptr %5, align 8, !tbaa !13
  %122 = srem i64 %120, %121
  %123 = icmp ne i64 %122, 0
  br i1 %123, label %124, label %128

124:                                              ; preds = %115
  %125 = load i64, ptr %5, align 8, !tbaa !13
  %126 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEx(ptr noundef nonnull align 8 dereferenceable(8) @_ZSt4cout, i64 noundef %125)
  %127 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEPFRSoS_E(ptr noundef nonnull align 8 dereferenceable(8) %126, ptr noundef @_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_)
  store i32 0, ptr %1, align 4
  store i32 1, ptr %6, align 4
  br label %184

128:                                              ; preds = %115, %107
  %129 = load i64, ptr getelementptr inbounds ([100100 x i64], ptr @r, i64 0, i64 1), align 8, !tbaa !13
  store i64 %129, ptr %5, align 8, !tbaa !13
  %130 = load i64, ptr %5, align 8, !tbaa !13
  %131 = icmp sgt i64 %130, 1
  br i1 %131, label %132, label %141

132:                                              ; preds = %128
  %133 = load i64, ptr @a, align 16, !tbaa !13
  %134 = load i64, ptr %5, align 8, !tbaa !13
  %135 = srem i64 %133, %134
  %136 = icmp ne i64 %135, 0
  br i1 %136, label %137, label %141

137:                                              ; preds = %132
  %138 = load i64, ptr %5, align 8, !tbaa !13
  %139 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEx(ptr noundef nonnull align 8 dereferenceable(8) @_ZSt4cout, i64 noundef %138)
  %140 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEPFRSoS_E(ptr noundef nonnull align 8 dereferenceable(8) %139, ptr noundef @_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_)
  store i32 0, ptr %1, align 4
  store i32 1, ptr %6, align 4
  br label %184

141:                                              ; preds = %132, %128
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #7
  store i32 1, ptr %7, align 4, !tbaa !8
  br label %142

142:                                              ; preds = %178, %141
  %143 = load i32, ptr %7, align 4, !tbaa !8
  %144 = load i32, ptr @n, align 4, !tbaa !8
  %145 = sub nsw i32 %144, 1
  %146 = icmp slt i32 %143, %145
  br i1 %146, label %148, label %147

147:                                              ; preds = %142
  store i32 11, ptr %6, align 4
  br label %181

148:                                              ; preds = %142
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #7
  %149 = load i32, ptr %7, align 4, !tbaa !8
  %150 = sub nsw i32 %149, 1
  %151 = sext i32 %150 to i64
  %152 = getelementptr inbounds [100100 x i64], ptr @l, i64 0, i64 %151
  %153 = load i64, ptr %152, align 8, !tbaa !13
  %154 = load i32, ptr %7, align 4, !tbaa !8
  %155 = add nsw i32 %154, 1
  %156 = sext i32 %155 to i64
  %157 = getelementptr inbounds [100100 x i64], ptr @r, i64 0, i64 %156
  %158 = load i64, ptr %157, align 8, !tbaa !13
  %159 = call noundef i64 @_ZSt5__gcdIxET_S0_S0_(i64 noundef %153, i64 noundef %158)
  store i64 %159, ptr %8, align 8, !tbaa !13
  %160 = load i64, ptr %8, align 8, !tbaa !13
  %161 = icmp sgt i64 %160, 1
  br i1 %161, label %162, label %174

162:                                              ; preds = %148
  %163 = load i32, ptr %7, align 4, !tbaa !8
  %164 = sext i32 %163 to i64
  %165 = getelementptr inbounds [100100 x i64], ptr @a, i64 0, i64 %164
  %166 = load i64, ptr %165, align 8, !tbaa !13
  %167 = load i64, ptr %8, align 8, !tbaa !13
  %168 = srem i64 %166, %167
  %169 = icmp ne i64 %168, 0
  br i1 %169, label %170, label %174

170:                                              ; preds = %162
  %171 = load i64, ptr %8, align 8, !tbaa !13
  %172 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEx(ptr noundef nonnull align 8 dereferenceable(8) @_ZSt4cout, i64 noundef %171)
  %173 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEPFRSoS_E(ptr noundef nonnull align 8 dereferenceable(8) %172, ptr noundef @_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_)
  store i32 0, ptr %1, align 4
  store i32 1, ptr %6, align 4
  br label %175

174:                                              ; preds = %162, %148
  store i32 0, ptr %6, align 4
  br label %175

175:                                              ; preds = %174, %170
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #7
  %176 = load i32, ptr %6, align 4
  switch i32 %176, label %181 [
    i32 0, label %177
  ]

177:                                              ; preds = %175
  br label %178

178:                                              ; preds = %177
  %179 = load i32, ptr %7, align 4, !tbaa !8
  %180 = add nsw i32 %179, 1
  store i32 %180, ptr %7, align 4, !tbaa !8
  br label %142, !llvm.loop !17

181:                                              ; preds = %175, %147
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #7
  %182 = load i32, ptr %6, align 4
  switch i32 %182, label %184 [
    i32 11, label %183
  ]

183:                                              ; preds = %181
  store i32 0, ptr %1, align 4
  store i32 1, ptr %6, align 4
  br label %184

184:                                              ; preds = %183, %181, %137, %124
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #7
  br label %185

185:                                              ; preds = %184, %45, %37
  %186 = load i32, ptr %1, align 4
  ret i32 %186
}

declare noundef zeroext i1 @_ZNSt8ios_base15sync_with_stdioEb(i1 noundef zeroext) #1

; Function Attrs: mustprogress nounwind uwtable
declare noundef ptr @_ZNSt9basic_iosIcSt11char_traitsIcEE3tieEPSo(ptr noundef nonnull align 8 dereferenceable(264), ptr noundef) #2 align 2

declare noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERi(ptr noundef nonnull align 8 dereferenceable(16), ptr noundef nonnull align 4 dereferenceable(4)) #1

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

; Function Attrs: mustprogress uwtable
declare noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERx(ptr noundef nonnull align 8 dereferenceable(16), ptr noundef nonnull align 8 dereferenceable(8)) #4 align 2

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

; Function Attrs: mustprogress uwtable
declare noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEx(ptr noundef nonnull align 8 dereferenceable(8), i64 noundef) #4 align 2

; Function Attrs: mustprogress uwtable
declare noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEPFRSoS_E(ptr noundef nonnull align 8 dereferenceable(8), ptr noundef) #4 align 2

; Function Attrs: inlinehint mustprogress uwtable
declare noundef nonnull align 8 dereferenceable(8) ptr @_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_(ptr noundef nonnull align 8 dereferenceable(8)) #5

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef nonnull align 8 dereferenceable(8) ptr @_ZSt3maxIxERKT_S2_S2_(ptr noundef nonnull align 8 dereferenceable(8), ptr noundef nonnull align 8 dereferenceable(8)) #6

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef i64 @_ZSt5__gcdIxET_S0_S0_(i64 noundef, i64 noundef) #2

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

%"class.std::basic_istream" = type { ptr, i64, %"class.std::basic_ios" }
%"class.std::basic_ios" = type { %"class.std::ios_base", ptr, i8, i8, ptr, ptr, ptr, ptr }
%"class.std::ios_base" = type { ptr, i64, i64, i32, i32, i32, ptr, %"struct.std::ios_base::_Words", [8 x %"struct.std::ios_base::_Words"], i32, ptr, %"class.std::locale" }
%"struct.std::ios_base::_Words" = type { ptr, i64 }
%"class.std::locale" = type { ptr }
%"class.std::basic_ostream" = type { ptr, %"class.std::basic_ios" }

@n = external dso_local global i32, align 4
@a = external dso_local global [100100 x i64], align 16
@l = external dso_local local_unnamed_addr global [100100 x i64], align 16
@r = external dso_local local_unnamed_addr global [100100 x i64], align 16
@_ZSt3cin = external global %"class.std::basic_istream", align 8
@_ZSt4cout = external global %"class.std::basic_ostream", align 8

; Function Attrs: mustprogress norecurse uwtable
define dso_local noundef i32 @main() local_unnamed_addr #0 {
  %1 = tail call noundef zeroext i1 @_ZNSt8ios_base15sync_with_stdioEb(i1 noundef zeroext false)
  %2 = load ptr, ptr @_ZSt3cin, align 8, !tbaa !5
  %3 = getelementptr i8, ptr %2, i64 -24
  %4 = load i64, ptr %3, align 8
  %5 = getelementptr inbounds i8, ptr @_ZSt3cin, i64 %4
  %6 = tail call noundef ptr @_ZNSt9basic_iosIcSt11char_traitsIcEE3tieEPSo(ptr noundef nonnull align 8 dereferenceable(264) %5, ptr noundef null)
  %7 = load ptr, ptr @_ZSt4cout, align 8, !tbaa !5
  %8 = getelementptr i8, ptr %7, i64 -24
  %9 = load i64, ptr %8, align 8
  %10 = getelementptr inbounds i8, ptr @_ZSt4cout, i64 %9
  %11 = tail call noundef ptr @_ZNSt9basic_iosIcSt11char_traitsIcEE3tieEPSo(ptr noundef nonnull align 8 dereferenceable(264) %10, ptr noundef null)
  %12 = tail call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERi(ptr noundef nonnull align 8 dereferenceable(16) @_ZSt3cin, ptr noundef nonnull align 4 dereferenceable(4) @n)
  %13 = load i32, ptr @n, align 4, !tbaa !8
  %14 = icmp sgt i32 %13, 0
  br i1 %14, label %.lr.ph, label %._crit_edge

._crit_edge:                                      ; preds = %.lr.ph, %0
  %15 = phi i32 [ %13, %0 ], [ %18, %.lr.ph ]
  switch i32 %15, label %27 [
    i32 1, label %21
    i32 2, label %24
  ]

.lr.ph:                                           ; preds = %0, %.lr.ph
  %indvars.iv = phi i64 [ %indvars.iv.next, %.lr.ph ], [ 0, %0 ]
  %16 = getelementptr inbounds [100100 x i64], ptr @a, i64 0, i64 %indvars.iv
  %17 = tail call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERx(ptr noundef nonnull align 8 dereferenceable(16) @_ZSt3cin, ptr noundef nonnull align 8 dereferenceable(8) %16)
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %18 = load i32, ptr @n, align 4, !tbaa !8
  %19 = sext i32 %18 to i64
  %20 = icmp slt i64 %indvars.iv.next, %19
  br i1 %20, label %.lr.ph, label %._crit_edge, !llvm.loop !11

21:                                               ; preds = %._crit_edge
  %22 = load i64, ptr @a, align 16, !tbaa !13
  %23 = add nsw i64 %22, 1
  br label %.critedge46.sink.split

24:                                               ; preds = %._crit_edge
  %25 = tail call noundef nonnull align 8 dereferenceable(8) ptr @_ZSt3maxIxERKT_S2_S2_(ptr noundef nonnull align 8 dereferenceable(8) @a, ptr noundef nonnull align 8 dereferenceable(8) getelementptr inbounds (i8, ptr @a, i64 8))
  %26 = load i64, ptr %25, align 8, !tbaa !13
  br label %.critedge46.sink.split

27:                                               ; preds = %._crit_edge
  %28 = load i64, ptr @a, align 16, !tbaa !13
  store i64 %28, ptr @l, align 16, !tbaa !13
  %29 = icmp sgt i32 %15, 1
  br i1 %29, label %.lr.ph52, label %._crit_edge53.thread

._crit_edge53.thread:                             ; preds = %27
  %30 = add nsw i32 %15, -1
  %31 = sext i32 %30 to i64
  %32 = getelementptr inbounds [100100 x i64], ptr @a, i64 0, i64 %31
  %33 = load i64, ptr %32, align 8, !tbaa !13
  %34 = getelementptr inbounds [100100 x i64], ptr @r, i64 0, i64 %31
  store i64 %33, ptr %34, align 8, !tbaa !13
  %35 = add i32 %15, -2
  br label %._crit_edge58

._crit_edge53:                                    ; preds = %.lr.ph52
  %36 = add nsw i32 %49, -1
  %37 = sext i32 %36 to i64
  %38 = getelementptr inbounds [100100 x i64], ptr @a, i64 0, i64 %37
  %39 = load i64, ptr %38, align 8, !tbaa !13
  %40 = getelementptr inbounds [100100 x i64], ptr @r, i64 0, i64 %37
  store i64 %39, ptr %40, align 8, !tbaa !13
  %41 = add i32 %49, -2
  %42 = icmp sgt i32 %49, 1
  br i1 %42, label %.lr.ph57.preheader, label %._crit_edge58

.lr.ph57.preheader:                               ; preds = %._crit_edge53
  %43 = zext nneg i32 %41 to i64
  br label %.lr.ph57

.lr.ph52:                                         ; preds = %27, %.lr.ph52
  %44 = phi i64 [ %47, %.lr.ph52 ], [ %28, %27 ]
  %indvars.iv67 = phi i64 [ %indvars.iv.next68, %.lr.ph52 ], [ 1, %27 ]
  %45 = getelementptr inbounds [100100 x i64], ptr @a, i64 0, i64 %indvars.iv67
  %46 = load i64, ptr %45, align 8, !tbaa !13
  %47 = tail call noundef i64 @_ZSt5__gcdIxET_S0_S0_(i64 noundef %44, i64 noundef %46)
  %48 = getelementptr inbounds [100100 x i64], ptr @l, i64 0, i64 %indvars.iv67
  store i64 %47, ptr %48, align 8, !tbaa !13
  %indvars.iv.next68 = add nuw nsw i64 %indvars.iv67, 1
  %49 = load i32, ptr @n, align 4, !tbaa !8
  %50 = sext i32 %49 to i64
  %51 = icmp slt i64 %indvars.iv.next68, %50
  br i1 %51, label %.lr.ph52, label %._crit_edge53, !llvm.loop !15

._crit_edge58.loopexit:                           ; preds = %.lr.ph57
  %.pre = load i32, ptr @n, align 4, !tbaa !8
  %.pre76 = add nsw i32 %.pre, -2
  br label %._crit_edge58

._crit_edge58:                                    ; preds = %._crit_edge53.thread, %._crit_edge58.loopexit, %._crit_edge53
  %.pre-phi = phi i32 [ %.pre76, %._crit_edge58.loopexit ], [ %41, %._crit_edge53 ], [ %35, %._crit_edge53.thread ]
  %52 = phi i32 [ %.pre, %._crit_edge58.loopexit ], [ %49, %._crit_edge53 ], [ %15, %._crit_edge53.thread ]
  %53 = sext i32 %.pre-phi to i64
  %54 = getelementptr inbounds [100100 x i64], ptr @l, i64 0, i64 %53
  %55 = load i64, ptr %54, align 8, !tbaa !13
  %56 = icmp sgt i64 %55, 1
  br i1 %56, label %64, label %70

.lr.ph57:                                         ; preds = %.lr.ph57.preheader, %.lr.ph57
  %indvars.iv70 = phi i64 [ %43, %.lr.ph57.preheader ], [ %indvars.iv.next71, %.lr.ph57 ]
  %57 = add nuw nsw i64 %indvars.iv70, 1
  %58 = getelementptr inbounds [100100 x i64], ptr @r, i64 0, i64 %57
  %59 = load i64, ptr %58, align 8, !tbaa !13
  %60 = getelementptr inbounds [100100 x i64], ptr @a, i64 0, i64 %indvars.iv70
  %61 = load i64, ptr %60, align 8, !tbaa !13
  %62 = tail call noundef i64 @_ZSt5__gcdIxET_S0_S0_(i64 noundef %59, i64 noundef %61)
  %63 = getelementptr inbounds [100100 x i64], ptr @r, i64 0, i64 %indvars.iv70
  store i64 %62, ptr %63, align 8, !tbaa !13
  %indvars.iv.next71 = add nsw i64 %indvars.iv70, -1
  %.not81 = icmp eq i64 %indvars.iv70, 0
  br i1 %.not81, label %._crit_edge58.loopexit, label %.lr.ph57, !llvm.loop !16

64:                                               ; preds = %._crit_edge58
  %65 = add nsw i32 %52, -1
  %66 = sext i32 %65 to i64
  %67 = getelementptr inbounds [100100 x i64], ptr @a, i64 0, i64 %66
  %68 = load i64, ptr %67, align 8, !tbaa !13
  %69 = srem i64 %68, %55
  %.not = icmp eq i64 %69, 0
  br i1 %.not, label %70, label %.critedge46.sink.split

70:                                               ; preds = %64, %._crit_edge58
  %71 = load i64, ptr getelementptr inbounds (i8, ptr @r, i64 8), align 8, !tbaa !13
  %72 = icmp sgt i64 %71, 1
  br i1 %72, label %73, label %76

73:                                               ; preds = %70
  %74 = load i64, ptr @a, align 16, !tbaa !13
  %75 = srem i64 %74, %71
  %.not42 = icmp eq i64 %75, 0
  br i1 %.not42, label %76, label %.critedge46.sink.split

76:                                               ; preds = %73, %70
  %.not4459 = icmp sgt i32 %52, 2
  br i1 %.not4459, label %.lr.ph62, label %.critedge46

.lr.ph62:                                         ; preds = %76, %88
  %indvars.iv73 = phi i64 [ %indvars.iv.next74, %88 ], [ 1, %76 ]
  %77 = add nsw i64 %indvars.iv73, -1
  %78 = getelementptr inbounds [100100 x i64], ptr @l, i64 0, i64 %77
  %79 = load i64, ptr %78, align 8, !tbaa !13
  %indvars.iv.next74 = add nuw nsw i64 %indvars.iv73, 1
  %80 = getelementptr inbounds [100100 x i64], ptr @r, i64 0, i64 %indvars.iv.next74
  %81 = load i64, ptr %80, align 8, !tbaa !13
  %82 = tail call noundef i64 @_ZSt5__gcdIxET_S0_S0_(i64 noundef %79, i64 noundef %81)
  %83 = icmp sgt i64 %82, 1
  br i1 %83, label %84, label %88

84:                                               ; preds = %.lr.ph62
  %85 = getelementptr inbounds [100100 x i64], ptr @a, i64 0, i64 %indvars.iv73
  %86 = load i64, ptr %85, align 8, !tbaa !13
  %87 = srem i64 %86, %82
  %.not43 = icmp eq i64 %87, 0
  br i1 %.not43, label %88, label %.critedge46.sink.split

88:                                               ; preds = %84, %.lr.ph62
  %89 = load i32, ptr @n, align 4, !tbaa !8
  %90 = add nsw i32 %89, -1
  %91 = sext i32 %90 to i64
  %.not44 = icmp slt i64 %indvars.iv.next74, %91
  br i1 %.not44, label %.lr.ph62, label %.critedge46, !llvm.loop !17

.critedge46.sink.split:                           ; preds = %84, %73, %64, %21, %24
  %.lcssa.sink = phi i64 [ %26, %24 ], [ %23, %21 ], [ %55, %64 ], [ %71, %73 ], [ %82, %84 ]
  %92 = tail call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEx(ptr noundef nonnull align 8 dereferenceable(8) @_ZSt4cout, i64 noundef %.lcssa.sink)
  %93 = tail call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEPFRSoS_E(ptr noundef nonnull align 8 dereferenceable(8) %92, ptr noundef nonnull @_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_)
  br label %.critedge46

.critedge46:                                      ; preds = %88, %.critedge46.sink.split, %76
  ret i32 0
}

declare noundef zeroext i1 @_ZNSt8ios_base15sync_with_stdioEb(i1 noundef zeroext) local_unnamed_addr #1

; Function Attrs: mustprogress nounwind uwtable
declare noundef ptr @_ZNSt9basic_iosIcSt11char_traitsIcEE3tieEPSo(ptr noundef nonnull align 8 dereferenceable(264), ptr noundef) local_unnamed_addr #2 align 2

declare noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERi(ptr noundef nonnull align 8 dereferenceable(16), ptr noundef nonnull align 4 dereferenceable(4)) local_unnamed_addr #1

; Function Attrs: mustprogress uwtable
declare noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERx(ptr noundef nonnull align 8 dereferenceable(16), ptr noundef nonnull align 8 dereferenceable(8)) local_unnamed_addr #3 align 2

; Function Attrs: mustprogress uwtable
declare noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEx(ptr noundef nonnull align 8 dereferenceable(8), i64 noundef) local_unnamed_addr #3 align 2

; Function Attrs: mustprogress uwtable
declare noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEPFRSoS_E(ptr noundef nonnull align 8 dereferenceable(8), ptr noundef) local_unnamed_addr #3 align 2

; Function Attrs: inlinehint mustprogress uwtable
declare noundef nonnull align 8 dereferenceable(8) ptr @_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_(ptr noundef nonnull align 8 dereferenceable(8)) #4

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef nonnull align 8 dereferenceable(8) ptr @_ZSt3maxIxERKT_S2_S2_(ptr noundef nonnull align 8 dereferenceable(8), ptr noundef nonnull align 8 dereferenceable(8)) local_unnamed_addr #5

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef i64 @_ZSt5__gcdIxET_S0_S0_(i64 noundef, i64 noundef) local_unnamed_addr #2

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

!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 = !{!"vtable pointer", !7, i64 0}
!7 = !{!"Simple C++ TBAA"}
!8 = !{!9, !9, i64 0}
!9 = !{!"int", !10, i64 0}
!10 = !{!"omnipotent char", !7, i64 0}
!11 = distinct !{!11, !12}
!12 = !{!"llvm.loop.mustprogress"}
!13 = !{!14, !14, i64 0}
!14 = !{!"long long", !10, i64 0}
!15 = distinct !{!15, !12}
!16 = distinct !{!16, !12}
!17 = distinct !{!17, !12}


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