; 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.hashbidimap1 = type { ptr, i64, i64, double, i32, ptr, ptr, ptr, ptr, ptr }
%struct.hashbidimap1_fkey = type { ptr, ptr, ptr, ptr, ptr, ptr }
%struct.hashbidimap1_entry = type { %struct.struct_s, %struct.struct_s, [2 x i64], [2 x ptr] }
%struct.struct_s = type { i32, i32, ptr, ptr, [10 x double] }
%struct.hashbidimap1_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: nounwind uwtable
define dso_local void @hbm1_clear(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
  call void @llvm.lifetime.start.p0(i64 8, ptr %3) #2
  store i64 0, ptr %3, align 8, !tbaa !9
  br label %5

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

11:                                               ; preds = %5
  call void @llvm.lifetime.end.p0(i64 8, ptr %3) #2
  br label %78

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

22:                                               ; preds = %12
  %23 = load ptr, ptr %4, align 8, !tbaa !5
  %24 = icmp ne ptr %23, inttoptr (i64 1 to ptr)
  br i1 %24, label %25, label %62

25:                                               ; preds = %22
  %26 = load ptr, ptr %2, align 8, !tbaa !5
  %27 = getelementptr inbounds %struct.hashbidimap1, ptr %26, i32 0, i32 5
  %28 = load ptr, ptr %27, align 8, !tbaa !16
  %29 = getelementptr inbounds %struct.hashbidimap1_fkey, ptr %28, i32 0, i32 3
  %30 = load ptr, ptr %29, align 8, !tbaa !17
  %31 = icmp ne ptr %30, null
  br i1 %31, label %32, label %40

32:                                               ; preds = %25
  %33 = load ptr, ptr %2, align 8, !tbaa !5
  %34 = getelementptr inbounds %struct.hashbidimap1, ptr %33, i32 0, i32 5
  %35 = load ptr, ptr %34, align 8, !tbaa !16
  %36 = getelementptr inbounds %struct.hashbidimap1_fkey, ptr %35, i32 0, i32 3
  %37 = load ptr, ptr %36, align 8, !tbaa !17
  %38 = load ptr, ptr %4, align 8, !tbaa !5
  %39 = getelementptr inbounds %struct.hashbidimap1_entry, ptr %38, i32 0, i32 0
  call void %37(ptr noundef byval(%struct.struct_s) align 8 %39)
  br label %40

40:                                               ; preds = %32, %25
  %41 = load ptr, ptr %2, align 8, !tbaa !5
  %42 = getelementptr inbounds %struct.hashbidimap1, ptr %41, i32 0, i32 6
  %43 = load ptr, ptr %42, align 8, !tbaa !19
  %44 = getelementptr inbounds %struct.hashbidimap1_fval, ptr %43, i32 0, i32 3
  %45 = load ptr, ptr %44, align 8, !tbaa !20
  %46 = icmp ne ptr %45, null
  br i1 %46, label %47, label %55

47:                                               ; preds = %40
  %48 = load ptr, ptr %2, align 8, !tbaa !5
  %49 = getelementptr inbounds %struct.hashbidimap1, ptr %48, i32 0, i32 6
  %50 = load ptr, ptr %49, align 8, !tbaa !19
  %51 = getelementptr inbounds %struct.hashbidimap1_fval, ptr %50, i32 0, i32 3
  %52 = load ptr, ptr %51, align 8, !tbaa !20
  %53 = load ptr, ptr %4, align 8, !tbaa !5
  %54 = getelementptr inbounds %struct.hashbidimap1_entry, ptr %53, i32 0, i32 1
  call void %52(ptr noundef byval(%struct.struct_s) align 8 %54)
  br label %55

55:                                               ; preds = %47, %40
  %56 = load ptr, ptr %2, align 8, !tbaa !5
  %57 = getelementptr inbounds %struct.hashbidimap1, ptr %56, i32 0, i32 7
  %58 = load ptr, ptr %57, align 8, !tbaa !22
  %59 = getelementptr inbounds %struct.cmc_alloc_node, ptr %58, i32 0, i32 3
  %60 = load ptr, ptr %59, align 8, !tbaa !23
  %61 = load ptr, ptr %4, align 8, !tbaa !5
  call void %60(ptr noundef %61)
  br label %62

62:                                               ; preds = %55, %22, %12
  %63 = load ptr, ptr %2, align 8, !tbaa !5
  %64 = getelementptr inbounds %struct.hashbidimap1, ptr %63, i32 0, i32 0
  %65 = load ptr, ptr %64, align 8, !tbaa !15
  %66 = load i64, ptr %3, align 8, !tbaa !9
  %67 = getelementptr inbounds [2 x ptr], ptr %65, i64 %66
  %68 = getelementptr inbounds [2 x ptr], ptr %67, i64 0, i64 0
  store ptr null, ptr %68, align 8, !tbaa !5
  %69 = load ptr, ptr %2, align 8, !tbaa !5
  %70 = getelementptr inbounds %struct.hashbidimap1, ptr %69, i32 0, i32 0
  %71 = load ptr, ptr %70, align 8, !tbaa !15
  %72 = load i64, ptr %3, align 8, !tbaa !9
  %73 = getelementptr inbounds [2 x ptr], ptr %71, i64 %72
  %74 = getelementptr inbounds [2 x ptr], ptr %73, i64 0, i64 1
  store ptr null, ptr %74, align 8, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 8, ptr %4) #2
  br label %75

75:                                               ; preds = %62
  %76 = load i64, ptr %3, align 8, !tbaa !9
  %77 = add i64 %76, 1
  store i64 %77, ptr %3, align 8, !tbaa !9
  br label %5, !llvm.loop !25

78:                                               ; preds = %11
  %79 = load ptr, ptr %2, align 8, !tbaa !5
  %80 = getelementptr inbounds %struct.hashbidimap1, ptr %79, i32 0, i32 2
  store i64 0, ptr %80, align 8, !tbaa !27
  %81 = load ptr, ptr %2, align 8, !tbaa !5
  %82 = getelementptr inbounds %struct.hashbidimap1, ptr %81, i32 0, i32 4
  store i32 0, ptr %82, align 8, !tbaa !28
  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, !10, i64 0}
!10 = !{!"long", !7, i64 0}
!11 = !{!12, !10, i64 8}
!12 = !{!"hashbidimap1", !6, i64 0, !10, i64 8, !10, i64 16, !13, i64 24, !14, i64 32, !6, i64 40, !6, i64 48, !6, i64 56, !6, i64 64, !6, i64 72}
!13 = !{!"double", !7, i64 0}
!14 = !{!"int", !7, i64 0}
!15 = !{!12, !6, i64 0}
!16 = !{!12, !6, i64 40}
!17 = !{!18, !6, i64 24}
!18 = !{!"hashbidimap1_fkey", !6, i64 0, !6, i64 8, !6, i64 16, !6, i64 24, !6, i64 32, !6, i64 40}
!19 = !{!12, !6, i64 48}
!20 = !{!21, !6, i64 24}
!21 = !{!"hashbidimap1_fval", !6, i64 0, !6, i64 8, !6, i64 16, !6, i64 24, !6, i64 32, !6, i64 40}
!22 = !{!12, !6, i64 56}
!23 = !{!24, !6, i64 24}
!24 = !{!"cmc_alloc_node", !6, i64 0, !6, i64 8, !6, i64 16, !6, i64 24}
!25 = distinct !{!25, !26}
!26 = !{!"llvm.loop.mustprogress"}
!27 = !{!12, !10, i64 16}
!28 = !{!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: nounwind uwtable
define dso_local void @hbm1_clear(ptr nocapture noundef %0) local_unnamed_addr #0 {
  %2 = getelementptr inbounds i8, ptr %0, i64 8
  %3 = load i64, ptr %2, align 8, !tbaa !5
  %.not26 = icmp eq i64 %3, 0
  br i1 %.not26, label %._crit_edge, label %.lr.ph

.lr.ph:                                           ; 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 %9

._crit_edge:                                      ; preds = %29, %1
  %7 = getelementptr inbounds i8, ptr %0, i64 16
  store i64 0, ptr %7, align 8, !tbaa !13
  %8 = getelementptr inbounds i8, ptr %0, i64 32
  store i32 0, ptr %8, align 8, !tbaa !14
  ret void

9:                                                ; preds = %.lr.ph, %29
  %10 = phi i64 [ %3, %.lr.ph ], [ %30, %29 ]
  %.025 = phi i64 [ 0, %.lr.ph ], [ %35, %29 ]
  %11 = load ptr, ptr %0, align 8, !tbaa !15
  %12 = getelementptr inbounds [2 x ptr], ptr %11, i64 %.025
  %13 = load ptr, ptr %12, align 8, !tbaa !16
  %switch = icmp ult ptr %13, inttoptr (i64 2 to ptr)
  br i1 %switch, label %29, label %14

14:                                               ; preds = %9
  %15 = load ptr, ptr %4, align 8, !tbaa !17
  %16 = getelementptr inbounds i8, ptr %15, i64 24
  %17 = load ptr, ptr %16, align 8, !tbaa !18
  %.not = icmp eq ptr %17, null
  br i1 %.not, label %19, label %18

18:                                               ; preds = %14
  tail call void %17(ptr noundef nonnull byval(%struct.struct_s) align 8 %13) #1
  br label %19

19:                                               ; preds = %18, %14
  %20 = load ptr, ptr %5, align 8, !tbaa !20
  %21 = getelementptr inbounds i8, ptr %20, i64 24
  %22 = load ptr, ptr %21, align 8, !tbaa !21
  %.not24 = icmp eq ptr %22, null
  br i1 %.not24, label %25, label %23

23:                                               ; preds = %19
  %24 = getelementptr inbounds i8, ptr %13, i64 104
  tail call void %22(ptr noundef nonnull byval(%struct.struct_s) align 8 %24) #1
  br label %25

25:                                               ; preds = %23, %19
  %26 = load ptr, ptr %6, align 8, !tbaa !23
  %27 = getelementptr inbounds i8, ptr %26, i64 24
  %28 = load ptr, ptr %27, align 8, !tbaa !24
  tail call void %28(ptr noundef nonnull %13) #1
  %.pre = load ptr, ptr %0, align 8, !tbaa !15
  %.pre27 = load i64, ptr %2, align 8, !tbaa !5
  br label %29

29:                                               ; preds = %9, %25
  %30 = phi i64 [ %10, %9 ], [ %.pre27, %25 ]
  %31 = phi ptr [ %11, %9 ], [ %.pre, %25 ]
  %32 = getelementptr inbounds [2 x ptr], ptr %31, i64 %.025
  store ptr null, ptr %32, align 8, !tbaa !16
  %33 = load ptr, ptr %0, align 8, !tbaa !15
  %34 = getelementptr inbounds [2 x ptr], ptr %33, i64 %.025, i64 1
  store ptr null, ptr %34, align 8, !tbaa !16
  %35 = add nuw i64 %.025, 1
  %36 = icmp ult i64 %35, %30
  br i1 %36, label %9, label %._crit_edge, !llvm.loop !26
}

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, !10, i64 8}
!6 = !{!"hashbidimap1", !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, i64 64, !7, i64 72}
!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, !12, i64 32}
!15 = !{!6, !7, i64 0}
!16 = !{!7, !7, i64 0}
!17 = !{!6, !7, i64 40}
!18 = !{!19, !7, i64 24}
!19 = !{!"hashbidimap1_fkey", !7, i64 0, !7, i64 8, !7, i64 16, !7, i64 24, !7, i64 32, !7, i64 40}
!20 = !{!6, !7, i64 48}
!21 = !{!22, !7, i64 24}
!22 = !{!"hashbidimap1_fval", !7, i64 0, !7, i64 8, !7, i64 16, !7, i64 24, !7, i64 32, !7, i64 40}
!23 = !{!6, !7, i64 56}
!24 = !{!25, !7, i64 24}
!25 = !{!"cmc_alloc_node", !7, i64 0, !7, i64 8, !7, i64 16, !7, i64 24}
!26 = distinct !{!26, !27}
!27 = !{!"llvm.loop.mustprogress"}


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