; LLVM IR from LeoVen/C-Macro-Collections :: tests (types)

; 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.hashmultiset0 = type { ptr, i64, i64, i64, double, i32, ptr, ptr }
%struct.hashmultiset0_entry = type { ptr, i64, i64, i32 }
%struct.hashmultiset0_fval = type { ptr, ptr, ptr, ptr, ptr, ptr }

; 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 nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #0

; Function Attrs: nounwind uwtable
declare dso_local zeroext i1 @hms0_empty(ptr noundef) #1

; Function Attrs: nounwind uwtable
define dso_local zeroext i1 @hms0_max(ptr noundef %0, ptr noundef %1) #1 {
  %3 = alloca i1, align 1
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca i8, align 1
  %7 = alloca ptr, align 8
  %8 = alloca ptr, align 8
  %9 = alloca i64, align 8
  store ptr %0, ptr %4, align 8, !tbaa !5
  store ptr %1, ptr %5, align 8, !tbaa !5
  %10 = load ptr, ptr %4, align 8, !tbaa !5
  %11 = call zeroext i1 @hms0_empty(ptr noundef %10)
  br i1 %11, label %12, label %15

12:                                               ; preds = %2
  %13 = load ptr, ptr %4, align 8, !tbaa !5
  %14 = getelementptr inbounds %struct.hashmultiset0, ptr %13, i32 0, i32 5
  store i32 2, ptr %14, align 8, !tbaa !9
  store i1 false, ptr %3, align 1
  br label %83

15:                                               ; preds = %2
  call void @llvm.lifetime.start.p0(i64 1, ptr %6) #2
  store i8 1, ptr %6, align 1, !tbaa !14
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #2
  store ptr null, ptr %8, align 8, !tbaa !5
  %16 = load ptr, ptr %8, align 8, !tbaa !5
  store ptr %16, ptr %7, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #2
  store i64 0, ptr %9, align 8, !tbaa !16
  br label %17

17:                                               ; preds = %71, %15
  %18 = load i64, ptr %9, align 8, !tbaa !16
  %19 = load ptr, ptr %4, align 8, !tbaa !5
  %20 = getelementptr inbounds %struct.hashmultiset0, ptr %19, i32 0, i32 1
  %21 = load i64, ptr %20, align 8, !tbaa !17
  %22 = icmp ult i64 %18, %21
  br i1 %22, label %24, label %23

23:                                               ; preds = %17
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #2
  br label %74

24:                                               ; preds = %17
  %25 = load ptr, ptr %4, align 8, !tbaa !5
  %26 = getelementptr inbounds %struct.hashmultiset0, ptr %25, i32 0, i32 0
  %27 = load ptr, ptr %26, align 8, !tbaa !18
  %28 = load i64, ptr %9, align 8, !tbaa !16
  %29 = getelementptr inbounds %struct.hashmultiset0_entry, ptr %27, i64 %28
  %30 = getelementptr inbounds %struct.hashmultiset0_entry, ptr %29, i32 0, i32 3
  %31 = load i32, ptr %30, align 8, !tbaa !19
  %32 = icmp eq i32 %31, 1
  br i1 %32, label %33, label %70

33:                                               ; preds = %24
  %34 = load i8, ptr %6, align 1, !tbaa !14, !range !21, !noundef !22
  %35 = trunc i8 %34 to i1
  br i1 %35, label %36, label %44

36:                                               ; preds = %33
  %37 = load ptr, ptr %4, align 8, !tbaa !5
  %38 = getelementptr inbounds %struct.hashmultiset0, ptr %37, i32 0, i32 0
  %39 = load ptr, ptr %38, align 8, !tbaa !18
  %40 = load i64, ptr %9, align 8, !tbaa !16
  %41 = getelementptr inbounds %struct.hashmultiset0_entry, ptr %39, i64 %40
  %42 = getelementptr inbounds %struct.hashmultiset0_entry, ptr %41, i32 0, i32 0
  %43 = load ptr, ptr %42, align 8, !tbaa !23
  store ptr %43, ptr %7, align 8, !tbaa !5
  store i8 0, ptr %6, align 1, !tbaa !14
  br label %69

44:                                               ; preds = %33
  %45 = load ptr, ptr %4, align 8, !tbaa !5
  %46 = getelementptr inbounds %struct.hashmultiset0, ptr %45, i32 0, i32 6
  %47 = load ptr, ptr %46, align 8, !tbaa !24
  %48 = getelementptr inbounds %struct.hashmultiset0_fval, ptr %47, i32 0, i32 0
  %49 = load ptr, ptr %48, align 8, !tbaa !25
  %50 = load ptr, ptr %4, align 8, !tbaa !5
  %51 = getelementptr inbounds %struct.hashmultiset0, ptr %50, i32 0, i32 0
  %52 = load ptr, ptr %51, align 8, !tbaa !18
  %53 = load i64, ptr %9, align 8, !tbaa !16
  %54 = getelementptr inbounds %struct.hashmultiset0_entry, ptr %52, i64 %53
  %55 = getelementptr inbounds %struct.hashmultiset0_entry, ptr %54, i32 0, i32 0
  %56 = load ptr, ptr %55, align 8, !tbaa !23
  %57 = load ptr, ptr %7, align 8, !tbaa !5
  %58 = call i32 %49(ptr noundef %56, ptr noundef %57)
  %59 = icmp sgt i32 %58, 0
  br i1 %59, label %60, label %68

60:                                               ; preds = %44
  %61 = load ptr, ptr %4, align 8, !tbaa !5
  %62 = getelementptr inbounds %struct.hashmultiset0, ptr %61, i32 0, i32 0
  %63 = load ptr, ptr %62, align 8, !tbaa !18
  %64 = load i64, ptr %9, align 8, !tbaa !16
  %65 = getelementptr inbounds %struct.hashmultiset0_entry, ptr %63, i64 %64
  %66 = getelementptr inbounds %struct.hashmultiset0_entry, ptr %65, i32 0, i32 0
  %67 = load ptr, ptr %66, align 8, !tbaa !23
  store ptr %67, ptr %7, align 8, !tbaa !5
  br label %68

68:                                               ; preds = %60, %44
  br label %69

69:                                               ; preds = %68, %36
  br label %70

70:                                               ; preds = %69, %24
  br label %71

71:                                               ; preds = %70
  %72 = load i64, ptr %9, align 8, !tbaa !16
  %73 = add i64 %72, 1
  store i64 %73, ptr %9, align 8, !tbaa !16
  br label %17, !llvm.loop !27

74:                                               ; preds = %23
  %75 = load ptr, ptr %5, align 8, !tbaa !5
  %76 = icmp ne ptr %75, null
  br i1 %76, label %77, label %80

77:                                               ; preds = %74
  %78 = load ptr, ptr %7, align 8, !tbaa !5
  %79 = load ptr, ptr %5, align 8, !tbaa !5
  store ptr %78, ptr %79, align 8, !tbaa !5
  br label %80

80:                                               ; preds = %77, %74
  %81 = load ptr, ptr %4, align 8, !tbaa !5
  %82 = getelementptr inbounds %struct.hashmultiset0, ptr %81, i32 0, i32 5
  store i32 0, ptr %82, align 8, !tbaa !9
  store i1 true, ptr %3, align 1
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #2
  call void @llvm.lifetime.end.p0(i64 1, ptr %6) #2
  br label %83

83:                                               ; preds = %80, %12
  %84 = load i1, ptr %3, align 1
  ret i1 %84
}

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 = { 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, !13, i64 40}
!10 = !{!"hashmultiset0", !6, i64 0, !11, i64 8, !11, i64 16, !11, i64 24, !12, i64 32, !13, i64 40, !6, i64 48, !6, i64 56}
!11 = !{!"long", !7, i64 0}
!12 = !{!"double", !7, i64 0}
!13 = !{!"int", !7, i64 0}
!14 = !{!15, !15, i64 0}
!15 = !{!"_Bool", !7, i64 0}
!16 = !{!11, !11, i64 0}
!17 = !{!10, !11, i64 8}
!18 = !{!10, !6, i64 0}
!19 = !{!20, !13, i64 24}
!20 = !{!"hashmultiset0_entry", !6, i64 0, !11, i64 8, !11, i64 16, !13, i64 24}
!21 = !{i8 0, i8 2}
!22 = !{}
!23 = !{!20, !6, i64 0}
!24 = !{!10, !6, i64 48}
!25 = !{!26, !6, i64 0}
!26 = !{!"hashmultiset0_fval", !6, i64 0, !6, i64 8, !6, i64 16, !6, i64 24, !6, i64 32, !6, i64 40}
!27 = distinct !{!27, !28}
!28 = !{!"llvm.loop.mustprogress"}


; 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.hashmultiset0_entry = type { ptr, i64, i64, i32 }

; Function Attrs: nounwind uwtable
declare dso_local zeroext i1 @hms0_empty(ptr noundef) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
define dso_local noundef zeroext i1 @hms0_max(ptr noundef %0, ptr noundef writeonly %1) local_unnamed_addr #0 {
  %3 = tail call zeroext i1 @hms0_empty(ptr noundef %0)
  br i1 %3, label %29, label %.preheader

.preheader:                                       ; preds = %2
  %4 = getelementptr inbounds i8, ptr %0, i64 8
  %5 = load i64, ptr %4, align 8, !tbaa !5
  %.not29 = icmp eq i64 %5, 0
  br i1 %.not29, label %._crit_edge, label %.lr.ph

.lr.ph:                                           ; preds = %.preheader
  %6 = getelementptr inbounds i8, ptr %0, i64 48
  br label %7

._crit_edge:                                      ; preds = %24, %.preheader
  %.022.lcssa = phi ptr [ null, %.preheader ], [ %.1, %24 ]
  %.not = icmp eq ptr %1, null
  br i1 %.not, label %29, label %28

7:                                                ; preds = %.lr.ph, %24
  %.028 = phi i64 [ 0, %.lr.ph ], [ %25, %24 ]
  %.02227 = phi ptr [ null, %.lr.ph ], [ %.1, %24 ]
  %.02326 = phi i1 [ true, %.lr.ph ], [ %.124, %24 ]
  %8 = load ptr, ptr %0, align 8, !tbaa !13
  %9 = getelementptr inbounds %struct.hashmultiset0_entry, ptr %8, i64 %.028
  %10 = getelementptr inbounds i8, ptr %9, i64 24
  %11 = load i32, ptr %10, align 8, !tbaa !14
  %12 = icmp eq i32 %11, 1
  br i1 %12, label %13, label %24

13:                                               ; preds = %7
  br i1 %.02326, label %.sink.split, label %14

14:                                               ; preds = %13
  %15 = load ptr, ptr %6, align 8, !tbaa !16
  %16 = load ptr, ptr %15, align 8, !tbaa !17
  %17 = load ptr, ptr %9, align 8, !tbaa !19
  %18 = tail call i32 %16(ptr noundef %17, ptr noundef %.02227) #1
  %19 = icmp sgt i32 %18, 0
  br i1 %19, label %20, label %24

20:                                               ; preds = %14
  %21 = load ptr, ptr %0, align 8, !tbaa !13
  %22 = getelementptr inbounds %struct.hashmultiset0_entry, ptr %21, i64 %.028
  br label %.sink.split

.sink.split:                                      ; preds = %13, %20
  %.sink = phi ptr [ %22, %20 ], [ %9, %13 ]
  %23 = load ptr, ptr %.sink, align 8, !tbaa !19
  br label %24

24:                                               ; preds = %.sink.split, %7, %14
  %.124 = phi i1 [ false, %14 ], [ %.02326, %7 ], [ false, %.sink.split ]
  %.1 = phi ptr [ %.02227, %14 ], [ %.02227, %7 ], [ %23, %.sink.split ]
  %25 = add nuw i64 %.028, 1
  %26 = load i64, ptr %4, align 8, !tbaa !5
  %27 = icmp ult i64 %25, %26
  br i1 %27, label %7, label %._crit_edge, !llvm.loop !20

28:                                               ; preds = %._crit_edge
  store ptr %.022.lcssa, ptr %1, align 8, !tbaa !22
  br label %29

29:                                               ; preds = %._crit_edge, %28, %2
  %.sink30 = phi i32 [ 2, %2 ], [ 0, %28 ], [ 0, %._crit_edge ]
  %30 = getelementptr inbounds i8, ptr %0, i64 40
  store i32 %.sink30, ptr %30, align 8, !tbaa !23
  %.021 = xor i1 %3, true
  ret i1 %.021
}

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 = { 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, !10, i64 8}
!6 = !{!"hashmultiset0", !7, i64 0, !10, i64 8, !10, i64 16, !10, i64 24, !11, i64 32, !12, i64 40, !7, i64 48, !7, i64 56}
!7 = !{!"any pointer", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"long", !8, i64 0}
!11 = !{!"double", !8, i64 0}
!12 = !{!"int", !8, i64 0}
!13 = !{!6, !7, i64 0}
!14 = !{!15, !12, i64 24}
!15 = !{!"hashmultiset0_entry", !7, i64 0, !10, i64 8, !10, i64 16, !12, i64 24}
!16 = !{!6, !7, i64 48}
!17 = !{!18, !7, i64 0}
!18 = !{!"hashmultiset0_fval", !7, i64 0, !7, i64 8, !7, i64 16, !7, i64 24, !7, i64 32, !7, i64 40}
!19 = !{!15, !7, i64 0}
!20 = distinct !{!20, !21}
!21 = !{!"llvm.loop.mustprogress"}
!22 = !{!7, !7, i64 0}
!23 = !{!6, !12, i64 40}


; Effective O3 passes: AggressiveInstCombinePass,CorrelatedValuePropagationPass,EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,JumpThreadingPass,LCSSAPass,LICMPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass,TailCallElimPass