; 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: 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
declare dso_local ptr @h1_new_custom(i64 noundef, i32 noundef, ptr noundef, ptr noundef, ptr noundef) #2

; Function Attrs: nounwind uwtable
define dso_local ptr @h1_copy_of(ptr noundef %0) #2 {
  %2 = alloca ptr, align 8
  %3 = alloca ptr, align 8
  %4 = alloca ptr, align 8
  %5 = alloca i32, align 4
  %6 = alloca i64, align 8
  %7 = alloca %struct.struct_s, align 8
  store ptr %0, ptr %3, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %4) #3
  %8 = load ptr, ptr %3, align 8, !tbaa !5
  %9 = getelementptr inbounds %struct.heap1, ptr %8, i32 0, i32 1
  %10 = load i64, ptr %9, align 8, !tbaa !9
  %11 = load ptr, ptr %3, align 8, !tbaa !5
  %12 = getelementptr inbounds %struct.heap1, ptr %11, i32 0, i32 3
  %13 = load i32, ptr %12, align 8, !tbaa !13
  %14 = load ptr, ptr %3, align 8, !tbaa !5
  %15 = getelementptr inbounds %struct.heap1, ptr %14, i32 0, i32 5
  %16 = load ptr, ptr %15, align 8, !tbaa !14
  %17 = load ptr, ptr %3, align 8, !tbaa !5
  %18 = getelementptr inbounds %struct.heap1, ptr %17, i32 0, i32 6
  %19 = load ptr, ptr %18, align 8, !tbaa !15
  %20 = call ptr @h1_new_custom(i64 noundef %10, i32 noundef %13, ptr noundef %16, ptr noundef %19, ptr noundef null)
  store ptr %20, ptr %4, align 8, !tbaa !5
  %21 = load ptr, ptr %4, align 8, !tbaa !5
  %22 = icmp ne ptr %21, null
  br i1 %22, label %26, label %23

23:                                               ; preds = %1
  %24 = load ptr, ptr %3, align 8, !tbaa !5
  %25 = getelementptr inbounds %struct.heap1, ptr %24, i32 0, i32 4
  store i32 7, ptr %25, align 4, !tbaa !16
  store ptr null, ptr %2, align 8
  store i32 1, ptr %5, align 4
  br label %81

26:                                               ; preds = %1
  %27 = load ptr, ptr %3, align 8, !tbaa !5
  %28 = getelementptr inbounds %struct.heap1, ptr %27, i32 0, i32 5
  %29 = load ptr, ptr %28, align 8, !tbaa !14
  %30 = getelementptr inbounds %struct.heap1_fval, ptr %29, i32 0, i32 1
  %31 = load ptr, ptr %30, align 8, !tbaa !17
  %32 = icmp ne ptr %31, null
  br i1 %32, label %33, label %61

33:                                               ; preds = %26
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #3
  store i64 0, ptr %6, align 8, !tbaa !19
  br label %34

34:                                               ; preds = %57, %33
  %35 = load i64, ptr %6, align 8, !tbaa !19
  %36 = load ptr, ptr %3, align 8, !tbaa !5
  %37 = getelementptr inbounds %struct.heap1, ptr %36, i32 0, i32 2
  %38 = load i64, ptr %37, align 8, !tbaa !20
  %39 = icmp ult i64 %35, %38
  br i1 %39, label %41, label %40

40:                                               ; preds = %34
  store i32 2, ptr %5, align 4
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #3
  br label %60

41:                                               ; preds = %34
  %42 = load ptr, ptr %4, align 8, !tbaa !5
  %43 = getelementptr inbounds %struct.heap1, ptr %42, i32 0, i32 0
  %44 = load ptr, ptr %43, align 8, !tbaa !21
  %45 = load i64, ptr %6, align 8, !tbaa !19
  %46 = getelementptr inbounds %struct.struct_s, ptr %44, i64 %45
  call void @llvm.lifetime.start.p0(i64 104, ptr %7) #3
  %47 = load ptr, ptr %3, align 8, !tbaa !5
  %48 = getelementptr inbounds %struct.heap1, ptr %47, i32 0, i32 5
  %49 = load ptr, ptr %48, align 8, !tbaa !14
  %50 = getelementptr inbounds %struct.heap1_fval, ptr %49, i32 0, i32 1
  %51 = load ptr, ptr %50, align 8, !tbaa !17
  %52 = load ptr, ptr %3, align 8, !tbaa !5
  %53 = getelementptr inbounds %struct.heap1, ptr %52, i32 0, i32 0
  %54 = load ptr, ptr %53, align 8, !tbaa !21
  %55 = load i64, ptr %6, align 8, !tbaa !19
  %56 = getelementptr inbounds %struct.struct_s, ptr %54, i64 %55
  call void %51(ptr dead_on_unwind writable sret(%struct.struct_s) align 8 %7, ptr noundef byval(%struct.struct_s) align 8 %56)
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %46, ptr align 8 %7, i64 104, i1 false), !tbaa.struct !22
  call void @llvm.lifetime.end.p0(i64 104, ptr %7) #3
  br label %57

57:                                               ; preds = %41
  %58 = load i64, ptr %6, align 8, !tbaa !19
  %59 = add i64 %58, 1
  store i64 %59, ptr %6, align 8, !tbaa !19
  br label %34, !llvm.loop !25

60:                                               ; preds = %40
  br label %72

61:                                               ; preds = %26
  %62 = load ptr, ptr %4, align 8, !tbaa !5
  %63 = getelementptr inbounds %struct.heap1, ptr %62, i32 0, i32 0
  %64 = load ptr, ptr %63, align 8, !tbaa !21
  %65 = load ptr, ptr %3, align 8, !tbaa !5
  %66 = getelementptr inbounds %struct.heap1, ptr %65, i32 0, i32 0
  %67 = load ptr, ptr %66, align 8, !tbaa !21
  %68 = load ptr, ptr %3, align 8, !tbaa !5
  %69 = getelementptr inbounds %struct.heap1, ptr %68, i32 0, i32 2
  %70 = load i64, ptr %69, align 8, !tbaa !20
  %71 = mul i64 104, %70
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %64, ptr align 8 %67, i64 %71, i1 false)
  br label %72

72:                                               ; preds = %61, %60
  %73 = load ptr, ptr %3, align 8, !tbaa !5
  %74 = getelementptr inbounds %struct.heap1, ptr %73, i32 0, i32 2
  %75 = load i64, ptr %74, align 8, !tbaa !20
  %76 = load ptr, ptr %4, align 8, !tbaa !5
  %77 = getelementptr inbounds %struct.heap1, ptr %76, i32 0, i32 2
  store i64 %75, ptr %77, align 8, !tbaa !20
  %78 = load ptr, ptr %3, align 8, !tbaa !5
  %79 = getelementptr inbounds %struct.heap1, ptr %78, i32 0, i32 4
  store i32 0, ptr %79, align 4, !tbaa !16
  %80 = load ptr, ptr %4, align 8, !tbaa !5
  store ptr %80, ptr %2, align 8
  store i32 1, ptr %5, align 4
  br label %81

81:                                               ; preds = %72, %23
  call void @llvm.lifetime.end.p0(i64 8, ptr %4) #3
  %82 = load ptr, ptr %2, align 8
  ret ptr %82
}

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, !11, i64 8}
!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 = !{!10, !12, i64 24}
!14 = !{!10, !6, i64 32}
!15 = !{!10, !6, i64 40}
!16 = !{!10, !12, i64 28}
!17 = !{!18, !6, i64 8}
!18 = !{!"heap1_fval", !6, i64 0, !6, i64 8, !6, i64 16, !6, i64 24, !6, i64 32, !6, i64 40}
!19 = !{!11, !11, i64 0}
!20 = !{!10, !11, i64 16}
!21 = !{!10, !6, i64 0}
!22 = !{i64 0, i64 4, !23, i64 4, i64 4, !23, i64 8, i64 8, !5, i64 16, i64 8, !5, i64 24, i64 80, !24}
!23 = !{!12, !12, i64 0}
!24 = !{!7, !7, i64 0}
!25 = distinct !{!25, !26}
!26 = !{!"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: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture) #0

; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #0

; Function Attrs: mustprogress 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
declare dso_local ptr @h1_new_custom(i64 noundef, i32 noundef, ptr noundef, ptr noundef, ptr noundef) local_unnamed_addr #2

; Function Attrs: nounwind uwtable
define dso_local ptr @h1_copy_of(ptr nocapture noundef %0) local_unnamed_addr #2 {
  %2 = alloca %struct.struct_s, align 8
  %3 = getelementptr inbounds i8, ptr %0, i64 8
  %4 = load i64, ptr %3, align 8, !tbaa !5
  %5 = getelementptr inbounds i8, ptr %0, i64 24
  %6 = load i32, ptr %5, align 8, !tbaa !12
  %7 = getelementptr inbounds i8, ptr %0, i64 32
  %8 = load ptr, ptr %7, align 8, !tbaa !13
  %9 = getelementptr inbounds i8, ptr %0, i64 40
  %10 = load ptr, ptr %9, align 8, !tbaa !14
  %11 = tail call ptr @h1_new_custom(i64 noundef %4, i32 noundef %6, ptr noundef %8, ptr noundef %10, ptr noundef null)
  %.not = icmp eq ptr %11, null
  br i1 %.not, label %36, label %12

12:                                               ; preds = %1
  %13 = load ptr, ptr %7, align 8, !tbaa !13
  %14 = getelementptr inbounds i8, ptr %13, i64 8
  %15 = load ptr, ptr %14, align 8, !tbaa !15
  %.not24 = icmp eq ptr %15, null
  br i1 %.not24, label %28, label %.preheader

.preheader:                                       ; preds = %12
  %16 = getelementptr inbounds i8, ptr %0, i64 16
  %17 = load i64, ptr %16, align 8, !tbaa !17
  %.not26 = icmp eq i64 %17, 0
  br i1 %.not26, label %.loopexit, label %.lr.ph

.lr.ph:                                           ; preds = %.preheader, %.lr.ph
  %.025 = phi i64 [ %25, %.lr.ph ], [ 0, %.preheader ]
  %18 = load ptr, ptr %11, align 8, !tbaa !18
  %19 = getelementptr inbounds %struct.struct_s, ptr %18, i64 %.025
  call void @llvm.lifetime.start.p0(i64 104, ptr nonnull %2) #3
  %20 = load ptr, ptr %7, align 8, !tbaa !13
  %21 = getelementptr inbounds i8, ptr %20, i64 8
  %22 = load ptr, ptr %21, align 8, !tbaa !15
  %23 = load ptr, ptr %0, align 8, !tbaa !18
  %24 = getelementptr inbounds %struct.struct_s, ptr %23, i64 %.025
  call void %22(ptr dead_on_unwind nonnull writable sret(%struct.struct_s) align 8 %2, ptr noundef byval(%struct.struct_s) align 8 %24) #3
  call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 8 dereferenceable(104) %19, ptr noundef nonnull align 8 dereferenceable(104) %2, i64 104, i1 false), !tbaa.struct !19
  call void @llvm.lifetime.end.p0(i64 104, ptr nonnull %2) #3
  %25 = add nuw i64 %.025, 1
  %26 = load i64, ptr %16, align 8, !tbaa !17
  %27 = icmp ult i64 %25, %26
  br i1 %27, label %.lr.ph, label %.loopexit, !llvm.loop !23

28:                                               ; preds = %12
  %29 = load ptr, ptr %11, align 8, !tbaa !18
  %30 = load ptr, ptr %0, align 8, !tbaa !18
  %31 = getelementptr inbounds i8, ptr %0, i64 16
  %32 = load i64, ptr %31, align 8, !tbaa !17
  %33 = mul i64 %32, 104
  tail call void @llvm.memcpy.p0.p0.i64(ptr align 8 %29, ptr align 8 %30, i64 %33, i1 false)
  %.pre = load i64, ptr %31, align 8, !tbaa !17
  br label %.loopexit

.loopexit:                                        ; preds = %.lr.ph, %.preheader, %28
  %34 = phi i64 [ 0, %.preheader ], [ %.pre, %28 ], [ %26, %.lr.ph ]
  %35 = getelementptr inbounds i8, ptr %11, i64 16
  store i64 %34, ptr %35, align 8, !tbaa !17
  br label %36

36:                                               ; preds = %1, %.loopexit
  %.sink = phi i32 [ 0, %.loopexit ], [ 7, %1 ]
  %37 = getelementptr inbounds i8, ptr %0, i64 28
  store i32 %.sink, ptr %37, align 4, !tbaa !25
  ret ptr %11
}

attributes #0 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { mustprogress 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, !10, i64 8}
!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, !11, i64 24}
!13 = !{!6, !7, i64 32}
!14 = !{!6, !7, i64 40}
!15 = !{!16, !7, i64 8}
!16 = !{!"heap1_fval", !7, i64 0, !7, i64 8, !7, i64 16, !7, i64 24, !7, i64 32, !7, i64 40}
!17 = !{!6, !10, i64 16}
!18 = !{!6, !7, i64 0}
!19 = !{i64 0, i64 4, !20, i64 4, i64 4, !20, i64 8, i64 8, !21, i64 16, i64 8, !21, i64 24, i64 80, !22}
!20 = !{!11, !11, i64 0}
!21 = !{!7, !7, i64 0}
!22 = !{!8, !8, i64 0}
!23 = distinct !{!23, !24}
!24 = !{!"llvm.loop.mustprogress"}
!25 = !{!6, !11, i64 28}


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