; LLVM IR from libxsmm/libxsmm :: src (generator_common)

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

@libxsmm_get_ulp_precision.precision = external hidden global i32, align 4
@libxsmm_get_ulp_precision.hasBeenInited = external hidden global i32, align 4
@.str.226 = external hidden unnamed_addr constant [22 x i8], align 1

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

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

; Function Attrs: nounwind uwtable
define dso_local i32 @libxsmm_get_ulp_precision() #1 {
  %1 = alloca ptr, align 8
  %2 = alloca double, align 8
  %3 = load i32, ptr @libxsmm_get_ulp_precision.hasBeenInited, align 4, !tbaa !5
  %4 = icmp eq i32 0, %3
  br i1 %4, label %5, label %23

5:                                                ; preds = %0
  call void @llvm.lifetime.start.p0(i64 8, ptr %1) #4
  %6 = call ptr @getenv(ptr noundef @.str.226) #4
  store ptr %6, ptr %1, align 8, !tbaa !9
  %7 = load ptr, ptr %1, align 8, !tbaa !9
  %8 = icmp ne ptr null, %7
  br i1 %8, label %9, label %22

9:                                                ; preds = %5
  call void @llvm.lifetime.start.p0(i64 8, ptr %2) #4
  %10 = load ptr, ptr %1, align 8, !tbaa !9
  %11 = call double @atof(ptr noundef %10) #5
  store double %11, ptr %2, align 8, !tbaa !11
  %12 = load double, ptr %2, align 8, !tbaa !11
  %13 = fcmp oge double 5.000000e-01, %12
  br i1 %13, label %14, label %15

14:                                               ; preds = %9
  store i32 0, ptr @libxsmm_get_ulp_precision.precision, align 4, !tbaa !5
  br label %21

15:                                               ; preds = %9
  %16 = load double, ptr %2, align 8, !tbaa !11
  %17 = fcmp oge double 1.000000e+00, %16
  br i1 %17, label %18, label %19

18:                                               ; preds = %15
  store i32 1, ptr @libxsmm_get_ulp_precision.precision, align 4, !tbaa !5
  br label %20

19:                                               ; preds = %15
  store i32 2, ptr @libxsmm_get_ulp_precision.precision, align 4, !tbaa !5
  br label %20

20:                                               ; preds = %19, %18
  br label %21

21:                                               ; preds = %20, %14
  call void @llvm.lifetime.end.p0(i64 8, ptr %2) #4
  br label %22

22:                                               ; preds = %21, %5
  store i32 1, ptr @libxsmm_get_ulp_precision.hasBeenInited, align 4, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 8, ptr %1) #4
  br label %23

23:                                               ; preds = %22, %0
  %24 = load i32, ptr @libxsmm_get_ulp_precision.precision, align 4, !tbaa !5
  ret i32 %24
}

; Function Attrs: nounwind
declare ptr @getenv(ptr noundef) #2

; Function Attrs: inlinehint nounwind willreturn memory(read) uwtable
declare double @atof(ptr noundef nonnull) #3

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { 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 #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 = { inlinehint nounwind willreturn memory(read) 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 #4 = { nounwind }
attributes #5 = { nounwind willreturn memory(read) }

!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/C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"any pointer", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"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"

@libxsmm_get_ulp_precision.precision = external hidden local_unnamed_addr global i32, align 4
@libxsmm_get_ulp_precision.hasBeenInited = external hidden local_unnamed_addr global i32, align 4
@.str.226 = external hidden unnamed_addr constant [22 x i8], align 1

; Function Attrs: nofree nounwind memory(readwrite, argmem: read, inaccessiblemem: read) uwtable
define dso_local i32 @libxsmm_get_ulp_precision() local_unnamed_addr #0 {
  %1 = load i32, ptr @libxsmm_get_ulp_precision.hasBeenInited, align 4, !tbaa !5
  %2 = icmp eq i32 %1, 0
  br i1 %2, label %3, label %9

3:                                                ; preds = %0
  %4 = tail call ptr @getenv(ptr noundef nonnull @.str.226) #3
  %.not = icmp eq ptr %4, null
  br i1 %.not, label %8, label %.sink.split

.sink.split:                                      ; preds = %3
  %5 = tail call double @atof(ptr noundef %4) #4
  %6 = fcmp ugt double %5, 5.000000e-01
  %7 = fcmp ugt double %5, 1.000000e+00
  %. = select i1 %7, i32 2, i32 1
  %.sink = select i1 %6, i32 %., i32 0
  store i32 %.sink, ptr @libxsmm_get_ulp_precision.precision, align 4, !tbaa !5
  br label %8

8:                                                ; preds = %.sink.split, %3
  store i32 1, ptr @libxsmm_get_ulp_precision.hasBeenInited, align 4, !tbaa !5
  br label %9

9:                                                ; preds = %8, %0
  %10 = load i32, ptr @libxsmm_get_ulp_precision.precision, align 4, !tbaa !5
  ret i32 %10
}

; Function Attrs: nofree nounwind memory(read)
declare noundef ptr @getenv(ptr nocapture noundef) local_unnamed_addr #1

; Function Attrs: inlinehint mustprogress nofree nounwind willreturn memory(read) uwtable
declare double @atof(ptr nocapture noundef nonnull) local_unnamed_addr #2

attributes #0 = { nofree nounwind memory(readwrite, argmem: read, inaccessiblemem: read) 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 = { nofree nounwind memory(read) "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 #2 = { inlinehint mustprogress nofree nounwind willreturn memory(read) 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 #3 = { nounwind }
attributes #4 = { nounwind willreturn memory(read) }

!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/C++ TBAA"}


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