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

; 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 [27 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [70 x i8], align 1
@__PRETTY_FUNCTION__.libxsmm_typesize = external hidden unnamed_addr constant [49 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [32 x i8], align 1

; Function Attrs: nounwind uwtable
define dso_local zeroext i8 @libxsmm_typesize(i32 noundef %0) #0 {
  %2 = alloca i32, align 4
  %3 = alloca i8, align 1
  store i32 %0, ptr %2, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 1, ptr %3) #3
  %4 = load i32, ptr %2, align 4, !tbaa !5
  %5 = icmp eq i32 0, %4
  br i1 %5, label %6, label %7

6:                                                ; preds = %1
  br label %87

7:                                                ; preds = %1
  %8 = load i32, ptr %2, align 4, !tbaa !5
  %9 = icmp eq i32 1, %8
  br i1 %9, label %10, label %11

10:                                               ; preds = %7
  br label %85

11:                                               ; preds = %7
  %12 = load i32, ptr %2, align 4, !tbaa !5
  %13 = icmp eq i32 2, %12
  br i1 %13, label %14, label %15

14:                                               ; preds = %11
  br label %83

15:                                               ; preds = %11
  %16 = load i32, ptr %2, align 4, !tbaa !5
  %17 = icmp eq i32 3, %16
  br i1 %17, label %18, label %19

18:                                               ; preds = %15
  br label %81

19:                                               ; preds = %15
  %20 = load i32, ptr %2, align 4, !tbaa !5
  %21 = icmp eq i32 4, %20
  br i1 %21, label %22, label %23

22:                                               ; preds = %19
  br label %79

23:                                               ; preds = %19
  %24 = load i32, ptr %2, align 4, !tbaa !5
  %25 = icmp eq i32 5, %24
  br i1 %25, label %26, label %27

26:                                               ; preds = %23
  br label %77

27:                                               ; preds = %23
  %28 = load i32, ptr %2, align 4, !tbaa !5
  %29 = icmp eq i32 6, %28
  br i1 %29, label %30, label %31

30:                                               ; preds = %27
  br label %75

31:                                               ; preds = %27
  %32 = load i32, ptr %2, align 4, !tbaa !5
  %33 = icmp eq i32 7, %32
  br i1 %33, label %34, label %35

34:                                               ; preds = %31
  br label %73

35:                                               ; preds = %31
  %36 = load i32, ptr %2, align 4, !tbaa !5
  %37 = icmp eq i32 8, %36
  br i1 %37, label %38, label %39

38:                                               ; preds = %35
  br label %71

39:                                               ; preds = %35
  %40 = load i32, ptr %2, align 4, !tbaa !5
  %41 = icmp eq i32 9, %40
  br i1 %41, label %42, label %43

42:                                               ; preds = %39
  br label %69

43:                                               ; preds = %39
  %44 = load i32, ptr %2, align 4, !tbaa !5
  %45 = icmp eq i32 10, %44
  br i1 %45, label %46, label %47

46:                                               ; preds = %43
  br label %67

47:                                               ; preds = %43
  %48 = load i32, ptr %2, align 4, !tbaa !5
  %49 = icmp eq i32 11, %48
  br i1 %49, label %50, label %51

50:                                               ; preds = %47
  br label %65

51:                                               ; preds = %47
  %52 = load i32, ptr %2, align 4, !tbaa !5
  %53 = icmp eq i32 12, %52
  br i1 %53, label %54, label %55

54:                                               ; preds = %51
  br label %63

55:                                               ; preds = %51
  %56 = load i32, ptr %2, align 4, !tbaa !5
  %57 = icmp eq i32 13, %56
  br i1 %57, label %58, label %59

58:                                               ; preds = %55
  br label %61

59:                                               ; preds = %55
  call void @__assert_fail(ptr noundef @.str, ptr noundef @.str.1, i32 noundef 52, ptr noundef @__PRETTY_FUNCTION__.libxsmm_typesize) #4
  unreachable

60:                                               ; No predecessors!
  br label %61

61:                                               ; preds = %60, %58
  %62 = phi i32 [ 1, %58 ], [ 0, %60 ]
  br label %63

63:                                               ; preds = %61, %54
  %64 = phi i32 [ 1, %54 ], [ %62, %61 ]
  br label %65

65:                                               ; preds = %63, %50
  %66 = phi i32 [ 2, %50 ], [ %64, %63 ]
  br label %67

67:                                               ; preds = %65, %46
  %68 = phi i32 [ 2, %46 ], [ %66, %65 ]
  br label %69

69:                                               ; preds = %67, %42
  %70 = phi i32 [ 4, %42 ], [ %68, %67 ]
  br label %71

71:                                               ; preds = %69, %38
  %72 = phi i32 [ 4, %38 ], [ %70, %69 ]
  br label %73

73:                                               ; preds = %71, %34
  %74 = phi i32 [ 8, %34 ], [ %72, %71 ]
  br label %75

75:                                               ; preds = %73, %30
  %76 = phi i32 [ 8, %30 ], [ %74, %73 ]
  br label %77

77:                                               ; preds = %75, %26
  %78 = phi i32 [ 1, %26 ], [ %76, %75 ]
  br label %79

79:                                               ; preds = %77, %22
  %80 = phi i32 [ 1, %22 ], [ %78, %77 ]
  br label %81

81:                                               ; preds = %79, %18
  %82 = phi i32 [ 2, %18 ], [ %80, %79 ]
  br label %83

83:                                               ; preds = %81, %14
  %84 = phi i32 [ 2, %14 ], [ %82, %81 ]
  br label %85

85:                                               ; preds = %83, %10
  %86 = phi i32 [ 4, %10 ], [ %84, %83 ]
  br label %87

87:                                               ; preds = %85, %6
  %88 = phi i32 [ 8, %6 ], [ %86, %85 ]
  %89 = trunc i32 %88 to i8
  store i8 %89, ptr %3, align 1, !tbaa !9
  %90 = load i8, ptr %3, align 1, !tbaa !9
  %91 = zext i8 %90 to i32
  %92 = icmp ne i32 0, %91
  br i1 %92, label %93, label %95

93:                                               ; preds = %87
  %94 = load i8, ptr %3, align 1, !tbaa !9
  call void @llvm.lifetime.end.p0(i64 1, ptr %3) #3
  ret i8 %94

95:                                               ; preds = %87
  call void @__assert_fail(ptr noundef @.str.2, ptr noundef @.str.1, i32 noundef 58, ptr noundef @__PRETTY_FUNCTION__.libxsmm_typesize) #4
  unreachable
}

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

; Function Attrs: noreturn nounwind
declare void @__assert_fail(ptr noundef, ptr noundef, i32 noundef, ptr 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 = { noreturn 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 = { nounwind }
attributes #4 = { noreturn 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 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!7, !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 [27 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [70 x i8], align 1
@__PRETTY_FUNCTION__.libxsmm_typesize = external hidden unnamed_addr constant [49 x i8], align 1
@switch.table.libxsmm_typesize = private unnamed_addr constant [11 x i8] c"\02\02\01\02\08\02\04\02\02\02\01", align 1

; Function Attrs: nounwind uwtable
define dso_local zeroext range(i8 1, 9) i8 @libxsmm_typesize(i32 noundef %0) local_unnamed_addr #0 {
  switch i32 %0, label %2 [
    i32 0, label %7
    i32 1, label %.fold.split
  ]

2:                                                ; preds = %1
  %3 = and i32 %0, -2
  %switch.tableidx = add i32 %3, -2
  %4 = icmp ult i32 %switch.tableidx, 11
  br i1 %4, label %switch.hole_check, label %5

5:                                                ; preds = %switch.hole_check, %2
  tail call void @__assert_fail(ptr noundef nonnull @.str, ptr noundef nonnull @.str.1, i32 noundef 52, ptr noundef nonnull @__PRETTY_FUNCTION__.libxsmm_typesize) #2
  unreachable

.fold.split:                                      ; preds = %1
  br label %7

switch.hole_check:                                ; preds = %2
  %switch.maskindex = trunc nuw i32 %switch.tableidx to i16
  %switch.shifted = lshr i16 1365, %switch.maskindex
  %switch.lobit = trunc i16 %switch.shifted to i1
  br i1 %switch.lobit, label %switch.lookup, label %5

switch.lookup:                                    ; preds = %switch.hole_check
  %6 = zext nneg i32 %switch.tableidx to i64
  %switch.gep = getelementptr inbounds [11 x i8], ptr @switch.table.libxsmm_typesize, i64 0, i64 %6
  %switch.load = load i8, ptr %switch.gep, align 1
  br label %7

7:                                                ; preds = %switch.lookup, %.fold.split, %1
  %8 = phi i8 [ 8, %1 ], [ 4, %.fold.split ], [ %switch.load, %switch.lookup ]
  ret i8 %8
}

; Function Attrs: noreturn nounwind
declare void @__assert_fail(ptr noundef, ptr noundef, i32 noundef, ptr noundef) local_unnamed_addr #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 = { noreturn 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 #2 = { noreturn 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)"}


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