; LLVM IR from tangjz/acm-icpc :: 51nod (1379)

; 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
@len = external dso_local global i32, align 4
@fib = external dso_local global [91 x i64], align 16
@n = external dso_local global i64, align 8
@.str = external hidden unnamed_addr constant [3 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [5 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [4 x i8], align 1

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef i32 @_Z7mod_powii(i32 noundef, 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 i32, align 4
  %3 = alloca i32, align 4
  store i32 0, ptr %1, align 4
  store i64 1, ptr getelementptr inbounds ([91 x i64], ptr @fib, i64 0, i64 1), align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %2) #6
  store i32 2, ptr %2, align 4, !tbaa !9
  br label %4

4:                                                ; preds = %23, %0
  %5 = load i32, ptr %2, align 4, !tbaa !9
  %6 = icmp slt i32 %5, 91
  br i1 %6, label %8, label %7

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

8:                                                ; preds = %4
  %9 = load i32, ptr %2, align 4, !tbaa !9
  %10 = sub nsw i32 %9, 1
  %11 = sext i32 %10 to i64
  %12 = getelementptr inbounds [91 x i64], ptr @fib, i64 0, i64 %11
  %13 = load i64, ptr %12, align 8, !tbaa !5
  %14 = load i32, ptr %2, align 4, !tbaa !9
  %15 = sub nsw i32 %14, 2
  %16 = sext i32 %15 to i64
  %17 = getelementptr inbounds [91 x i64], ptr @fib, i64 0, i64 %16
  %18 = load i64, ptr %17, align 8, !tbaa !5
  %19 = add nsw i64 %13, %18
  %20 = load i32, ptr %2, align 4, !tbaa !9
  %21 = sext i32 %20 to i64
  %22 = getelementptr inbounds [91 x i64], ptr @fib, i64 0, i64 %21
  store i64 %19, ptr %22, align 8, !tbaa !5
  br label %23

23:                                               ; preds = %8
  %24 = load i32, ptr %2, align 4, !tbaa !9
  %25 = add nsw i32 %24, 1
  store i32 %25, ptr %2, align 4, !tbaa !9
  br label %4, !llvm.loop !11

26:                                               ; preds = %7
  call void @llvm.lifetime.start.p0(i64 4, ptr %3) #6
  store i32 2, ptr %3, align 4, !tbaa !9
  br label %27

27:                                               ; preds = %42, %26
  %28 = load i32, ptr %3, align 4, !tbaa !9
  %29 = icmp slt i32 %28, 91
  br i1 %29, label %31, label %30

30:                                               ; preds = %27
  call void @llvm.lifetime.end.p0(i64 4, ptr %3) #6
  br label %45

31:                                               ; preds = %27
  %32 = load i32, ptr %3, align 4, !tbaa !9
  %33 = sub nsw i32 %32, 1
  %34 = sext i32 %33 to i64
  %35 = getelementptr inbounds [91 x i64], ptr @fib, i64 0, i64 %34
  %36 = load i64, ptr %35, align 8, !tbaa !5
  %37 = load i32, ptr %3, align 4, !tbaa !9
  %38 = sext i32 %37 to i64
  %39 = getelementptr inbounds [91 x i64], ptr @fib, i64 0, i64 %38
  %40 = load i64, ptr %39, align 8, !tbaa !5
  %41 = or i64 %40, %36
  store i64 %41, ptr %39, align 8, !tbaa !5
  br label %42

42:                                               ; preds = %31
  %43 = load i32, ptr %3, align 4, !tbaa !9
  %44 = add nsw i32 %43, 1
  store i32 %44, ptr %3, align 4, !tbaa !9
  br label %27, !llvm.loop !13

45:                                               ; preds = %30
  %46 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str, ptr noundef @t)
  br label %47

47:                                               ; preds = %79, %45
  %48 = load i32, ptr @t, align 4, !tbaa !9
  %49 = add nsw i32 %48, -1
  store i32 %49, ptr @t, align 4, !tbaa !9
  %50 = icmp ne i32 %48, 0
  br i1 %50, label %51, label %80

51:                                               ; preds = %47
  %52 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str.1, ptr noundef @n)
  %53 = load i64, ptr @n, align 8, !tbaa !5
  %54 = icmp slt i64 %53, 91
  br i1 %54, label %55, label %62

55:                                               ; preds = %51
  %56 = load i64, ptr @n, align 8, !tbaa !5
  %57 = getelementptr inbounds [91 x i64], ptr @fib, i64 0, i64 %56
  %58 = load i64, ptr %57, align 8, !tbaa !5
  %59 = srem i64 %58, 1000000007
  %60 = trunc i64 %59 to i32
  %61 = call i32 (ptr, ...) @printf(ptr noundef @.str.2, i32 noundef %60)
  br label %79

62:                                               ; preds = %51
  %63 = load i64, ptr @n, align 8, !tbaa !5
  %64 = sitofp i64 %63 to double
  %65 = call double @sqrt(double noundef 5.000000e+00) #6
  %66 = fadd double 1.000000e+00, %65
  %67 = call double @log2(double noundef %66) #6
  %68 = fsub double %67, 1.000000e+00
  %69 = call double @sqrt(double noundef 5.000000e+00) #6
  %70 = call double @log2(double noundef %69) #6
  %71 = fneg double %70
  %72 = call double @llvm.fmuladd.f64(double %64, double %68, double %71)
  %73 = fadd double %72, 1.000000e+00
  %74 = fptosi double %73 to i32
  store i32 %74, ptr @len, align 4, !tbaa !9
  %75 = load i32, ptr @len, align 4, !tbaa !9
  %76 = call noundef i32 @_Z7mod_powii(i32 noundef 2, i32 noundef %75)
  %77 = sub nsw i32 %76, 1
  %78 = call i32 (ptr, ...) @printf(ptr noundef @.str.2, i32 noundef %77)
  br label %79

79:                                               ; preds = %62, %55
  br label %47, !llvm.loop !14

80:                                               ; preds = %47
  ret i32 0
}

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

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

; Function Attrs: nounwind
declare double @log2(double noundef) #4

; Function Attrs: nounwind
declare double @sqrt(double noundef) #4

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare double @llvm.fmuladd.f64(double, double, double) #5

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 = { "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 = { nounwind "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #5 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
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 = !{!"long long", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"int", !7, i64 0}
!11 = distinct !{!11, !12}
!12 = !{!"llvm.loop.mustprogress"}
!13 = distinct !{!13, !12}
!14 = distinct !{!14, !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
@len = external dso_local local_unnamed_addr global i32, align 4
@fib = external dso_local local_unnamed_addr global [91 x i64], align 16
@n = external dso_local global i64, align 8
@.str = external hidden unnamed_addr constant [3 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [5 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [4 x i8], align 1

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

; Function Attrs: mustprogress norecurse nounwind uwtable
define dso_local noundef i32 @main() local_unnamed_addr #1 {
  store i64 1, ptr getelementptr inbounds (i8, ptr @fib, i64 8), align 8, !tbaa !5
  br label %1

1:                                                ; preds = %8, %0
  %2 = phi i64 [ 1, %0 ], [ %21, %8 ]
  %indvars.iv = phi i64 [ 2, %0 ], [ %indvars.iv.next.3, %8 ]
  %3 = add nsw i64 %indvars.iv, -2
  %4 = getelementptr inbounds [91 x i64], ptr @fib, i64 0, i64 %3
  %5 = load i64, ptr %4, align 16, !tbaa !5
  %6 = add nsw i64 %5, %2
  %7 = getelementptr inbounds [91 x i64], ptr @fib, i64 0, i64 %indvars.iv
  store i64 %6, ptr %7, align 16, !tbaa !5
  %exitcond.not = icmp eq i64 %indvars.iv, 90
  br i1 %exitcond.not, label %.preheader.preheader, label %8, !llvm.loop !9

8:                                                ; preds = %1
  %indvars.iv.next = or disjoint i64 %indvars.iv, 1
  %9 = add nsw i64 %indvars.iv, -1
  %10 = getelementptr inbounds [91 x i64], ptr @fib, i64 0, i64 %9
  %11 = load i64, ptr %10, align 8, !tbaa !5
  %12 = add nsw i64 %11, %6
  %13 = getelementptr inbounds [91 x i64], ptr @fib, i64 0, i64 %indvars.iv.next
  store i64 %12, ptr %13, align 8, !tbaa !5
  %indvars.iv.next.1 = add nuw nsw i64 %indvars.iv, 2
  %14 = getelementptr inbounds [91 x i64], ptr @fib, i64 0, i64 %indvars.iv
  %15 = load i64, ptr %14, align 16, !tbaa !5
  %16 = add nsw i64 %15, %12
  %17 = getelementptr inbounds [91 x i64], ptr @fib, i64 0, i64 %indvars.iv.next.1
  store i64 %16, ptr %17, align 16, !tbaa !5
  %indvars.iv.next.2 = add nuw nsw i64 %indvars.iv, 3
  %18 = or disjoint i64 %indvars.iv, 1
  %19 = getelementptr inbounds [91 x i64], ptr @fib, i64 0, i64 %18
  %20 = load i64, ptr %19, align 8, !tbaa !5
  %21 = add nsw i64 %20, %16
  %22 = getelementptr inbounds [91 x i64], ptr @fib, i64 0, i64 %indvars.iv.next.2
  store i64 %21, ptr %22, align 8, !tbaa !5
  %indvars.iv.next.3 = add nuw nsw i64 %indvars.iv, 4
  br label %1

.preheader.preheader:                             ; preds = %1
  %.pre = load i64, ptr getelementptr inbounds (i8, ptr @fib, i64 8), align 8, !tbaa !5
  br label %.preheader

23:                                               ; preds = %.preheader
  %24 = tail call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull @t)
  %25 = load i32, ptr @t, align 4, !tbaa !11
  %26 = add nsw i32 %25, -1
  store i32 %26, ptr @t, align 4, !tbaa !11
  %.not13 = icmp eq i32 %25, 0
  br i1 %.not13, label %._crit_edge, label %.lr.ph

.preheader:                                       ; preds = %.preheader.1, %.preheader.preheader
  %27 = phi i64 [ %.pre, %.preheader.preheader ], [ %39, %.preheader.1 ]
  %indvars.iv15 = phi i64 [ 2, %.preheader.preheader ], [ %indvars.iv.next16.3, %.preheader.1 ]
  %28 = getelementptr inbounds [91 x i64], ptr @fib, i64 0, i64 %indvars.iv15
  %29 = load i64, ptr %28, align 16, !tbaa !5
  %30 = or i64 %29, %27
  store i64 %30, ptr %28, align 16, !tbaa !5
  %exitcond18.not = icmp eq i64 %indvars.iv15, 90
  br i1 %exitcond18.not, label %23, label %.preheader.1, !llvm.loop !13

.preheader.1:                                     ; preds = %.preheader
  %indvars.iv.next16 = or disjoint i64 %indvars.iv15, 1
  %31 = getelementptr inbounds [91 x i64], ptr @fib, i64 0, i64 %indvars.iv.next16
  %32 = load i64, ptr %31, align 8, !tbaa !5
  %33 = or i64 %32, %30
  store i64 %33, ptr %31, align 8, !tbaa !5
  %indvars.iv.next16.1 = add nuw nsw i64 %indvars.iv15, 2
  %34 = getelementptr inbounds [91 x i64], ptr @fib, i64 0, i64 %indvars.iv.next16.1
  %35 = load i64, ptr %34, align 16, !tbaa !5
  %36 = or i64 %35, %33
  store i64 %36, ptr %34, align 16, !tbaa !5
  %indvars.iv.next16.2 = add nuw nsw i64 %indvars.iv15, 3
  %37 = getelementptr inbounds [91 x i64], ptr @fib, i64 0, i64 %indvars.iv.next16.2
  %38 = load i64, ptr %37, align 8, !tbaa !5
  %39 = or i64 %38, %36
  store i64 %39, ptr %37, align 8, !tbaa !5
  %indvars.iv.next16.3 = add nuw nsw i64 %indvars.iv15, 4
  br label %.preheader

.lr.ph:                                           ; preds = %23, %55
  %40 = tail call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str.1, ptr noundef nonnull @n)
  %41 = load i64, ptr @n, align 8, !tbaa !5
  %42 = icmp slt i64 %41, 91
  br i1 %42, label %43, label %48

43:                                               ; preds = %.lr.ph
  %44 = getelementptr inbounds [91 x i64], ptr @fib, i64 0, i64 %41
  %45 = load i64, ptr %44, align 8, !tbaa !5
  %46 = srem i64 %45, 1000000007
  %47 = trunc nsw i64 %46 to i32
  br label %55

48:                                               ; preds = %.lr.ph
  %49 = uitofp nneg i64 %41 to double
  %50 = tail call double @llvm.fmuladd.f64(double %49, double 0x3FE6373AD151CA68, double 0xBFF2934F0979A372)
  %51 = fadd double %50, 1.000000e+00
  %52 = fptosi double %51 to i32
  store i32 %52, ptr @len, align 4, !tbaa !11
  %53 = tail call noundef i32 @_Z7mod_powii(i32 noundef 2, i32 noundef %52)
  %54 = add nsw i32 %53, -1
  br label %55

55:                                               ; preds = %48, %43
  %.sink = phi i32 [ %54, %48 ], [ %47, %43 ]
  %56 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.2, i32 noundef %.sink)
  %57 = load i32, ptr @t, align 4, !tbaa !11
  %58 = add nsw i32 %57, -1
  store i32 %58, ptr @t, align 4, !tbaa !11
  %.not = icmp eq i32 %57, 0
  br i1 %.not, label %._crit_edge, label %.lr.ph, !llvm.loop !14

._crit_edge:                                      ; preds = %55, %23
  ret i32 0
}

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

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

; Function Attrs: mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare double @llvm.fmuladd.f64(double, double, double) #3

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 norecurse 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 = { 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 #3 = { mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none) }

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


; Effective O3 passes: BDCEPass,EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,IndVarSimplifyPass,InferAlignmentPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,PostOrderFunctionAttrsPass,ReassociatePass,SROAPass,SimplifyCFGPass,TailCallElimPass