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

@.str.20 = external hidden unnamed_addr constant [57 x i8], align 1
@.str.21 = external hidden unnamed_addr constant [58 x i8], align 1
@.str.22 = external hidden unnamed_addr constant [57 x i8], align 1
@.str.23 = external hidden unnamed_addr constant [58 x i8], align 1
@.str.24 = external hidden unnamed_addr constant [58 x i8], align 1
@.str.25 = external hidden unnamed_addr constant [59 x i8], align 1
@.str.26 = external hidden unnamed_addr constant [61 x i8], align 1
@.str.27 = external hidden unnamed_addr constant [62 x i8], align 1
@.str.28 = external hidden unnamed_addr constant [61 x i8], align 1
@.str.29 = external hidden unnamed_addr constant [62 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

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

; 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_pos32() #2 {
  %1 = alloca i32, align 4
  %2 = alloca [10 x i32], align 16
  %3 = alloca i32, align 4
  call void @llvm.lifetime.start.p0(i64 40, ptr %2) #5
  call void @llvm.memset.p0.i64(ptr align 16 %2, i8 0, i64 40, i1 false)
  %4 = getelementptr inbounds [10 x i32], ptr %2, i32 0, i32 5
  store i32 65537, ptr %4, align 4
  %5 = getelementptr inbounds [10 x i32], ptr %2, i32 0, i32 6
  store i32 65537, ptr %5, align 8
  %6 = getelementptr inbounds [10 x i32], ptr %2, i32 0, i32 7
  store i32 65537, ptr %6, align 4
  %7 = getelementptr inbounds [10 x i32], ptr %2, i32 0, i32 8
  store i32 65537, ptr %7, align 16
  %8 = getelementptr inbounds [10 x i32], ptr %2, i32 0, i32 9
  store i32 65537, ptr %8, align 4
  br label %9

9:                                                ; preds = %0
  %10 = getelementptr inbounds [10 x i32], ptr %2, i64 0, i64 0
  %11 = call i64 @count_zeros_at_bit_pos32(ptr noundef %10, i64 noundef 0, i32 noundef 0)
  %12 = icmp eq i64 %11, 0
  br i1 %12, label %15, label %13

13:                                               ; preds = %9
  %14 = call i32 (ptr, ...) @printf(ptr noundef @.str.20)
  store i32 0, ptr %1, align 4
  store i32 1, ptr %3, align 4
  br label %103

15:                                               ; preds = %9
  br label %16

16:                                               ; preds = %15
  br label %17

17:                                               ; preds = %16
  br label %18

18:                                               ; preds = %17
  %19 = getelementptr inbounds [10 x i32], ptr %2, i64 0, i64 0
  %20 = call i64 @count_zeros_at_bit_pos32(ptr noundef %19, i64 noundef 0, i32 noundef 16)
  %21 = icmp eq i64 %20, 0
  br i1 %21, label %24, label %22

22:                                               ; preds = %18
  %23 = call i32 (ptr, ...) @printf(ptr noundef @.str.21)
  store i32 0, ptr %1, align 4
  store i32 1, ptr %3, align 4
  br label %103

24:                                               ; preds = %18
  br label %25

25:                                               ; preds = %24
  br label %26

26:                                               ; preds = %25
  br label %27

27:                                               ; preds = %26
  %28 = getelementptr inbounds [10 x i32], ptr %2, i64 0, i64 0
  %29 = call i64 @count_zeros_at_bit_pos32(ptr noundef %28, i64 noundef 3, i32 noundef 0)
  %30 = icmp eq i64 %29, 3
  br i1 %30, label %33, label %31

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

33:                                               ; preds = %27
  br label %34

34:                                               ; preds = %33
  br label %35

35:                                               ; preds = %34
  br label %36

36:                                               ; preds = %35
  %37 = getelementptr inbounds [10 x i32], ptr %2, i64 0, i64 0
  %38 = call i64 @count_zeros_at_bit_pos32(ptr noundef %37, i64 noundef 3, i32 noundef 16)
  %39 = icmp eq i64 %38, 3
  br i1 %39, label %42, label %40

40:                                               ; preds = %36
  %41 = call i32 (ptr, ...) @printf(ptr noundef @.str.23)
  store i32 0, ptr %1, align 4
  store i32 1, ptr %3, align 4
  br label %103

42:                                               ; preds = %36
  br label %43

43:                                               ; preds = %42
  br label %44

44:                                               ; preds = %43
  br label %45

45:                                               ; preds = %44
  %46 = getelementptr inbounds [10 x i32], ptr %2, i64 0, i64 0
  %47 = call i64 @count_zeros_at_bit_pos32(ptr noundef %46, i64 noundef 10, i32 noundef 0)
  %48 = icmp eq i64 %47, 5
  br i1 %48, label %51, label %49

49:                                               ; preds = %45
  %50 = call i32 (ptr, ...) @printf(ptr noundef @.str.24)
  store i32 0, ptr %1, align 4
  store i32 1, ptr %3, align 4
  br label %103

51:                                               ; preds = %45
  br label %52

52:                                               ; preds = %51
  br label %53

53:                                               ; preds = %52
  br label %54

54:                                               ; preds = %53
  %55 = getelementptr inbounds [10 x i32], ptr %2, i64 0, i64 0
  %56 = call i64 @count_zeros_at_bit_pos32(ptr noundef %55, i64 noundef 10, i32 noundef 16)
  %57 = icmp eq i64 %56, 5
  br i1 %57, label %60, label %58

58:                                               ; preds = %54
  %59 = call i32 (ptr, ...) @printf(ptr noundef @.str.25)
  store i32 0, ptr %1, align 4
  store i32 1, ptr %3, align 4
  br label %103

60:                                               ; preds = %54
  br label %61

61:                                               ; preds = %60
  br label %62

62:                                               ; preds = %61
  br label %63

63:                                               ; preds = %62
  %64 = getelementptr inbounds [10 x i32], ptr %2, i64 0, i64 0
  %65 = getelementptr inbounds i32, ptr %64, i64 3
  %66 = call i64 @count_zeros_at_bit_pos32(ptr noundef %65, i64 noundef 7, i32 noundef 0)
  %67 = icmp eq i64 %66, 2
  br i1 %67, label %70, label %68

68:                                               ; preds = %63
  %69 = call i32 (ptr, ...) @printf(ptr noundef @.str.26)
  store i32 0, ptr %1, align 4
  store i32 1, ptr %3, align 4
  br label %103

70:                                               ; preds = %63
  br label %71

71:                                               ; preds = %70
  br label %72

72:                                               ; preds = %71
  br label %73

73:                                               ; preds = %72
  %74 = getelementptr inbounds [10 x i32], ptr %2, i64 0, i64 0
  %75 = getelementptr inbounds i32, ptr %74, i64 3
  %76 = call i64 @count_zeros_at_bit_pos32(ptr noundef %75, i64 noundef 7, i32 noundef 16)
  %77 = icmp eq i64 %76, 2
  br i1 %77, label %80, label %78

78:                                               ; preds = %73
  %79 = call i32 (ptr, ...) @printf(ptr noundef @.str.27)
  store i32 0, ptr %1, align 4
  store i32 1, ptr %3, align 4
  br label %103

80:                                               ; preds = %73
  br label %81

81:                                               ; preds = %80
  br label %82

82:                                               ; preds = %81
  br label %83

83:                                               ; preds = %82
  %84 = getelementptr inbounds [10 x i32], ptr %2, i64 0, i64 0
  %85 = getelementptr inbounds i32, ptr %84, i64 5
  %86 = call i64 @count_zeros_at_bit_pos32(ptr noundef %85, i64 noundef 5, i32 noundef 0)
  %87 = icmp eq i64 %86, 0
  br i1 %87, label %90, label %88

88:                                               ; preds = %83
  %89 = call i32 (ptr, ...) @printf(ptr noundef @.str.28)
  store i32 0, ptr %1, align 4
  store i32 1, ptr %3, align 4
  br label %103

90:                                               ; preds = %83
  br label %91

91:                                               ; preds = %90
  br label %92

92:                                               ; preds = %91
  br label %93

93:                                               ; preds = %92
  %94 = getelementptr inbounds [10 x i32], ptr %2, i64 0, i64 0
  %95 = getelementptr inbounds i32, ptr %94, i64 5
  %96 = call i64 @count_zeros_at_bit_pos32(ptr noundef %95, i64 noundef 5, i32 noundef 16)
  %97 = icmp eq i64 %96, 0
  br i1 %97, label %100, label %98

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

100:                                              ; preds = %93
  br label %101

101:                                              ; preds = %100
  br label %102

102:                                              ; preds = %101
  store i32 1, ptr %1, align 4
  store i32 1, ptr %3, align 4
  br label %103

103:                                              ; preds = %102, %98, %88, %78, %68, %58, %49, %40, %31, %22, %13
  call void @llvm.lifetime.end.p0(i64 40, ptr %2) #5
  %104 = load i32, ptr %1, align 4
  ret i32 %104
}

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

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

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

@.str.20 = external hidden unnamed_addr constant [57 x i8], align 1
@.str.21 = external hidden unnamed_addr constant [58 x i8], align 1
@.str.22 = external hidden unnamed_addr constant [57 x i8], align 1
@.str.23 = external hidden unnamed_addr constant [58 x i8], align 1
@.str.24 = external hidden unnamed_addr constant [58 x i8], align 1
@.str.25 = external hidden unnamed_addr constant [59 x i8], align 1
@.str.26 = external hidden unnamed_addr constant [61 x i8], align 1
@.str.27 = external hidden unnamed_addr constant [62 x i8], align 1
@.str.28 = external hidden unnamed_addr constant [61 x i8], align 1
@.str.29 = external hidden unnamed_addr constant [62 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: nofree nounwind
declare noundef i32 @printf(ptr nocapture noundef readonly, ...) local_unnamed_addr #1

; 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_pos32() local_unnamed_addr #2 {
  %1 = alloca [10 x i32], align 16
  call void @llvm.lifetime.start.p0(i64 40, ptr nonnull %1) #5
  call void @llvm.memset.p0.i64(ptr noundef nonnull align 16 dereferenceable(40) %1, i8 0, i64 32, i1 false)
  %2 = getelementptr inbounds i8, ptr %1, i64 20
  store <4 x i32> <i32 65537, i32 65537, i32 65537, i32 65537>, ptr %2, align 4
  %3 = getelementptr inbounds i8, ptr %1, i64 36
  store i32 65537, ptr %3, align 4
  %4 = call i64 @count_zeros_at_bit_pos32(ptr noundef nonnull %1, i64 noundef 0, i32 noundef 0)
  %5 = icmp eq i64 %4, 0
  br i1 %5, label %6, label %.sink.split

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

9:                                                ; preds = %6
  %10 = call i64 @count_zeros_at_bit_pos32(ptr noundef nonnull %1, i64 noundef 3, i32 noundef 0)
  %11 = icmp eq i64 %10, 3
  br i1 %11, label %12, label %.sink.split

12:                                               ; preds = %9
  %13 = call i64 @count_zeros_at_bit_pos32(ptr noundef nonnull %1, i64 noundef 3, i32 noundef 16)
  %14 = icmp eq i64 %13, 3
  br i1 %14, label %15, label %.sink.split

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

18:                                               ; preds = %15
  %19 = call i64 @count_zeros_at_bit_pos32(ptr noundef nonnull %1, i64 noundef 10, i32 noundef 16)
  %20 = icmp eq i64 %19, 5
  br i1 %20, label %21, label %.sink.split

21:                                               ; preds = %18
  %22 = getelementptr inbounds i8, ptr %1, i64 12
  %23 = call i64 @count_zeros_at_bit_pos32(ptr noundef nonnull %22, i64 noundef 7, i32 noundef 0)
  %24 = icmp eq i64 %23, 2
  br i1 %24, label %25, label %.sink.split

25:                                               ; preds = %21
  %26 = call i64 @count_zeros_at_bit_pos32(ptr noundef nonnull %22, i64 noundef 7, i32 noundef 16)
  %27 = icmp eq i64 %26, 2
  br i1 %27, label %28, label %.sink.split

28:                                               ; preds = %25
  %29 = call i64 @count_zeros_at_bit_pos32(ptr noundef nonnull %2, i64 noundef 5, i32 noundef 0)
  %30 = icmp eq i64 %29, 0
  br i1 %30, label %31, label %.sink.split

31:                                               ; preds = %28
  %32 = call i64 @count_zeros_at_bit_pos32(ptr noundef nonnull %2, i64 noundef 5, i32 noundef 16)
  %33 = icmp eq i64 %32, 0
  br i1 %33, label %35, label %.sink.split

.sink.split:                                      ; preds = %31, %28, %25, %21, %18, %15, %12, %9, %6, %0
  %.str.29.sink = phi ptr [ @.str.20, %0 ], [ @.str.21, %6 ], [ @.str.22, %9 ], [ @.str.23, %12 ], [ @.str.24, %15 ], [ @.str.25, %18 ], [ @.str.26, %21 ], [ @.str.27, %25 ], [ @.str.28, %28 ], [ @.str.29, %31 ]
  %34 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) %.str.29.sink)
  br label %35

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

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

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

attributes #0 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { 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 #2 = { 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 #3 = { mustprogress nocallback nofree nounwind willreturn memory(argmem: write) }
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: DSEPass,EarlyCSEPass,GlobalOptPass,IPSCCPPass,InferFunctionAttrsPass,InstCombinePass,SLPVectorizerPass,SROAPass,SimplifyCFGPass