; LLVM IR from sfu-dis/mosaicdb :: benchmarks/egen/DateTime.ll (ZN4TPCE9CDateTime10YMDtoDaynoEiii)

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

@.str = external hidden unnamed_addr constant [20 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [79 x i8], align 1
@__PRETTY_FUNCTION__._ZN4TPCE9CDateTime10YMDtoDaynoEiii = external hidden unnamed_addr constant [62 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [20 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [7 x i8], align 1
@_ZZN4TPCE9CDateTime10YMDtoDaynoEiiiE10MonthArray = external hidden constant [12 x i32], align 16

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

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

; Function Attrs: mustprogress nounwind uwtable
define dso_local noundef i32 @_ZN4TPCE9CDateTime10YMDtoDaynoEiii(i32 noundef %0, i32 noundef %1, i32 noundef %2) #1 align 2 {
  %4 = alloca i32, align 4
  %5 = alloca i32, align 4
  %6 = alloca i32, align 4
  %7 = alloca i32, align 4
  store i32 %0, ptr %4, align 4, !tbaa !5
  store i32 %1, ptr %5, align 4, !tbaa !5
  store i32 %2, ptr %6, align 4, !tbaa !5
  %8 = load i32, ptr %5, align 4, !tbaa !5
  %9 = icmp sge i32 %8, 1
  br i1 %9, label %10, label %13

10:                                               ; preds = %3
  %11 = load i32, ptr %5, align 4, !tbaa !5
  %12 = icmp sle i32 %11, 12
  br label %13

13:                                               ; preds = %10, %3
  %14 = phi i1 [ false, %3 ], [ %12, %10 ]
  br i1 %14, label %15, label %16

15:                                               ; preds = %13
  br label %18

16:                                               ; preds = %13
  call void @__assert_fail(ptr noundef @.str, ptr noundef @.str.1, i32 noundef 88, ptr noundef @__PRETTY_FUNCTION__._ZN4TPCE9CDateTime10YMDtoDaynoEiii) #3
  unreachable

17:                                               ; No predecessors!
  br label %18

18:                                               ; preds = %17, %15
  %19 = load i32, ptr %6, align 4, !tbaa !5
  %20 = icmp sge i32 %19, 1
  br i1 %20, label %21, label %24

21:                                               ; preds = %18
  %22 = load i32, ptr %6, align 4, !tbaa !5
  %23 = icmp sle i32 %22, 31
  br label %24

24:                                               ; preds = %21, %18
  %25 = phi i1 [ false, %18 ], [ %23, %21 ]
  br i1 %25, label %26, label %27

26:                                               ; preds = %24
  br label %29

27:                                               ; preds = %24
  call void @__assert_fail(ptr noundef @.str.2, ptr noundef @.str.1, i32 noundef 89, ptr noundef @__PRETTY_FUNCTION__._ZN4TPCE9CDateTime10YMDtoDaynoEiii) #3
  unreachable

28:                                               ; No predecessors!
  br label %29

29:                                               ; preds = %28, %26
  %30 = load i32, ptr %4, align 4, !tbaa !5
  %31 = icmp sgt i32 %30, 0
  br i1 %31, label %32, label %33

32:                                               ; preds = %29
  br label %35

33:                                               ; preds = %29
  call void @__assert_fail(ptr noundef @.str.3, ptr noundef @.str.1, i32 noundef 90, ptr noundef @__PRETTY_FUNCTION__._ZN4TPCE9CDateTime10YMDtoDaynoEiii) #3
  unreachable

34:                                               ; No predecessors!
  br label %35

35:                                               ; preds = %34, %32
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #4
  %36 = load i32, ptr %5, align 4, !tbaa !5
  %37 = sub nsw i32 %36, 1
  %38 = sext i32 %37 to i64
  %39 = getelementptr inbounds [12 x i32], ptr @_ZZN4TPCE9CDateTime10YMDtoDaynoEiiiE10MonthArray, i64 0, i64 %38
  %40 = load i32, ptr %39, align 4, !tbaa !5
  %41 = load i32, ptr %6, align 4, !tbaa !5
  %42 = add nsw i32 %40, %41
  %43 = sub nsw i32 %42, 1
  store i32 %43, ptr %7, align 4, !tbaa !5
  %44 = load i32, ptr %5, align 4, !tbaa !5
  %45 = icmp sgt i32 %44, 2
  br i1 %45, label %46, label %66

46:                                               ; preds = %35
  %47 = load i32, ptr %4, align 4, !tbaa !5
  %48 = srem i32 %47, 4
  %49 = icmp eq i32 %48, 0
  br i1 %49, label %50, label %66

50:                                               ; preds = %46
  %51 = load i32, ptr %4, align 4, !tbaa !5
  %52 = srem i32 %51, 400
  %53 = icmp eq i32 %52, 0
  br i1 %53, label %54, label %57

54:                                               ; preds = %50
  %55 = load i32, ptr %7, align 4, !tbaa !5
  %56 = add nsw i32 %55, 1
  store i32 %56, ptr %7, align 4, !tbaa !5
  br label %65

57:                                               ; preds = %50
  %58 = load i32, ptr %4, align 4, !tbaa !5
  %59 = srem i32 %58, 100
  %60 = icmp ne i32 %59, 0
  br i1 %60, label %61, label %64

61:                                               ; preds = %57
  %62 = load i32, ptr %7, align 4, !tbaa !5
  %63 = add nsw i32 %62, 1
  store i32 %63, ptr %7, align 4, !tbaa !5
  br label %64

64:                                               ; preds = %61, %57
  br label %65

65:                                               ; preds = %64, %54
  br label %66

66:                                               ; preds = %65, %46, %35
  %67 = load i32, ptr %4, align 4, !tbaa !5
  %68 = add nsw i32 %67, -1
  store i32 %68, ptr %4, align 4, !tbaa !5
  %69 = load i32, ptr %4, align 4, !tbaa !5
  %70 = sdiv i32 %69, 400
  %71 = mul nsw i32 %70, 146097
  %72 = load i32, ptr %7, align 4, !tbaa !5
  %73 = add nsw i32 %72, %71
  store i32 %73, ptr %7, align 4, !tbaa !5
  %74 = load i32, ptr %4, align 4, !tbaa !5
  %75 = srem i32 %74, 400
  store i32 %75, ptr %4, align 4, !tbaa !5
  %76 = load i32, ptr %4, align 4, !tbaa !5
  %77 = sdiv i32 %76, 100
  %78 = mul nsw i32 %77, 36524
  %79 = load i32, ptr %7, align 4, !tbaa !5
  %80 = add nsw i32 %79, %78
  store i32 %80, ptr %7, align 4, !tbaa !5
  %81 = load i32, ptr %4, align 4, !tbaa !5
  %82 = srem i32 %81, 100
  store i32 %82, ptr %4, align 4, !tbaa !5
  %83 = load i32, ptr %4, align 4, !tbaa !5
  %84 = sdiv i32 %83, 4
  %85 = mul nsw i32 %84, 1461
  %86 = load i32, ptr %7, align 4, !tbaa !5
  %87 = add nsw i32 %86, %85
  store i32 %87, ptr %7, align 4, !tbaa !5
  %88 = load i32, ptr %4, align 4, !tbaa !5
  %89 = srem i32 %88, 4
  store i32 %89, ptr %4, align 4, !tbaa !5
  %90 = load i32, ptr %4, align 4, !tbaa !5
  %91 = mul nsw i32 %90, 365
  %92 = load i32, ptr %7, align 4, !tbaa !5
  %93 = add nsw i32 %92, %91
  store i32 %93, ptr %7, align 4, !tbaa !5
  %94 = load i32, ptr %7, align 4, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #4
  ret i32 %94
}

; Function Attrs: noreturn nounwind
declare void @__assert_fail(ptr noundef, ptr noundef, i32 noundef, ptr noundef) #2

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { 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 #2 = { noreturn 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 = { noreturn nounwind }
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"}


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

@.str = external hidden unnamed_addr constant [20 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [79 x i8], align 1
@__PRETTY_FUNCTION__._ZN4TPCE9CDateTime10YMDtoDaynoEiii = external hidden unnamed_addr constant [62 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [20 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [7 x i8], align 1
@_ZZN4TPCE9CDateTime10YMDtoDaynoEiiiE10MonthArray = external hidden local_unnamed_addr constant [12 x i32], align 16

; Function Attrs: mustprogress nounwind uwtable
define dso_local noundef i32 @_ZN4TPCE9CDateTime10YMDtoDaynoEiii(i32 noundef %0, i32 noundef %1, i32 noundef %2) local_unnamed_addr #0 align 2 {
  %4 = add i32 %1, -1
  %5 = icmp ult i32 %4, 12
  br i1 %5, label %7, label %6

6:                                                ; preds = %3
  tail call void @__assert_fail(ptr noundef nonnull @.str, ptr noundef nonnull @.str.1, i32 noundef 88, ptr noundef nonnull @__PRETTY_FUNCTION__._ZN4TPCE9CDateTime10YMDtoDaynoEiii) #2
  unreachable

7:                                                ; preds = %3
  %8 = add i32 %2, -1
  %9 = icmp ult i32 %8, 31
  br i1 %9, label %11, label %10

10:                                               ; preds = %7
  tail call void @__assert_fail(ptr noundef nonnull @.str.2, ptr noundef nonnull @.str.1, i32 noundef 89, ptr noundef nonnull @__PRETTY_FUNCTION__._ZN4TPCE9CDateTime10YMDtoDaynoEiii) #2
  unreachable

11:                                               ; preds = %7
  %12 = icmp sgt i32 %0, 0
  br i1 %12, label %14, label %13

13:                                               ; preds = %11
  tail call void @__assert_fail(ptr noundef nonnull @.str.3, ptr noundef nonnull @.str.1, i32 noundef 90, ptr noundef nonnull @__PRETTY_FUNCTION__._ZN4TPCE9CDateTime10YMDtoDaynoEiii) #2
  unreachable

14:                                               ; preds = %11
  %15 = zext nneg i32 %4 to i64
  %16 = getelementptr inbounds [12 x i32], ptr @_ZZN4TPCE9CDateTime10YMDtoDaynoEiiiE10MonthArray, i64 0, i64 %15
  %17 = load i32, ptr %16, align 4, !tbaa !5
  %18 = add nsw i32 %17, %2
  %19 = add nsw i32 %18, -1
  %20 = icmp ugt i32 %1, 2
  %21 = and i32 %0, 3
  %22 = icmp eq i32 %21, 0
  %or.cond = and i1 %20, %22
  br i1 %or.cond, label %23, label %28

23:                                               ; preds = %14
  %24 = urem i32 %0, 400
  %25 = icmp eq i32 %24, 0
  br i1 %25, label %28, label %26

26:                                               ; preds = %23
  %27 = urem i32 %0, 100
  %.not = icmp eq i32 %27, 0
  %spec.select = select i1 %.not, i32 %19, i32 %18
  br label %28

28:                                               ; preds = %26, %23, %14
  %.0 = phi i32 [ %19, %14 ], [ %18, %23 ], [ %spec.select, %26 ]
  %29 = add nsw i32 %0, -1
  %30 = udiv i32 %29, 400
  %31 = mul nuw nsw i32 %30, 146097
  %32 = urem i32 %29, 400
  %.lhs.trunc = trunc nuw nsw i32 %32 to i16
  %33 = udiv i16 %.lhs.trunc, 100
  %.zext = zext nneg i16 %33 to i32
  %34 = mul nuw nsw i32 %.zext, 36524
  %35 = urem i16 %.lhs.trunc, 100
  %.zext31 = zext nneg i16 %35 to i32
  %36 = lshr i32 %.zext31, 2
  %37 = mul nuw nsw i32 %36, 1461
  %38 = and i32 %.zext31, 3
  %39 = mul nuw nsw i32 %38, 365
  %40 = add nuw i32 %34, %31
  %41 = add nuw i32 %40, %37
  %42 = add nuw i32 %41, %39
  %43 = add i32 %42, %.0
  ret i32 %43
}

; Function Attrs: noreturn nounwind
declare void @__assert_fail(ptr noundef, ptr noundef, i32 noundef, ptr noundef) local_unnamed_addr #1

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 = { noreturn 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 #2 = { noreturn 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"}


; Effective O3 passes: CorrelatedValuePropagationPass,EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,InferFunctionAttrsPass,InstCombinePass,ReassociatePass,SCCPPass,SROAPass,SimplifyCFGPass,TailCallElimPass