; LLVM IR from abeaumont/competitive-programming :: kattis/booking.ll (Z3d2iiiiii)

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

@__const._Z3d2iiiiii.md = external hidden unnamed_addr constant [13 x i32], align 16

; Function Attrs: mustprogress nounwind uwtable
define dso_local noundef i32 @_Z3d2iiiiii(i32 noundef %0, i32 noundef %1, i32 noundef %2, i32 noundef %3, i32 noundef %4) #0 {
  %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
  %12 = alloca [13 x i32], align 16
  %13 = alloca i32, align 4
  store i32 %0, ptr %6, align 4, !tbaa !5
  store i32 %1, ptr %7, align 4, !tbaa !5
  store i32 %2, ptr %8, align 4, !tbaa !5
  store i32 %3, ptr %9, align 4, !tbaa !5
  store i32 %4, ptr %10, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %11) #3
  %14 = load i32, ptr %6, align 4, !tbaa !5
  %15 = sub nsw i32 %14, 2013
  %16 = mul nsw i32 %15, 365
  %17 = mul nsw i32 %16, 24
  %18 = mul nsw i32 %17, 60
  store i32 %18, ptr %11, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 52, ptr %12) #3
  call void @llvm.memcpy.p0.p0.i64(ptr align 16 %12, ptr align 16 @__const._Z3d2iiiiii.md, i64 52, i1 false)
  %19 = load i32, ptr %6, align 4, !tbaa !5
  %20 = icmp eq i32 %19, 2016
  br i1 %20, label %21, label %25

21:                                               ; preds = %5
  %22 = getelementptr inbounds [13 x i32], ptr %12, i64 0, i64 2
  %23 = load i32, ptr %22, align 8, !tbaa !5
  %24 = add nsw i32 %23, 1
  store i32 %24, ptr %22, align 8, !tbaa !5
  br label %25

25:                                               ; preds = %21, %5
  call void @llvm.lifetime.start.p0(i64 4, ptr %13) #3
  store i32 1, ptr %13, align 4, !tbaa !5
  br label %26

26:                                               ; preds = %41, %25
  %27 = load i32, ptr %13, align 4, !tbaa !5
  %28 = icmp slt i32 %27, 13
  br i1 %28, label %30, label %29

29:                                               ; preds = %26
  call void @llvm.lifetime.end.p0(i64 4, ptr %13) #3
  br label %44

30:                                               ; preds = %26
  %31 = load i32, ptr %13, align 4, !tbaa !5
  %32 = sub nsw i32 %31, 1
  %33 = sext i32 %32 to i64
  %34 = getelementptr inbounds [13 x i32], ptr %12, i64 0, i64 %33
  %35 = load i32, ptr %34, align 4, !tbaa !5
  %36 = load i32, ptr %13, align 4, !tbaa !5
  %37 = sext i32 %36 to i64
  %38 = getelementptr inbounds [13 x i32], ptr %12, i64 0, i64 %37
  %39 = load i32, ptr %38, align 4, !tbaa !5
  %40 = add nsw i32 %39, %35
  store i32 %40, ptr %38, align 4, !tbaa !5
  br label %41

41:                                               ; preds = %30
  %42 = load i32, ptr %13, align 4, !tbaa !5
  %43 = add nsw i32 %42, 1
  store i32 %43, ptr %13, align 4, !tbaa !5
  br label %26, !llvm.loop !9

44:                                               ; preds = %29
  %45 = load i32, ptr %7, align 4, !tbaa !5
  %46 = sub nsw i32 %45, 1
  %47 = sext i32 %46 to i64
  %48 = getelementptr inbounds [13 x i32], ptr %12, i64 0, i64 %47
  %49 = load i32, ptr %48, align 4, !tbaa !5
  %50 = load i32, ptr %8, align 4, !tbaa !5
  %51 = add nsw i32 %50, %49
  store i32 %51, ptr %8, align 4, !tbaa !5
  %52 = load i32, ptr %11, align 4, !tbaa !5
  %53 = load i32, ptr %8, align 4, !tbaa !5
  %54 = mul nsw i32 %53, 24
  %55 = mul nsw i32 %54, 60
  %56 = add nsw i32 %52, %55
  %57 = load i32, ptr %9, align 4, !tbaa !5
  %58 = mul nsw i32 %57, 60
  %59 = add nsw i32 %56, %58
  %60 = load i32, ptr %10, align 4, !tbaa !5
  %61 = add nsw i32 %59, %60
  call void @llvm.lifetime.end.p0(i64 52, ptr %12) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #3
  ret i32 %61
}

; 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 nounwind willreturn memory(argmem: readwrite)
declare void @llvm.memcpy.p0.p0.i64(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i64, i1 immarg) #2

; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #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 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #3 = { 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"}


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

@__const._Z3d2iiiiii.md = external hidden unnamed_addr constant [13 x i32], align 16

; Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn memory(none) uwtable
define dso_local noundef i32 @_Z3d2iiiiii(i32 noundef %0, i32 noundef %1, i32 noundef %2, i32 noundef %3, i32 noundef %4) local_unnamed_addr #0 {
  %6 = alloca [13 x i32], align 16
  call void @llvm.lifetime.start.p0(i64 52, ptr nonnull %6) #3
  call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 16 dereferenceable(52) %6, ptr noundef nonnull align 16 dereferenceable(52) @__const._Z3d2iiiiii.md, i64 52, i1 false)
  %7 = icmp eq i32 %0, 2016
  %8 = getelementptr inbounds i8, ptr %6, i64 8
  %.pre = load i32, ptr %8, align 8
  %9 = zext i1 %7 to i32
  %10 = add nsw i32 %.pre, %9
  %11 = load i32, ptr %6, align 16, !tbaa !5
  %12 = getelementptr inbounds i8, ptr %6, i64 4
  %13 = load i32, ptr %12, align 4, !tbaa !5
  %14 = add nsw i32 %13, %11
  store i32 %14, ptr %12, align 4, !tbaa !5
  %15 = getelementptr inbounds i8, ptr %6, i64 8
  %16 = add nsw i32 %10, %14
  store i32 %16, ptr %15, align 8, !tbaa !5
  %17 = getelementptr inbounds i8, ptr %6, i64 12
  %18 = load i32, ptr %17, align 4, !tbaa !5
  %19 = add nsw i32 %18, %16
  store i32 %19, ptr %17, align 4, !tbaa !5
  %20 = getelementptr inbounds i8, ptr %6, i64 16
  %21 = load i32, ptr %20, align 16, !tbaa !5
  %22 = add nsw i32 %21, %19
  store i32 %22, ptr %20, align 16, !tbaa !5
  %23 = getelementptr inbounds i8, ptr %6, i64 20
  %24 = load i32, ptr %23, align 4, !tbaa !5
  %25 = add nsw i32 %24, %22
  store i32 %25, ptr %23, align 4, !tbaa !5
  %26 = getelementptr inbounds i8, ptr %6, i64 24
  %27 = load i32, ptr %26, align 8, !tbaa !5
  %28 = add nsw i32 %27, %25
  store i32 %28, ptr %26, align 8, !tbaa !5
  %29 = getelementptr inbounds i8, ptr %6, i64 28
  %30 = load i32, ptr %29, align 4, !tbaa !5
  %31 = add nsw i32 %30, %28
  store i32 %31, ptr %29, align 4, !tbaa !5
  %32 = getelementptr inbounds i8, ptr %6, i64 32
  %33 = load i32, ptr %32, align 16, !tbaa !5
  %34 = add nsw i32 %33, %31
  store i32 %34, ptr %32, align 16, !tbaa !5
  %35 = getelementptr inbounds i8, ptr %6, i64 36
  %36 = load i32, ptr %35, align 4, !tbaa !5
  %37 = add nsw i32 %36, %34
  store i32 %37, ptr %35, align 4, !tbaa !5
  %38 = getelementptr inbounds i8, ptr %6, i64 40
  %39 = load i32, ptr %38, align 8, !tbaa !5
  %40 = add nsw i32 %39, %37
  store i32 %40, ptr %38, align 8, !tbaa !5
  %41 = getelementptr inbounds i8, ptr %6, i64 44
  %42 = load i32, ptr %41, align 4, !tbaa !5
  %43 = add nsw i32 %42, %40
  store i32 %43, ptr %41, align 4, !tbaa !5
  %44 = getelementptr inbounds i8, ptr %6, i64 48
  %45 = load i32, ptr %44, align 16, !tbaa !5
  %46 = add nsw i32 %45, %43
  store i32 %46, ptr %44, align 16, !tbaa !5
  %47 = mul i32 %0, 525600
  %48 = add i32 %47, -1058032800
  %49 = add nsw i32 %1, -1
  %50 = sext i32 %49 to i64
  %51 = getelementptr inbounds [13 x i32], ptr %6, i64 0, i64 %50
  %52 = load i32, ptr %51, align 4, !tbaa !5
  %53 = add nsw i32 %52, %2
  %54 = mul i32 %53, 1440
  %55 = mul nsw i32 %3, 60
  %56 = add i32 %48, %55
  %57 = add i32 %56, %4
  %58 = add i32 %57, %54
  call void @llvm.lifetime.end.p0(i64 52, ptr nonnull %6) #3
  ret i32 %58
}

; 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 nounwind willreturn memory(argmem: readwrite)
declare void @llvm.memcpy.p0.p0.i64(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i64, i1 immarg) #2

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

attributes #0 = { mustprogress nofree norecurse nosync nounwind willreturn memory(none) 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 nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #3 = { 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: DSEPass,GVNPass,GlobalOptPass,IndVarSimplifyPass,InferAlignmentPass,InferFunctionAttrsPass,InstCombinePass,LoopRotatePass,PostOrderFunctionAttrsPass,ReassociatePass,SROAPass,SimplifyCFGPass