; 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.hashmultimap1 = type { ptr, i64, i64, double, i32, ptr, ptr, ptr }
%struct.hashmultimap1_entry = type { %struct.struct_s, %struct.struct_s, ptr, ptr }
%struct.struct_s = type { i32, i32, ptr, ptr, [10 x double] }
%struct.hashmultimap1_fkey = type { ptr, ptr, ptr, ptr, ptr, ptr }
%struct.hashmultimap1_fval = type { ptr, ptr, ptr, ptr, ptr, ptr }
%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: nocallback nofree nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #1

; Function Attrs: nounwind uwtable
define dso_local void @hmm1_clear(ptr noundef %0) #2 {
  %2 = alloca ptr, align 8
  %3 = alloca i64, align 8
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  store ptr %0, ptr %2, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %3) #3
  store i64 0, ptr %3, align 8, !tbaa !9
  br label %6

6:                                                ; preds = %66, %1
  %7 = load i64, ptr %3, align 8, !tbaa !9
  %8 = load ptr, ptr %2, align 8, !tbaa !5
  %9 = getelementptr inbounds %struct.hashmultimap1, ptr %8, i32 0, i32 1
  %10 = load i64, ptr %9, align 8, !tbaa !11
  %11 = icmp ult i64 %7, %10
  br i1 %11, label %13, label %12

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

13:                                               ; preds = %6
  call void @llvm.lifetime.start.p0(i64 8, ptr %4) #3
  %14 = load ptr, ptr %2, align 8, !tbaa !5
  %15 = getelementptr inbounds %struct.hashmultimap1, ptr %14, i32 0, i32 0
  %16 = load ptr, ptr %15, align 8, !tbaa !15
  %17 = load i64, ptr %3, align 8, !tbaa !9
  %18 = getelementptr inbounds [2 x ptr], ptr %16, i64 %17
  %19 = getelementptr inbounds [2 x ptr], ptr %18, i64 0, i64 0
  %20 = load ptr, ptr %19, align 8, !tbaa !5
  store ptr %20, ptr %4, align 8, !tbaa !5
  br label %21

21:                                               ; preds = %57, %13
  %22 = load ptr, ptr %4, align 8, !tbaa !5
  %23 = icmp ne ptr %22, null
  br i1 %23, label %24, label %65

24:                                               ; preds = %21
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #3
  %25 = load ptr, ptr %4, align 8, !tbaa !5
  %26 = getelementptr inbounds %struct.hashmultimap1_entry, ptr %25, i32 0, i32 2
  %27 = load ptr, ptr %26, align 8, !tbaa !16
  store ptr %27, ptr %5, align 8, !tbaa !5
  %28 = load ptr, ptr %2, align 8, !tbaa !5
  %29 = getelementptr inbounds %struct.hashmultimap1, ptr %28, i32 0, i32 5
  %30 = load ptr, ptr %29, align 8, !tbaa !19
  %31 = getelementptr inbounds %struct.hashmultimap1_fkey, ptr %30, i32 0, i32 3
  %32 = load ptr, ptr %31, align 8, !tbaa !20
  %33 = icmp ne ptr %32, null
  br i1 %33, label %34, label %42

34:                                               ; preds = %24
  %35 = load ptr, ptr %2, align 8, !tbaa !5
  %36 = getelementptr inbounds %struct.hashmultimap1, ptr %35, i32 0, i32 5
  %37 = load ptr, ptr %36, align 8, !tbaa !19
  %38 = getelementptr inbounds %struct.hashmultimap1_fkey, ptr %37, i32 0, i32 3
  %39 = load ptr, ptr %38, align 8, !tbaa !20
  %40 = load ptr, ptr %4, align 8, !tbaa !5
  %41 = getelementptr inbounds %struct.hashmultimap1_entry, ptr %40, i32 0, i32 0
  call void %39(ptr noundef byval(%struct.struct_s) align 8 %41)
  br label %42

42:                                               ; preds = %34, %24
  %43 = load ptr, ptr %2, align 8, !tbaa !5
  %44 = getelementptr inbounds %struct.hashmultimap1, ptr %43, i32 0, i32 6
  %45 = load ptr, ptr %44, align 8, !tbaa !22
  %46 = getelementptr inbounds %struct.hashmultimap1_fval, ptr %45, i32 0, i32 3
  %47 = load ptr, ptr %46, align 8, !tbaa !23
  %48 = icmp ne ptr %47, null
  br i1 %48, label %49, label %57

49:                                               ; preds = %42
  %50 = load ptr, ptr %2, align 8, !tbaa !5
  %51 = getelementptr inbounds %struct.hashmultimap1, ptr %50, i32 0, i32 6
  %52 = load ptr, ptr %51, align 8, !tbaa !22
  %53 = getelementptr inbounds %struct.hashmultimap1_fval, ptr %52, i32 0, i32 3
  %54 = load ptr, ptr %53, align 8, !tbaa !23
  %55 = load ptr, ptr %4, align 8, !tbaa !5
  %56 = getelementptr inbounds %struct.hashmultimap1_entry, ptr %55, i32 0, i32 1
  call void %54(ptr noundef byval(%struct.struct_s) align 8 %56)
  br label %57

57:                                               ; preds = %49, %42
  %58 = load ptr, ptr %2, align 8, !tbaa !5
  %59 = getelementptr inbounds %struct.hashmultimap1, ptr %58, i32 0, i32 7
  %60 = load ptr, ptr %59, align 8, !tbaa !25
  %61 = getelementptr inbounds %struct.cmc_alloc_node, ptr %60, i32 0, i32 3
  %62 = load ptr, ptr %61, align 8, !tbaa !26
  %63 = load ptr, ptr %4, align 8, !tbaa !5
  call void %62(ptr noundef %63)
  %64 = load ptr, ptr %5, align 8, !tbaa !5
  store ptr %64, ptr %4, align 8, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #3
  br label %21, !llvm.loop !28

65:                                               ; preds = %21
  call void @llvm.lifetime.end.p0(i64 8, ptr %4) #3
  br label %66

66:                                               ; preds = %65
  %67 = load i64, ptr %3, align 8, !tbaa !9
  %68 = add i64 %67, 1
  store i64 %68, ptr %3, align 8, !tbaa !9
  br label %6, !llvm.loop !30

69:                                               ; preds = %12
  %70 = load ptr, ptr %2, align 8, !tbaa !5
  %71 = getelementptr inbounds %struct.hashmultimap1, ptr %70, i32 0, i32 0
  %72 = load ptr, ptr %71, align 8, !tbaa !15
  %73 = load ptr, ptr %2, align 8, !tbaa !5
  %74 = getelementptr inbounds %struct.hashmultimap1, ptr %73, i32 0, i32 1
  %75 = load i64, ptr %74, align 8, !tbaa !11
  %76 = mul i64 16, %75
  call void @llvm.memset.p0.i64(ptr align 8 %72, i8 0, i64 %76, i1 false)
  %77 = load ptr, ptr %2, align 8, !tbaa !5
  %78 = getelementptr inbounds %struct.hashmultimap1, ptr %77, i32 0, i32 2
  store i64 0, ptr %78, align 8, !tbaa !31
  %79 = load ptr, ptr %2, align 8, !tbaa !5
  %80 = getelementptr inbounds %struct.hashmultimap1, ptr %79, i32 0, i32 4
  store i32 0, ptr %80, align 8, !tbaa !32
  ret void
}

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { nocallback nofree nounwind willreturn memory(argmem: write) }
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, !10, i64 0}
!10 = !{!"long", !7, i64 0}
!11 = !{!12, !10, i64 8}
!12 = !{!"hashmultimap1", !6, i64 0, !10, i64 8, !10, i64 16, !13, i64 24, !14, i64 32, !6, i64 40, !6, i64 48, !6, i64 56}
!13 = !{!"double", !7, i64 0}
!14 = !{!"int", !7, i64 0}
!15 = !{!12, !6, i64 0}
!16 = !{!17, !6, i64 208}
!17 = !{!"hashmultimap1_entry", !18, i64 0, !18, i64 104, !6, i64 208, !6, i64 216}
!18 = !{!"struct_s", !14, i64 0, !14, i64 4, !6, i64 8, !6, i64 16, !7, i64 24}
!19 = !{!12, !6, i64 40}
!20 = !{!21, !6, i64 24}
!21 = !{!"hashmultimap1_fkey", !6, i64 0, !6, i64 8, !6, i64 16, !6, i64 24, !6, i64 32, !6, i64 40}
!22 = !{!12, !6, i64 48}
!23 = !{!24, !6, i64 24}
!24 = !{!"hashmultimap1_fval", !6, i64 0, !6, i64 8, !6, i64 16, !6, i64 24, !6, i64 32, !6, i64 40}
!25 = !{!12, !6, i64 56}
!26 = !{!27, !6, i64 24}
!27 = !{!"cmc_alloc_node", !6, i64 0, !6, i64 8, !6, i64 16, !6, i64 24}
!28 = distinct !{!28, !29}
!29 = !{!"llvm.loop.mustprogress"}
!30 = distinct !{!30, !29}
!31 = !{!12, !10, i64 16}
!32 = !{!12, !14, i64 32}


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

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

; Function Attrs: nounwind uwtable
define dso_local void @hmm1_clear(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
  %.not31 = icmp eq i64 %3, 0
  br i1 %.not31, label %._crit_edge30, label %.lr.ph29

.lr.ph29:                                         ; preds = %1
  %4 = getelementptr inbounds i8, ptr %0, i64 40
  %5 = getelementptr inbounds i8, ptr %0, i64 48
  %6 = getelementptr inbounds i8, ptr %0, i64 56
  br label %11

._crit_edge30.loopexit:                           ; preds = %._crit_edge
  %7 = shl i64 %32, 4
  br label %._crit_edge30

._crit_edge30:                                    ; preds = %._crit_edge30.loopexit, %1
  %.lcssa = phi i64 [ 0, %1 ], [ %7, %._crit_edge30.loopexit ]
  %8 = load ptr, ptr %0, align 8, !tbaa !13
  tail call void @llvm.memset.p0.i64(ptr align 8 %8, i8 0, i64 %.lcssa, i1 false)
  %9 = getelementptr inbounds i8, ptr %0, i64 16
  store i64 0, ptr %9, align 8, !tbaa !14
  %10 = getelementptr inbounds i8, ptr %0, i64 32
  store i32 0, ptr %10, align 8, !tbaa !15
  ret void

11:                                               ; preds = %.lr.ph29, %._crit_edge
  %12 = phi i64 [ %3, %.lr.ph29 ], [ %32, %._crit_edge ]
  %.027 = phi i64 [ 0, %.lr.ph29 ], [ %33, %._crit_edge ]
  %13 = load ptr, ptr %0, align 8, !tbaa !13
  %14 = getelementptr inbounds [2 x ptr], ptr %13, i64 %.027
  %15 = load ptr, ptr %14, align 8, !tbaa !16
  %.not25 = icmp eq ptr %15, null
  br i1 %.not25, label %._crit_edge, label %.lr.ph

.lr.ph:                                           ; preds = %11, %28
  %.01926 = phi ptr [ %17, %28 ], [ %15, %11 ]
  %16 = getelementptr inbounds i8, ptr %.01926, i64 208
  %17 = load ptr, ptr %16, align 8, !tbaa !17
  %18 = load ptr, ptr %4, align 8, !tbaa !20
  %19 = getelementptr inbounds i8, ptr %18, i64 24
  %20 = load ptr, ptr %19, align 8, !tbaa !21
  %.not23 = icmp eq ptr %20, null
  br i1 %.not23, label %22, label %21

21:                                               ; preds = %.lr.ph
  tail call void %20(ptr noundef nonnull byval(%struct.struct_s) align 8 %.01926) #2
  br label %22

22:                                               ; preds = %21, %.lr.ph
  %23 = load ptr, ptr %5, align 8, !tbaa !23
  %24 = getelementptr inbounds i8, ptr %23, i64 24
  %25 = load ptr, ptr %24, align 8, !tbaa !24
  %.not24 = icmp eq ptr %25, null
  br i1 %.not24, label %28, label %26

26:                                               ; preds = %22
  %27 = getelementptr inbounds i8, ptr %.01926, i64 104
  tail call void %25(ptr noundef nonnull byval(%struct.struct_s) align 8 %27) #2
  br label %28

28:                                               ; preds = %26, %22
  %29 = load ptr, ptr %6, align 8, !tbaa !26
  %30 = getelementptr inbounds i8, ptr %29, i64 24
  %31 = load ptr, ptr %30, align 8, !tbaa !27
  tail call void %31(ptr noundef nonnull %.01926) #2
  %.not = icmp eq ptr %17, null
  br i1 %.not, label %._crit_edge.loopexit, label %.lr.ph, !llvm.loop !29

._crit_edge.loopexit:                             ; preds = %28
  %.pre = load i64, ptr %2, align 8, !tbaa !5
  br label %._crit_edge

._crit_edge:                                      ; preds = %._crit_edge.loopexit, %11
  %32 = phi i64 [ %.pre, %._crit_edge.loopexit ], [ %12, %11 ]
  %33 = add nuw i64 %.027, 1
  %34 = icmp ult i64 %33, %32
  br i1 %34, label %11, label %._crit_edge30.loopexit, !llvm.loop !31
}

attributes #0 = { mustprogress nocallback nofree nounwind willreturn memory(argmem: write) }
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 = !{!"hashmultimap1", !7, i64 0, !10, i64 8, !10, i64 16, !11, i64 24, !12, i64 32, !7, 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 = !{!6, !10, i64 16}
!15 = !{!6, !12, i64 32}
!16 = !{!7, !7, i64 0}
!17 = !{!18, !7, i64 208}
!18 = !{!"hashmultimap1_entry", !19, i64 0, !19, i64 104, !7, i64 208, !7, i64 216}
!19 = !{!"struct_s", !12, i64 0, !12, i64 4, !7, i64 8, !7, i64 16, !8, i64 24}
!20 = !{!6, !7, i64 40}
!21 = !{!22, !7, i64 24}
!22 = !{!"hashmultimap1_fkey", !7, i64 0, !7, i64 8, !7, i64 16, !7, i64 24, !7, i64 32, !7, i64 40}
!23 = !{!6, !7, i64 48}
!24 = !{!25, !7, i64 24}
!25 = !{!"hashmultimap1_fval", !7, i64 0, !7, i64 8, !7, i64 16, !7, i64 24, !7, i64 32, !7, i64 40}
!26 = !{!6, !7, i64 56}
!27 = !{!28, !7, i64 24}
!28 = !{!"cmc_alloc_node", !7, i64 0, !7, i64 8, !7, i64 16, !7, i64 24}
!29 = distinct !{!29, !30}
!30 = !{!"llvm.loop.mustprogress"}
!31 = distinct !{!31, !30}


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