; LLVM IR from vteromero/VTEnc :: tests/unit (bits_test)

; 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.9 = external hidden unnamed_addr constant [33 x i8], align 1
@.str.10 = external hidden unnamed_addr constant [33 x i8], align 1
@.str.11 = external hidden unnamed_addr constant [33 x i8], align 1
@.str.12 = external hidden unnamed_addr constant [33 x i8], align 1
@.str.13 = external hidden unnamed_addr constant [34 x i8], align 1
@.str.14 = external hidden unnamed_addr constant [34 x i8], align 1
@.str.15 = external hidden unnamed_addr constant [34 x i8], align 1
@.str.16 = external hidden unnamed_addr constant [35 x i8], align 1
@.str.17 = external hidden unnamed_addr constant [35 x i8], align 1
@.str.18 = external hidden unnamed_addr constant [35 x i8], align 1

declare i32 @printf(ptr noundef, ...) #0

; Function Attrs: nounwind uwtable
define dso_local i32 @test_bits_len_u8() #1 {
  %1 = alloca i32, align 4
  br label %2

2:                                                ; preds = %0
  %3 = call i32 @bits_len_u8(i8 noundef zeroext 0)
  %4 = icmp eq i32 %3, 1
  br i1 %4, label %7, label %5

5:                                                ; preds = %2
  %6 = call i32 (ptr, ...) @printf(ptr noundef @.str.9)
  store i32 0, ptr %1, align 4
  br label %72

7:                                                ; preds = %2
  br label %8

8:                                                ; preds = %7
  br label %9

9:                                                ; preds = %8
  %10 = call i32 @bits_len_u8(i8 noundef zeroext 1)
  %11 = icmp eq i32 %10, 1
  br i1 %11, label %14, label %12

12:                                               ; preds = %9
  %13 = call i32 (ptr, ...) @printf(ptr noundef @.str.10)
  store i32 0, ptr %1, align 4
  br label %72

14:                                               ; preds = %9
  br label %15

15:                                               ; preds = %14
  br label %16

16:                                               ; preds = %15
  %17 = call i32 @bits_len_u8(i8 noundef zeroext 3)
  %18 = icmp eq i32 %17, 2
  br i1 %18, label %21, label %19

19:                                               ; preds = %16
  %20 = call i32 (ptr, ...) @printf(ptr noundef @.str.11)
  store i32 0, ptr %1, align 4
  br label %72

21:                                               ; preds = %16
  br label %22

22:                                               ; preds = %21
  br label %23

23:                                               ; preds = %22
  %24 = call i32 @bits_len_u8(i8 noundef zeroext 7)
  %25 = icmp eq i32 %24, 3
  br i1 %25, label %28, label %26

26:                                               ; preds = %23
  %27 = call i32 (ptr, ...) @printf(ptr noundef @.str.12)
  store i32 0, ptr %1, align 4
  br label %72

28:                                               ; preds = %23
  br label %29

29:                                               ; preds = %28
  br label %30

30:                                               ; preds = %29
  %31 = call i32 @bits_len_u8(i8 noundef zeroext 11)
  %32 = icmp eq i32 %31, 4
  br i1 %32, label %35, label %33

33:                                               ; preds = %30
  %34 = call i32 (ptr, ...) @printf(ptr noundef @.str.13)
  store i32 0, ptr %1, align 4
  br label %72

35:                                               ; preds = %30
  br label %36

36:                                               ; preds = %35
  br label %37

37:                                               ; preds = %36
  %38 = call i32 @bits_len_u8(i8 noundef zeroext 25)
  %39 = icmp eq i32 %38, 5
  br i1 %39, label %42, label %40

40:                                               ; preds = %37
  %41 = call i32 (ptr, ...) @printf(ptr noundef @.str.14)
  store i32 0, ptr %1, align 4
  br label %72

42:                                               ; preds = %37
  br label %43

43:                                               ; preds = %42
  br label %44

44:                                               ; preds = %43
  %45 = call i32 @bits_len_u8(i8 noundef zeroext 50)
  %46 = icmp eq i32 %45, 6
  br i1 %46, label %49, label %47

47:                                               ; preds = %44
  %48 = call i32 (ptr, ...) @printf(ptr noundef @.str.15)
  store i32 0, ptr %1, align 4
  br label %72

49:                                               ; preds = %44
  br label %50

50:                                               ; preds = %49
  br label %51

51:                                               ; preds = %50
  %52 = call i32 @bits_len_u8(i8 noundef zeroext 100)
  %53 = icmp eq i32 %52, 7
  br i1 %53, label %56, label %54

54:                                               ; preds = %51
  %55 = call i32 (ptr, ...) @printf(ptr noundef @.str.16)
  store i32 0, ptr %1, align 4
  br label %72

56:                                               ; preds = %51
  br label %57

57:                                               ; preds = %56
  br label %58

58:                                               ; preds = %57
  %59 = call i32 @bits_len_u8(i8 noundef zeroext -56)
  %60 = icmp eq i32 %59, 8
  br i1 %60, label %63, label %61

61:                                               ; preds = %58
  %62 = call i32 (ptr, ...) @printf(ptr noundef @.str.17)
  store i32 0, ptr %1, align 4
  br label %72

63:                                               ; preds = %58
  br label %64

64:                                               ; preds = %63
  br label %65

65:                                               ; preds = %64
  %66 = call i32 @bits_len_u8(i8 noundef zeroext -1)
  %67 = icmp eq i32 %66, 8
  br i1 %67, label %70, label %68

68:                                               ; preds = %65
  %69 = call i32 (ptr, ...) @printf(ptr noundef @.str.18)
  store i32 0, ptr %1, align 4
  br label %72

70:                                               ; preds = %65
  br label %71

71:                                               ; preds = %70
  store i32 1, ptr %1, align 4
  br label %72

72:                                               ; preds = %71, %68, %61, %54, %47, %40, %33, %26, %19, %12, %5
  %73 = load i32, ptr %1, align 4
  ret i32 %73
}

; Function Attrs: inlinehint nounwind uwtable
declare hidden i32 @bits_len_u8(i8 noundef zeroext) #2

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

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


; 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.9 = external hidden unnamed_addr constant [33 x i8], align 1
@.str.10 = external hidden unnamed_addr constant [33 x i8], align 1
@.str.11 = external hidden unnamed_addr constant [33 x i8], align 1
@.str.12 = external hidden unnamed_addr constant [33 x i8], align 1
@.str.13 = external hidden unnamed_addr constant [34 x i8], align 1
@.str.14 = external hidden unnamed_addr constant [34 x i8], align 1
@.str.15 = external hidden unnamed_addr constant [34 x i8], align 1
@.str.16 = external hidden unnamed_addr constant [35 x i8], align 1
@.str.17 = external hidden unnamed_addr constant [35 x i8], align 1
@.str.18 = external hidden unnamed_addr constant [35 x i8], align 1

; Function Attrs: nofree nounwind
declare noundef i32 @printf(ptr nocapture noundef readonly, ...) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
define dso_local range(i32 0, 2) i32 @test_bits_len_u8() local_unnamed_addr #1 {
  %1 = tail call i32 @bits_len_u8(i8 noundef zeroext 0)
  %2 = icmp eq i32 %1, 1
  br i1 %2, label %3, label %.sink.split

3:                                                ; preds = %0
  %4 = tail call i32 @bits_len_u8(i8 noundef zeroext 1)
  %5 = icmp eq i32 %4, 1
  br i1 %5, label %6, label %.sink.split

6:                                                ; preds = %3
  %7 = tail call i32 @bits_len_u8(i8 noundef zeroext 3)
  %8 = icmp eq i32 %7, 2
  br i1 %8, label %9, label %.sink.split

9:                                                ; preds = %6
  %10 = tail call i32 @bits_len_u8(i8 noundef zeroext 7)
  %11 = icmp eq i32 %10, 3
  br i1 %11, label %12, label %.sink.split

12:                                               ; preds = %9
  %13 = tail call i32 @bits_len_u8(i8 noundef zeroext 11)
  %14 = icmp eq i32 %13, 4
  br i1 %14, label %15, label %.sink.split

15:                                               ; preds = %12
  %16 = tail call i32 @bits_len_u8(i8 noundef zeroext 25)
  %17 = icmp eq i32 %16, 5
  br i1 %17, label %18, label %.sink.split

18:                                               ; preds = %15
  %19 = tail call i32 @bits_len_u8(i8 noundef zeroext 50)
  %20 = icmp eq i32 %19, 6
  br i1 %20, label %21, label %.sink.split

21:                                               ; preds = %18
  %22 = tail call i32 @bits_len_u8(i8 noundef zeroext 100)
  %23 = icmp eq i32 %22, 7
  br i1 %23, label %24, label %.sink.split

24:                                               ; preds = %21
  %25 = tail call i32 @bits_len_u8(i8 noundef zeroext -56)
  %26 = icmp eq i32 %25, 8
  br i1 %26, label %27, label %.sink.split

27:                                               ; preds = %24
  %28 = tail call i32 @bits_len_u8(i8 noundef zeroext -1)
  %29 = icmp eq i32 %28, 8
  br i1 %29, label %31, label %.sink.split

.sink.split:                                      ; preds = %27, %24, %21, %18, %15, %12, %9, %6, %3, %0
  %.str.18.sink = phi ptr [ @.str.9, %0 ], [ @.str.10, %3 ], [ @.str.11, %6 ], [ @.str.12, %9 ], [ @.str.13, %12 ], [ @.str.14, %15 ], [ @.str.15, %18 ], [ @.str.16, %21 ], [ @.str.17, %24 ], [ @.str.18, %27 ]
  %30 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) %.str.18.sink)
  br label %31

31:                                               ; preds = %.sink.split, %27
  %.0 = phi i32 [ 1, %27 ], [ 0, %.sink.split ]
  ret i32 %.0
}

; Function Attrs: inlinehint nounwind uwtable
declare hidden i32 @bits_len_u8(i8 noundef zeroext) local_unnamed_addr #2

attributes #0 = { nofree 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 #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 = { inlinehint 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" }

!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: GlobalOptPass,IPSCCPPass,InferFunctionAttrsPass,InstCombinePass,SROAPass,SimplifyCFGPass,TailCallElimPass