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

; 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: 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: nounwind uwtable
declare dso_local ptr @hms0_new_custom(i64 noundef, double noundef, ptr noundef, ptr noundef, ptr noundef) #2

; Function Attrs: nounwind uwtable
define dso_local ptr @hms0_copy_of(ptr noundef %0) #2 {
  %2 = alloca ptr, align 8
  %3 = alloca ptr, align 8
  %4 = alloca ptr, align 8
  %5 = alloca i32, align 4
  %6 = alloca i64, align 8
  %7 = alloca ptr, align 8
  %8 = alloca ptr, align 8
  store ptr %0, ptr %3, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %4) #3
  %9 = load ptr, ptr %3, align 8, !tbaa !5
  %10 = getelementptr inbounds %struct.hashmultiset0, ptr %9, i32 0, i32 1
  %11 = load i64, ptr %10, align 8, !tbaa !9
  %12 = uitofp i64 %11 to double
  %13 = load ptr, ptr %3, align 8, !tbaa !5
  %14 = getelementptr inbounds %struct.hashmultiset0, ptr %13, i32 0, i32 4
  %15 = load double, ptr %14, align 8, !tbaa !14
  %16 = fmul double %12, %15
  %17 = fptoui double %16 to i64
  %18 = load ptr, ptr %3, align 8, !tbaa !5
  %19 = getelementptr inbounds %struct.hashmultiset0, ptr %18, i32 0, i32 4
  %20 = load double, ptr %19, align 8, !tbaa !14
  %21 = load ptr, ptr %3, align 8, !tbaa !5
  %22 = getelementptr inbounds %struct.hashmultiset0, ptr %21, i32 0, i32 6
  %23 = load ptr, ptr %22, align 8, !tbaa !15
  %24 = load ptr, ptr %3, align 8, !tbaa !5
  %25 = getelementptr inbounds %struct.hashmultiset0, ptr %24, i32 0, i32 7
  %26 = load ptr, ptr %25, align 8, !tbaa !16
  %27 = call ptr @hms0_new_custom(i64 noundef %17, double noundef %20, ptr noundef %23, ptr noundef %26, ptr noundef null)
  store ptr %27, ptr %4, align 8, !tbaa !5
  %28 = load ptr, ptr %4, align 8, !tbaa !5
  %29 = icmp ne ptr %28, null
  br i1 %29, label %33, label %30

30:                                               ; preds = %1
  %31 = load ptr, ptr %3, align 8, !tbaa !5
  %32 = getelementptr inbounds %struct.hashmultiset0, ptr %31, i32 0, i32 5
  store i32 7, ptr %32, align 8, !tbaa !17
  store ptr null, ptr %2, align 8
  store i32 1, ptr %5, align 4
  br label %129

33:                                               ; preds = %1
  %34 = load ptr, ptr %3, align 8, !tbaa !5
  %35 = getelementptr inbounds %struct.hashmultiset0, ptr %34, i32 0, i32 6
  %36 = load ptr, ptr %35, align 8, !tbaa !15
  %37 = getelementptr inbounds %struct.hashmultiset0_fval, ptr %36, i32 0, i32 1
  %38 = load ptr, ptr %37, align 8, !tbaa !18
  %39 = icmp ne ptr %38, null
  br i1 %39, label %40, label %104

40:                                               ; preds = %33
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #3
  store i64 0, ptr %6, align 8, !tbaa !20
  br label %41

41:                                               ; preds = %100, %40
  %42 = load i64, ptr %6, align 8, !tbaa !20
  %43 = load ptr, ptr %3, align 8, !tbaa !5
  %44 = getelementptr inbounds %struct.hashmultiset0, ptr %43, i32 0, i32 1
  %45 = load i64, ptr %44, align 8, !tbaa !9
  %46 = icmp ult i64 %42, %45
  br i1 %46, label %48, label %47

47:                                               ; preds = %41
  store i32 2, ptr %5, align 4
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #3
  br label %103

48:                                               ; preds = %41
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #3
  %49 = load ptr, ptr %3, align 8, !tbaa !5
  %50 = getelementptr inbounds %struct.hashmultiset0, ptr %49, i32 0, i32 0
  %51 = load ptr, ptr %50, align 8, !tbaa !21
  %52 = load i64, ptr %6, align 8, !tbaa !20
  %53 = getelementptr inbounds %struct.hashmultiset0_entry, ptr %51, i64 %52
  store ptr %53, ptr %7, align 8, !tbaa !5
  %54 = load ptr, ptr %7, align 8, !tbaa !5
  %55 = getelementptr inbounds %struct.hashmultiset0_entry, ptr %54, i32 0, i32 3
  %56 = load i32, ptr %55, align 8, !tbaa !22
  %57 = icmp ne i32 %56, 0
  br i1 %57, label %58, label %99

58:                                               ; preds = %48
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #3
  %59 = load ptr, ptr %4, align 8, !tbaa !5
  %60 = getelementptr inbounds %struct.hashmultiset0, ptr %59, i32 0, i32 0
  %61 = load ptr, ptr %60, align 8, !tbaa !21
  %62 = load i64, ptr %6, align 8, !tbaa !20
  %63 = getelementptr inbounds %struct.hashmultiset0_entry, ptr %61, i64 %62
  store ptr %63, ptr %8, align 8, !tbaa !5
  %64 = load ptr, ptr %7, align 8, !tbaa !5
  %65 = getelementptr inbounds %struct.hashmultiset0_entry, ptr %64, i32 0, i32 3
  %66 = load i32, ptr %65, align 8, !tbaa !22
  %67 = icmp eq i32 %66, -1
  br i1 %67, label %68, label %71

68:                                               ; preds = %58
  %69 = load ptr, ptr %8, align 8, !tbaa !5
  %70 = getelementptr inbounds %struct.hashmultiset0_entry, ptr %69, i32 0, i32 3
  store i32 -1, ptr %70, align 8, !tbaa !22
  br label %98

71:                                               ; preds = %58
  %72 = load ptr, ptr %7, align 8, !tbaa !5
  %73 = getelementptr inbounds %struct.hashmultiset0_entry, ptr %72, i32 0, i32 3
  %74 = load i32, ptr %73, align 8, !tbaa !22
  %75 = load ptr, ptr %8, align 8, !tbaa !5
  %76 = getelementptr inbounds %struct.hashmultiset0_entry, ptr %75, i32 0, i32 3
  store i32 %74, ptr %76, align 8, !tbaa !22
  %77 = load ptr, ptr %7, align 8, !tbaa !5
  %78 = getelementptr inbounds %struct.hashmultiset0_entry, ptr %77, i32 0, i32 2
  %79 = load i64, ptr %78, align 8, !tbaa !24
  %80 = load ptr, ptr %8, align 8, !tbaa !5
  %81 = getelementptr inbounds %struct.hashmultiset0_entry, ptr %80, i32 0, i32 2
  store i64 %79, ptr %81, align 8, !tbaa !24
  %82 = load ptr, ptr %7, align 8, !tbaa !5
  %83 = getelementptr inbounds %struct.hashmultiset0_entry, ptr %82, i32 0, i32 1
  %84 = load i64, ptr %83, align 8, !tbaa !25
  %85 = load ptr, ptr %8, align 8, !tbaa !5
  %86 = getelementptr inbounds %struct.hashmultiset0_entry, ptr %85, i32 0, i32 1
  store i64 %84, ptr %86, align 8, !tbaa !25
  %87 = load ptr, ptr %3, align 8, !tbaa !5
  %88 = getelementptr inbounds %struct.hashmultiset0, ptr %87, i32 0, i32 6
  %89 = load ptr, ptr %88, align 8, !tbaa !15
  %90 = getelementptr inbounds %struct.hashmultiset0_fval, ptr %89, i32 0, i32 1
  %91 = load ptr, ptr %90, align 8, !tbaa !18
  %92 = load ptr, ptr %7, align 8, !tbaa !5
  %93 = getelementptr inbounds %struct.hashmultiset0_entry, ptr %92, i32 0, i32 0
  %94 = load ptr, ptr %93, align 8, !tbaa !26
  %95 = call ptr %91(ptr noundef %94)
  %96 = load ptr, ptr %8, align 8, !tbaa !5
  %97 = getelementptr inbounds %struct.hashmultiset0_entry, ptr %96, i32 0, i32 0
  store ptr %95, ptr %97, align 8, !tbaa !26
  br label %98

98:                                               ; preds = %71, %68
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #3
  br label %99

99:                                               ; preds = %98, %48
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #3
  br label %100

100:                                              ; preds = %99
  %101 = load i64, ptr %6, align 8, !tbaa !20
  %102 = add i64 %101, 1
  store i64 %102, ptr %6, align 8, !tbaa !20
  br label %41, !llvm.loop !27

103:                                              ; preds = %47
  br label %115

104:                                              ; preds = %33
  %105 = load ptr, ptr %4, align 8, !tbaa !5
  %106 = getelementptr inbounds %struct.hashmultiset0, ptr %105, i32 0, i32 0
  %107 = load ptr, ptr %106, align 8, !tbaa !21
  %108 = load ptr, ptr %3, align 8, !tbaa !5
  %109 = getelementptr inbounds %struct.hashmultiset0, ptr %108, i32 0, i32 0
  %110 = load ptr, ptr %109, align 8, !tbaa !21
  %111 = load ptr, ptr %3, align 8, !tbaa !5
  %112 = getelementptr inbounds %struct.hashmultiset0, ptr %111, i32 0, i32 1
  %113 = load i64, ptr %112, align 8, !tbaa !9
  %114 = mul i64 32, %113
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %107, ptr align 8 %110, i64 %114, i1 false)
  br label %115

115:                                              ; preds = %104, %103
  %116 = load ptr, ptr %3, align 8, !tbaa !5
  %117 = getelementptr inbounds %struct.hashmultiset0, ptr %116, i32 0, i32 2
  %118 = load i64, ptr %117, align 8, !tbaa !29
  %119 = load ptr, ptr %4, align 8, !tbaa !5
  %120 = getelementptr inbounds %struct.hashmultiset0, ptr %119, i32 0, i32 2
  store i64 %118, ptr %120, align 8, !tbaa !29
  %121 = load ptr, ptr %3, align 8, !tbaa !5
  %122 = getelementptr inbounds %struct.hashmultiset0, ptr %121, i32 0, i32 3
  %123 = load i64, ptr %122, align 8, !tbaa !30
  %124 = load ptr, ptr %4, align 8, !tbaa !5
  %125 = getelementptr inbounds %struct.hashmultiset0, ptr %124, i32 0, i32 3
  store i64 %123, ptr %125, align 8, !tbaa !30
  %126 = load ptr, ptr %3, align 8, !tbaa !5
  %127 = getelementptr inbounds %struct.hashmultiset0, ptr %126, i32 0, i32 5
  store i32 0, ptr %127, align 8, !tbaa !17
  %128 = load ptr, ptr %4, align 8, !tbaa !5
  store ptr %128, ptr %2, align 8
  store i32 1, ptr %5, align 4
  br label %129

129:                                              ; preds = %115, %30
  call void @llvm.lifetime.end.p0(i64 8, ptr %4) #3
  %130 = load ptr, ptr %2, align 8
  ret ptr %130
}

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

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

; Function Attrs: nounwind uwtable
declare dso_local ptr @hms0_new_custom(i64 noundef, double noundef, ptr noundef, ptr noundef, ptr noundef) local_unnamed_addr #1

; Function Attrs: nounwind uwtable
define dso_local ptr @hms0_copy_of(ptr nocapture noundef %0) local_unnamed_addr #1 {
  %2 = getelementptr inbounds i8, ptr %0, i64 8
  %3 = load i64, ptr %2, align 8, !tbaa !5
  %4 = uitofp i64 %3 to double
  %5 = getelementptr inbounds i8, ptr %0, i64 32
  %6 = load double, ptr %5, align 8, !tbaa !13
  %7 = fmul double %6, %4
  %8 = fptoui double %7 to i64
  %9 = getelementptr inbounds i8, ptr %0, i64 48
  %10 = load ptr, ptr %9, align 8, !tbaa !14
  %11 = getelementptr inbounds i8, ptr %0, i64 56
  %12 = load ptr, ptr %11, align 8, !tbaa !15
  %13 = tail call ptr @hms0_new_custom(i64 noundef %8, double noundef %6, ptr noundef %10, ptr noundef %12, ptr noundef null)
  %.not = icmp eq ptr %13, null
  br i1 %.not, label %51, label %14

14:                                               ; preds = %1
  %15 = load ptr, ptr %9, align 8, !tbaa !14
  %16 = getelementptr inbounds i8, ptr %15, i64 8
  %17 = load ptr, ptr %16, align 8, !tbaa !16
  %.not39 = icmp eq ptr %17, null
  br i1 %.not39, label %43, label %.preheader

.preheader:                                       ; preds = %14
  %18 = load i64, ptr %2, align 8, !tbaa !5
  %.not42 = icmp eq i64 %18, 0
  br i1 %.not42, label %.loopexit, label %.lr.ph

.lr.ph:                                           ; preds = %.preheader, %39
  %19 = phi i64 [ %40, %39 ], [ %18, %.preheader ]
  %.03641 = phi i64 [ %41, %39 ], [ 0, %.preheader ]
  %20 = load ptr, ptr %0, align 8, !tbaa !18
  %21 = getelementptr inbounds %struct.hashmultiset0_entry, ptr %20, i64 %.03641
  %22 = getelementptr inbounds i8, ptr %21, i64 24
  %23 = load i32, ptr %22, align 8, !tbaa !19
  %.not40 = icmp eq i32 %23, 0
  br i1 %.not40, label %39, label %24

24:                                               ; preds = %.lr.ph
  %25 = load ptr, ptr %13, align 8, !tbaa !18
  %26 = getelementptr inbounds %struct.hashmultiset0_entry, ptr %25, i64 %.03641
  %27 = icmp eq i32 %23, -1
  %28 = getelementptr inbounds i8, ptr %26, i64 24
  br i1 %27, label %29, label %30

29:                                               ; preds = %24
  store i32 -1, ptr %28, align 8, !tbaa !19
  br label %39

30:                                               ; preds = %24
  store i32 %23, ptr %28, align 8, !tbaa !19
  %31 = getelementptr inbounds i8, ptr %21, i64 8
  %32 = getelementptr inbounds i8, ptr %26, i64 8
  %33 = load <2 x i64>, ptr %31, align 8, !tbaa !21
  store <2 x i64> %33, ptr %32, align 8, !tbaa !21
  %34 = load ptr, ptr %9, align 8, !tbaa !14
  %35 = getelementptr inbounds i8, ptr %34, i64 8
  %36 = load ptr, ptr %35, align 8, !tbaa !16
  %37 = load ptr, ptr %21, align 8, !tbaa !22
  %38 = tail call ptr %36(ptr noundef %37) #2
  store ptr %38, ptr %26, align 8, !tbaa !22
  %.pre = load i64, ptr %2, align 8, !tbaa !5
  br label %39

39:                                               ; preds = %29, %30, %.lr.ph
  %40 = phi i64 [ %19, %29 ], [ %.pre, %30 ], [ %19, %.lr.ph ]
  %41 = add nuw i64 %.03641, 1
  %42 = icmp ult i64 %41, %40
  br i1 %42, label %.lr.ph, label %.loopexit, !llvm.loop !23

43:                                               ; preds = %14
  %44 = load ptr, ptr %13, align 8, !tbaa !18
  %45 = load ptr, ptr %0, align 8, !tbaa !18
  %46 = load i64, ptr %2, align 8, !tbaa !5
  %47 = shl i64 %46, 5
  tail call void @llvm.memcpy.p0.p0.i64(ptr align 8 %44, ptr align 8 %45, i64 %47, i1 false)
  br label %.loopexit

.loopexit:                                        ; preds = %39, %.preheader, %43
  %48 = getelementptr inbounds i8, ptr %0, i64 16
  %49 = getelementptr inbounds i8, ptr %13, i64 16
  %50 = load <2 x i64>, ptr %48, align 8, !tbaa !21
  store <2 x i64> %50, ptr %49, align 8, !tbaa !21
  br label %51

51:                                               ; preds = %1, %.loopexit
  %.sink = phi i32 [ 0, %.loopexit ], [ 7, %1 ]
  %52 = getelementptr inbounds i8, ptr %0, i64 40
  store i32 %.sink, ptr %52, align 8, !tbaa !25
  ret ptr %13
}

attributes #0 = { mustprogress nocallback nofree 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, !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, !11, i64 32}
!14 = !{!6, !7, i64 48}
!15 = !{!6, !7, i64 56}
!16 = !{!17, !7, i64 8}
!17 = !{!"hashmultiset0_fval", !7, i64 0, !7, i64 8, !7, i64 16, !7, i64 24, !7, i64 32, !7, i64 40}
!18 = !{!6, !7, i64 0}
!19 = !{!20, !12, i64 24}
!20 = !{!"hashmultiset0_entry", !7, i64 0, !10, i64 8, !10, i64 16, !12, i64 24}
!21 = !{!10, !10, i64 0}
!22 = !{!20, !7, i64 0}
!23 = distinct !{!23, !24}
!24 = !{!"llvm.loop.mustprogress"}
!25 = !{!6, !12, i64 40}


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