; LLVM IR from hao14293/2021-Postgraduate-408 :: DailySummary (计算两个日期间的天数)

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

@month = external dso_local global [13 x [2 x i32]], align 16
@.str = external hidden unnamed_addr constant [5 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [4 x i8], align 1

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef zeroext i1 @_Z6isLeapi(i32 noundef) #0

; Function Attrs: mustprogress norecurse uwtable
define dso_local noundef i32 @main() #1 {
  %1 = alloca i32, align 4
  %2 = alloca i32, align 4
  %3 = alloca i32, align 4
  %4 = alloca i32, align 4
  %5 = alloca i32, align 4
  %6 = alloca i32, align 4
  %7 = alloca i32, align 4
  %8 = alloca i32, align 4
  %9 = alloca i32, align 4
  %10 = alloca i32, align 4
  %11 = alloca i32, align 4
  store i32 0, ptr %1, align 4
  call void @llvm.lifetime.start.p0(i64 4, ptr %2) #4
  call void @llvm.lifetime.start.p0(i64 4, ptr %3) #4
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #4
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #4
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #4
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #4
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #4
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #4
  br label %12

12:                                               ; preds = %78, %0
  %13 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str, ptr noundef %2, ptr noundef %6)
  %14 = icmp ne i32 %13, -1
  br i1 %14, label %15, label %81

15:                                               ; preds = %12
  %16 = load i32, ptr %2, align 4, !tbaa !5
  %17 = load i32, ptr %6, align 4, !tbaa !5
  %18 = icmp sgt i32 %16, %17
  br i1 %18, label %19, label %23

19:                                               ; preds = %15
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #4
  %20 = load i32, ptr %2, align 4, !tbaa !5
  store i32 %20, ptr %10, align 4, !tbaa !5
  %21 = load i32, ptr %6, align 4, !tbaa !5
  store i32 %21, ptr %2, align 4, !tbaa !5
  %22 = load i32, ptr %10, align 4, !tbaa !5
  store i32 %22, ptr %6, align 4, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #4
  br label %23

23:                                               ; preds = %19, %15
  %24 = load i32, ptr %2, align 4, !tbaa !5
  %25 = sdiv i32 %24, 10000
  store i32 %25, ptr %3, align 4, !tbaa !5
  %26 = load i32, ptr %2, align 4, !tbaa !5
  %27 = srem i32 %26, 10000
  %28 = sdiv i32 %27, 100
  store i32 %28, ptr %4, align 4, !tbaa !5
  %29 = load i32, ptr %2, align 4, !tbaa !5
  %30 = srem i32 %29, 100
  store i32 %30, ptr %5, align 4, !tbaa !5
  %31 = load i32, ptr %6, align 4, !tbaa !5
  %32 = sdiv i32 %31, 10000
  store i32 %32, ptr %7, align 4, !tbaa !5
  %33 = load i32, ptr %6, align 4, !tbaa !5
  %34 = srem i32 %33, 10000
  %35 = sdiv i32 %34, 100
  store i32 %35, ptr %8, align 4, !tbaa !5
  %36 = load i32, ptr %6, align 4, !tbaa !5
  %37 = srem i32 %36, 100
  store i32 %37, ptr %9, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %11) #4
  store i32 1, ptr %11, align 4, !tbaa !5
  br label %38

38:                                               ; preds = %75, %23
  %39 = load i32, ptr %3, align 4, !tbaa !5
  %40 = load i32, ptr %7, align 4, !tbaa !5
  %41 = icmp slt i32 %39, %40
  br i1 %41, label %50, label %42

42:                                               ; preds = %38
  %43 = load i32, ptr %4, align 4, !tbaa !5
  %44 = load i32, ptr %8, align 4, !tbaa !5
  %45 = icmp slt i32 %43, %44
  br i1 %45, label %50, label %46

46:                                               ; preds = %42
  %47 = load i32, ptr %5, align 4, !tbaa !5
  %48 = load i32, ptr %9, align 4, !tbaa !5
  %49 = icmp slt i32 %47, %48
  br label %50

50:                                               ; preds = %46, %42, %38
  %51 = phi i1 [ true, %42 ], [ true, %38 ], [ %49, %46 ]
  br i1 %51, label %52, label %78

52:                                               ; preds = %50
  %53 = load i32, ptr %5, align 4, !tbaa !5
  %54 = add nsw i32 %53, 1
  store i32 %54, ptr %5, align 4, !tbaa !5
  %55 = load i32, ptr %5, align 4, !tbaa !5
  %56 = load i32, ptr %4, align 4, !tbaa !5
  %57 = sext i32 %56 to i64
  %58 = getelementptr inbounds [13 x [2 x i32]], ptr @month, i64 0, i64 %57
  %59 = load i32, ptr %3, align 4, !tbaa !5
  %60 = call noundef zeroext i1 @_Z6isLeapi(i32 noundef %59)
  %61 = zext i1 %60 to i64
  %62 = getelementptr inbounds [2 x i32], ptr %58, i64 0, i64 %61
  %63 = load i32, ptr %62, align 4, !tbaa !5
  %64 = add nsw i32 %63, 1
  %65 = icmp eq i32 %55, %64
  br i1 %65, label %66, label %69

66:                                               ; preds = %52
  %67 = load i32, ptr %4, align 4, !tbaa !5
  %68 = add nsw i32 %67, 1
  store i32 %68, ptr %4, align 4, !tbaa !5
  store i32 1, ptr %5, align 4, !tbaa !5
  br label %69

69:                                               ; preds = %66, %52
  %70 = load i32, ptr %4, align 4, !tbaa !5
  %71 = icmp eq i32 %70, 13
  br i1 %71, label %72, label %75

72:                                               ; preds = %69
  %73 = load i32, ptr %3, align 4, !tbaa !5
  %74 = add nsw i32 %73, 1
  store i32 %74, ptr %3, align 4, !tbaa !5
  store i32 1, ptr %4, align 4, !tbaa !5
  br label %75

75:                                               ; preds = %72, %69
  %76 = load i32, ptr %11, align 4, !tbaa !5
  %77 = add nsw i32 %76, 1
  store i32 %77, ptr %11, align 4, !tbaa !5
  br label %38, !llvm.loop !9

78:                                               ; preds = %50
  %79 = load i32, ptr %11, align 4, !tbaa !5
  %80 = call i32 (ptr, ...) @printf(ptr noundef @.str.1, i32 noundef %79)
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #4
  br label %12, !llvm.loop !11

81:                                               ; preds = %12
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %3) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %2) #4
  ret i32 0
}

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

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

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

declare i32 @printf(ptr noundef, ...) #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 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 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 }

!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 = distinct !{!9, !10}
!10 = !{!"llvm.loop.mustprogress"}
!11 = distinct !{!11, !10}


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

@month = external dso_local local_unnamed_addr global [13 x [2 x i32]], align 16
@.str = external hidden unnamed_addr constant [5 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [4 x i8], align 1

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef zeroext i1 @_Z6isLeapi(i32 noundef) local_unnamed_addr #0

; Function Attrs: mustprogress norecurse nounwind uwtable
define dso_local noundef i32 @main() local_unnamed_addr #1 {
  %1 = alloca i32, align 4
  %2 = alloca i32, align 4
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %1) #4
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %2) #4
  %3 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull %1, ptr noundef nonnull %2)
  %.not34 = icmp eq i32 %3, -1
  br i1 %.not34, label %._crit_edge36, label %.lr.ph

.lr.ph:                                           ; preds = %0, %._crit_edge
  %4 = load i32, ptr %1, align 4, !tbaa !5
  %5 = load i32, ptr %2, align 4, !tbaa !5
  %6 = icmp sgt i32 %4, %5
  br i1 %6, label %7, label %8

7:                                                ; preds = %.lr.ph
  store i32 %5, ptr %1, align 4, !tbaa !5
  store i32 %4, ptr %2, align 4, !tbaa !5
  br label %8

8:                                                ; preds = %7, %.lr.ph
  %9 = phi i32 [ %4, %7 ], [ %5, %.lr.ph ]
  %10 = phi i32 [ %5, %7 ], [ %4, %.lr.ph ]
  %11 = sdiv i32 %10, 10000
  %12 = srem i32 %10, 10000
  %.lhs.trunc = trunc nsw i32 %12 to i16
  %13 = sdiv i16 %.lhs.trunc, 100
  %14 = srem i32 %10, 100
  %15 = sdiv i32 %9, 10000
  %16 = srem i32 %9, 10000
  %.lhs.trunc26 = trunc nsw i32 %16 to i16
  %17 = sdiv i16 %.lhs.trunc26, 100
  %.sext27 = sext i16 %17 to i32
  %18 = srem i32 %9, 100
  %19 = icmp slt i32 %11, %15
  %20 = icmp slt i16 %13, %17
  %or.cond28 = select i1 %19, i1 true, i1 %20
  %21 = icmp slt i32 %14, %18
  %or.cond2429 = or i1 %or.cond28, %21
  br i1 %or.cond2429, label %.critedge.preheader, label %._crit_edge

.critedge.preheader:                              ; preds = %8
  %.sext = sext i16 %13 to i32
  br label %.critedge

.critedge:                                        ; preds = %.critedge.preheader, %.critedge
  %.033 = phi i32 [ %32, %.critedge ], [ 1, %.critedge.preheader ]
  %.01632 = phi i32 [ %.1, %.critedge ], [ %11, %.critedge.preheader ]
  %.01731 = phi i32 [ %.2, %.critedge ], [ %.sext, %.critedge.preheader ]
  %.01930 = phi i32 [ %spec.select, %.critedge ], [ %14, %.critedge.preheader ]
  %22 = add nsw i32 %.01930, 1
  %23 = sext i32 %.01731 to i64
  %24 = call noundef zeroext i1 @_Z6isLeapi(i32 noundef %.01632)
  %25 = zext i1 %24 to i64
  %26 = getelementptr inbounds [13 x [2 x i32]], ptr @month, i64 0, i64 %23, i64 %25
  %27 = load i32, ptr %26, align 4, !tbaa !5
  %28 = icmp eq i32 %.01930, %27
  %spec.select = select i1 %28, i32 1, i32 %22
  %29 = zext i1 %28 to i32
  %spec.select25 = add nsw i32 %.01731, %29
  %30 = icmp eq i32 %spec.select25, 13
  %.2 = select i1 %30, i32 1, i32 %spec.select25
  %31 = zext i1 %30 to i32
  %.1 = add nsw i32 %.01632, %31
  %32 = add nuw nsw i32 %.033, 1
  %33 = icmp slt i32 %.1, %15
  %34 = icmp slt i32 %.2, %.sext27
  %or.cond = select i1 %33, i1 true, i1 %34
  %35 = icmp slt i32 %spec.select, %18
  %or.cond24 = select i1 %or.cond, i1 true, i1 %35
  br i1 %or.cond24, label %.critedge, label %._crit_edge, !llvm.loop !9

._crit_edge:                                      ; preds = %.critedge, %8
  %.0.lcssa = phi i32 [ 1, %8 ], [ %32, %.critedge ]
  %36 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.1, i32 noundef %.0.lcssa)
  %37 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull %1, ptr noundef nonnull %2)
  %.not = icmp eq i32 %37, -1
  br i1 %.not, label %._crit_edge36, label %.lr.ph, !llvm.loop !11

._crit_edge36:                                    ; preds = %._crit_edge, %0
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %2) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %1) #4
  ret i32 0
}

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

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

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

; Function Attrs: nofree nounwind
declare noundef i32 @printf(ptr nocapture noundef readonly, ...) local_unnamed_addr #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 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #3 = { nofree nounwind "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #4 = { 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 = distinct !{!9, !10}
!10 = !{!"llvm.loop.mustprogress"}
!11 = distinct !{!11, !10}


; Effective O3 passes: CorrelatedValuePropagationPass,EarlyCSEPass,GVNPass,GlobalOptPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,JumpThreadingPass,LCSSAPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,PostOrderFunctionAttrsPass,ReassociatePass,SROAPass,SimplifyCFGPass