; 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.heap1 = type { ptr, i64, i64, i32, i32, ptr, ptr }
%struct.heap1_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: nounwind uwtable
define dso_local zeroext i1 @h1_contains(ptr noundef %0, ptr noundef byval(%struct.struct_s) align 8 %1) #1 {
  %3 = alloca ptr, align 8
  %4 = alloca i8, align 1
  %5 = alloca i64, align 8
  %6 = alloca i32, align 4
  store ptr %0, ptr %3, align 8, !tbaa !5
  %7 = load ptr, ptr %3, align 8, !tbaa !5
  %8 = getelementptr inbounds %struct.heap1, ptr %7, i32 0, i32 4
  store i32 0, ptr %8, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 1, ptr %4) #2
  store i8 0, ptr %4, align 1, !tbaa !13
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #2
  store i64 0, ptr %5, align 8, !tbaa !15
  br label %9

9:                                                ; preds = %31, %2
  %10 = load i64, ptr %5, align 8, !tbaa !15
  %11 = load ptr, ptr %3, align 8, !tbaa !5
  %12 = getelementptr inbounds %struct.heap1, ptr %11, i32 0, i32 2
  %13 = load i64, ptr %12, align 8, !tbaa !16
  %14 = icmp ult i64 %10, %13
  br i1 %14, label %16, label %15

15:                                               ; preds = %9
  store i32 2, ptr %6, align 4
  br label %34

16:                                               ; preds = %9
  %17 = load ptr, ptr %3, align 8, !tbaa !5
  %18 = getelementptr inbounds %struct.heap1, ptr %17, i32 0, i32 5
  %19 = load ptr, ptr %18, align 8, !tbaa !17
  %20 = getelementptr inbounds %struct.heap1_fval, ptr %19, i32 0, i32 0
  %21 = load ptr, ptr %20, align 8, !tbaa !18
  %22 = load ptr, ptr %3, align 8, !tbaa !5
  %23 = getelementptr inbounds %struct.heap1, ptr %22, i32 0, i32 0
  %24 = load ptr, ptr %23, align 8, !tbaa !20
  %25 = load i64, ptr %5, align 8, !tbaa !15
  %26 = getelementptr inbounds %struct.struct_s, ptr %24, i64 %25
  %27 = call i32 %21(ptr noundef byval(%struct.struct_s) align 8 %26, ptr noundef byval(%struct.struct_s) align 8 %1)
  %28 = icmp eq i32 %27, 0
  br i1 %28, label %29, label %30

29:                                               ; preds = %16
  store i8 1, ptr %4, align 1, !tbaa !13
  store i32 2, ptr %6, align 4
  br label %34

30:                                               ; preds = %16
  br label %31

31:                                               ; preds = %30
  %32 = load i64, ptr %5, align 8, !tbaa !15
  %33 = add i64 %32, 1
  store i64 %33, ptr %5, align 8, !tbaa !15
  br label %9, !llvm.loop !21

34:                                               ; preds = %29, %15
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #2
  br label %35

35:                                               ; preds = %34
  %36 = load i8, ptr %4, align 1, !tbaa !13, !range !23, !noundef !24
  %37 = trunc i8 %36 to i1
  store i32 1, ptr %6, align 4
  call void @llvm.lifetime.end.p0(i64 1, ptr %4) #2
  ret i1 %37
}

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, !12, i64 28}
!10 = !{!"heap1", !6, i64 0, !11, i64 8, !11, i64 16, !12, i64 24, !12, i64 28, !6, i64 32, !6, i64 40}
!11 = !{!"long", !7, i64 0}
!12 = !{!"int", !7, i64 0}
!13 = !{!14, !14, i64 0}
!14 = !{!"_Bool", !7, i64 0}
!15 = !{!11, !11, i64 0}
!16 = !{!10, !11, i64 16}
!17 = !{!10, !6, i64 32}
!18 = !{!19, !6, i64 0}
!19 = !{!"heap1_fval", !6, i64 0, !6, i64 8, !6, i64 16, !6, i64 24, !6, i64 32, !6, i64 40}
!20 = !{!10, !6, i64 0}
!21 = distinct !{!21, !22}
!22 = !{!"llvm.loop.mustprogress"}
!23 = !{i8 0, i8 2}
!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.struct_s = type { i32, i32, ptr, ptr, [10 x double] }

; Function Attrs: nounwind uwtable
define dso_local noundef zeroext i1 @h1_contains(ptr nocapture noundef %0, ptr noundef byval(%struct.struct_s) align 8 %1) local_unnamed_addr #0 {
  %3 = getelementptr inbounds i8, ptr %0, i64 28
  store i32 0, ptr %3, align 4, !tbaa !5
  %4 = getelementptr inbounds i8, ptr %0, i64 32
  %5 = getelementptr inbounds i8, ptr %0, i64 16
  %6 = load i64, ptr %5, align 8, !tbaa !12
  %.not = icmp eq i64 %6, 0
  br i1 %.not, label %._crit_edge, label %.lr.ph

7:                                                ; preds = %.lr.ph
  %8 = add nuw i64 %.08, 1
  %9 = load i64, ptr %5, align 8, !tbaa !12
  %10 = icmp ult i64 %8, %9
  br i1 %10, label %.lr.ph, label %._crit_edge, !llvm.loop !13

.lr.ph:                                           ; preds = %2, %7
  %.08 = phi i64 [ %8, %7 ], [ 0, %2 ]
  %11 = load ptr, ptr %4, align 8, !tbaa !15
  %12 = load ptr, ptr %11, align 8, !tbaa !16
  %13 = load ptr, ptr %0, align 8, !tbaa !18
  %14 = getelementptr inbounds %struct.struct_s, ptr %13, i64 %.08
  %15 = tail call i32 %12(ptr noundef byval(%struct.struct_s) align 8 %14, ptr noundef nonnull byval(%struct.struct_s) align 8 %1) #1
  %16 = icmp eq i32 %15, 0
  br i1 %16, label %._crit_edge, label %7

._crit_edge:                                      ; preds = %7, %.lr.ph, %2
  %.lcssa = phi i1 [ false, %2 ], [ %16, %.lr.ph ], [ %16, %7 ]
  ret i1 %.lcssa
}

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


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