; LLVM IR from tangjz/acm-icpc :: hdu (6037)

; Unoptimized IR (clang -disable-llvm-passes):
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128"
target triple = "x86_64-unknown-linux-gnu"

%"struct.fastIO::Ostream_fwrite" = type { ptr, ptr, ptr }
%struct.FracExp = type { i32, [19 x i32] }
%"struct.int128_t::BigInt" = type { i64, i64 }

@_ZN6fastIO7IOerrorE = external dso_local global i8, align 1
@_ZN6fastIO7OstreamE = external dso_local global %"struct.fastIO::Ostream_fwrite", align 8
@cur = external dso_local global %struct.FracExp, align 4
@f = external dso_local global [172513 x double], align 16
@.str = external hidden unnamed_addr constant [11 x i8], align 1

; Function Attrs: mustprogress uwtable
declare dso_local noundef i32 @_Z3dfsN8int128_t6BigIntEi(i64, i64, 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 norecurse uwtable
define dso_local noundef i32 @main() #2 {
  %1 = alloca i32, align 4
  %2 = alloca %"struct.int128_t::BigInt", align 8
  %3 = alloca i32, align 4
  %4 = alloca [19 x i32], align 16
  %5 = alloca [33 x i8], align 16
  %6 = alloca i32, align 4
  %7 = alloca i32, align 4
  %8 = alloca i32, align 4
  %9 = alloca i32, align 4
  %10 = alloca %"struct.int128_t::BigInt", align 8
  %11 = alloca %"struct.int128_t::BigInt", align 8
  store i32 0, ptr %1, align 4
  call void @llvm.lifetime.start.p0(i64 16, ptr %2) #7
  call void @_ZN8int128_t6BigIntC2Ev(ptr noundef nonnull align 8 dereferenceable(16) %2)
  call void @llvm.lifetime.start.p0(i64 4, ptr %3) #7
  call void @llvm.lifetime.start.p0(i64 76, ptr %4) #7
  call void @llvm.lifetime.start.p0(i64 33, ptr %5) #7
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #7
  store i32 1, ptr %6, align 4, !tbaa !5
  br label %12

12:                                               ; preds = %55, %0
  call void @_ZN6fastIO4readIN8int128_t6BigIntEEEvRT_(ptr noundef nonnull align 8 dereferenceable(16) %2)
  call void @_ZN6fastIO4readIiEEvRT_(ptr noundef nonnull align 4 dereferenceable(4) %3)
  %13 = load i8, ptr @_ZN6fastIO7IOerrorE, align 1, !tbaa !9, !range !11, !noundef !12
  %14 = trunc i8 %13 to i1
  %15 = xor i1 %14, true
  br i1 %15, label %17, label %16

16:                                               ; preds = %12
  store i32 2, ptr %7, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #7
  br label %58

17:                                               ; preds = %12
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #7
  store i32 0, ptr %8, align 4, !tbaa !5
  br label %18

18:                                               ; preds = %27, %17
  %19 = load i32, ptr %8, align 4, !tbaa !5
  %20 = load i32, ptr %3, align 4, !tbaa !5
  %21 = icmp slt i32 %19, %20
  br i1 %21, label %23, label %22

22:                                               ; preds = %18
  store i32 5, ptr %7, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #7
  br label %30

23:                                               ; preds = %18
  %24 = load i32, ptr %8, align 4, !tbaa !5
  %25 = sext i32 %24 to i64
  %26 = getelementptr inbounds [19 x i32], ptr %4, i64 0, i64 %25
  call void @_ZN6fastIO4readIiEEvRT_(ptr noundef nonnull align 4 dereferenceable(4) %26)
  br label %27

27:                                               ; preds = %23
  %28 = load i32, ptr %8, align 4, !tbaa !5
  %29 = add nsw i32 %28, 1
  store i32 %29, ptr %8, align 4, !tbaa !5
  br label %18, !llvm.loop !13

30:                                               ; preds = %22
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #7
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %10, ptr align 8 %2, i64 16, i1 false), !tbaa.struct !15
  %31 = load i32, ptr %3, align 4, !tbaa !5
  %32 = getelementptr inbounds [19 x i32], ptr %4, i64 0, i64 0
  %33 = getelementptr inbounds { i64, i64 }, ptr %10, i32 0, i32 0
  %34 = load i64, ptr %33, align 8
  %35 = getelementptr inbounds { i64, i64 }, ptr %10, i32 0, i32 1
  %36 = load i64, ptr %35, align 8
  %37 = call noundef i32 @_ZN7FracExp5parseEN8int128_t6BigIntEiPi(ptr noundef nonnull align 4 dereferenceable(80) @cur, i64 %34, i64 %36, i32 noundef %31, ptr noundef %32)
  store i32 %37, ptr %9, align 4, !tbaa !5
  %38 = getelementptr inbounds [33 x i8], ptr %5, i64 0, i64 0
  %39 = load i32, ptr %6, align 4, !tbaa !5
  %40 = call i32 (ptr, ptr, ...) @sprintf(ptr noundef %38, ptr noundef @.str, i32 noundef %39) #7
  %41 = getelementptr inbounds [33 x i8], ptr %5, i64 0, i64 0
  call void @_ZN6fastIO14Ostream_fwrite5printEPc(ptr noundef nonnull align 8 dereferenceable(24) @_ZN6fastIO7OstreamE, ptr noundef %41)
  %42 = call { i64, i64 } @_ZNK7FracExp5valueEv(ptr noundef nonnull align 4 dereferenceable(80) @cur)
  %43 = getelementptr inbounds { i64, i64 }, ptr %11, i32 0, i32 0
  %44 = extractvalue { i64, i64 } %42, 0
  store i64 %44, ptr %43, align 8
  %45 = getelementptr inbounds { i64, i64 }, ptr %11, i32 0, i32 1
  %46 = extractvalue { i64, i64 } %42, 1
  store i64 %46, ptr %45, align 8
  %47 = load i32, ptr %9, align 4, !tbaa !5
  %48 = getelementptr inbounds { i64, i64 }, ptr %11, i32 0, i32 0
  %49 = load i64, ptr %48, align 8
  %50 = getelementptr inbounds { i64, i64 }, ptr %11, i32 0, i32 1
  %51 = load i64, ptr %50, align 8
  %52 = call noundef i32 @_Z3dfsN8int128_t6BigIntEi(i64 %49, i64 %51, i32 noundef %47)
  %53 = sext i32 %52 to i64
  %54 = getelementptr inbounds [172513 x double], ptr @f, i64 0, i64 %53
  call void @_ZN6fastIO7printlnIdEEvRKT_(ptr noundef nonnull align 8 dereferenceable(8) %54)
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #7
  br label %55

55:                                               ; preds = %30
  %56 = load i32, ptr %6, align 4, !tbaa !5
  %57 = add nsw i32 %56, 1
  store i32 %57, ptr %6, align 4, !tbaa !5
  br label %12, !llvm.loop !18

58:                                               ; preds = %16
  store i32 0, ptr %1, align 4
  store i32 1, ptr %7, align 4
  call void @llvm.lifetime.end.p0(i64 33, ptr %5) #7
  call void @llvm.lifetime.end.p0(i64 76, ptr %4) #7
  call void @llvm.lifetime.end.p0(i64 4, ptr %3) #7
  call void @llvm.lifetime.end.p0(i64 16, ptr %2) #7
  %59 = load i32, ptr %1, align 4
  ret i32 %59
}

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZN8int128_t6BigIntC2Ev(ptr noundef nonnull align 8 dereferenceable(16)) unnamed_addr #3 align 2

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local void @_ZN6fastIO4readIN8int128_t6BigIntEEEvRT_(ptr noundef nonnull align 8 dereferenceable(16)) #4

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local void @_ZN6fastIO4readIiEEvRT_(ptr noundef nonnull align 4 dereferenceable(4)) #4

; Function Attrs: mustprogress uwtable
declare dso_local noundef i32 @_ZN7FracExp5parseEN8int128_t6BigIntEiPi(ptr noundef nonnull align 4 dereferenceable(80), i64, i64, i32 noundef, ptr noundef) #0 align 2

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: readwrite)
declare void @llvm.memcpy.p0.p0.i64(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i64, i1 immarg) #5

; Function Attrs: nounwind
declare i32 @sprintf(ptr noundef, ptr noundef, ...) #6

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN6fastIO14Ostream_fwrite5printEPc(ptr noundef nonnull align 8 dereferenceable(24), ptr noundef) #0 align 2

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

; Function Attrs: mustprogress uwtable
declare dso_local { i64, i64 } @_ZNK7FracExp5valueEv(ptr noundef nonnull align 4 dereferenceable(80)) #0 align 2

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 = { 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 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 #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 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #6 = { nounwind "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #7 = { 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 = !{i8 0, i8 2}
!12 = !{}
!13 = distinct !{!13, !14}
!14 = !{!"llvm.loop.mustprogress"}
!15 = !{i64 0, i64 8, !16, i64 8, i64 8, !16}
!16 = !{!17, !17, i64 0}
!17 = !{!"long long", !7, i64 0}
!18 = distinct !{!18, !14}


; Optimized IR (opt -passes='default<O3>'):
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128"
target triple = "x86_64-unknown-linux-gnu"

%"struct.fastIO::Ostream_fwrite" = type { ptr, ptr, ptr }
%struct.FracExp = type { i32, [19 x i32] }
%"struct.int128_t::BigInt" = type { i64, i64 }

@_ZN6fastIO7IOerrorE = external dso_local local_unnamed_addr global i8, align 1
@_ZN6fastIO7OstreamE = external dso_local global %"struct.fastIO::Ostream_fwrite", align 8
@cur = external dso_local global %struct.FracExp, align 4
@f = external dso_local global [172513 x double], align 16
@.str = external hidden unnamed_addr constant [11 x i8], align 1

; Function Attrs: mustprogress uwtable
declare dso_local noundef i32 @_Z3dfsN8int128_t6BigIntEi(i64, i64, 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 norecurse uwtable
define dso_local noundef i32 @main() local_unnamed_addr #2 {
  %1 = alloca %"struct.int128_t::BigInt", align 8
  %2 = alloca i32, align 4
  %3 = alloca [19 x i32], align 16
  %4 = alloca [33 x i8], align 16
  call void @llvm.lifetime.start.p0(i64 16, ptr nonnull %1) #6
  call void @_ZN8int128_t6BigIntC2Ev(ptr noundef nonnull align 8 dereferenceable(16) %1)
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %2) #6
  call void @llvm.lifetime.start.p0(i64 76, ptr nonnull %3) #6
  call void @llvm.lifetime.start.p0(i64 33, ptr nonnull %4) #6
  call void @_ZN6fastIO4readIN8int128_t6BigIntEEEvRT_(ptr noundef nonnull align 8 dereferenceable(16) %1)
  call void @_ZN6fastIO4readIiEEvRT_(ptr noundef nonnull align 4 dereferenceable(4) %2)
  %5 = load i8, ptr @_ZN6fastIO7IOerrorE, align 1, !tbaa !5, !range !9, !noundef !10
  %6 = trunc nuw i8 %5 to i1
  br i1 %6, label %._crit_edge13, label %.preheader.lr.ph

.preheader.lr.ph:                                 ; preds = %0
  %.sroa.22.0..sroa_idx = getelementptr inbounds i8, ptr %1, i64 8
  br label %.preheader

.preheader:                                       ; preds = %.preheader.lr.ph, %._crit_edge
  %.012 = phi i32 [ 1, %.preheader.lr.ph ], [ %17, %._crit_edge ]
  %7 = load i32, ptr %2, align 4, !tbaa !11
  %8 = icmp sgt i32 %7, 0
  br i1 %8, label %.lr.ph, label %._crit_edge

._crit_edge13:                                    ; preds = %._crit_edge, %0
  call void @llvm.lifetime.end.p0(i64 33, ptr nonnull %4) #6
  call void @llvm.lifetime.end.p0(i64 76, ptr nonnull %3) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %2) #6
  call void @llvm.lifetime.end.p0(i64 16, ptr nonnull %1) #6
  ret i32 0

._crit_edge:                                      ; preds = %.lr.ph, %.preheader
  %.lcssa = phi i32 [ %7, %.preheader ], [ %21, %.lr.ph ]
  %.sroa.01.0.copyload = load i64, ptr %1, align 8, !tbaa !13
  %.sroa.22.0.copyload = load i64, ptr %.sroa.22.0..sroa_idx, align 8, !tbaa !13
  %9 = call noundef i32 @_ZN7FracExp5parseEN8int128_t6BigIntEiPi(ptr noundef nonnull align 4 dereferenceable(80) @cur, i64 %.sroa.01.0.copyload, i64 %.sroa.22.0.copyload, i32 noundef %.lcssa, ptr noundef nonnull %3)
  %10 = call i32 (ptr, ptr, ...) @sprintf(ptr noundef nonnull dereferenceable(1) %4, ptr noundef nonnull dereferenceable(1) @.str, i32 noundef %.012) #6
  call void @_ZN6fastIO14Ostream_fwrite5printEPc(ptr noundef nonnull align 8 dereferenceable(24) @_ZN6fastIO7OstreamE, ptr noundef nonnull %4)
  %11 = call { i64, i64 } @_ZNK7FracExp5valueEv(ptr noundef nonnull align 4 dereferenceable(80) @cur)
  %12 = extractvalue { i64, i64 } %11, 0
  %13 = extractvalue { i64, i64 } %11, 1
  %14 = call noundef i32 @_Z3dfsN8int128_t6BigIntEi(i64 %12, i64 %13, i32 noundef %9)
  %15 = sext i32 %14 to i64
  %16 = getelementptr inbounds [172513 x double], ptr @f, i64 0, i64 %15
  call void @_ZN6fastIO7printlnIdEEvRKT_(ptr noundef nonnull align 8 dereferenceable(8) %16)
  %17 = add nuw nsw i32 %.012, 1
  call void @_ZN6fastIO4readIN8int128_t6BigIntEEEvRT_(ptr noundef nonnull align 8 dereferenceable(16) %1)
  call void @_ZN6fastIO4readIiEEvRT_(ptr noundef nonnull align 4 dereferenceable(4) %2)
  %18 = load i8, ptr @_ZN6fastIO7IOerrorE, align 1, !tbaa !5, !range !9, !noundef !10
  %19 = trunc nuw i8 %18 to i1
  br i1 %19, label %._crit_edge13, label %.preheader, !llvm.loop !15

.lr.ph:                                           ; preds = %.preheader, %.lr.ph
  %indvars.iv = phi i64 [ %indvars.iv.next, %.lr.ph ], [ 0, %.preheader ]
  %20 = getelementptr inbounds [19 x i32], ptr %3, i64 0, i64 %indvars.iv
  call void @_ZN6fastIO4readIiEEvRT_(ptr noundef nonnull align 4 dereferenceable(4) %20)
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %21 = load i32, ptr %2, align 4, !tbaa !11
  %22 = sext i32 %21 to i64
  %23 = icmp slt i64 %indvars.iv.next, %22
  br i1 %23, label %.lr.ph, label %._crit_edge, !llvm.loop !17
}

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZN8int128_t6BigIntC2Ev(ptr noundef nonnull align 8 dereferenceable(16)) unnamed_addr #3 align 2

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local void @_ZN6fastIO4readIN8int128_t6BigIntEEEvRT_(ptr noundef nonnull align 8 dereferenceable(16)) local_unnamed_addr #4

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local void @_ZN6fastIO4readIiEEvRT_(ptr noundef nonnull align 4 dereferenceable(4)) local_unnamed_addr #4

; Function Attrs: mustprogress uwtable
declare dso_local noundef i32 @_ZN7FracExp5parseEN8int128_t6BigIntEiPi(ptr noundef nonnull align 4 dereferenceable(80), i64, i64, i32 noundef, ptr noundef) local_unnamed_addr #0 align 2

; Function Attrs: nofree nounwind
declare noundef i32 @sprintf(ptr noalias nocapture noundef writeonly, ptr nocapture noundef readonly, ...) local_unnamed_addr #5

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN6fastIO14Ostream_fwrite5printEPc(ptr noundef nonnull align 8 dereferenceable(24), ptr noundef) local_unnamed_addr #0 align 2

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local void @_ZN6fastIO7printlnIdEEvRKT_(ptr noundef nonnull align 8 dereferenceable(8)) local_unnamed_addr #4

; Function Attrs: mustprogress uwtable
declare dso_local { i64, i64 } @_ZNK7FracExp5valueEv(ptr noundef nonnull align 4 dereferenceable(80)) local_unnamed_addr #0 align 2

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


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