; LLVM IR from seppo0010/rlite :: tests (hyperloglog-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"

%struct.greatest_run_info = type { i32, i32, i32, i32, i32, i32, %struct.greatest_suite_info, ptr, i32, ptr, ptr, ptr, ptr, ptr, i32, i32, ptr, ptr, i64, i64, [1 x %struct.__jmp_buf_tag] }
%struct.greatest_suite_info = type { i32, i32, i32, i32, i64, i64, i64, i64 }
%struct.__jmp_buf_tag = type { [8 x i64], i32, %struct.__sigset_t }
%struct.__sigset_t = type { [16 x i64] }

@__const.test_hyperloglog_add_count.argv = external hidden unnamed_addr constant [3 x ptr], align 16
@__const.test_hyperloglog_add_count.argvlen = external hidden unnamed_addr constant [3 x i64], align 16
@greatest_info = external global %struct.greatest_run_info, align 8
@.str.3 = external hidden unnamed_addr constant [74 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [12 x i8], align 1
@.str.5 = external hidden unnamed_addr constant [12 x i8], align 1
@.str.6 = external hidden unnamed_addr constant [10 x i8], align 1

; Function Attrs: nounwind uwtable
define dso_local i32 @test_hyperloglog_add_count() #0 {
  %1 = alloca i32, align 4
  %2 = alloca i32, align 4
  %3 = alloca ptr, align 8
  %4 = alloca i64, align 8
  %5 = alloca i64, align 8
  %6 = alloca [3 x ptr], align 16
  %7 = alloca [3 x i64], align 16
  %8 = alloca i32, align 4
  call void @llvm.lifetime.start.p0(i64 4, ptr %2) #5
  call void @llvm.lifetime.start.p0(i64 8, ptr %3) #5
  store ptr null, ptr %3, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %4) #5
  store i64 -1, ptr %4, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #5
  store i64 -1, ptr %5, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 24, ptr %6) #5
  call void @llvm.memcpy.p0.p0.i64(ptr align 16 %6, ptr align 16 @__const.test_hyperloglog_add_count.argv, i64 24, i1 false)
  call void @llvm.lifetime.start.p0(i64 24, ptr %7) #5
  call void @llvm.memcpy.p0.p0.i64(ptr align 16 %7, ptr align 16 @__const.test_hyperloglog_add_count.argvlen, i64 24, i1 false)
  %9 = getelementptr inbounds [3 x ptr], ptr %6, i64 0, i64 0
  %10 = getelementptr inbounds [3 x i64], ptr %7, i64 0, i64 0
  %11 = call i32 @rl_str_pfadd(ptr noundef null, i64 noundef 0, i32 noundef 3, ptr noundef %9, ptr noundef %10, ptr noundef %3, ptr noundef %4)
  store i32 %11, ptr %2, align 4, !tbaa !11
  br label %12

12:                                               ; preds = %0
  %13 = load i32, ptr getelementptr inbounds (%struct.greatest_run_info, ptr @greatest_info, i32 0, i32 5), align 4, !tbaa !13
  %14 = add i32 %13, 1
  store i32 %14, ptr getelementptr inbounds (%struct.greatest_run_info, ptr @greatest_info, i32 0, i32 5), align 4, !tbaa !13
  %15 = load i32, ptr %2, align 4, !tbaa !11
  %16 = icmp ne i32 1, %15
  br i1 %16, label %17, label %21

17:                                               ; preds = %12
  br label %18

18:                                               ; preds = %17
  store ptr @.str.3, ptr getelementptr inbounds (%struct.greatest_run_info, ptr @greatest_info, i32 0, i32 7), align 8, !tbaa !16
  store i32 17, ptr getelementptr inbounds (%struct.greatest_run_info, ptr @greatest_info, i32 0, i32 8), align 8, !tbaa !17
  store ptr @.str.4, ptr getelementptr inbounds (%struct.greatest_run_info, ptr @greatest_info, i32 0, i32 9), align 8, !tbaa !18
  store i32 -1, ptr %1, align 4
  store i32 1, ptr %8, align 4
  br label %53

19:                                               ; No predecessors!
  br label %20

20:                                               ; preds = %19
  br label %21

21:                                               ; preds = %20, %12
  br label %22

22:                                               ; preds = %21
  br label %23

23:                                               ; preds = %22
  %24 = call i32 @rl_str_pfcount(i32 noundef 1, ptr noundef %3, ptr noundef %4, ptr noundef %5, ptr noundef null, ptr noundef null)
  store i32 %24, ptr %2, align 4, !tbaa !11
  br label %25

25:                                               ; preds = %23
  %26 = load i32, ptr getelementptr inbounds (%struct.greatest_run_info, ptr @greatest_info, i32 0, i32 5), align 4, !tbaa !13
  %27 = add i32 %26, 1
  store i32 %27, ptr getelementptr inbounds (%struct.greatest_run_info, ptr @greatest_info, i32 0, i32 5), align 4, !tbaa !13
  %28 = load i32, ptr %2, align 4, !tbaa !11
  %29 = icmp ne i32 0, %28
  br i1 %29, label %30, label %34

30:                                               ; preds = %25
  br label %31

31:                                               ; preds = %30
  store ptr @.str.3, ptr getelementptr inbounds (%struct.greatest_run_info, ptr @greatest_info, i32 0, i32 7), align 8, !tbaa !16
  store i32 18, ptr getelementptr inbounds (%struct.greatest_run_info, ptr @greatest_info, i32 0, i32 8), align 8, !tbaa !17
  store ptr @.str.5, ptr getelementptr inbounds (%struct.greatest_run_info, ptr @greatest_info, i32 0, i32 9), align 8, !tbaa !18
  store i32 -1, ptr %1, align 4
  store i32 1, ptr %8, align 4
  br label %53

32:                                               ; No predecessors!
  br label %33

33:                                               ; preds = %32
  br label %34

34:                                               ; preds = %33, %25
  br label %35

35:                                               ; preds = %34
  br label %36

36:                                               ; preds = %35
  br label %37

37:                                               ; preds = %36
  %38 = load i32, ptr getelementptr inbounds (%struct.greatest_run_info, ptr @greatest_info, i32 0, i32 5), align 4, !tbaa !13
  %39 = add i32 %38, 1
  store i32 %39, ptr getelementptr inbounds (%struct.greatest_run_info, ptr @greatest_info, i32 0, i32 5), align 4, !tbaa !13
  %40 = load i64, ptr %5, align 8, !tbaa !9
  %41 = icmp ne i64 %40, 3
  br i1 %41, label %42, label %46

42:                                               ; preds = %37
  br label %43

43:                                               ; preds = %42
  store ptr @.str.3, ptr getelementptr inbounds (%struct.greatest_run_info, ptr @greatest_info, i32 0, i32 7), align 8, !tbaa !16
  store i32 19, ptr getelementptr inbounds (%struct.greatest_run_info, ptr @greatest_info, i32 0, i32 8), align 8, !tbaa !17
  store ptr @.str.6, ptr getelementptr inbounds (%struct.greatest_run_info, ptr @greatest_info, i32 0, i32 9), align 8, !tbaa !18
  store i32 -1, ptr %1, align 4
  store i32 1, ptr %8, align 4
  br label %53

44:                                               ; No predecessors!
  br label %45

45:                                               ; preds = %44
  br label %46

46:                                               ; preds = %45, %37
  br label %47

47:                                               ; preds = %46
  br label %48

48:                                               ; preds = %47
  %49 = load ptr, ptr %3, align 8, !tbaa !5
  call void @free(ptr noundef %49) #5
  br label %50

50:                                               ; preds = %48
  store ptr null, ptr getelementptr inbounds (%struct.greatest_run_info, ptr @greatest_info, i32 0, i32 9), align 8, !tbaa !18
  store i32 0, ptr %1, align 4
  store i32 1, ptr %8, align 4
  br label %53

51:                                               ; No predecessors!
  br label %52

52:                                               ; preds = %51
  store i32 0, ptr %8, align 4
  br label %53

53:                                               ; preds = %52, %50, %43, %31, %18
  call void @llvm.lifetime.end.p0(i64 24, ptr %7) #5
  call void @llvm.lifetime.end.p0(i64 24, ptr %6) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %4) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %3) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %2) #5
  %54 = load i32, ptr %8, align 4
  switch i32 %54, label %57 [
    i32 0, label %55
    i32 1, label %55
  ]

55:                                               ; preds = %53, %53
  %56 = load i32, ptr %1, align 4
  ret i32 %56

57:                                               ; preds = %53
  unreachable
}

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

; 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) #2

declare i32 @rl_str_pfadd(ptr noundef, i64 noundef, i32 noundef, ptr noundef, ptr noundef, ptr noundef, ptr noundef) #3

declare i32 @rl_str_pfcount(i32 noundef, ptr noundef, ptr noundef, ptr noundef, ptr noundef, ptr noundef) #3

; Function Attrs: nounwind
declare void @free(ptr noundef) #4

; 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 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #3 = { "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 = { 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 #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)"}
!5 = !{!6, !6, i64 0}
!6 = !{!"any pointer", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"long", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"int", !7, i64 0}
!13 = !{!14, !12, i64 20}
!14 = !{!"greatest_run_info", !12, i64 0, !12, i64 4, !12, i64 8, !12, i64 12, !12, i64 16, !12, i64 20, !15, i64 24, !6, i64 72, !12, i64 80, !6, i64 88, !6, i64 96, !6, i64 104, !6, i64 112, !6, i64 120, !12, i64 128, !12, i64 132, !6, i64 136, !6, i64 144, !10, i64 152, !10, i64 160, !7, i64 168}
!15 = !{!"greatest_suite_info", !12, i64 0, !12, i64 4, !12, i64 8, !12, i64 12, !10, i64 16, !10, i64 24, !10, i64 32, !10, i64 40}
!16 = !{!14, !6, i64 72}
!17 = !{!14, !12, i64 80}
!18 = !{!14, !6, i64 88}


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

%struct.greatest_run_info = type { i32, i32, i32, i32, i32, i32, %struct.greatest_suite_info, ptr, i32, ptr, ptr, ptr, ptr, ptr, i32, i32, ptr, ptr, i64, i64, [1 x %struct.__jmp_buf_tag] }
%struct.greatest_suite_info = type { i32, i32, i32, i32, i64, i64, i64, i64 }
%struct.__jmp_buf_tag = type { [8 x i64], i32, %struct.__sigset_t }
%struct.__sigset_t = type { [16 x i64] }

@__const.test_hyperloglog_add_count.argv = external hidden unnamed_addr constant [3 x ptr], align 16
@__const.test_hyperloglog_add_count.argvlen = external hidden unnamed_addr constant [3 x i64], align 16
@greatest_info = external local_unnamed_addr global %struct.greatest_run_info, align 8
@.str.3 = external hidden unnamed_addr constant [74 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [12 x i8], align 1
@.str.5 = external hidden unnamed_addr constant [12 x i8], align 1
@.str.6 = external hidden unnamed_addr constant [10 x i8], align 1

; Function Attrs: nounwind uwtable
define dso_local range(i32 -1, 1) i32 @test_hyperloglog_add_count() local_unnamed_addr #0 {
  %1 = alloca ptr, align 8
  %2 = alloca i64, align 8
  %3 = alloca i64, align 8
  %4 = alloca [3 x ptr], align 16
  %5 = alloca [3 x i64], align 16
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %1) #5
  store ptr null, ptr %1, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %2) #5
  store i64 -1, ptr %2, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %3) #5
  store i64 -1, ptr %3, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 24, ptr nonnull %4) #5
  call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 16 dereferenceable(24) %4, ptr noundef nonnull align 16 dereferenceable(24) @__const.test_hyperloglog_add_count.argv, i64 24, i1 false)
  call void @llvm.lifetime.start.p0(i64 24, ptr nonnull %5) #5
  call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 16 dereferenceable(24) %5, ptr noundef nonnull align 16 dereferenceable(24) @__const.test_hyperloglog_add_count.argvlen, i64 24, i1 false)
  %6 = call i32 @rl_str_pfadd(ptr noundef null, i64 noundef 0, i32 noundef 3, ptr noundef nonnull %4, ptr noundef nonnull %5, ptr noundef nonnull %1, ptr noundef nonnull %2) #5
  %7 = load i32, ptr getelementptr inbounds (i8, ptr @greatest_info, i64 20), align 4, !tbaa !11
  %8 = add i32 %7, 1
  store i32 %8, ptr getelementptr inbounds (i8, ptr @greatest_info, i64 20), align 4, !tbaa !11
  %.not = icmp eq i32 %6, 1
  br i1 %.not, label %10, label %9

9:                                                ; preds = %0
  store ptr @.str.3, ptr getelementptr inbounds (i8, ptr @greatest_info, i64 72), align 8, !tbaa !15
  store i32 17, ptr getelementptr inbounds (i8, ptr @greatest_info, i64 80), align 8, !tbaa !16
  br label %21

10:                                               ; preds = %0
  %11 = call i32 @rl_str_pfcount(i32 noundef 1, ptr noundef nonnull %1, ptr noundef nonnull %2, ptr noundef nonnull %3, ptr noundef null, ptr noundef null) #5
  %12 = load i32, ptr getelementptr inbounds (i8, ptr @greatest_info, i64 20), align 4, !tbaa !11
  %13 = add i32 %12, 1
  store i32 %13, ptr getelementptr inbounds (i8, ptr @greatest_info, i64 20), align 4, !tbaa !11
  %.not3 = icmp eq i32 %11, 0
  br i1 %.not3, label %15, label %14

14:                                               ; preds = %10
  store ptr @.str.3, ptr getelementptr inbounds (i8, ptr @greatest_info, i64 72), align 8, !tbaa !15
  store i32 18, ptr getelementptr inbounds (i8, ptr @greatest_info, i64 80), align 8, !tbaa !16
  br label %21

15:                                               ; preds = %10
  %16 = add i32 %12, 2
  store i32 %16, ptr getelementptr inbounds (i8, ptr @greatest_info, i64 20), align 4, !tbaa !11
  %17 = load i64, ptr %3, align 8, !tbaa !9
  %.not4 = icmp eq i64 %17, 3
  br i1 %.not4, label %19, label %18

18:                                               ; preds = %15
  store ptr @.str.3, ptr getelementptr inbounds (i8, ptr @greatest_info, i64 72), align 8, !tbaa !15
  store i32 19, ptr getelementptr inbounds (i8, ptr @greatest_info, i64 80), align 8, !tbaa !16
  br label %21

19:                                               ; preds = %15
  %20 = load ptr, ptr %1, align 8, !tbaa !5
  call void @free(ptr noundef %20) #5
  br label %21

21:                                               ; preds = %19, %18, %14, %9
  %.sink = phi ptr [ null, %19 ], [ @.str.6, %18 ], [ @.str.5, %14 ], [ @.str.4, %9 ]
  %.0 = phi i32 [ 0, %19 ], [ -1, %18 ], [ -1, %14 ], [ -1, %9 ]
  store ptr %.sink, ptr getelementptr inbounds (i8, ptr @greatest_info, i64 88), align 8, !tbaa !17
  call void @llvm.lifetime.end.p0(i64 24, ptr nonnull %5) #5
  call void @llvm.lifetime.end.p0(i64 24, ptr nonnull %4) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %3) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %2) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %1) #5
  ret i32 %.0
}

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

; 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) #2

declare i32 @rl_str_pfadd(ptr noundef, i64 noundef, i32 noundef, ptr noundef, ptr noundef, ptr noundef, ptr noundef) local_unnamed_addr #3

declare i32 @rl_str_pfcount(i32 noundef, ptr noundef, ptr noundef, ptr noundef, ptr noundef, ptr noundef) local_unnamed_addr #3

; Function Attrs: mustprogress nounwind willreturn allockind("free") memory(argmem: readwrite, inaccessiblemem: readwrite)
declare void @free(ptr allocptr nocapture noundef) local_unnamed_addr #4

; Function Attrs: mustprogress 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 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { mustprogress nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #3 = { "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 = { mustprogress nounwind willreturn allockind("free") memory(argmem: readwrite, inaccessiblemem: readwrite) "alloc-family"="malloc" "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)"}
!5 = !{!6, !6, i64 0}
!6 = !{!"any pointer", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"long", !7, i64 0}
!11 = !{!12, !13, i64 20}
!12 = !{!"greatest_run_info", !13, i64 0, !13, i64 4, !13, i64 8, !13, i64 12, !13, i64 16, !13, i64 20, !14, i64 24, !6, i64 72, !13, i64 80, !6, i64 88, !6, i64 96, !6, i64 104, !6, i64 112, !6, i64 120, !13, i64 128, !13, i64 132, !6, i64 136, !6, i64 144, !10, i64 152, !10, i64 160, !7, i64 168}
!13 = !{!"int", !7, i64 0}
!14 = !{!"greatest_suite_info", !13, i64 0, !13, i64 4, !13, i64 8, !13, i64 12, !10, i64 16, !10, i64 24, !10, i64 32, !10, i64 40}
!15 = !{!12, !6, i64 72}
!16 = !{!12, !13, i64 80}
!17 = !{!12, !6, i64 88}


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