; 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.intervalheap1 = type { ptr, i64, i64, i64, i32, ptr, ptr }
%struct.intervalheap1_fval = type { ptr, ptr, 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: nocallback nofree nounwind willreturn memory(argmem: readwrite)
declare void @llvm.memcpy.p0.p0.i64(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i64, i1 immarg) #1

; Function Attrs: nounwind uwtable
define dso_local zeroext i1 @ih1_equals(ptr noundef %0, ptr noundef %1) #2 {
  %3 = alloca i1, align 1
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca i64, align 8
  %7 = alloca i32, align 4
  %8 = alloca %struct.struct_s, align 8
  %9 = alloca %struct.struct_s, align 8
  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.intervalheap1, 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.intervalheap1, 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.intervalheap1, ptr %14, i32 0, i32 3
  %16 = load i64, ptr %15, align 8, !tbaa !13
  %17 = load ptr, ptr %5, align 8, !tbaa !5
  %18 = getelementptr inbounds %struct.intervalheap1, ptr %17, i32 0, i32 3
  %19 = load i64, ptr %18, align 8, !tbaa !13
  %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 %67

22:                                               ; preds = %2
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #3
  store i64 0, ptr %6, align 8, !tbaa !14
  br label %23

23:                                               ; preds = %61, %22
  %24 = load i64, ptr %6, align 8, !tbaa !14
  %25 = load ptr, ptr %4, align 8, !tbaa !5
  %26 = getelementptr inbounds %struct.intervalheap1, ptr %25, i32 0, i32 3
  %27 = load i64, ptr %26, align 8, !tbaa !13
  %28 = icmp ult i64 %24, %27
  br i1 %28, label %30, label %29

29:                                               ; preds = %23
  store i32 2, ptr %7, align 4
  br label %64

30:                                               ; preds = %23
  call void @llvm.lifetime.start.p0(i64 104, ptr %8) #3
  %31 = load ptr, ptr %4, align 8, !tbaa !5
  %32 = getelementptr inbounds %struct.intervalheap1, ptr %31, i32 0, i32 0
  %33 = load ptr, ptr %32, align 8, !tbaa !15
  %34 = load i64, ptr %6, align 8, !tbaa !14
  %35 = udiv i64 %34, 2
  %36 = getelementptr inbounds [2 x %struct.struct_s], ptr %33, i64 %35
  %37 = load i64, ptr %6, align 8, !tbaa !14
  %38 = urem i64 %37, 2
  %39 = getelementptr inbounds [2 x %struct.struct_s], ptr %36, i64 0, i64 %38
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %8, ptr align 8 %39, i64 104, i1 false), !tbaa.struct !16
  call void @llvm.lifetime.start.p0(i64 104, ptr %9) #3
  %40 = load ptr, ptr %5, align 8, !tbaa !5
  %41 = getelementptr inbounds %struct.intervalheap1, ptr %40, i32 0, i32 0
  %42 = load ptr, ptr %41, align 8, !tbaa !15
  %43 = load i64, ptr %6, align 8, !tbaa !14
  %44 = udiv i64 %43, 2
  %45 = getelementptr inbounds [2 x %struct.struct_s], ptr %42, i64 %44
  %46 = load i64, ptr %6, align 8, !tbaa !14
  %47 = urem i64 %46, 2
  %48 = getelementptr inbounds [2 x %struct.struct_s], ptr %45, i64 0, i64 %47
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %9, ptr align 8 %48, i64 104, i1 false), !tbaa.struct !16
  %49 = load ptr, ptr %4, align 8, !tbaa !5
  %50 = getelementptr inbounds %struct.intervalheap1, ptr %49, i32 0, i32 5
  %51 = load ptr, ptr %50, align 8, !tbaa !19
  %52 = getelementptr inbounds %struct.intervalheap1_fval, ptr %51, i32 0, i32 0
  %53 = load ptr, ptr %52, align 8, !tbaa !20
  %54 = call i32 %53(ptr noundef byval(%struct.struct_s) align 8 %8, ptr noundef byval(%struct.struct_s) align 8 %9)
  %55 = icmp ne i32 %54, 0
  br i1 %55, label %56, label %57

56:                                               ; preds = %30
  store i1 false, ptr %3, align 1
  store i32 1, ptr %7, align 4
  br label %58

57:                                               ; preds = %30
  store i32 0, ptr %7, align 4
  br label %58

58:                                               ; preds = %57, %56
  call void @llvm.lifetime.end.p0(i64 104, ptr %9) #3
  call void @llvm.lifetime.end.p0(i64 104, ptr %8) #3
  %59 = load i32, ptr %7, align 4
  switch i32 %59, label %64 [
    i32 0, label %60
  ]

60:                                               ; preds = %58
  br label %61

61:                                               ; preds = %60
  %62 = load i64, ptr %6, align 8, !tbaa !14
  %63 = add i64 %62, 1
  store i64 %63, ptr %6, align 8, !tbaa !14
  br label %23, !llvm.loop !22

64:                                               ; preds = %58, %29
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #3
  %65 = load i32, ptr %7, align 4
  switch i32 %65, label %69 [
    i32 2, label %66
    i32 1, label %67
  ]

66:                                               ; preds = %64
  store i1 true, ptr %3, align 1
  br label %67

67:                                               ; preds = %66, %64, %21
  %68 = load i1, ptr %3, align 1
  ret i1 %68

69:                                               ; preds = %64
  unreachable
}

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
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, !12, i64 32}
!10 = !{!"intervalheap1", !6, i64 0, !11, i64 8, !11, i64 16, !11, i64 24, !12, i64 32, !6, i64 40, !6, i64 48}
!11 = !{!"long", !7, i64 0}
!12 = !{!"int", !7, i64 0}
!13 = !{!10, !11, i64 24}
!14 = !{!11, !11, i64 0}
!15 = !{!10, !6, i64 0}
!16 = !{i64 0, i64 4, !17, i64 4, i64 4, !17, i64 8, i64 8, !5, i64 16, i64 8, !5, i64 24, i64 80, !18}
!17 = !{!12, !12, i64 0}
!18 = !{!7, !7, i64 0}
!19 = !{!10, !6, i64 40}
!20 = !{!21, !6, i64 0}
!21 = !{!"intervalheap1_fval", !6, i64 0, !6, i64 8, !6, i64 16, !6, i64 24, !6, i64 32, !6, i64 40}
!22 = distinct !{!22, !23}
!23 = !{!"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] }

; Function Attrs: nounwind uwtable
define dso_local noundef zeroext i1 @ih1_equals(ptr nocapture noundef %0, ptr nocapture 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 24
  %6 = load i64, ptr %5, align 8, !tbaa !12
  %7 = getelementptr inbounds i8, ptr %1, i64 24
  %8 = load i64, ptr %7, align 8, !tbaa !12
  %.not = icmp eq i64 %6, %8
  br i1 %.not, label %.preheader, label %.loopexit

.preheader:                                       ; preds = %2
  %9 = icmp eq i64 %6, 0
  br i1 %9, label %.loopexit, label %.lr.ph

.lr.ph:                                           ; preds = %.preheader
  %10 = getelementptr inbounds i8, ptr %0, i64 40
  br label %14

11:                                               ; preds = %14
  %12 = add nuw i64 %.01620, 1
  %13 = load i64, ptr %5, align 8, !tbaa !12
  %.not23 = icmp ult i64 %12, %13
  br i1 %.not23, label %14, label %.loopexit, !llvm.loop !13

14:                                               ; preds = %.lr.ph, %11
  %.01620 = phi i64 [ 0, %.lr.ph ], [ %12, %11 ]
  %15 = load ptr, ptr %0, align 8, !tbaa !15
  %16 = lshr i64 %.01620, 1
  %17 = and i64 %.01620, 1
  %18 = getelementptr inbounds [2 x %struct.struct_s], ptr %15, i64 %16, i64 %17
  %19 = load ptr, ptr %1, align 8, !tbaa !15
  %20 = getelementptr inbounds [2 x %struct.struct_s], ptr %19, i64 %16, i64 %17
  %21 = load ptr, ptr %10, align 8, !tbaa !16
  %22 = load ptr, ptr %21, align 8, !tbaa !17
  %23 = tail call i32 %22(ptr noundef nonnull byval(%struct.struct_s) align 8 %18, ptr noundef nonnull byval(%struct.struct_s) align 8 %20) #1
  %.not19 = icmp eq i32 %23, 0
  br i1 %.not19, label %11, label %.loopexit

.loopexit:                                        ; preds = %11, %14, %.preheader, %2
  %.3 = phi i1 [ false, %2 ], [ true, %.preheader ], [ %.not19, %14 ], [ %.not19, %11 ]
  ret i1 %.3
}

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, !11, i64 32}
!6 = !{!"intervalheap1", !7, i64 0, !10, i64 8, !10, i64 16, !10, i64 24, !11, 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 = !{!"int", !8, i64 0}
!12 = !{!6, !10, i64 24}
!13 = distinct !{!13, !14}
!14 = !{!"llvm.loop.mustprogress"}
!15 = !{!6, !7, i64 0}
!16 = !{!6, !7, i64 40}
!17 = !{!18, !7, i64 0}
!18 = !{!"intervalheap1_fval", !7, i64 0, !7, i64 8, !7, i64 16, !7, i64 24, !7, i64 32, !7, i64 40}


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