; 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.hashset1 = type { ptr, i64, i64, double, i32, ptr, ptr }
%struct.hashset1_entry = type { %struct.struct_s, 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: nounwind uwtable
declare hidden ptr @hs1_impl_get_entry(ptr noundef, ptr noundef byval(%struct.struct_s) align 8) #1

; Function Attrs: nounwind uwtable
define dso_local zeroext i1 @hs1_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
  store ptr %0, ptr %4, align 8, !tbaa !5
  store ptr %1, ptr %5, align 8, !tbaa !5
  %10 = load ptr, ptr %4, align 8, !tbaa !5
  %11 = getelementptr inbounds %struct.hashset1, ptr %10, i32 0, i32 4
  store i32 0, ptr %11, align 8, !tbaa !9
  %12 = load ptr, ptr %5, align 8, !tbaa !5
  %13 = getelementptr inbounds %struct.hashset1, ptr %12, i32 0, i32 4
  store i32 0, ptr %13, align 8, !tbaa !9
  %14 = load ptr, ptr %4, align 8, !tbaa !5
  %15 = getelementptr inbounds %struct.hashset1, ptr %14, i32 0, i32 2
  %16 = load i64, ptr %15, align 8, !tbaa !14
  %17 = load ptr, ptr %5, align 8, !tbaa !5
  %18 = getelementptr inbounds %struct.hashset1, ptr %17, i32 0, i32 2
  %19 = load i64, ptr %18, align 8, !tbaa !14
  %20 = icmp ne i64 %16, %19
  br i1 %20, label %21, label %22

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

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

30:                                               ; preds = %22
  %31 = load ptr, ptr %4, align 8, !tbaa !5
  br label %34

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

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

39:                                               ; preds = %34
  %40 = load ptr, ptr %5, align 8, !tbaa !5
  br label %43

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

43:                                               ; preds = %41, %39
  %44 = phi ptr [ %40, %39 ], [ %42, %41 ]
  store ptr %44, 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 %45

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

51:                                               ; preds = %45
  store i32 2, ptr %9, align 4
  br label %77

52:                                               ; preds = %45
  %53 = load ptr, ptr %6, align 8, !tbaa !5
  %54 = getelementptr inbounds %struct.hashset1, ptr %53, i32 0, i32 0
  %55 = load ptr, ptr %54, align 8, !tbaa !17
  %56 = load i64, ptr %8, align 8, !tbaa !16
  %57 = getelementptr inbounds %struct.hashset1_entry, ptr %55, i64 %56
  %58 = getelementptr inbounds %struct.hashset1_entry, ptr %57, i32 0, i32 2
  %59 = load i32, ptr %58, align 8, !tbaa !18
  %60 = icmp eq i32 %59, 1
  br i1 %60, label %61, label %73

61:                                               ; preds = %52
  %62 = load ptr, ptr %7, align 8, !tbaa !5
  %63 = load ptr, ptr %6, align 8, !tbaa !5
  %64 = getelementptr inbounds %struct.hashset1, ptr %63, i32 0, i32 0
  %65 = load ptr, ptr %64, align 8, !tbaa !17
  %66 = load i64, ptr %8, align 8, !tbaa !16
  %67 = getelementptr inbounds %struct.hashset1_entry, ptr %65, i64 %66
  %68 = getelementptr inbounds %struct.hashset1_entry, ptr %67, i32 0, i32 0
  %69 = call ptr @hs1_impl_get_entry(ptr noundef %62, ptr noundef byval(%struct.struct_s) align 8 %68)
  %70 = icmp ne ptr %69, null
  br i1 %70, label %72, label %71

71:                                               ; preds = %61
  store i1 false, ptr %3, align 1
  store i32 1, ptr %9, align 4
  br label %77

72:                                               ; preds = %61
  br label %73

73:                                               ; preds = %72, %52
  br label %74

74:                                               ; preds = %73
  %75 = load i64, ptr %8, align 8, !tbaa !16
  %76 = add i64 %75, 1
  store i64 %76, ptr %8, align 8, !tbaa !16
  br label %45, !llvm.loop !21

77:                                               ; preds = %71, %51
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #2
  %78 = load i32, ptr %9, align 4
  switch i32 %78, label %80 [
    i32 2, label %79
  ]

79:                                               ; preds = %77
  store i1 true, ptr %3, align 1
  store i32 1, ptr %9, align 4
  br label %80

80:                                               ; preds = %79, %77
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #2
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #2
  br label %81

81:                                               ; preds = %80, %21
  %82 = load i1, ptr %3, align 1
  ret i1 %82
}

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 = !{!"hashset1", !6, i64 0, !11, i64 8, !11, i64 16, !12, i64 24, !13, i64 32, !6, i64 40, !6, i64 48}
!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, !13, i64 112}
!19 = !{!"hashset1_entry", !20, i64 0, !11, i64 104, !13, i64 112}
!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"}


; 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] }
%struct.hashset1_entry = type { %struct.struct_s, i64, i32 }

; Function Attrs: nounwind uwtable
declare hidden ptr @hs1_impl_get_entry(ptr noundef, ptr noundef byval(%struct.struct_s) align 8) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
define dso_local noundef zeroext i1 @hs1_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 %.critedge

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
  %.not24.not25.not = icmp eq i64 %19, 0
  br i1 %.not24.not25.not, label %.critedge, label %.lr.ph

.lr.ph:                                           ; preds = %9, %28
  %20 = phi i64 [ %29, %28 ], [ %19, %9 ]
  %.02126 = phi i64 [ %30, %28 ], [ 0, %9 ]
  %21 = load ptr, ptr %15, align 8, !tbaa !15
  %22 = getelementptr inbounds %struct.hashset1_entry, ptr %21, i64 %.02126
  %23 = getelementptr inbounds i8, ptr %22, i64 112
  %24 = load i32, ptr %23, align 8, !tbaa !16
  %25 = icmp eq i32 %24, 1
  br i1 %25, label %26, label %28

26:                                               ; preds = %.lr.ph
  %27 = tail call ptr @hs1_impl_get_entry(ptr noundef %17, ptr noundef nonnull byval(%struct.struct_s) align 8 %22)
  %.not23 = icmp eq ptr %27, null
  br i1 %.not23, label %.critedge, label %._crit_edge

._crit_edge:                                      ; preds = %26
  %.pre = load i64, ptr %18, align 8, !tbaa !14
  br label %28

28:                                               ; preds = %._crit_edge, %.lr.ph
  %29 = phi i64 [ %.pre, %._crit_edge ], [ %20, %.lr.ph ]
  %30 = add nuw i64 %.02126, 1
  %.not24.not = icmp ult i64 %30, %29
  br i1 %.not24.not, label %.lr.ph, label %.critedge, !llvm.loop !19

.critedge:                                        ; preds = %26, %28, %9, %2
  %.2 = phi i1 [ false, %2 ], [ true, %9 ], [ false, %26 ], [ true, %28 ]
  ret i1 %.2
}

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 = !{!"hashset1", !7, i64 0, !10, i64 8, !10, i64 16, !11, i64 24, !12, i64 32, !7, i64 40, !7, i64 48}
!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 = !{!17, !12, i64 112}
!17 = !{!"hashset1_entry", !18, i64 0, !10, i64 104, !12, i64 112}
!18 = !{!"struct_s", !12, i64 0, !12, i64 4, !7, i64 8, !7, i64 16, !8, i64 24}
!19 = distinct !{!19, !20}
!20 = !{!"llvm.loop.mustprogress"}


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