; 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.hashmultiset1 = type { ptr, i64, i64, i64, double, i32, ptr, ptr }
%struct.hashmultiset1_fval = type { ptr, ptr, ptr, ptr, ptr, ptr }
%struct.hashmultiset1_entry = type { %struct.struct_s, i64, i64, i32 }
%struct.struct_s = type { i32, i32, ptr, ptr, [10 x double] }
%struct.cmc_alloc_node = type { 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
define dso_local void @hms1_free(ptr noundef %0) #1 {
  %2 = alloca ptr, align 8
  %3 = alloca i64, align 8
  %4 = alloca ptr, align 8
  store ptr %0, ptr %2, align 8, !tbaa !5
  %5 = load ptr, ptr %2, align 8, !tbaa !5
  %6 = getelementptr inbounds %struct.hashmultiset1, ptr %5, i32 0, i32 6
  %7 = load ptr, ptr %6, align 8, !tbaa !9
  %8 = getelementptr inbounds %struct.hashmultiset1_fval, ptr %7, i32 0, i32 3
  %9 = load ptr, ptr %8, align 8, !tbaa !14
  %10 = icmp ne ptr %9, null
  br i1 %10, label %11, label %42

11:                                               ; preds = %1
  call void @llvm.lifetime.start.p0(i64 8, ptr %3) #2
  store i64 0, ptr %3, align 8, !tbaa !16
  br label %12

12:                                               ; preds = %38, %11
  %13 = load i64, ptr %3, align 8, !tbaa !16
  %14 = load ptr, ptr %2, align 8, !tbaa !5
  %15 = getelementptr inbounds %struct.hashmultiset1, ptr %14, i32 0, i32 1
  %16 = load i64, ptr %15, align 8, !tbaa !17
  %17 = icmp ult i64 %13, %16
  br i1 %17, label %19, label %18

18:                                               ; preds = %12
  call void @llvm.lifetime.end.p0(i64 8, ptr %3) #2
  br label %41

19:                                               ; preds = %12
  call void @llvm.lifetime.start.p0(i64 8, ptr %4) #2
  %20 = load ptr, ptr %2, align 8, !tbaa !5
  %21 = getelementptr inbounds %struct.hashmultiset1, ptr %20, i32 0, i32 0
  %22 = load ptr, ptr %21, align 8, !tbaa !18
  %23 = load i64, ptr %3, align 8, !tbaa !16
  %24 = getelementptr inbounds %struct.hashmultiset1_entry, ptr %22, i64 %23
  store ptr %24, ptr %4, align 8, !tbaa !5
  %25 = load ptr, ptr %4, align 8, !tbaa !5
  %26 = getelementptr inbounds %struct.hashmultiset1_entry, ptr %25, i32 0, i32 3
  %27 = load i32, ptr %26, align 8, !tbaa !19
  %28 = icmp eq i32 %27, 1
  br i1 %28, label %29, label %37

29:                                               ; preds = %19
  %30 = load ptr, ptr %2, align 8, !tbaa !5
  %31 = getelementptr inbounds %struct.hashmultiset1, ptr %30, i32 0, i32 6
  %32 = load ptr, ptr %31, align 8, !tbaa !9
  %33 = getelementptr inbounds %struct.hashmultiset1_fval, ptr %32, i32 0, i32 3
  %34 = load ptr, ptr %33, align 8, !tbaa !14
  %35 = load ptr, ptr %4, align 8, !tbaa !5
  %36 = getelementptr inbounds %struct.hashmultiset1_entry, ptr %35, i32 0, i32 0
  call void %34(ptr noundef byval(%struct.struct_s) align 8 %36)
  br label %37

37:                                               ; preds = %29, %19
  call void @llvm.lifetime.end.p0(i64 8, ptr %4) #2
  br label %38

38:                                               ; preds = %37
  %39 = load i64, ptr %3, align 8, !tbaa !16
  %40 = add i64 %39, 1
  store i64 %40, ptr %3, align 8, !tbaa !16
  br label %12, !llvm.loop !22

41:                                               ; preds = %18
  br label %42

42:                                               ; preds = %41, %1
  %43 = load ptr, ptr %2, align 8, !tbaa !5
  %44 = getelementptr inbounds %struct.hashmultiset1, ptr %43, i32 0, i32 7
  %45 = load ptr, ptr %44, align 8, !tbaa !24
  %46 = getelementptr inbounds %struct.cmc_alloc_node, ptr %45, i32 0, i32 3
  %47 = load ptr, ptr %46, align 8, !tbaa !25
  %48 = load ptr, ptr %2, align 8, !tbaa !5
  %49 = getelementptr inbounds %struct.hashmultiset1, ptr %48, i32 0, i32 0
  %50 = load ptr, ptr %49, align 8, !tbaa !18
  call void %47(ptr noundef %50)
  %51 = load ptr, ptr %2, align 8, !tbaa !5
  %52 = getelementptr inbounds %struct.hashmultiset1, ptr %51, i32 0, i32 7
  %53 = load ptr, ptr %52, align 8, !tbaa !24
  %54 = getelementptr inbounds %struct.cmc_alloc_node, ptr %53, i32 0, i32 3
  %55 = load ptr, ptr %54, align 8, !tbaa !25
  %56 = load ptr, ptr %2, align 8, !tbaa !5
  call void %55(ptr noundef %56)
  ret void
}

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, !6, i64 48}
!10 = !{!"hashmultiset1", !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, !6, i64 24}
!15 = !{!"hashmultiset1_fval", !6, i64 0, !6, i64 8, !6, i64 16, !6, i64 24, !6, i64 32, !6, i64 40}
!16 = !{!11, !11, i64 0}
!17 = !{!10, !11, i64 8}
!18 = !{!10, !6, i64 0}
!19 = !{!20, !13, i64 120}
!20 = !{!"hashmultiset1_entry", !21, i64 0, !11, i64 104, !11, i64 112, !13, i64 120}
!21 = !{!"struct_s", !13, i64 0, !13, i64 4, !6, i64 8, !6, i64 16, !7, i64 24}
!22 = distinct !{!22, !23}
!23 = !{!"llvm.loop.mustprogress"}
!24 = !{!10, !6, i64 56}
!25 = !{!26, !6, i64 24}
!26 = !{!"cmc_alloc_node", !6, i64 0, !6, i64 8, !6, i64 16, !6, i64 24}


; 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.hashmultiset1_entry = type { %struct.struct_s, i64, i64, i32 }
%struct.struct_s = type { i32, i32, ptr, ptr, [10 x double] }

; Function Attrs: nounwind uwtable
define dso_local void @hms1_free(ptr noundef %0) local_unnamed_addr #0 {
  %2 = getelementptr inbounds i8, ptr %0, i64 48
  %3 = load ptr, ptr %2, align 8, !tbaa !5
  %4 = getelementptr inbounds i8, ptr %3, i64 24
  %5 = load ptr, ptr %4, align 8, !tbaa !13
  %.not = icmp eq ptr %5, null
  br i1 %.not, label %.loopexit, label %.preheader

.preheader:                                       ; preds = %1
  %6 = getelementptr inbounds i8, ptr %0, i64 8
  %7 = load i64, ptr %6, align 8, !tbaa !15
  %.not13 = icmp eq i64 %7, 0
  br i1 %.not13, label %.loopexit, label %.lr.ph

.lr.ph:                                           ; preds = %.preheader, %18
  %8 = phi i64 [ %19, %18 ], [ %7, %.preheader ]
  %.012 = phi i64 [ %20, %18 ], [ 0, %.preheader ]
  %9 = load ptr, ptr %0, align 8, !tbaa !16
  %10 = getelementptr inbounds %struct.hashmultiset1_entry, ptr %9, i64 %.012
  %11 = getelementptr inbounds i8, ptr %10, i64 120
  %12 = load i32, ptr %11, align 8, !tbaa !17
  %13 = icmp eq i32 %12, 1
  br i1 %13, label %14, label %18

14:                                               ; preds = %.lr.ph
  %15 = load ptr, ptr %2, align 8, !tbaa !5
  %16 = getelementptr inbounds i8, ptr %15, i64 24
  %17 = load ptr, ptr %16, align 8, !tbaa !13
  tail call void %17(ptr noundef nonnull byval(%struct.struct_s) align 8 %10) #1
  %.pre = load i64, ptr %6, align 8, !tbaa !15
  br label %18

18:                                               ; preds = %14, %.lr.ph
  %19 = phi i64 [ %.pre, %14 ], [ %8, %.lr.ph ]
  %20 = add nuw i64 %.012, 1
  %21 = icmp ult i64 %20, %19
  br i1 %21, label %.lr.ph, label %.loopexit, !llvm.loop !20

.loopexit:                                        ; preds = %18, %.preheader, %1
  %22 = getelementptr inbounds i8, ptr %0, i64 56
  %23 = load ptr, ptr %22, align 8, !tbaa !22
  %24 = getelementptr inbounds i8, ptr %23, i64 24
  %25 = load ptr, ptr %24, align 8, !tbaa !23
  %26 = load ptr, ptr %0, align 8, !tbaa !16
  tail call void %25(ptr noundef %26) #1
  %27 = load ptr, ptr %22, align 8, !tbaa !22
  %28 = getelementptr inbounds i8, ptr %27, i64 24
  %29 = load ptr, ptr %28, align 8, !tbaa !23
  tail call void %29(ptr noundef nonnull %0) #1
  ret void
}

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, !7, i64 48}
!6 = !{!"hashmultiset1", !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 = !{!14, !7, i64 24}
!14 = !{!"hashmultiset1_fval", !7, i64 0, !7, i64 8, !7, i64 16, !7, i64 24, !7, i64 32, !7, i64 40}
!15 = !{!6, !10, i64 8}
!16 = !{!6, !7, i64 0}
!17 = !{!18, !12, i64 120}
!18 = !{!"hashmultiset1_entry", !19, i64 0, !10, i64 104, !10, i64 112, !12, i64 120}
!19 = !{!"struct_s", !12, i64 0, !12, i64 4, !7, i64 8, !7, i64 16, !8, i64 24}
!20 = distinct !{!20, !21}
!21 = !{!"llvm.loop.mustprogress"}
!22 = !{!6, !7, i64 56}
!23 = !{!24, !7, i64 24}
!24 = !{!"cmc_alloc_node", !7, i64 0, !7, i64 8, !7, i64 16, !7, i64 24}


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