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

; 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 @hm1_clear(ptr noundef %0) #2 {
  %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.hashmap1, ptr %5, i32 0, i32 5
  %7 = load ptr, ptr %6, align 8, !tbaa !9
  %8 = getelementptr inbounds %struct.hashmap1_fkey, 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 %18, label %11

11:                                               ; preds = %1
  %12 = load ptr, ptr %2, align 8, !tbaa !5
  %13 = getelementptr inbounds %struct.hashmap1, ptr %12, i32 0, i32 6
  %14 = load ptr, ptr %13, align 8, !tbaa !16
  %15 = getelementptr inbounds %struct.hashmap1_fval, ptr %14, i32 0, i32 3
  %16 = load ptr, ptr %15, align 8, !tbaa !17
  %17 = icmp ne ptr %16, null
  br i1 %17, label %18, label %72

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

19:                                               ; preds = %68, %18
  %20 = load i64, ptr %3, align 8, !tbaa !19
  %21 = load ptr, ptr %2, align 8, !tbaa !5
  %22 = getelementptr inbounds %struct.hashmap1, ptr %21, i32 0, i32 1
  %23 = load i64, ptr %22, align 8, !tbaa !20
  %24 = icmp ult i64 %20, %23
  br i1 %24, label %26, label %25

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

26:                                               ; preds = %19
  call void @llvm.lifetime.start.p0(i64 8, ptr %4) #3
  %27 = load ptr, ptr %2, align 8, !tbaa !5
  %28 = getelementptr inbounds %struct.hashmap1, ptr %27, i32 0, i32 0
  %29 = load ptr, ptr %28, align 8, !tbaa !21
  %30 = load i64, ptr %3, align 8, !tbaa !19
  %31 = getelementptr inbounds %struct.hashmap1_entry, ptr %29, i64 %30
  store ptr %31, ptr %4, align 8, !tbaa !5
  %32 = load ptr, ptr %4, align 8, !tbaa !5
  %33 = getelementptr inbounds %struct.hashmap1_entry, ptr %32, i32 0, i32 3
  %34 = load i32, ptr %33, align 8, !tbaa !22
  %35 = icmp eq i32 %34, 1
  br i1 %35, label %36, label %67

36:                                               ; preds = %26
  %37 = load ptr, ptr %2, align 8, !tbaa !5
  %38 = getelementptr inbounds %struct.hashmap1, ptr %37, i32 0, i32 5
  %39 = load ptr, ptr %38, align 8, !tbaa !9
  %40 = getelementptr inbounds %struct.hashmap1_fkey, ptr %39, i32 0, i32 3
  %41 = load ptr, ptr %40, align 8, !tbaa !14
  %42 = icmp ne ptr %41, null
  br i1 %42, label %43, label %51

43:                                               ; preds = %36
  %44 = load ptr, ptr %2, align 8, !tbaa !5
  %45 = getelementptr inbounds %struct.hashmap1, ptr %44, i32 0, i32 5
  %46 = load ptr, ptr %45, align 8, !tbaa !9
  %47 = getelementptr inbounds %struct.hashmap1_fkey, ptr %46, i32 0, i32 3
  %48 = load ptr, ptr %47, align 8, !tbaa !14
  %49 = load ptr, ptr %4, align 8, !tbaa !5
  %50 = getelementptr inbounds %struct.hashmap1_entry, ptr %49, i32 0, i32 0
  call void %48(ptr noundef byval(%struct.struct_s) align 8 %50)
  br label %51

51:                                               ; preds = %43, %36
  %52 = load ptr, ptr %2, align 8, !tbaa !5
  %53 = getelementptr inbounds %struct.hashmap1, ptr %52, i32 0, i32 6
  %54 = load ptr, ptr %53, align 8, !tbaa !16
  %55 = getelementptr inbounds %struct.hashmap1_fval, ptr %54, i32 0, i32 3
  %56 = load ptr, ptr %55, align 8, !tbaa !17
  %57 = icmp ne ptr %56, null
  br i1 %57, label %58, label %66

58:                                               ; preds = %51
  %59 = load ptr, ptr %2, align 8, !tbaa !5
  %60 = getelementptr inbounds %struct.hashmap1, ptr %59, i32 0, i32 6
  %61 = load ptr, ptr %60, align 8, !tbaa !16
  %62 = getelementptr inbounds %struct.hashmap1_fval, ptr %61, i32 0, i32 3
  %63 = load ptr, ptr %62, align 8, !tbaa !17
  %64 = load ptr, ptr %4, align 8, !tbaa !5
  %65 = getelementptr inbounds %struct.hashmap1_entry, ptr %64, i32 0, i32 1
  call void %63(ptr noundef byval(%struct.struct_s) align 8 %65)
  br label %66

66:                                               ; preds = %58, %51
  br label %67

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

68:                                               ; preds = %67
  %69 = load i64, ptr %3, align 8, !tbaa !19
  %70 = add i64 %69, 1
  store i64 %70, ptr %3, align 8, !tbaa !19
  br label %19, !llvm.loop !25

71:                                               ; preds = %25
  br label %72

72:                                               ; preds = %71, %11
  %73 = load ptr, ptr %2, align 8, !tbaa !5
  %74 = getelementptr inbounds %struct.hashmap1, ptr %73, i32 0, i32 0
  %75 = load ptr, ptr %74, align 8, !tbaa !21
  %76 = load ptr, ptr %2, align 8, !tbaa !5
  %77 = getelementptr inbounds %struct.hashmap1, ptr %76, i32 0, i32 1
  %78 = load i64, ptr %77, align 8, !tbaa !20
  %79 = mul i64 224, %78
  call void @llvm.memset.p0.i64(ptr align 8 %75, i8 0, i64 %79, i1 false)
  %80 = load ptr, ptr %2, align 8, !tbaa !5
  %81 = getelementptr inbounds %struct.hashmap1, ptr %80, i32 0, i32 2
  store i64 0, ptr %81, align 8, !tbaa !27
  %82 = load ptr, ptr %2, align 8, !tbaa !5
  %83 = getelementptr inbounds %struct.hashmap1, ptr %82, i32 0, i32 4
  store i32 0, ptr %83, align 8, !tbaa !28
  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, !6, i64 40}
!10 = !{!"hashmap1", !6, i64 0, !11, i64 8, !11, i64 16, !12, i64 24, !13, i64 32, !6, 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 = !{!"hashmap1_fkey", !6, i64 0, !6, i64 8, !6, i64 16, !6, i64 24, !6, i64 32, !6, i64 40}
!16 = !{!10, !6, i64 48}
!17 = !{!18, !6, i64 24}
!18 = !{!"hashmap1_fval", !6, i64 0, !6, i64 8, !6, i64 16, !6, i64 24, !6, i64 32, !6, i64 40}
!19 = !{!11, !11, i64 0}
!20 = !{!10, !11, i64 8}
!21 = !{!10, !6, i64 0}
!22 = !{!23, !13, i64 216}
!23 = !{!"hashmap1_entry", !24, i64 0, !24, i64 104, !11, i64 208, !13, i64 216}
!24 = !{!"struct_s", !13, i64 0, !13, i64 4, !6, i64 8, !6, i64 16, !7, i64 24}
!25 = distinct !{!25, !26}
!26 = !{!"llvm.loop.mustprogress"}
!27 = !{!10, !11, i64 16}
!28 = !{!10, !13, 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.hashmap1_entry = type { %struct.struct_s, %struct.struct_s, i64, i32 }
%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 @hm1_clear(ptr nocapture noundef %0) local_unnamed_addr #1 {
  %2 = getelementptr inbounds i8, ptr %0, i64 40
  %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 %6, label %11

6:                                                ; preds = %1
  %7 = getelementptr inbounds i8, ptr %0, i64 48
  %8 = load ptr, ptr %7, align 8, !tbaa !15
  %9 = getelementptr inbounds i8, ptr %8, i64 24
  %10 = load ptr, ptr %9, align 8, !tbaa !16
  %.not19 = icmp eq ptr %10, null
  br i1 %.not19, label %..loopexit_crit_edge, label %11

..loopexit_crit_edge:                             ; preds = %6
  %.phi.trans.insert = getelementptr inbounds i8, ptr %0, i64 8
  %.pre = load i64, ptr %.phi.trans.insert, align 8, !tbaa !18
  br label %.loopexit

11:                                               ; preds = %6, %1
  %12 = getelementptr inbounds i8, ptr %0, i64 8
  %13 = load i64, ptr %12, align 8, !tbaa !18
  %.not23 = icmp eq i64 %13, 0
  br i1 %.not23, label %.loopexit, label %.lr.ph

.lr.ph:                                           ; preds = %11
  %14 = getelementptr inbounds i8, ptr %0, i64 48
  br label %15

15:                                               ; preds = %.lr.ph, %32
  %.022 = phi i64 [ 0, %.lr.ph ], [ %33, %32 ]
  %16 = load ptr, ptr %0, align 8, !tbaa !19
  %17 = getelementptr inbounds %struct.hashmap1_entry, ptr %16, i64 %.022
  %18 = getelementptr inbounds i8, ptr %17, i64 216
  %19 = load i32, ptr %18, align 8, !tbaa !20
  %20 = icmp eq i32 %19, 1
  br i1 %20, label %21, label %32

21:                                               ; preds = %15
  %22 = load ptr, ptr %2, align 8, !tbaa !5
  %23 = getelementptr inbounds i8, ptr %22, i64 24
  %24 = load ptr, ptr %23, align 8, !tbaa !13
  %.not20 = icmp eq ptr %24, null
  br i1 %.not20, label %26, label %25

25:                                               ; preds = %21
  tail call void %24(ptr noundef nonnull byval(%struct.struct_s) align 8 %17) #2
  br label %26

26:                                               ; preds = %25, %21
  %27 = load ptr, ptr %14, align 8, !tbaa !15
  %28 = getelementptr inbounds i8, ptr %27, i64 24
  %29 = load ptr, ptr %28, align 8, !tbaa !16
  %.not21 = icmp eq ptr %29, null
  br i1 %.not21, label %32, label %30

30:                                               ; preds = %26
  %31 = getelementptr inbounds i8, ptr %17, i64 104
  tail call void %29(ptr noundef nonnull byval(%struct.struct_s) align 8 %31) #2
  br label %32

32:                                               ; preds = %26, %30, %15
  %33 = add nuw i64 %.022, 1
  %34 = load i64, ptr %12, align 8, !tbaa !18
  %35 = icmp ult i64 %33, %34
  br i1 %35, label %15, label %.loopexit, !llvm.loop !23

.loopexit:                                        ; preds = %32, %..loopexit_crit_edge, %11
  %36 = phi i64 [ %.pre, %..loopexit_crit_edge ], [ 0, %11 ], [ %34, %32 ]
  %37 = load ptr, ptr %0, align 8, !tbaa !19
  %38 = mul i64 %36, 224
  tail call void @llvm.memset.p0.i64(ptr align 8 %37, i8 0, i64 %38, i1 false)
  %39 = getelementptr inbounds i8, ptr %0, i64 16
  store i64 0, ptr %39, align 8, !tbaa !25
  %40 = getelementptr inbounds i8, ptr %0, i64 32
  store i32 0, ptr %40, align 8, !tbaa !26
  ret void
}

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, !7, i64 40}
!6 = !{!"hashmap1", !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 = !{!14, !7, i64 24}
!14 = !{!"hashmap1_fkey", !7, i64 0, !7, i64 8, !7, i64 16, !7, i64 24, !7, i64 32, !7, i64 40}
!15 = !{!6, !7, i64 48}
!16 = !{!17, !7, i64 24}
!17 = !{!"hashmap1_fval", !7, i64 0, !7, i64 8, !7, i64 16, !7, i64 24, !7, i64 32, !7, i64 40}
!18 = !{!6, !10, i64 8}
!19 = !{!6, !7, i64 0}
!20 = !{!21, !12, i64 216}
!21 = !{!"hashmap1_entry", !22, i64 0, !22, i64 104, !10, i64 208, !12, i64 216}
!22 = !{!"struct_s", !12, i64 0, !12, i64 4, !7, i64 8, !7, i64 16, !8, i64 24}
!23 = distinct !{!23, !24}
!24 = !{!"llvm.loop.mustprogress"}
!25 = !{!6, !10, i64 16}
!26 = !{!6, !12, i64 32}


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