; LLVM IR from USDA-ARS-ACSL/MAIZSIM :: Crop source/timer.ll (ZN5Timer6juldayEiii)

; 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 [31 x i8], align 1
@_ZTIPKc = external constant ptr

; Function Attrs: mustprogress uwtable
define dso_local noundef i32 @_ZN5Timer6juldayEiii(ptr noundef nonnull align 8 dereferenceable(36) %0, i32 noundef %1, i32 noundef %2, i32 noundef %3) #0 align 2 {
  %5 = alloca ptr, align 8
  %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 i32, align 4
  %13 = alloca i32, align 4
  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
  store i32 %3, ptr %8, align 4, !tbaa !9
  %14 = load ptr, ptr %5, align 8
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #3
  store i32 588829, ptr %9, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #3
  call void @llvm.lifetime.start.p0(i64 4, ptr %11) #3
  call void @llvm.lifetime.start.p0(i64 4, ptr %12) #3
  %15 = load i32, ptr %8, align 4, !tbaa !9
  store i32 %15, ptr %12, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %13) #3
  %16 = load i32, ptr %12, align 4, !tbaa !9
  %17 = icmp eq i32 %16, 0
  br i1 %17, label %18, label %20

18:                                               ; preds = %4
  %19 = call ptr @__cxa_allocate_exception(i64 8) #3
  store ptr @.str, ptr %19, align 16, !tbaa !5
  call void @__cxa_throw(ptr %19, ptr @_ZTIPKc, ptr null) #4
  unreachable

20:                                               ; preds = %4
  %21 = load i32, ptr %12, align 4, !tbaa !9
  %22 = icmp slt i32 %21, 0
  br i1 %22, label %23, label %26

23:                                               ; preds = %20
  %24 = load i32, ptr %12, align 4, !tbaa !9
  %25 = add nsw i32 %24, 1
  store i32 %25, ptr %12, align 4, !tbaa !9
  br label %26

26:                                               ; preds = %23, %20
  %27 = load i32, ptr %6, align 4, !tbaa !9
  %28 = icmp sgt i32 %27, 2
  br i1 %28, label %29, label %32

29:                                               ; preds = %26
  %30 = load i32, ptr %6, align 4, !tbaa !9
  %31 = add nsw i32 %30, 1
  store i32 %31, ptr %13, align 4, !tbaa !9
  br label %37

32:                                               ; preds = %26
  %33 = load i32, ptr %12, align 4, !tbaa !9
  %34 = add nsw i32 %33, -1
  store i32 %34, ptr %12, align 4, !tbaa !9
  %35 = load i32, ptr %6, align 4, !tbaa !9
  %36 = add nsw i32 %35, 13
  store i32 %36, ptr %13, align 4, !tbaa !9
  br label %37

37:                                               ; preds = %32, %29
  %38 = load i32, ptr %12, align 4, !tbaa !9
  %39 = sitofp i32 %38 to double
  %40 = fmul double 3.650000e+02, %39
  %41 = call double @llvm.floor.f64(double %40)
  %42 = load i32, ptr %12, align 4, !tbaa !9
  %43 = sitofp i32 %42 to double
  %44 = call double @llvm.fmuladd.f64(double 2.500000e-01, double %43, double 2.000000e+03)
  %45 = call double @llvm.floor.f64(double %44)
  %46 = fadd double %41, %45
  %47 = load i32, ptr %13, align 4, !tbaa !9
  %48 = sitofp i32 %47 to double
  %49 = fmul double 3.060010e+01, %48
  %50 = call double @llvm.floor.f64(double %49)
  %51 = fadd double %46, %50
  %52 = load i32, ptr %7, align 4, !tbaa !9
  %53 = sitofp i32 %52 to double
  %54 = fadd double %51, %53
  %55 = fadd double %54, 0x413A3AD300000000
  %56 = fptosi double %55 to i32
  store i32 %56, ptr %11, align 4, !tbaa !9
  %57 = load i32, ptr %7, align 4, !tbaa !9
  %58 = load i32, ptr %6, align 4, !tbaa !9
  %59 = load i32, ptr %8, align 4, !tbaa !9
  %60 = mul nsw i32 12, %59
  %61 = add nsw i32 %58, %60
  %62 = mul nsw i32 31, %61
  %63 = add nsw i32 %57, %62
  %64 = icmp sge i32 %63, 588829
  br i1 %64, label %65, label %81

65:                                               ; preds = %37
  %66 = load i32, ptr %12, align 4, !tbaa !9
  %67 = sitofp i32 %66 to double
  %68 = fmul double 1.000000e-02, %67
  %69 = fptosi double %68 to i32
  store i32 %69, ptr %10, align 4, !tbaa !9
  %70 = load i32, ptr %10, align 4, !tbaa !9
  %71 = sub nsw i32 2, %70
  %72 = load i32, ptr %10, align 4, !tbaa !9
  %73 = sitofp i32 %72 to double
  %74 = fmul double 2.500000e-01, %73
  %75 = fptosi double %74 to i32
  %76 = add nsw i32 %71, %75
  %77 = load i32, ptr %11, align 4, !tbaa !9
  %78 = add nsw i32 %77, %76
  store i32 %78, ptr %11, align 4, !tbaa !9
  %79 = load i32, ptr %11, align 4, !tbaa !9
  %80 = sub nsw i32 %79, 2415019
  store i32 %80, ptr %11, align 4, !tbaa !9
  br label %81

81:                                               ; preds = %65, %37
  %82 = load i32, ptr %11, align 4, !tbaa !9
  call void @llvm.lifetime.end.p0(i64 4, ptr %13) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %12) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #3
  ret i32 %82
}

; 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

declare ptr @__cxa_allocate_exception(i64)

declare void @__cxa_throw(ptr, ptr, ptr)

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

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

attributes #0 = { mustprogress 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 nosync nounwind speculatable willreturn memory(none) }
attributes #3 = { nounwind }
attributes #4 = { noreturn }

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


; 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 [31 x i8], align 1
@_ZTIPKc = external constant ptr

; Function Attrs: mustprogress uwtable
define dso_local noundef i32 @_ZN5Timer6juldayEiii(ptr nocapture noundef nonnull readnone align 8 dereferenceable(36) %0, i32 noundef %1, i32 noundef %2, i32 noundef %3) local_unnamed_addr #0 align 2 {
  %5 = icmp eq i32 %3, 0
  br i1 %5, label %6, label %8

6:                                                ; preds = %4
  %7 = tail call ptr @__cxa_allocate_exception(i64 8) #2
  store ptr @.str, ptr %7, align 16, !tbaa !5
  tail call void @__cxa_throw(ptr nonnull %7, ptr nonnull @_ZTIPKc, ptr null) #3
  unreachable

8:                                                ; preds = %4
  %9 = lshr i32 %3, 31
  %10 = icmp slt i32 %1, 3
  %11 = sext i1 %10 to i32
  %spec.select = add i32 %11, %3
  %.1 = add i32 %spec.select, %9
  %.0.v = select i1 %10, i32 13, i32 1
  %.0 = add nsw i32 %.0.v, %1
  %12 = sitofp i32 %.1 to double
  %13 = fmul double %12, 3.650000e+02
  %14 = tail call double @llvm.floor.f64(double %13)
  %15 = tail call double @llvm.fmuladd.f64(double %12, double 2.500000e-01, double 2.000000e+03)
  %16 = tail call double @llvm.floor.f64(double %15)
  %17 = fadd double %14, %16
  %18 = sitofp i32 %.0 to double
  %19 = fmul double %18, 3.060010e+01
  %20 = tail call double @llvm.floor.f64(double %19)
  %21 = fadd double %20, %17
  %22 = sitofp i32 %2 to double
  %23 = fadd double %21, %22
  %24 = fadd double %23, 0x413A3AD300000000
  %25 = fptosi double %24 to i32
  %26 = mul nsw i32 %3, 12
  %27 = add nsw i32 %26, %1
  %28 = mul nsw i32 %27, 31
  %29 = add nsw i32 %28, %2
  %30 = icmp sgt i32 %29, 588828
  br i1 %30, label %31, label %39

31:                                               ; preds = %8
  %32 = fmul double %12, 1.000000e-02
  %33 = fptosi double %32 to i32
  %34 = sitofp i32 %33 to double
  %35 = fmul double %34, 2.500000e-01
  %36 = fptosi double %35 to i32
  %reass.sub = sub i32 %36, %33
  %37 = add i32 %reass.sub, -2415017
  %38 = add i32 %37, %25
  br label %39

39:                                               ; preds = %31, %8
  %.022 = phi i32 [ %38, %31 ], [ %25, %8 ]
  ret i32 %.022
}

declare ptr @__cxa_allocate_exception(i64) local_unnamed_addr

declare void @__cxa_throw(ptr, ptr, ptr) local_unnamed_addr

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

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

attributes #0 = { mustprogress 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 speculatable willreturn memory(none) }
attributes #2 = { nounwind }
attributes #3 = { noreturn }

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


; Effective O3 passes: EarlyCSEPass,GlobalOptPass,IPSCCPPass,InferFunctionAttrsPass,InstCombinePass,PostOrderFunctionAttrsPass,ReassociatePass,SROAPass,SimplifyCFGPass,TailCallElimPass