; LLVM IR from InsightSoftwareConsortium/ITK :: Modules/ThirdParty/Netlib/src/netlib/slatec (dgamr)

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

; Function Attrs: nounwind uwtable
define dso_local double @dgamr_(ptr noundef %0) #0 {
  %2 = alloca double, align 8
  %3 = alloca ptr, align 8
  %4 = alloca double, align 8
  %5 = alloca double, align 8
  %6 = alloca double, align 8
  %7 = alloca i32, align 4
  store ptr %0, ptr %3, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %4) #4
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #4
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #4
  store double 0.000000e+00, ptr %4, align 8, !tbaa !9
  %8 = load ptr, ptr %3, align 8, !tbaa !5
  %9 = load double, ptr %8, align 8, !tbaa !9
  %10 = fcmp ole double %9, 0.000000e+00
  br i1 %10, label %11, label %19

11:                                               ; preds = %1
  %12 = load ptr, ptr %3, align 8, !tbaa !5
  %13 = call double @d_int(ptr noundef %12)
  %14 = load ptr, ptr %3, align 8, !tbaa !5
  %15 = load double, ptr %14, align 8, !tbaa !9
  %16 = fcmp oeq double %13, %15
  br i1 %16, label %17, label %19

17:                                               ; preds = %11
  %18 = load double, ptr %4, align 8, !tbaa !9
  store double %18, ptr %2, align 8
  store i32 1, ptr %7, align 4
  br label %48

19:                                               ; preds = %11, %1
  %20 = load ptr, ptr %3, align 8, !tbaa !5
  %21 = load double, ptr %20, align 8, !tbaa !9
  %22 = fcmp oge double %21, 0.000000e+00
  br i1 %22, label %23, label %26

23:                                               ; preds = %19
  %24 = load ptr, ptr %3, align 8, !tbaa !5
  %25 = load double, ptr %24, align 8, !tbaa !9
  br label %30

26:                                               ; preds = %19
  %27 = load ptr, ptr %3, align 8, !tbaa !5
  %28 = load double, ptr %27, align 8, !tbaa !9
  %29 = fneg double %28
  br label %30

30:                                               ; preds = %26, %23
  %31 = phi double [ %25, %23 ], [ %29, %26 ]
  %32 = fcmp ogt double %31, 1.000000e+01
  br i1 %32, label %33, label %34

33:                                               ; preds = %30
  br label %39

34:                                               ; preds = %30
  %35 = load ptr, ptr %3, align 8, !tbaa !5
  %36 = call double @dgamma_(ptr noundef %35)
  %37 = fdiv double 1.000000e+00, %36
  store double %37, ptr %4, align 8, !tbaa !9
  %38 = load double, ptr %4, align 8, !tbaa !9
  store double %38, ptr %2, align 8
  store i32 1, ptr %7, align 4
  br label %48

39:                                               ; preds = %33
  %40 = load ptr, ptr %3, align 8, !tbaa !5
  %41 = call i32 @dlgams_(ptr noundef %40, ptr noundef %5, ptr noundef %6)
  %42 = load double, ptr %6, align 8, !tbaa !9
  %43 = load double, ptr %5, align 8, !tbaa !9
  %44 = fneg double %43
  %45 = call double @exp(double noundef %44) #4
  %46 = fmul double %42, %45
  store double %46, ptr %4, align 8, !tbaa !9
  %47 = load double, ptr %4, align 8, !tbaa !9
  store double %47, ptr %2, align 8
  store i32 1, ptr %7, align 4
  br label %48

48:                                               ; preds = %39, %34, %17
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %4) #4
  %49 = load double, ptr %2, align 8
  ret double %49
}

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

declare double @d_int(ptr noundef) #2

declare double @dgamma_(ptr noundef) #2

declare i32 @dlgams_(ptr noundef, ptr noundef, ptr noundef) #2

; Function Attrs: nounwind
declare double @exp(double noundef) #3

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


; 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: nounwind uwtable
define dso_local double @dgamr_(ptr noundef %0) local_unnamed_addr #0 {
  %2 = alloca double, align 8
  %3 = alloca double, align 8
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %2) #4
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %3) #4
  %4 = load double, ptr %0, align 8, !tbaa !5
  %5 = fcmp ugt double %4, 0.000000e+00
  br i1 %5, label %10, label %6

6:                                                ; preds = %1
  %7 = tail call double @d_int(ptr noundef nonnull %0) #4
  %8 = load double, ptr %0, align 8, !tbaa !5
  %9 = fcmp oeq double %7, %8
  br i1 %9, label %26, label %10

10:                                               ; preds = %6, %1
  %11 = phi double [ %8, %6 ], [ %4, %1 ]
  %12 = fcmp ult double %11, 0.000000e+00
  %13 = fneg double %11
  %14 = select i1 %12, double %13, double %11
  %15 = fcmp ogt double %14, 1.000000e+01
  br i1 %15, label %19, label %16

16:                                               ; preds = %10
  %17 = tail call double @dgamma_(ptr noundef nonnull %0) #4
  %18 = fdiv double 1.000000e+00, %17
  br label %26

19:                                               ; preds = %10
  %20 = call i32 @dlgams_(ptr noundef nonnull %0, ptr noundef nonnull %2, ptr noundef nonnull %3) #4
  %21 = load double, ptr %3, align 8, !tbaa !5
  %22 = load double, ptr %2, align 8, !tbaa !5
  %23 = fneg double %22
  %24 = call double @exp(double noundef %23) #4
  %25 = fmul double %21, %24
  br label %26

26:                                               ; preds = %6, %19, %16
  %.0 = phi double [ %25, %19 ], [ %18, %16 ], [ 0.000000e+00, %6 ]
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %3) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %2) #4
  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

declare double @d_int(ptr noundef) local_unnamed_addr #2

declare double @dgamma_(ptr noundef) local_unnamed_addr #2

declare i32 @dlgams_(ptr noundef, ptr noundef, ptr noundef) local_unnamed_addr #2

; Function Attrs: mustprogress nofree nounwind willreturn memory(write)
declare double @exp(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 = { "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 = { 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 = !{!"double", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}


; Effective O3 passes: EarlyCSEPass,GVNPass,GlobalOptPass,InferFunctionAttrsPass,InstCombinePass,SROAPass,SimplifyCFGPass,TailCallElimPass