; LLVM IR from kazunetakahashi/atcoder :: 201610_12/1203_DDCC2016_final (B)

; 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" }
%"struct.std::_Setprecision" = type { i32 }

@R = external dso_local global double, align 8
@N = external dso_local global i32, align 4
@M = external dso_local global i32, align 4
@cuts = external dso_local global [1010 x double], align 16
@_ZSt3cin = external global %"class.std::basic_istream", align 8
@_ZSt4cerr = external global %"class.std::basic_ostream", align 8
@.str = external hidden unnamed_addr constant [2 x i8], align 1
@_ZSt4cout = external global %"class.std::basic_ostream", align 8

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef double @_Z3cuti(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 nounwind uwtable
declare dso_local noundef double @_Z3resi(i32 noundef) #0

; Function Attrs: mustprogress norecurse uwtable
define dso_local noundef i32 @main() #2 {
  %1 = alloca i32, align 4
  %2 = alloca i32, align 4
  %3 = alloca [1010 x i8], align 16
  %4 = alloca i8, align 1
  %5 = alloca i32, align 4
  %6 = alloca double, align 8
  %7 = alloca double, align 8
  %8 = alloca i32, align 4
  %9 = alloca i32, align 4
  %10 = alloca [2 x i32], align 4
  %11 = alloca i32, align 4
  %12 = alloca i32, align 4
  %13 = alloca i32, align 4
  %14 = alloca %"struct.std::_Setprecision", align 4
  store i32 0, ptr %1, align 4
  %15 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERd(ptr noundef nonnull align 8 dereferenceable(16) @_ZSt3cin, ptr noundef nonnull align 8 dereferenceable(8) @R)
  %16 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERi(ptr noundef nonnull align 8 dereferenceable(16) %15, ptr noundef nonnull align 4 dereferenceable(4) @N)
  %17 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERi(ptr noundef nonnull align 8 dereferenceable(16) %16, ptr noundef nonnull align 4 dereferenceable(4) @M)
  call void @llvm.lifetime.start.p0(i64 4, ptr %2) #7
  store i32 0, ptr %2, align 4, !tbaa !5
  br label %18

18:                                               ; preds = %29, %0
  %19 = load i32, ptr %2, align 4, !tbaa !5
  %20 = load i32, ptr @N, align 4, !tbaa !5
  %21 = icmp slt i32 %19, %20
  br i1 %21, label %23, label %22

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

23:                                               ; preds = %18
  %24 = load i32, ptr %2, align 4, !tbaa !5
  %25 = call noundef double @_Z3cuti(i32 noundef %24)
  %26 = load i32, ptr %2, align 4, !tbaa !5
  %27 = sext i32 %26 to i64
  %28 = getelementptr inbounds [1010 x double], ptr @cuts, i64 0, i64 %27
  store double %25, ptr %28, align 8, !tbaa !9
  br label %29

29:                                               ; preds = %23
  %30 = load i32, ptr %2, align 4, !tbaa !5
  %31 = add nsw i32 %30, 1
  store i32 %31, ptr %2, align 4, !tbaa !5
  br label %18, !llvm.loop !11

32:                                               ; preds = %22
  call void @llvm.lifetime.start.p0(i64 1010, ptr %3) #7
  %33 = getelementptr inbounds [1010 x i8], ptr %3, i64 0, i64 0
  %34 = getelementptr inbounds [1010 x i8], ptr %3, i64 0, i64 0
  %35 = getelementptr inbounds i8, ptr %34, i64 1010
  call void @llvm.lifetime.start.p0(i64 1, ptr %4) #7
  store i8 0, ptr %4, align 1, !tbaa !13
  call void @_ZSt4fillIPbbEvT_S1_RKT0_(ptr noundef %33, ptr noundef %35, ptr noundef nonnull align 1 dereferenceable(1) %4)
  call void @llvm.lifetime.end.p0(i64 1, ptr %4) #7
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #7
  store i32 0, ptr %5, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #7
  store double 0.000000e+00, ptr %6, align 8, !tbaa !9
  br label %36

36:                                               ; preds = %160, %32
  %37 = load i32, ptr %5, align 4, !tbaa !5
  %38 = load i32, ptr @N, align 4, !tbaa !5
  %39 = icmp slt i32 %37, %38
  br i1 %39, label %40, label %161

40:                                               ; preds = %36
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #7
  store double 0.000000e+00, ptr %7, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #7
  store i32 -1, ptr %8, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #7
  store i32 0, ptr %9, align 4, !tbaa !5
  br label %41

41:                                               ; preds = %62, %40
  %42 = load i32, ptr %9, align 4, !tbaa !5
  %43 = load i32, ptr @N, align 4, !tbaa !5
  %44 = icmp slt i32 %42, %43
  br i1 %44, label %46, label %45

45:                                               ; preds = %41
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #7
  br label %65

46:                                               ; preds = %41
  %47 = load i32, ptr %9, align 4, !tbaa !5
  %48 = sext i32 %47 to i64
  %49 = getelementptr inbounds [1010 x i8], ptr %3, i64 0, i64 %48
  %50 = load i8, ptr %49, align 1, !tbaa !13, !range !15, !noundef !16
  %51 = trunc i8 %50 to i1
  br i1 %51, label %61, label %52

52:                                               ; preds = %46
  %53 = load double, ptr %7, align 8, !tbaa !9
  %54 = load i32, ptr %9, align 4, !tbaa !5
  %55 = call noundef double @_Z3resi(i32 noundef %54)
  %56 = fcmp olt double %53, %55
  br i1 %56, label %57, label %61

57:                                               ; preds = %52
  %58 = load i32, ptr %9, align 4, !tbaa !5
  %59 = call noundef double @_Z3resi(i32 noundef %58)
  store double %59, ptr %7, align 8, !tbaa !9
  %60 = load i32, ptr %9, align 4, !tbaa !5
  store i32 %60, ptr %8, align 4, !tbaa !5
  br label %61

61:                                               ; preds = %57, %52, %46
  br label %62

62:                                               ; preds = %61
  %63 = load i32, ptr %9, align 4, !tbaa !5
  %64 = add nsw i32 %63, 1
  store i32 %64, ptr %9, align 4, !tbaa !5
  br label %41, !llvm.loop !17

65:                                               ; preds = %45
  %66 = load double, ptr %7, align 8, !tbaa !9
  %67 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEd(ptr noundef nonnull align 8 dereferenceable(8) @_ZSt4cerr, double noundef %66)
  %68 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc(ptr noundef nonnull align 8 dereferenceable(8) %67, ptr noundef @.str)
  %69 = load i32, ptr %8, align 4, !tbaa !5
  %70 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEi(ptr noundef nonnull align 8 dereferenceable(8) %68, i32 noundef %69)
  %71 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEPFRSoS_E(ptr noundef nonnull align 8 dereferenceable(8) %70, ptr noundef @_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_)
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #7
  %72 = load i32, ptr %8, align 4, !tbaa !5
  %73 = load i32, ptr @M, align 4, !tbaa !5
  %74 = sub nsw i32 %72, %73
  %75 = getelementptr inbounds [2 x i32], ptr %10, i64 0, i64 0
  store i32 %74, ptr %75, align 4, !tbaa !5
  %76 = load i32, ptr %8, align 4, !tbaa !5
  %77 = load i32, ptr @M, align 4, !tbaa !5
  %78 = add nsw i32 %76, %77
  %79 = getelementptr inbounds [2 x i32], ptr %10, i64 0, i64 1
  store i32 %78, ptr %79, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %11) #7
  store i32 0, ptr %11, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %12) #7
  store i32 0, ptr %12, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %13) #7
  store i32 0, ptr %13, align 4, !tbaa !5
  br label %80

80:                                               ; preds = %112, %65
  %81 = load i32, ptr %13, align 4, !tbaa !5
  %82 = icmp slt i32 %81, 2
  br i1 %82, label %84, label %83

83:                                               ; preds = %80
  call void @llvm.lifetime.end.p0(i64 4, ptr %13) #7
  br label %115

84:                                               ; preds = %80
  %85 = load i32, ptr %13, align 4, !tbaa !5
  %86 = sext i32 %85 to i64
  %87 = getelementptr inbounds [2 x i32], ptr %10, i64 0, i64 %86
  %88 = load i32, ptr %87, align 4, !tbaa !5
  %89 = icmp sle i32 %88, 0
  br i1 %89, label %97, label %90

90:                                               ; preds = %84
  %91 = load i32, ptr %13, align 4, !tbaa !5
  %92 = sext i32 %91 to i64
  %93 = getelementptr inbounds [2 x i32], ptr %10, i64 0, i64 %92
  %94 = load i32, ptr %93, align 4, !tbaa !5
  %95 = load i32, ptr @N, align 4, !tbaa !5
  %96 = icmp sge i32 %94, %95
  br i1 %96, label %97, label %98

97:                                               ; preds = %90, %84
  br label %112

98:                                               ; preds = %90
  %99 = load i32, ptr %13, align 4, !tbaa !5
  %100 = sext i32 %99 to i64
  %101 = getelementptr inbounds [2 x i32], ptr %10, i64 0, i64 %100
  %102 = load i32, ptr %101, align 4, !tbaa !5
  %103 = sext i32 %102 to i64
  %104 = getelementptr inbounds [1010 x i8], ptr %3, i64 0, i64 %103
  %105 = load i8, ptr %104, align 1, !tbaa !13, !range !15, !noundef !16
  %106 = trunc i8 %105 to i1
  br i1 %106, label %107, label %108

107:                                              ; preds = %98
  br label %112

108:                                              ; preds = %98
  %109 = load i32, ptr %13, align 4, !tbaa !5
  store i32 %109, ptr %12, align 4, !tbaa !5
  %110 = load i32, ptr %11, align 4, !tbaa !5
  %111 = add nsw i32 %110, 1
  store i32 %111, ptr %11, align 4, !tbaa !5
  br label %112

112:                                              ; preds = %108, %107, %97
  %113 = load i32, ptr %13, align 4, !tbaa !5
  %114 = add nsw i32 %113, 1
  store i32 %114, ptr %13, align 4, !tbaa !5
  br label %80, !llvm.loop !18

115:                                              ; preds = %83
  %116 = load i32, ptr %8, align 4, !tbaa !5
  %117 = call noundef double @_Z3resi(i32 noundef %116)
  %118 = load double, ptr %6, align 8, !tbaa !9
  %119 = fadd double %118, %117
  store double %119, ptr %6, align 8, !tbaa !9
  %120 = load i32, ptr %8, align 4, !tbaa !5
  %121 = sext i32 %120 to i64
  %122 = getelementptr inbounds [1010 x i8], ptr %3, i64 0, i64 %121
  store i8 1, ptr %122, align 1, !tbaa !13
  %123 = load i32, ptr %11, align 4, !tbaa !5
  %124 = icmp eq i32 %123, 0
  br i1 %124, label %125, label %128

125:                                              ; preds = %115
  %126 = load i32, ptr %5, align 4, !tbaa !5
  %127 = add nsw i32 %126, 1
  store i32 %127, ptr %5, align 4, !tbaa !5
  br label %160

128:                                              ; preds = %115
  %129 = load i32, ptr %11, align 4, !tbaa !5
  %130 = icmp eq i32 %129, 1
  br i1 %130, label %131, label %140

131:                                              ; preds = %128
  %132 = load i32, ptr %12, align 4, !tbaa !5
  %133 = sext i32 %132 to i64
  %134 = getelementptr inbounds [2 x i32], ptr %10, i64 0, i64 %133
  %135 = load i32, ptr %134, align 4, !tbaa !5
  %136 = sext i32 %135 to i64
  %137 = getelementptr inbounds [1010 x i8], ptr %3, i64 0, i64 %136
  store i8 1, ptr %137, align 1, !tbaa !13
  %138 = load i32, ptr %5, align 4, !tbaa !5
  %139 = add nsw i32 %138, 2
  store i32 %139, ptr %5, align 4, !tbaa !5
  br label %159

140:                                              ; preds = %128
  %141 = getelementptr inbounds [2 x i32], ptr %10, i64 0, i64 0
  %142 = load i32, ptr %141, align 4, !tbaa !5
  %143 = getelementptr inbounds [2 x i32], ptr %10, i64 0, i64 1
  %144 = load i32, ptr %143, align 4, !tbaa !5
  %145 = icmp slt i32 %142, %144
  br i1 %145, label %146, label %151

146:                                              ; preds = %140
  %147 = getelementptr inbounds [2 x i32], ptr %10, i64 0, i64 1
  %148 = load i32, ptr %147, align 4, !tbaa !5
  %149 = sext i32 %148 to i64
  %150 = getelementptr inbounds [1010 x i8], ptr %3, i64 0, i64 %149
  store i8 1, ptr %150, align 1, !tbaa !13
  br label %156

151:                                              ; preds = %140
  %152 = getelementptr inbounds [2 x i32], ptr %10, i64 0, i64 0
  %153 = load i32, ptr %152, align 4, !tbaa !5
  %154 = sext i32 %153 to i64
  %155 = getelementptr inbounds [1010 x i8], ptr %3, i64 0, i64 %154
  store i8 1, ptr %155, align 1, !tbaa !13
  br label %156

156:                                              ; preds = %151, %146
  %157 = load i32, ptr %5, align 4, !tbaa !5
  %158 = add nsw i32 %157, 2
  store i32 %158, ptr %5, align 4, !tbaa !5
  br label %159

159:                                              ; preds = %156, %131
  br label %160

160:                                              ; preds = %159, %125
  call void @llvm.lifetime.end.p0(i64 4, ptr %12) #7
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #7
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #7
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #7
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #7
  br label %36, !llvm.loop !19

161:                                              ; preds = %36
  %162 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEPFRSt8ios_baseS0_E(ptr noundef nonnull align 8 dereferenceable(8) @_ZSt4cout, ptr noundef @_ZSt5fixedRSt8ios_base)
  %163 = call i32 @_ZSt12setprecisioni(i32 noundef 12)
  %164 = getelementptr inbounds %"struct.std::_Setprecision", ptr %14, i32 0, i32 0
  store i32 %163, ptr %164, align 4
  %165 = getelementptr inbounds %"struct.std::_Setprecision", ptr %14, i32 0, i32 0
  %166 = load i32, ptr %165, align 4
  %167 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZStlsIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_St13_Setprecision(ptr noundef nonnull align 8 dereferenceable(8) %162, i32 %166)
  %168 = load double, ptr %6, align 8, !tbaa !9
  %169 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEd(ptr noundef nonnull align 8 dereferenceable(8) %167, double noundef %168)
  %170 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEPFRSoS_E(ptr noundef nonnull align 8 dereferenceable(8) %169, ptr noundef @_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_)
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #7
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #7
  call void @llvm.lifetime.end.p0(i64 1010, ptr %3) #7
  %171 = load i32, ptr %1, align 4
  ret i32 %171
}

; Function Attrs: mustprogress uwtable
declare noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERd(ptr noundef nonnull align 8 dereferenceable(16), ptr noundef nonnull align 8 dereferenceable(8)) #3 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)) #4

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local void @_ZSt4fillIPbbEvT_S1_RKT0_(ptr noundef, ptr noundef, ptr noundef nonnull align 1 dereferenceable(1)) #5

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

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

declare noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEi(ptr noundef nonnull align 8 dereferenceable(8), i32 noundef) #4

; Function Attrs: mustprogress uwtable
declare noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEPFRSoS_E(ptr noundef nonnull align 8 dereferenceable(8), ptr noundef) #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)) #5

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

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

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

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local i32 @_ZSt12setprecisioni(i32 noundef) #6

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

@R = external dso_local global double, align 8
@N = external dso_local global i32, align 4
@M = external dso_local global i32, align 4
@cuts = external dso_local local_unnamed_addr global [1010 x double], align 16
@_ZSt3cin = external global %"class.std::basic_istream", align 8
@_ZSt4cerr = external global %"class.std::basic_ostream", align 8
@.str = external hidden unnamed_addr constant [2 x i8], align 1
@_ZSt4cout = external global %"class.std::basic_ostream", align 8

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

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

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

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

; Function Attrs: mustprogress norecurse uwtable
define dso_local noundef i32 @main() local_unnamed_addr #2 {
  %1 = alloca [1010 x i8], align 16
  %2 = alloca i8, align 1
  %3 = alloca [2 x i32], align 4
  %4 = tail call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERd(ptr noundef nonnull align 8 dereferenceable(16) @_ZSt3cin, ptr noundef nonnull align 8 dereferenceable(8) @R)
  %5 = tail call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERi(ptr noundef nonnull align 8 dereferenceable(16) %4, ptr noundef nonnull align 4 dereferenceable(4) @N)
  %6 = tail call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERi(ptr noundef nonnull align 8 dereferenceable(16) %5, ptr noundef nonnull align 4 dereferenceable(4) @M)
  %7 = load i32, ptr @N, align 4, !tbaa !5
  %8 = icmp sgt i32 %7, 0
  br i1 %8, label %.lr.ph, label %._crit_edge

._crit_edge:                                      ; preds = %.lr.ph, %0
  call void @llvm.lifetime.start.p0(i64 1010, ptr nonnull %1) #8
  %9 = getelementptr inbounds i8, ptr %1, i64 1010
  call void @llvm.lifetime.start.p0(i64 1, ptr nonnull %2) #8
  store i8 0, ptr %2, align 1, !tbaa !9
  call void @_ZSt4fillIPbbEvT_S1_RKT0_(ptr noundef nonnull %1, ptr noundef nonnull %9, ptr noundef nonnull align 1 dereferenceable(1) %2)
  call void @llvm.lifetime.end.p0(i64 1, ptr nonnull %2) #8
  %10 = load i32, ptr @N, align 4, !tbaa !5
  %11 = icmp sgt i32 %10, 0
  br i1 %11, label %.preheader.lr.ph, label %._crit_edge61

.preheader.lr.ph:                                 ; preds = %._crit_edge
  %12 = getelementptr inbounds i8, ptr %3, i64 4
  br label %.preheader

.lr.ph:                                           ; preds = %0, %.lr.ph
  %indvars.iv = phi i64 [ %indvars.iv.next, %.lr.ph ], [ 0, %0 ]
  %13 = trunc nuw nsw i64 %indvars.iv to i32
  %14 = tail call noundef double @_Z3cuti(i32 noundef %13)
  %15 = getelementptr inbounds [1010 x double], ptr @cuts, i64 0, i64 %indvars.iv
  store double %14, ptr %15, align 8, !tbaa !11
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %16 = load i32, ptr @N, align 4, !tbaa !5
  %17 = sext i32 %16 to i64
  %18 = icmp slt i64 %indvars.iv.next, %17
  br i1 %18, label %.lr.ph, label %._crit_edge, !llvm.loop !13

.preheader:                                       ; preds = %.preheader.lr.ph, %67
  %19 = phi i32 [ %10, %.preheader.lr.ph ], [ %69, %67 ]
  %.04260 = phi double [ 0.000000e+00, %.preheader.lr.ph ], [ %58, %67 ]
  %.04359 = phi i32 [ 0, %.preheader.lr.ph ], [ %68, %67 ]
  %20 = icmp sgt i32 %19, 0
  br i1 %20, label %.lr.ph53, label %._crit_edge54

._crit_edge54:                                    ; preds = %39, %.preheader
  %.040.lcssa = phi double [ 0.000000e+00, %.preheader ], [ %.141, %39 ]
  %.038.lcssa = phi i32 [ -1, %.preheader ], [ %.139, %39 ]
  %21 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEd(ptr noundef nonnull align 8 dereferenceable(8) @_ZSt4cerr, double noundef %.040.lcssa)
  %22 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc(ptr noundef nonnull align 8 dereferenceable(8) %21, ptr noundef nonnull @.str)
  %23 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEi(ptr noundef nonnull align 8 dereferenceable(8) %22, i32 noundef %.038.lcssa)
  %24 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEPFRSoS_E(ptr noundef nonnull align 8 dereferenceable(8) %23, ptr noundef nonnull @_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_)
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %3) #8
  %25 = load i32, ptr @M, align 4, !tbaa !5
  %26 = sub nsw i32 %.038.lcssa, %25
  store i32 %26, ptr %3, align 4, !tbaa !5
  %27 = add nsw i32 %25, %.038.lcssa
  store i32 %27, ptr %12, align 4, !tbaa !5
  %28 = load i32, ptr @N, align 4
  %29 = icmp sgt i32 %26, 0
  %.not = icmp slt i32 %26, %28
  %or.cond = select i1 %29, i1 %.not, i1 false
  br i1 %or.cond, label %43, label %48

.lr.ph53:                                         ; preds = %.preheader, %39
  %indvars.iv64 = phi i64 [ %indvars.iv.next65, %39 ], [ 0, %.preheader ]
  %.03851 = phi i32 [ %.139, %39 ], [ -1, %.preheader ]
  %.04050 = phi double [ %.141, %39 ], [ 0.000000e+00, %.preheader ]
  %30 = getelementptr inbounds [1010 x i8], ptr %1, i64 0, i64 %indvars.iv64
  %31 = load i8, ptr %30, align 1, !tbaa !9, !range !15, !noundef !16
  %32 = trunc nuw i8 %31 to i1
  br i1 %32, label %39, label %33

33:                                               ; preds = %.lr.ph53
  %34 = trunc nuw nsw i64 %indvars.iv64 to i32
  %35 = call noundef double @_Z3resi(i32 noundef %34)
  %36 = fcmp olt double %.04050, %35
  br i1 %36, label %37, label %39

37:                                               ; preds = %33
  %38 = call noundef double @_Z3resi(i32 noundef %34)
  br label %39

39:                                               ; preds = %.lr.ph53, %33, %37
  %.141 = phi double [ %.04050, %.lr.ph53 ], [ %38, %37 ], [ %.04050, %33 ]
  %.139 = phi i32 [ %.03851, %.lr.ph53 ], [ %34, %37 ], [ %.03851, %33 ]
  %indvars.iv.next65 = add nuw nsw i64 %indvars.iv64, 1
  %40 = load i32, ptr @N, align 4, !tbaa !5
  %41 = sext i32 %40 to i64
  %42 = icmp slt i64 %indvars.iv.next65, %41
  br i1 %42, label %.lr.ph53, label %._crit_edge54, !llvm.loop !17

43:                                               ; preds = %._crit_edge54
  %44 = zext nneg i32 %26 to i64
  %45 = getelementptr inbounds [1010 x i8], ptr %1, i64 0, i64 %44
  %46 = load i8, ptr %45, align 1, !tbaa !9, !range !15, !noundef !16
  %47 = xor i8 %46, 1
  %not. = zext nneg i8 %47 to i32
  br label %48

48:                                               ; preds = %43, %._crit_edge54
  %.136 = phi i32 [ 0, %._crit_edge54 ], [ %not., %43 ]
  %49 = icmp sgt i32 %27, 0
  %.not.1 = icmp slt i32 %27, %28
  %or.cond.1 = select i1 %49, i1 %.not.1, i1 false
  br i1 %or.cond.1, label %50, label %56

50:                                               ; preds = %48
  %51 = zext nneg i32 %27 to i64
  %52 = getelementptr inbounds [1010 x i8], ptr %1, i64 0, i64 %51
  %53 = load i8, ptr %52, align 1, !tbaa !9, !range !15, !noundef !16
  %54 = trunc nuw i8 %53 to i1
  %not..1 = xor i1 %54, true
  %55 = zext i1 %not..1 to i32
  %spec.select.1 = add nuw nsw i32 %.136, %55
  %not.70 = xor i1 %54, true
  %spec.select48.1 = zext i1 %not.70 to i64
  br label %56

56:                                               ; preds = %50, %48
  %.136.1 = phi i32 [ %.136, %48 ], [ %spec.select.1, %50 ]
  %.1.1 = phi i64 [ 0, %48 ], [ %spec.select48.1, %50 ]
  %57 = call noundef double @_Z3resi(i32 noundef %.038.lcssa)
  %58 = fadd double %.04260, %57
  %59 = sext i32 %.038.lcssa to i64
  %60 = getelementptr inbounds [1010 x i8], ptr %1, i64 0, i64 %59
  store i8 1, ptr %60, align 1, !tbaa !9
  switch i32 %.136.1, label %64 [
    i32 0, label %67
    i32 1, label %61
  ]

61:                                               ; preds = %56
  %62 = getelementptr inbounds [2 x i32], ptr %3, i64 0, i64 %.1.1
  %63 = load i32, ptr %62, align 4, !tbaa !5
  br label %.sink.split

64:                                               ; preds = %56
  %. = call i32 @llvm.smax.i32(i32 %26, i32 %27)
  br label %.sink.split

.sink.split:                                      ; preds = %64, %61
  %.sink = phi i32 [ %63, %61 ], [ %., %64 ]
  %65 = sext i32 %.sink to i64
  %66 = getelementptr inbounds [1010 x i8], ptr %1, i64 0, i64 %65
  store i8 1, ptr %66, align 1, !tbaa !9
  br label %67

67:                                               ; preds = %.sink.split, %56
  %.sink72 = phi i32 [ 1, %56 ], [ 2, %.sink.split ]
  %68 = add nuw nsw i32 %.04359, %.sink72
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %3) #8
  %69 = load i32, ptr @N, align 4, !tbaa !5
  %70 = icmp slt i32 %68, %69
  br i1 %70, label %.preheader, label %._crit_edge61, !llvm.loop !18

._crit_edge61:                                    ; preds = %67, %._crit_edge
  %.042.lcssa = phi double [ 0.000000e+00, %._crit_edge ], [ %58, %67 ]
  %71 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEPFRSt8ios_baseS0_E(ptr noundef nonnull align 8 dereferenceable(8) @_ZSt4cout, ptr noundef nonnull @_ZSt5fixedRSt8ios_base)
  %72 = call i32 @_ZSt12setprecisioni(i32 noundef 12)
  %73 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZStlsIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_St13_Setprecision(ptr noundef nonnull align 8 dereferenceable(8) %71, i32 %72)
  %74 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEd(ptr noundef nonnull align 8 dereferenceable(8) %73, double noundef %.042.lcssa)
  %75 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEPFRSoS_E(ptr noundef nonnull align 8 dereferenceable(8) %74, ptr noundef nonnull @_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_)
  call void @llvm.lifetime.end.p0(i64 1010, ptr nonnull %1) #8
  ret i32 0
}

; Function Attrs: mustprogress uwtable
declare noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERd(ptr noundef nonnull align 8 dereferenceable(16), ptr noundef nonnull align 8 dereferenceable(8)) local_unnamed_addr #3 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 #4

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local void @_ZSt4fillIPbbEvT_S1_RKT0_(ptr noundef, ptr noundef, ptr noundef nonnull align 1 dereferenceable(1)) local_unnamed_addr #5

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

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

declare noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEi(ptr noundef nonnull align 8 dereferenceable(8), i32 noundef) local_unnamed_addr #4

; 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)) #5

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

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

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

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local i32 @_ZSt12setprecisioni(i32 noundef) local_unnamed_addr #6

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

attributes #0 = { 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 #1 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 = { 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 = { "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 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #8 = { 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 = !{!12, !12, i64 0}
!12 = !{!"double", !7, i64 0}
!13 = distinct !{!13, !14}
!14 = !{!"llvm.loop.mustprogress"}
!15 = !{i8 0, i8 2}
!16 = !{}
!17 = distinct !{!17, !14}
!18 = distinct !{!18, !14}


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