; LLVM IR from vteromero/VTEnc :: tests/unit (countbits_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"

@__const.test_count_zeros_at_bit_pos16.values = external hidden unnamed_addr constant [10 x i16], align 16
@.str.10 = external hidden unnamed_addr constant [57 x i8], align 1
@.str.11 = external hidden unnamed_addr constant [57 x i8], align 1
@.str.12 = external hidden unnamed_addr constant [57 x i8], align 1
@.str.13 = external hidden unnamed_addr constant [57 x i8], align 1
@.str.14 = external hidden unnamed_addr constant [58 x i8], align 1
@.str.15 = external hidden unnamed_addr constant [58 x i8], align 1
@.str.16 = external hidden unnamed_addr constant [61 x i8], align 1
@.str.17 = external hidden unnamed_addr constant [61 x i8], align 1
@.str.18 = external hidden unnamed_addr constant [61 x i8], align 1
@.str.19 = external hidden unnamed_addr constant [61 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 nounwind willreturn memory(argmem: readwrite)
declare void @llvm.memcpy.p0.p0.i64(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i64, i1 immarg) #1

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

; 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 @test_count_zeros_at_bit_pos16() #3 {
  %1 = alloca i32, align 4
  %2 = alloca [10 x i16], align 16
  %3 = alloca i32, align 4
  call void @llvm.lifetime.start.p0(i64 20, ptr %2) #5
  call void @llvm.memcpy.p0.p0.i64(ptr align 16 %2, ptr align 16 @__const.test_count_zeros_at_bit_pos16.values, i64 20, i1 false)
  br label %4

4:                                                ; preds = %0
  %5 = getelementptr inbounds [10 x i16], ptr %2, i64 0, i64 0
  %6 = call i64 @count_zeros_at_bit_pos16(ptr noundef %5, i64 noundef 0, i32 noundef 0)
  %7 = icmp eq i64 %6, 0
  br i1 %7, label %10, label %8

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

10:                                               ; preds = %4
  br label %11

11:                                               ; preds = %10
  br label %12

12:                                               ; preds = %11
  br label %13

13:                                               ; preds = %12
  %14 = getelementptr inbounds [10 x i16], ptr %2, i64 0, i64 0
  %15 = call i64 @count_zeros_at_bit_pos16(ptr noundef %14, i64 noundef 0, i32 noundef 8)
  %16 = icmp eq i64 %15, 0
  br i1 %16, label %19, label %17

17:                                               ; preds = %13
  %18 = call i32 (ptr, ...) @printf(ptr noundef @.str.11)
  store i32 0, ptr %1, align 4
  store i32 1, ptr %3, align 4
  br label %98

19:                                               ; preds = %13
  br label %20

20:                                               ; preds = %19
  br label %21

21:                                               ; preds = %20
  br label %22

22:                                               ; preds = %21
  %23 = getelementptr inbounds [10 x i16], ptr %2, i64 0, i64 0
  %24 = call i64 @count_zeros_at_bit_pos16(ptr noundef %23, i64 noundef 3, i32 noundef 0)
  %25 = icmp eq i64 %24, 3
  br i1 %25, label %28, label %26

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

28:                                               ; preds = %22
  br label %29

29:                                               ; preds = %28
  br label %30

30:                                               ; preds = %29
  br label %31

31:                                               ; preds = %30
  %32 = getelementptr inbounds [10 x i16], ptr %2, i64 0, i64 0
  %33 = call i64 @count_zeros_at_bit_pos16(ptr noundef %32, i64 noundef 3, i32 noundef 8)
  %34 = icmp eq i64 %33, 3
  br i1 %34, label %37, label %35

35:                                               ; preds = %31
  %36 = call i32 (ptr, ...) @printf(ptr noundef @.str.13)
  store i32 0, ptr %1, align 4
  store i32 1, ptr %3, align 4
  br label %98

37:                                               ; preds = %31
  br label %38

38:                                               ; preds = %37
  br label %39

39:                                               ; preds = %38
  br label %40

40:                                               ; preds = %39
  %41 = getelementptr inbounds [10 x i16], ptr %2, i64 0, i64 0
  %42 = call i64 @count_zeros_at_bit_pos16(ptr noundef %41, i64 noundef 10, i32 noundef 0)
  %43 = icmp eq i64 %42, 5
  br i1 %43, label %46, label %44

44:                                               ; preds = %40
  %45 = call i32 (ptr, ...) @printf(ptr noundef @.str.14)
  store i32 0, ptr %1, align 4
  store i32 1, ptr %3, align 4
  br label %98

46:                                               ; preds = %40
  br label %47

47:                                               ; preds = %46
  br label %48

48:                                               ; preds = %47
  br label %49

49:                                               ; preds = %48
  %50 = getelementptr inbounds [10 x i16], ptr %2, i64 0, i64 0
  %51 = call i64 @count_zeros_at_bit_pos16(ptr noundef %50, i64 noundef 10, i32 noundef 8)
  %52 = icmp eq i64 %51, 5
  br i1 %52, label %55, label %53

53:                                               ; preds = %49
  %54 = call i32 (ptr, ...) @printf(ptr noundef @.str.15)
  store i32 0, ptr %1, align 4
  store i32 1, ptr %3, align 4
  br label %98

55:                                               ; preds = %49
  br label %56

56:                                               ; preds = %55
  br label %57

57:                                               ; preds = %56
  br label %58

58:                                               ; preds = %57
  %59 = getelementptr inbounds [10 x i16], ptr %2, i64 0, i64 0
  %60 = getelementptr inbounds i16, ptr %59, i64 3
  %61 = call i64 @count_zeros_at_bit_pos16(ptr noundef %60, i64 noundef 7, i32 noundef 0)
  %62 = icmp eq i64 %61, 2
  br i1 %62, label %65, label %63

63:                                               ; preds = %58
  %64 = call i32 (ptr, ...) @printf(ptr noundef @.str.16)
  store i32 0, ptr %1, align 4
  store i32 1, ptr %3, align 4
  br label %98

65:                                               ; preds = %58
  br label %66

66:                                               ; preds = %65
  br label %67

67:                                               ; preds = %66
  br label %68

68:                                               ; preds = %67
  %69 = getelementptr inbounds [10 x i16], ptr %2, i64 0, i64 0
  %70 = getelementptr inbounds i16, ptr %69, i64 3
  %71 = call i64 @count_zeros_at_bit_pos16(ptr noundef %70, i64 noundef 7, i32 noundef 8)
  %72 = icmp eq i64 %71, 2
  br i1 %72, label %75, label %73

73:                                               ; preds = %68
  %74 = call i32 (ptr, ...) @printf(ptr noundef @.str.17)
  store i32 0, ptr %1, align 4
  store i32 1, ptr %3, align 4
  br label %98

75:                                               ; preds = %68
  br label %76

76:                                               ; preds = %75
  br label %77

77:                                               ; preds = %76
  br label %78

78:                                               ; preds = %77
  %79 = getelementptr inbounds [10 x i16], ptr %2, i64 0, i64 0
  %80 = getelementptr inbounds i16, ptr %79, i64 5
  %81 = call i64 @count_zeros_at_bit_pos16(ptr noundef %80, i64 noundef 5, i32 noundef 0)
  %82 = icmp eq i64 %81, 0
  br i1 %82, label %85, label %83

83:                                               ; preds = %78
  %84 = call i32 (ptr, ...) @printf(ptr noundef @.str.18)
  store i32 0, ptr %1, align 4
  store i32 1, ptr %3, align 4
  br label %98

85:                                               ; preds = %78
  br label %86

86:                                               ; preds = %85
  br label %87

87:                                               ; preds = %86
  br label %88

88:                                               ; preds = %87
  %89 = getelementptr inbounds [10 x i16], ptr %2, i64 0, i64 0
  %90 = getelementptr inbounds i16, ptr %89, i64 5
  %91 = call i64 @count_zeros_at_bit_pos16(ptr noundef %90, i64 noundef 5, i32 noundef 8)
  %92 = icmp eq i64 %91, 0
  br i1 %92, label %95, label %93

93:                                               ; preds = %88
  %94 = call i32 (ptr, ...) @printf(ptr noundef @.str.19)
  store i32 0, ptr %1, align 4
  store i32 1, ptr %3, align 4
  br label %98

95:                                               ; preds = %88
  br label %96

96:                                               ; preds = %95
  br label %97

97:                                               ; preds = %96
  store i32 1, ptr %1, align 4
  store i32 1, ptr %3, align 4
  br label %98

98:                                               ; preds = %97, %93, %83, %73, %63, %53, %44, %35, %26, %17, %8
  call void @llvm.lifetime.end.p0(i64 20, ptr %2) #5
  %99 = load i32, ptr %1, align 4
  ret i32 %99
}

; Function Attrs: inlinehint nounwind uwtable
declare hidden i64 @count_zeros_at_bit_pos16(ptr noundef, i64 noundef, i32 noundef) #4

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


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

@__const.test_count_zeros_at_bit_pos16.values = external hidden unnamed_addr constant [10 x i16], align 16
@.str.10 = external hidden unnamed_addr constant [57 x i8], align 1
@.str.11 = external hidden unnamed_addr constant [57 x i8], align 1
@.str.12 = external hidden unnamed_addr constant [57 x i8], align 1
@.str.13 = external hidden unnamed_addr constant [57 x i8], align 1
@.str.14 = external hidden unnamed_addr constant [58 x i8], align 1
@.str.15 = external hidden unnamed_addr constant [58 x i8], align 1
@.str.16 = external hidden unnamed_addr constant [61 x i8], align 1
@.str.17 = external hidden unnamed_addr constant [61 x i8], align 1
@.str.18 = external hidden unnamed_addr constant [61 x i8], align 1
@.str.19 = external hidden unnamed_addr constant [61 x i8], align 1

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

; Function Attrs: mustprogress nocallback nofree nounwind willreturn memory(argmem: readwrite)
declare void @llvm.memcpy.p0.p0.i64(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i64, i1 immarg) #1

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

; Function Attrs: mustprogress 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 range(i32 0, 2) i32 @test_count_zeros_at_bit_pos16() local_unnamed_addr #3 {
  %1 = alloca [10 x i16], align 16
  call void @llvm.lifetime.start.p0(i64 20, ptr nonnull %1) #5
  call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 16 dereferenceable(20) %1, ptr noundef nonnull align 16 dereferenceable(20) @__const.test_count_zeros_at_bit_pos16.values, i64 20, i1 false)
  %2 = call i64 @count_zeros_at_bit_pos16(ptr noundef nonnull %1, i64 noundef 0, i32 noundef 0)
  %3 = icmp eq i64 %2, 0
  br i1 %3, label %4, label %.sink.split

4:                                                ; preds = %0
  %5 = call i64 @count_zeros_at_bit_pos16(ptr noundef nonnull %1, i64 noundef 0, i32 noundef 8)
  %6 = icmp eq i64 %5, 0
  br i1 %6, label %7, label %.sink.split

7:                                                ; preds = %4
  %8 = call i64 @count_zeros_at_bit_pos16(ptr noundef nonnull %1, i64 noundef 3, i32 noundef 0)
  %9 = icmp eq i64 %8, 3
  br i1 %9, label %10, label %.sink.split

10:                                               ; preds = %7
  %11 = call i64 @count_zeros_at_bit_pos16(ptr noundef nonnull %1, i64 noundef 3, i32 noundef 8)
  %12 = icmp eq i64 %11, 3
  br i1 %12, label %13, label %.sink.split

13:                                               ; preds = %10
  %14 = call i64 @count_zeros_at_bit_pos16(ptr noundef nonnull %1, i64 noundef 10, i32 noundef 0)
  %15 = icmp eq i64 %14, 5
  br i1 %15, label %16, label %.sink.split

16:                                               ; preds = %13
  %17 = call i64 @count_zeros_at_bit_pos16(ptr noundef nonnull %1, i64 noundef 10, i32 noundef 8)
  %18 = icmp eq i64 %17, 5
  br i1 %18, label %19, label %.sink.split

19:                                               ; preds = %16
  %20 = getelementptr inbounds i8, ptr %1, i64 6
  %21 = call i64 @count_zeros_at_bit_pos16(ptr noundef nonnull %20, i64 noundef 7, i32 noundef 0)
  %22 = icmp eq i64 %21, 2
  br i1 %22, label %23, label %.sink.split

23:                                               ; preds = %19
  %24 = call i64 @count_zeros_at_bit_pos16(ptr noundef nonnull %20, i64 noundef 7, i32 noundef 8)
  %25 = icmp eq i64 %24, 2
  br i1 %25, label %26, label %.sink.split

26:                                               ; preds = %23
  %27 = getelementptr inbounds i8, ptr %1, i64 10
  %28 = call i64 @count_zeros_at_bit_pos16(ptr noundef nonnull %27, i64 noundef 5, i32 noundef 0)
  %29 = icmp eq i64 %28, 0
  br i1 %29, label %30, label %.sink.split

30:                                               ; preds = %26
  %31 = call i64 @count_zeros_at_bit_pos16(ptr noundef nonnull %27, i64 noundef 5, i32 noundef 8)
  %32 = icmp eq i64 %31, 0
  br i1 %32, label %34, label %.sink.split

.sink.split:                                      ; preds = %30, %26, %23, %19, %16, %13, %10, %7, %4, %0
  %.str.19.sink = phi ptr [ @.str.10, %0 ], [ @.str.11, %4 ], [ @.str.12, %7 ], [ @.str.13, %10 ], [ @.str.14, %13 ], [ @.str.15, %16 ], [ @.str.16, %19 ], [ @.str.17, %23 ], [ @.str.18, %26 ], [ @.str.19, %30 ]
  %33 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) %.str.19.sink)
  br label %34

34:                                               ; preds = %.sink.split, %30
  %.0 = phi i32 [ 1, %30 ], [ 0, %.sink.split ]
  call void @llvm.lifetime.end.p0(i64 20, ptr nonnull %1) #5
  ret i32 %.0
}

; Function Attrs: inlinehint nounwind uwtable
declare hidden i64 @count_zeros_at_bit_pos16(ptr noundef, i64 noundef, i32 noundef) local_unnamed_addr #4

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