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

; 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.TPCE::CDateTime" = type { i32, i32, ptr }

; Function Attrs: mustprogress nounwind uwtable
define dso_local void @_ZN4TPCE9CDateTime3AddEiib(ptr noundef nonnull align 8 dereferenceable(16) %0, i32 noundef %1, i32 noundef %2, i1 noundef zeroext %3) #0 align 2 {
  %5 = alloca ptr, align 8
  %6 = alloca i32, align 4
  %7 = alloca i32, align 4
  %8 = alloca i8, align 1
  store ptr %0, ptr %5, align 8, !tbaa !5
  store i32 %1, ptr %6, align 4, !tbaa !9
  store i32 %2, ptr %7, align 4, !tbaa !9
  %9 = zext i1 %3 to i8
  store i8 %9, ptr %8, align 1, !tbaa !11
  %10 = load ptr, ptr %5, align 8
  %11 = load i8, ptr %8, align 1, !tbaa !11, !range !13, !noundef !14
  %12 = trunc i8 %11 to i1
  br i1 %12, label %13, label %20

13:                                               ; preds = %4
  %14 = load i32, ptr %6, align 4, !tbaa !9
  %15 = sdiv i32 %14, 5
  %16 = mul nsw i32 %15, 7
  %17 = load i32, ptr %6, align 4, !tbaa !9
  %18 = srem i32 %17, 5
  %19 = add nsw i32 %16, %18
  store i32 %19, ptr %6, align 4, !tbaa !9
  br label %20

20:                                               ; preds = %13, %4
  %21 = load i32, ptr %6, align 4, !tbaa !9
  %22 = getelementptr inbounds %"class.TPCE::CDateTime", ptr %10, i32 0, i32 0
  %23 = load i32, ptr %22, align 8, !tbaa !15
  %24 = add nsw i32 %23, %21
  store i32 %24, ptr %22, align 8, !tbaa !15
  %25 = load i32, ptr %7, align 4, !tbaa !9
  %26 = getelementptr inbounds %"class.TPCE::CDateTime", ptr %10, i32 0, i32 1
  %27 = load i32, ptr %26, align 4, !tbaa !17
  %28 = add nsw i32 %27, %25
  store i32 %28, ptr %26, align 4, !tbaa !17
  %29 = getelementptr inbounds %"class.TPCE::CDateTime", ptr %10, i32 0, i32 1
  %30 = load i32, ptr %29, align 4, !tbaa !17
  %31 = sdiv i32 %30, 86400000
  %32 = getelementptr inbounds %"class.TPCE::CDateTime", ptr %10, i32 0, i32 0
  %33 = load i32, ptr %32, align 8, !tbaa !15
  %34 = add nsw i32 %33, %31
  store i32 %34, ptr %32, align 8, !tbaa !15
  %35 = getelementptr inbounds %"class.TPCE::CDateTime", ptr %10, i32 0, i32 1
  %36 = load i32, ptr %35, align 4, !tbaa !17
  %37 = srem i32 %36, 86400000
  store i32 %37, ptr %35, align 4, !tbaa !17
  %38 = getelementptr inbounds %"class.TPCE::CDateTime", ptr %10, i32 0, i32 1
  %39 = load i32, ptr %38, align 4, !tbaa !17
  %40 = icmp slt i32 %39, 0
  br i1 %40, label %41, label %48

41:                                               ; preds = %20
  %42 = getelementptr inbounds %"class.TPCE::CDateTime", ptr %10, i32 0, i32 0
  %43 = load i32, ptr %42, align 8, !tbaa !15
  %44 = add nsw i32 %43, -1
  store i32 %44, ptr %42, align 8, !tbaa !15
  %45 = getelementptr inbounds %"class.TPCE::CDateTime", ptr %10, i32 0, i32 1
  %46 = load i32, ptr %45, align 4, !tbaa !17
  %47 = add nsw i32 %46, 86400000
  store i32 %47, ptr %45, align 4, !tbaa !17
  br label %48

48:                                               ; preds = %41, %20
  ret void
}

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

!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 = !{!"any pointer", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"int", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"bool", !7, i64 0}
!13 = !{i8 0, i8 2}
!14 = !{}
!15 = !{!16, !10, i64 0}
!16 = !{!"_ZTSN4TPCE9CDateTimeE", !10, i64 0, !10, i64 4, !6, i64 8}
!17 = !{!16, !10, i64 4}


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

; Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn memory(argmem: readwrite) uwtable
define dso_local void @_ZN4TPCE9CDateTime3AddEiib(ptr nocapture noundef nonnull align 8 dereferenceable(16) %0, i32 noundef %1, i32 noundef %2, i1 noundef zeroext %3) local_unnamed_addr #0 align 2 {
  br i1 %3, label %5, label %9

5:                                                ; preds = %4
  %6 = sdiv i32 %1, 5
  %7 = shl nsw i32 %6, 1
  %8 = add i32 %7, %1
  br label %9

9:                                                ; preds = %5, %4
  %.0 = phi i32 [ %8, %5 ], [ %1, %4 ]
  %10 = load i32, ptr %0, align 8, !tbaa !5
  %11 = add nsw i32 %10, %.0
  %12 = getelementptr inbounds i8, ptr %0, i64 4
  %13 = load i32, ptr %12, align 4, !tbaa !11
  %14 = add nsw i32 %13, %2
  %15 = sdiv i32 %14, 86400000
  %16 = add nsw i32 %15, %11
  store i32 %16, ptr %0, align 8, !tbaa !5
  %17 = srem i32 %14, 86400000
  store i32 %17, ptr %12, align 4, !tbaa !11
  %18 = icmp slt i32 %17, 0
  br i1 %18, label %19, label %22

19:                                               ; preds = %9
  %20 = add nsw i32 %16, -1
  store i32 %20, ptr %0, align 8, !tbaa !5
  %21 = add nsw i32 %17, 86400000
  store i32 %21, ptr %12, align 4, !tbaa !11
  br label %22

22:                                               ; preds = %19, %9
  ret void
}

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

!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, !7, i64 0}
!6 = !{!"_ZTSN4TPCE9CDateTimeE", !7, i64 0, !7, i64 4, !10, i64 8}
!7 = !{!"int", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C++ TBAA"}
!10 = !{!"any pointer", !8, i64 0}
!11 = !{!6, !7, i64 4}


; Effective O3 passes: DSEPass,EarlyCSEPass,GlobalOptPass,InstCombinePass,PostOrderFunctionAttrsPass,ReassociatePass,SROAPass