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

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

%union.anon = type { i32 }

; 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 float @libxsmm_sexp2_u8(i8 noundef zeroext %0) #1 {
  %2 = alloca i8, align 1
  %3 = alloca %union.anon, align 4
  %4 = alloca float, align 4
  %5 = alloca float, align 4
  store i8 %0, ptr %2, align 1, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %3) #3
  call void @llvm.memset.p0.i64(ptr align 4 %3, i8 0, i64 4, i1 false)
  %6 = load i8, ptr %2, align 1, !tbaa !5
  %7 = zext i8 %6 to i32
  %8 = icmp sgt i32 128, %7
  br i1 %8, label %9, label %42

9:                                                ; preds = %1
  %10 = load i8, ptr %2, align 1, !tbaa !5
  %11 = zext i8 %10 to i32
  %12 = icmp slt i32 31, %11
  br i1 %12, label %13, label %36

13:                                               ; preds = %9
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #3
  store float 0x43F0000000000000, ptr %4, align 4, !tbaa !8
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #3
  %14 = load i8, ptr %2, align 1, !tbaa !5
  %15 = zext i8 %14 to i32
  %16 = and i32 %15, 31
  %17 = shl i32 1, %16
  %18 = uitofp i32 %17 to float
  store float %18, ptr %5, align 4, !tbaa !8
  %19 = load float, ptr %5, align 4, !tbaa !8
  %20 = fmul float 0x41F0000000000000, %19
  store float %20, ptr %3, align 4, !tbaa !5
  %21 = load i8, ptr %2, align 1, !tbaa !5
  %22 = zext i8 %21 to i32
  %23 = icmp slt i32 95, %22
  br i1 %23, label %24, label %27

24:                                               ; preds = %13
  %25 = load float, ptr %3, align 4, !tbaa !5
  %26 = fmul float %25, 0x43F0000000000000
  store float %26, ptr %3, align 4, !tbaa !5
  br label %35

27:                                               ; preds = %13
  %28 = load i8, ptr %2, align 1, !tbaa !5
  %29 = zext i8 %28 to i32
  %30 = icmp slt i32 63, %29
  br i1 %30, label %31, label %34

31:                                               ; preds = %27
  %32 = load float, ptr %3, align 4, !tbaa !5
  %33 = fmul float %32, 0x41F0000000000000
  store float %33, ptr %3, align 4, !tbaa !5
  br label %34

34:                                               ; preds = %31, %27
  br label %35

35:                                               ; preds = %34, %24
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #3
  br label %41

36:                                               ; preds = %9
  %37 = load i8, ptr %2, align 1, !tbaa !5
  %38 = zext i8 %37 to i32
  %39 = shl i32 1, %38
  %40 = uitofp i32 %39 to float
  store float %40, ptr %3, align 4, !tbaa !5
  br label %41

41:                                               ; preds = %36, %35
  br label %43

42:                                               ; preds = %1
  store float 0x7FF0000000000000, ptr %3, align 4, !tbaa !5
  br label %43

43:                                               ; preds = %42, %41
  %44 = load float, ptr %3, align 4, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 4, ptr %3) #3
  ret float %44
}

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #2

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 = { nocallback nofree nounwind willreturn memory(argmem: write) }
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 = !{!"omnipotent char", !7, i64 0}
!7 = !{!"Simple C/C++ TBAA"}
!8 = !{!9, !9, i64 0}
!9 = !{!"float", !6, 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: mustprogress nofree norecurse nosync nounwind willreturn memory(none) uwtable
define dso_local float @libxsmm_sexp2_u8(i8 noundef zeroext %0) local_unnamed_addr #0 {
  %2 = zext i8 %0 to i32
  %3 = icmp sgt i8 %0, -1
  br i1 %3, label %4, label %21

4:                                                ; preds = %1
  %5 = icmp ugt i8 %0, 31
  br i1 %5, label %6, label %18

6:                                                ; preds = %4
  %7 = and i32 %2, 31
  %8 = shl nuw i32 1, %7
  %9 = uitofp i32 %8 to float
  %10 = fmul float %9, 0x41F0000000000000
  %11 = icmp ugt i8 %0, 95
  br i1 %11, label %12, label %14

12:                                               ; preds = %6
  %13 = fmul float %10, 0x43F0000000000000
  br label %21

14:                                               ; preds = %6
  %15 = icmp ugt i8 %0, 63
  br i1 %15, label %16, label %21

16:                                               ; preds = %14
  %17 = fmul float %10, 0x41F0000000000000
  br label %21

18:                                               ; preds = %4
  %19 = shl nuw i32 1, %2
  %20 = uitofp i32 %19 to float
  br label %21

21:                                               ; preds = %1, %12, %16, %14, %18
  %.sroa.0.1 = phi float [ %20, %18 ], [ %13, %12 ], [ %17, %16 ], [ %10, %14 ], [ 0x7FF0000000000000, %1 ]
  ret float %.sroa.0.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" }

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


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