; 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.hashmap0 = type { ptr, i64, i64, double, i32, ptr, ptr, ptr }
%struct.hashmap0_fkey = type { ptr, ptr, ptr, ptr, ptr, ptr }
%struct.hashmap0_fval = type { ptr, ptr, ptr, ptr, ptr, ptr }
%struct.hashmap0_entry = type { ptr, ptr, i64, i32 }
%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 @hm0_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.hashmap0, ptr %5, i32 0, i32 5
  %7 = load ptr, ptr %6, align 8, !tbaa !9
  %8 = getelementptr inbounds %struct.hashmap0_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.hashmap0, ptr %12, i32 0, i32 6
  %14 = load ptr, ptr %13, align 8, !tbaa !16
  %15 = getelementptr inbounds %struct.hashmap0_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 %74

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

19:                                               ; preds = %70, %18
  %20 = load i64, ptr %3, align 8, !tbaa !19
  %21 = load ptr, ptr %2, align 8, !tbaa !5
  %22 = getelementptr inbounds %struct.hashmap0, 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) #2
  br label %73

26:                                               ; preds = %19
  call void @llvm.lifetime.start.p0(i64 8, ptr %4) #2
  %27 = load ptr, ptr %2, align 8, !tbaa !5
  %28 = getelementptr inbounds %struct.hashmap0, 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.hashmap0_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.hashmap0_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 %69

36:                                               ; preds = %26
  %37 = load ptr, ptr %2, align 8, !tbaa !5
  %38 = getelementptr inbounds %struct.hashmap0, ptr %37, i32 0, i32 5
  %39 = load ptr, ptr %38, align 8, !tbaa !9
  %40 = getelementptr inbounds %struct.hashmap0_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 %52

43:                                               ; preds = %36
  %44 = load ptr, ptr %2, align 8, !tbaa !5
  %45 = getelementptr inbounds %struct.hashmap0, ptr %44, i32 0, i32 5
  %46 = load ptr, ptr %45, align 8, !tbaa !9
  %47 = getelementptr inbounds %struct.hashmap0_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.hashmap0_entry, ptr %49, i32 0, i32 0
  %51 = load ptr, ptr %50, align 8, !tbaa !24
  call void %48(ptr noundef %51)
  br label %52

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

59:                                               ; preds = %52
  %60 = load ptr, ptr %2, align 8, !tbaa !5
  %61 = getelementptr inbounds %struct.hashmap0, ptr %60, i32 0, i32 6
  %62 = load ptr, ptr %61, align 8, !tbaa !16
  %63 = getelementptr inbounds %struct.hashmap0_fval, ptr %62, i32 0, i32 3
  %64 = load ptr, ptr %63, align 8, !tbaa !17
  %65 = load ptr, ptr %4, align 8, !tbaa !5
  %66 = getelementptr inbounds %struct.hashmap0_entry, ptr %65, i32 0, i32 1
  %67 = load ptr, ptr %66, align 8, !tbaa !25
  call void %64(ptr noundef %67)
  br label %68

68:                                               ; preds = %59, %52
  br label %69

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

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

73:                                               ; preds = %25
  br label %74

74:                                               ; preds = %73, %11
  %75 = load ptr, ptr %2, align 8, !tbaa !5
  %76 = getelementptr inbounds %struct.hashmap0, ptr %75, i32 0, i32 7
  %77 = load ptr, ptr %76, align 8, !tbaa !28
  %78 = getelementptr inbounds %struct.cmc_alloc_node, ptr %77, i32 0, i32 3
  %79 = load ptr, ptr %78, align 8, !tbaa !29
  %80 = load ptr, ptr %2, align 8, !tbaa !5
  %81 = getelementptr inbounds %struct.hashmap0, ptr %80, i32 0, i32 0
  %82 = load ptr, ptr %81, align 8, !tbaa !21
  call void %79(ptr noundef %82)
  %83 = load ptr, ptr %2, align 8, !tbaa !5
  %84 = getelementptr inbounds %struct.hashmap0, ptr %83, i32 0, i32 7
  %85 = load ptr, ptr %84, align 8, !tbaa !28
  %86 = getelementptr inbounds %struct.cmc_alloc_node, ptr %85, i32 0, i32 3
  %87 = load ptr, ptr %86, align 8, !tbaa !29
  %88 = load ptr, ptr %2, align 8, !tbaa !5
  call void %87(ptr noundef %88)
  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 40}
!10 = !{!"hashmap0", !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 = !{!"hashmap0_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 = !{!"hashmap0_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 24}
!23 = !{!"hashmap0_entry", !6, i64 0, !6, i64 8, !11, i64 16, !13, i64 24}
!24 = !{!23, !6, i64 0}
!25 = !{!23, !6, i64 8}
!26 = distinct !{!26, !27}
!27 = !{!"llvm.loop.mustprogress"}
!28 = !{!10, !6, i64 56}
!29 = !{!30, !6, i64 24}
!30 = !{!"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.hashmap0_entry = type { ptr, ptr, i64, i32 }

; Function Attrs: nounwind uwtable
define dso_local void @hm0_free(ptr noundef %0) local_unnamed_addr #0 {
  %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, label %11

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, %34
  %.022 = phi i64 [ 0, %.lr.ph ], [ %35, %34 ]
  %16 = load ptr, ptr %0, align 8, !tbaa !19
  %17 = getelementptr inbounds %struct.hashmap0_entry, ptr %16, i64 %.022
  %18 = getelementptr inbounds i8, ptr %17, i64 24
  %19 = load i32, ptr %18, align 8, !tbaa !20
  %20 = icmp eq i32 %19, 1
  br i1 %20, label %21, label %34

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 %27, label %25

25:                                               ; preds = %21
  %26 = load ptr, ptr %17, align 8, !tbaa !22
  tail call void %24(ptr noundef %26) #1
  br label %27

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

31:                                               ; preds = %27
  %32 = getelementptr inbounds i8, ptr %17, i64 8
  %33 = load ptr, ptr %32, align 8, !tbaa !23
  tail call void %30(ptr noundef %33) #1
  br label %34

34:                                               ; preds = %27, %31, %15
  %35 = add nuw i64 %.022, 1
  %36 = load i64, ptr %12, align 8, !tbaa !18
  %37 = icmp ult i64 %35, %36
  br i1 %37, label %15, label %.loopexit, !llvm.loop !24

.loopexit:                                        ; preds = %34, %11, %6
  %38 = getelementptr inbounds i8, ptr %0, i64 56
  %39 = load ptr, ptr %38, align 8, !tbaa !26
  %40 = getelementptr inbounds i8, ptr %39, i64 24
  %41 = load ptr, ptr %40, align 8, !tbaa !27
  %42 = load ptr, ptr %0, align 8, !tbaa !19
  tail call void %41(ptr noundef %42) #1
  %43 = load ptr, ptr %38, align 8, !tbaa !26
  %44 = getelementptr inbounds i8, ptr %43, i64 24
  %45 = load ptr, ptr %44, align 8, !tbaa !27
  tail call void %45(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 40}
!6 = !{!"hashmap0", !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 = !{!"hashmap0_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 = !{!"hashmap0_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 24}
!21 = !{!"hashmap0_entry", !7, i64 0, !7, i64 8, !10, i64 16, !12, i64 24}
!22 = !{!21, !7, i64 0}
!23 = !{!21, !7, i64 8}
!24 = distinct !{!24, !25}
!25 = !{!"llvm.loop.mustprogress"}
!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}


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