; 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.struct_s = type { i32, i32, ptr, ptr, [10 x double] }
%struct.hashmultimap1 = type { ptr, i64, i64, double, i32, ptr, ptr, ptr }
%struct.hashmultimap1_entry = type { %struct.struct_s, %struct.struct_s, 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
declare dso_local i64 @hmm1_impl_key_count(ptr noundef, ptr noundef byval(%struct.struct_s) align 8) #1

; Function Attrs: nounwind uwtable
define dso_local zeroext i1 @hmm1_equals(ptr noundef %0, ptr noundef %1) #1 {
  %3 = alloca i1, align 1
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca ptr, align 8
  %8 = alloca i64, align 8
  %9 = alloca i32, align 4
  %10 = alloca ptr, align 8
  store ptr %0, ptr %4, align 8, !tbaa !5
  store ptr %1, ptr %5, align 8, !tbaa !5
  %11 = load ptr, ptr %4, align 8, !tbaa !5
  %12 = getelementptr inbounds %struct.hashmultimap1, ptr %11, i32 0, i32 4
  store i32 0, ptr %12, align 8, !tbaa !9
  %13 = load ptr, ptr %5, align 8, !tbaa !5
  %14 = getelementptr inbounds %struct.hashmultimap1, ptr %13, i32 0, i32 4
  store i32 0, ptr %14, align 8, !tbaa !9
  %15 = load ptr, ptr %4, align 8, !tbaa !5
  %16 = getelementptr inbounds %struct.hashmultimap1, ptr %15, i32 0, i32 2
  %17 = load i64, ptr %16, align 8, !tbaa !14
  %18 = load ptr, ptr %5, align 8, !tbaa !5
  %19 = getelementptr inbounds %struct.hashmultimap1, ptr %18, i32 0, i32 2
  %20 = load i64, ptr %19, align 8, !tbaa !14
  %21 = icmp ne i64 %17, %20
  br i1 %21, label %22, label %23

22:                                               ; preds = %2
  store i1 false, ptr %3, align 1
  br label %90

23:                                               ; preds = %2
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #2
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #2
  %24 = load ptr, ptr %4, align 8, !tbaa !5
  %25 = getelementptr inbounds %struct.hashmultimap1, ptr %24, i32 0, i32 1
  %26 = load i64, ptr %25, align 8, !tbaa !15
  %27 = load ptr, ptr %5, align 8, !tbaa !5
  %28 = getelementptr inbounds %struct.hashmultimap1, ptr %27, i32 0, i32 1
  %29 = load i64, ptr %28, align 8, !tbaa !15
  %30 = icmp ult i64 %26, %29
  br i1 %30, label %31, label %33

31:                                               ; preds = %23
  %32 = load ptr, ptr %4, align 8, !tbaa !5
  br label %35

33:                                               ; preds = %23
  %34 = load ptr, ptr %5, align 8, !tbaa !5
  br label %35

35:                                               ; preds = %33, %31
  %36 = phi ptr [ %32, %31 ], [ %34, %33 ]
  store ptr %36, ptr %6, align 8, !tbaa !5
  %37 = load ptr, ptr %6, align 8, !tbaa !5
  %38 = load ptr, ptr %4, align 8, !tbaa !5
  %39 = icmp eq ptr %37, %38
  br i1 %39, label %40, label %42

40:                                               ; preds = %35
  %41 = load ptr, ptr %5, align 8, !tbaa !5
  br label %44

42:                                               ; preds = %35
  %43 = load ptr, ptr %4, align 8, !tbaa !5
  br label %44

44:                                               ; preds = %42, %40
  %45 = phi ptr [ %41, %40 ], [ %43, %42 ]
  store ptr %45, ptr %7, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #2
  store i64 0, ptr %8, align 8, !tbaa !16
  br label %46

46:                                               ; preds = %83, %44
  %47 = load i64, ptr %8, align 8, !tbaa !16
  %48 = load ptr, ptr %6, align 8, !tbaa !5
  %49 = getelementptr inbounds %struct.hashmultimap1, ptr %48, i32 0, i32 1
  %50 = load i64, ptr %49, align 8, !tbaa !15
  %51 = icmp ult i64 %47, %50
  br i1 %51, label %53, label %52

52:                                               ; preds = %46
  store i32 2, ptr %9, align 4
  br label %86

53:                                               ; preds = %46
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #2
  %54 = load ptr, ptr %6, align 8, !tbaa !5
  %55 = getelementptr inbounds %struct.hashmultimap1, ptr %54, i32 0, i32 0
  %56 = load ptr, ptr %55, align 8, !tbaa !17
  %57 = load i64, ptr %8, align 8, !tbaa !16
  %58 = getelementptr inbounds [2 x ptr], ptr %56, i64 %57
  %59 = getelementptr inbounds [2 x ptr], ptr %58, i64 0, i64 0
  %60 = load ptr, ptr %59, align 8, !tbaa !5
  store ptr %60, ptr %10, align 8, !tbaa !5
  br label %61

61:                                               ; preds = %75, %53
  %62 = load ptr, ptr %10, align 8, !tbaa !5
  %63 = icmp ne ptr %62, null
  br i1 %63, label %64, label %79

64:                                               ; preds = %61
  %65 = load ptr, ptr %6, align 8, !tbaa !5
  %66 = load ptr, ptr %10, align 8, !tbaa !5
  %67 = getelementptr inbounds %struct.hashmultimap1_entry, ptr %66, i32 0, i32 0
  %68 = call i64 @hmm1_impl_key_count(ptr noundef %65, ptr noundef byval(%struct.struct_s) align 8 %67)
  %69 = load ptr, ptr %7, align 8, !tbaa !5
  %70 = load ptr, ptr %10, align 8, !tbaa !5
  %71 = getelementptr inbounds %struct.hashmultimap1_entry, ptr %70, i32 0, i32 0
  %72 = call i64 @hmm1_impl_key_count(ptr noundef %69, ptr noundef byval(%struct.struct_s) align 8 %71)
  %73 = icmp ne i64 %68, %72
  br i1 %73, label %74, label %75

74:                                               ; preds = %64
  store i1 false, ptr %3, align 1
  store i32 1, ptr %9, align 4
  br label %80

75:                                               ; preds = %64
  %76 = load ptr, ptr %10, align 8, !tbaa !5
  %77 = getelementptr inbounds %struct.hashmultimap1_entry, ptr %76, i32 0, i32 2
  %78 = load ptr, ptr %77, align 8, !tbaa !18
  store ptr %78, ptr %10, align 8, !tbaa !5
  br label %61, !llvm.loop !21

79:                                               ; preds = %61
  store i32 0, ptr %9, align 4
  br label %80

80:                                               ; preds = %79, %74
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #2
  %81 = load i32, ptr %9, align 4
  switch i32 %81, label %86 [
    i32 0, label %82
  ]

82:                                               ; preds = %80
  br label %83

83:                                               ; preds = %82
  %84 = load i64, ptr %8, align 8, !tbaa !16
  %85 = add i64 %84, 1
  store i64 %85, ptr %8, align 8, !tbaa !16
  br label %46, !llvm.loop !23

86:                                               ; preds = %80, %52
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #2
  %87 = load i32, ptr %9, align 4
  switch i32 %87, label %89 [
    i32 2, label %88
  ]

88:                                               ; preds = %86
  store i1 true, ptr %3, align 1
  store i32 1, ptr %9, align 4
  br label %89

89:                                               ; preds = %88, %86
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #2
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #2
  br label %90

90:                                               ; preds = %89, %22
  %91 = load i1, ptr %3, align 1
  ret i1 %91
}

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, !13, i64 32}
!10 = !{!"hashmultimap1", !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 = !{!10, !11, i64 16}
!15 = !{!10, !11, i64 8}
!16 = !{!11, !11, i64 0}
!17 = !{!10, !6, i64 0}
!18 = !{!19, !6, i64 208}
!19 = !{!"hashmultimap1_entry", !20, i64 0, !20, i64 104, !6, i64 208, !6, i64 216}
!20 = !{!"struct_s", !13, i64 0, !13, i64 4, !6, i64 8, !6, i64 16, !7, i64 24}
!21 = distinct !{!21, !22}
!22 = !{!"llvm.loop.mustprogress"}
!23 = distinct !{!23, !22}


; 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: nounwind uwtable
declare dso_local i64 @hmm1_impl_key_count(ptr noundef, ptr noundef byval(%struct.struct_s) align 8) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
define dso_local noundef zeroext i1 @hmm1_equals(ptr noundef %0, ptr noundef %1) local_unnamed_addr #0 {
  %3 = getelementptr inbounds i8, ptr %0, i64 32
  store i32 0, ptr %3, align 8, !tbaa !5
  %4 = getelementptr inbounds i8, ptr %1, i64 32
  store i32 0, ptr %4, align 8, !tbaa !5
  %5 = getelementptr inbounds i8, ptr %0, i64 16
  %6 = load i64, ptr %5, align 8, !tbaa !13
  %7 = getelementptr inbounds i8, ptr %1, i64 16
  %8 = load i64, ptr %7, align 8, !tbaa !13
  %.not = icmp eq i64 %6, %8
  br i1 %.not, label %9, label %.critedge34

9:                                                ; preds = %2
  %10 = getelementptr inbounds i8, ptr %0, i64 8
  %11 = load i64, ptr %10, align 8, !tbaa !14
  %12 = getelementptr inbounds i8, ptr %1, i64 8
  %13 = load i64, ptr %12, align 8, !tbaa !14
  %14 = icmp ult i64 %11, %13
  %15 = select i1 %14, ptr %0, ptr %1
  %16 = icmp eq ptr %15, %0
  %17 = select i1 %16, ptr %1, ptr %0
  %18 = getelementptr inbounds i8, ptr %15, i64 8
  %19 = load i64, ptr %18, align 8, !tbaa !14
  %.not32.not39.not = icmp eq i64 %19, 0
  br i1 %.not32.not39.not, label %.critedge34, label %.lr.ph41

.lr.ph41:                                         ; preds = %9, %.critedge
  %20 = phi i64 [ %27, %.critedge ], [ %19, %9 ]
  %.02740 = phi i64 [ %28, %.critedge ], [ 0, %9 ]
  %21 = load ptr, ptr %15, align 8, !tbaa !15
  %22 = getelementptr inbounds [2 x ptr], ptr %21, i64 %.02740
  %.036 = load ptr, ptr %22, align 8, !tbaa !16
  %.not3037 = icmp eq ptr %.036, null
  br i1 %.not3037, label %.critedge, label %.lr.ph

23:                                               ; preds = %.lr.ph
  %24 = getelementptr inbounds i8, ptr %.038, i64 208
  %.0 = load ptr, ptr %24, align 8, !tbaa !16
  %.not30 = icmp eq ptr %.0, null
  br i1 %.not30, label %.critedge.loopexit, label %.lr.ph, !llvm.loop !17

.lr.ph:                                           ; preds = %.lr.ph41, %23
  %.038 = phi ptr [ %.0, %23 ], [ %.036, %.lr.ph41 ]
  %25 = tail call i64 @hmm1_impl_key_count(ptr noundef nonnull %15, ptr noundef nonnull byval(%struct.struct_s) align 8 %.038)
  %26 = tail call i64 @hmm1_impl_key_count(ptr noundef %17, ptr noundef nonnull byval(%struct.struct_s) align 8 %.038)
  %.not31 = icmp eq i64 %25, %26
  br i1 %.not31, label %23, label %.critedge34

.critedge.loopexit:                               ; preds = %23
  %.pre = load i64, ptr %18, align 8, !tbaa !14
  br label %.critedge

.critedge:                                        ; preds = %.critedge.loopexit, %.lr.ph41
  %27 = phi i64 [ %.pre, %.critedge.loopexit ], [ %20, %.lr.ph41 ]
  %28 = add nuw i64 %.02740, 1
  %.not32.not = icmp ult i64 %28, %27
  br i1 %.not32.not, label %.lr.ph41, label %.critedge34, !llvm.loop !19

.critedge34:                                      ; preds = %.critedge, %.lr.ph, %9, %2
  %.4 = phi i1 [ false, %2 ], [ true, %9 ], [ false, %.lr.ph ], [ true, %.critedge ]
  ret i1 %.4
}

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" }

!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, !12, i64 32}
!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, !10, i64 16}
!14 = !{!6, !10, i64 8}
!15 = !{!6, !7, i64 0}
!16 = !{!7, !7, i64 0}
!17 = distinct !{!17, !18}
!18 = !{!"llvm.loop.mustprogress"}
!19 = distinct !{!19, !18}


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