; LLVM IR from InductiveComputerScience/infracore :: drivers/clock-c11 (clock-c11)

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

%struct.timespec = type { i64, i64 }

; Function Attrs: nounwind uwtable
define dso_local double @CurrentTime(ptr noundef %0, double noundef %1) #0 {
  %3 = alloca ptr, align 8
  %4 = alloca double, align 8
  %5 = alloca %struct.timespec, align 8
  %6 = alloca double, align 8
  %7 = alloca double, align 8
  %8 = alloca double, align 8
  store ptr %0, ptr %3, align 8, !tbaa !5
  store double %1, ptr %4, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 16, ptr %5) #4
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #4
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #4
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #4
  %9 = load double, ptr %4, align 8, !tbaa !9
  store double %9, ptr %8, align 8, !tbaa !9
  %10 = call i32 @timespec_get(ptr noundef %5, i32 noundef 1) #4
  %11 = getelementptr inbounds %struct.timespec, ptr %5, i32 0, i32 0
  %12 = load i64, ptr %11, align 8, !tbaa !11
  %13 = sitofp i64 %12 to double
  store double %13, ptr %6, align 8, !tbaa !9
  %14 = load double, ptr %8, align 8, !tbaa !9
  %15 = fcmp oge double %14, 0.000000e+00
  br i1 %15, label %16, label %28

16:                                               ; preds = %2
  %17 = load double, ptr %8, align 8, !tbaa !9
  %18 = fcmp ole double %17, 1.500000e+01
  br i1 %18, label %19, label %28

19:                                               ; preds = %16
  %20 = load double, ptr %6, align 8, !tbaa !9
  %21 = load double, ptr %8, align 8, !tbaa !9
  %22 = call double @pow(double noundef 1.000000e+01, double noundef %21) #4
  %23 = fdiv double %20, %22
  %24 = call double @llvm.floor.f64(double %23)
  %25 = load double, ptr %8, align 8, !tbaa !9
  %26 = call double @pow(double noundef 1.000000e+01, double noundef %25) #4
  %27 = fmul double %24, %26
  store double %27, ptr %6, align 8, !tbaa !9
  br label %61

28:                                               ; preds = %16, %2
  %29 = load double, ptr %8, align 8, !tbaa !9
  %30 = fcmp oge double %29, -9.000000e+00
  br i1 %30, label %31, label %59

31:                                               ; preds = %28
  %32 = load double, ptr %8, align 8, !tbaa !9
  %33 = fcmp olt double %32, 0.000000e+00
  br i1 %33, label %34, label %59

34:                                               ; preds = %31
  %35 = load double, ptr %8, align 8, !tbaa !9
  %36 = fneg double %35
  %37 = fsub double 1.500000e+01, %36
  store double %37, ptr %7, align 8, !tbaa !9
  %38 = load double, ptr %6, align 8, !tbaa !9
  %39 = load double, ptr %7, align 8, !tbaa !9
  %40 = call double @pow(double noundef 1.000000e+01, double noundef %39) #4
  %41 = call double @fmod(double noundef %38, double noundef %40) #4
  store double %41, ptr %6, align 8, !tbaa !9
  %42 = load double, ptr %6, align 8, !tbaa !9
  %43 = getelementptr inbounds %struct.timespec, ptr %5, i32 0, i32 1
  %44 = load i64, ptr %43, align 8, !tbaa !14
  %45 = sitofp i64 %44 to double
  %46 = call double @pow(double noundef 1.000000e+01, double noundef 9.000000e+00) #4
  %47 = fdiv double %45, %46
  %48 = fadd double %42, %47
  store double %48, ptr %6, align 8, !tbaa !9
  %49 = load double, ptr %6, align 8, !tbaa !9
  %50 = load double, ptr %8, align 8, !tbaa !9
  %51 = fneg double %50
  %52 = call double @pow(double noundef 1.000000e+01, double noundef %51) #4
  %53 = fmul double %49, %52
  %54 = call double @llvm.floor.f64(double %53)
  %55 = load double, ptr %8, align 8, !tbaa !9
  %56 = fneg double %55
  %57 = call double @pow(double noundef 1.000000e+01, double noundef %56) #4
  %58 = fdiv double %54, %57
  store double %58, ptr %6, align 8, !tbaa !9
  br label %60

59:                                               ; preds = %31, %28
  store double 0.000000e+00, ptr %6, align 8, !tbaa !9
  br label %60

60:                                               ; preds = %59, %34
  br label %61

61:                                               ; preds = %60, %19
  %62 = load double, ptr %6, align 8, !tbaa !9
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #4
  call void @llvm.lifetime.end.p0(i64 16, ptr %5) #4
  ret double %62
}

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

; Function Attrs: nounwind
declare i32 @timespec_get(ptr noundef, i32 noundef) #2

; Function Attrs: nounwind
declare double @pow(double noundef, double noundef) #2

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

; Function Attrs: nounwind
declare double @fmod(double noundef, double noundef) #2

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

attributes #0 = { 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 = { 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 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
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 = !{!"any pointer", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"double", !7, i64 0}
!11 = !{!12, !13, i64 0}
!12 = !{!"timespec", !13, i64 0, !13, i64 8}
!13 = !{!"long", !7, i64 0}
!14 = !{!12, !13, i64 8}


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

%struct.timespec = type { i64, i64 }

; Function Attrs: nounwind uwtable
define dso_local double @CurrentTime(ptr nocapture noundef readnone %0, double noundef %1) local_unnamed_addr #0 {
  %3 = alloca %struct.timespec, align 8
  call void @llvm.lifetime.start.p0(i64 16, ptr nonnull %3) #5
  %4 = call i32 @timespec_get(ptr noundef nonnull %3, i32 noundef 1) #5
  %5 = load i64, ptr %3, align 8, !tbaa !5
  %6 = sitofp i64 %5 to double
  %7 = fcmp oge double %1, 0.000000e+00
  %8 = fcmp ole double %1, 1.500000e+01
  %or.cond = and i1 %7, %8
  br i1 %or.cond, label %9, label %15

9:                                                ; preds = %2
  %10 = call double @pow(double noundef 1.000000e+01, double noundef %1) #5
  %11 = fdiv double %6, %10
  %12 = call double @llvm.floor.f64(double %11)
  %13 = call double @pow(double noundef 1.000000e+01, double noundef %1) #5
  %14 = fmul double %13, %12
  br label %33

15:                                               ; preds = %2
  %16 = fcmp oge double %1, -9.000000e+00
  %17 = fcmp olt double %1, 0.000000e+00
  %or.cond3 = and i1 %16, %17
  br i1 %or.cond3, label %18, label %33

18:                                               ; preds = %15
  %19 = fneg double %1
  %20 = fadd double %1, 1.500000e+01
  %21 = call double @pow(double noundef 1.000000e+01, double noundef %20) #5
  %22 = call double @fmod(double noundef %6, double noundef %21) #5
  %23 = getelementptr inbounds i8, ptr %3, i64 8
  %24 = load i64, ptr %23, align 8, !tbaa !10
  %25 = sitofp i64 %24 to double
  %26 = fdiv double %25, 1.000000e+09
  %27 = fadd double %22, %26
  %28 = call double @pow(double noundef 1.000000e+01, double noundef %19) #5
  %29 = fmul double %28, %27
  %30 = call double @llvm.floor.f64(double %29)
  %31 = call double @pow(double noundef 1.000000e+01, double noundef %19) #5
  %32 = fdiv double %30, %31
  br label %33

33:                                               ; preds = %15, %18, %9
  %.0 = phi double [ %14, %9 ], [ %32, %18 ], [ 0.000000e+00, %15 ]
  call void @llvm.lifetime.end.p0(i64 16, ptr nonnull %3) #5
  ret double %.0
}

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

; Function Attrs: nounwind
declare i32 @timespec_get(ptr noundef, i32 noundef) local_unnamed_addr #2

; Function Attrs: mustprogress nofree nounwind willreturn memory(write)
declare double @pow(double noundef, double noundef) local_unnamed_addr #3

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

; Function Attrs: mustprogress nofree nounwind willreturn memory(write)
declare double @fmod(double noundef, double noundef) 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) #1

attributes #0 = { 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 nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { 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 = { mustprogress nofree nounwind willreturn memory(write) "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 = { mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #5 = { 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, !7, i64 0}
!6 = !{!"timespec", !7, i64 0, !7, i64 8}
!7 = !{!"long", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!6, !7, i64 8}


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