; 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.linkedlist1 = type { ptr, ptr, i64, i32, ptr, ptr }
%struct.linkedlist1_fval = type { ptr, ptr, ptr, ptr, ptr, ptr }
%struct.linkedlist1_node = type { %struct.struct_s, 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
declare dso_local ptr @ll1_new_custom(ptr noundef, ptr noundef, ptr noundef) #1

; Function Attrs: nounwind uwtable
declare dso_local ptr @ll1_impl_new_node(ptr noundef, ptr noundef byval(%struct.struct_s) align 8) #1

; Function Attrs: nounwind uwtable
define dso_local ptr @ll1_copy_of(ptr noundef %0) #1 {
  %2 = alloca ptr, align 8
  %3 = alloca ptr, align 8
  %4 = alloca ptr, align 8
  %5 = alloca i32, align 4
  %6 = alloca ptr, align 8
  %7 = alloca ptr, align 8
  %8 = 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) #2
  %9 = load ptr, ptr %3, align 8, !tbaa !5
  %10 = getelementptr inbounds %struct.linkedlist1, ptr %9, i32 0, i32 4
  %11 = load ptr, ptr %10, align 8, !tbaa !9
  %12 = load ptr, ptr %3, align 8, !tbaa !5
  %13 = getelementptr inbounds %struct.linkedlist1, ptr %12, i32 0, i32 5
  %14 = load ptr, ptr %13, align 8, !tbaa !13
  %15 = call ptr @ll1_new_custom(ptr noundef %11, ptr noundef %14, ptr noundef null)
  store ptr %15, ptr %4, align 8, !tbaa !5
  %16 = load ptr, ptr %4, align 8, !tbaa !5
  %17 = icmp ne ptr %16, null
  br i1 %17, label %19, label %18

18:                                               ; preds = %1
  store ptr null, ptr %2, align 8
  store i32 1, ptr %5, align 4
  br label %87

19:                                               ; preds = %1
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #2
  %20 = load ptr, ptr %3, align 8, !tbaa !5
  %21 = getelementptr inbounds %struct.linkedlist1, ptr %20, i32 0, i32 0
  %22 = load ptr, ptr %21, align 8, !tbaa !14
  store ptr %22, ptr %6, align 8, !tbaa !5
  br label %23

23:                                               ; preds = %74, %19
  %24 = load ptr, ptr %6, align 8, !tbaa !5
  %25 = icmp ne ptr %24, null
  br i1 %25, label %26, label %78

26:                                               ; preds = %23
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #2
  %27 = load ptr, ptr %3, align 8, !tbaa !5
  %28 = getelementptr inbounds %struct.linkedlist1, ptr %27, i32 0, i32 4
  %29 = load ptr, ptr %28, align 8, !tbaa !9
  %30 = getelementptr inbounds %struct.linkedlist1_fval, ptr %29, i32 0, i32 1
  %31 = load ptr, ptr %30, align 8, !tbaa !15
  %32 = icmp ne ptr %31, null
  br i1 %32, label %33, label %43

33:                                               ; preds = %26
  %34 = load ptr, ptr %3, align 8, !tbaa !5
  %35 = load ptr, ptr %3, align 8, !tbaa !5
  %36 = getelementptr inbounds %struct.linkedlist1, ptr %35, i32 0, i32 4
  %37 = load ptr, ptr %36, align 8, !tbaa !9
  %38 = getelementptr inbounds %struct.linkedlist1_fval, ptr %37, i32 0, i32 1
  %39 = load ptr, ptr %38, align 8, !tbaa !15
  %40 = load ptr, ptr %6, align 8, !tbaa !5
  %41 = getelementptr inbounds %struct.linkedlist1_node, ptr %40, i32 0, i32 0
  call void %39(ptr dead_on_unwind writable sret(%struct.struct_s) align 8 %8, ptr noundef byval(%struct.struct_s) align 8 %41)
  %42 = call ptr @ll1_impl_new_node(ptr noundef %34, ptr noundef byval(%struct.struct_s) align 8 %8)
  store ptr %42, ptr %7, align 8, !tbaa !5
  br label %48

43:                                               ; preds = %26
  %44 = load ptr, ptr %3, align 8, !tbaa !5
  %45 = load ptr, ptr %6, align 8, !tbaa !5
  %46 = getelementptr inbounds %struct.linkedlist1_node, ptr %45, i32 0, i32 0
  %47 = call ptr @ll1_impl_new_node(ptr noundef %44, ptr noundef byval(%struct.struct_s) align 8 %46)
  store ptr %47, ptr %7, align 8, !tbaa !5
  br label %48

48:                                               ; preds = %43, %33
  %49 = load ptr, ptr %4, align 8, !tbaa !5
  %50 = getelementptr inbounds %struct.linkedlist1, ptr %49, i32 0, i32 0
  %51 = load ptr, ptr %50, align 8, !tbaa !14
  %52 = icmp ne ptr %51, null
  br i1 %52, label %60, label %53

53:                                               ; preds = %48
  %54 = load ptr, ptr %7, align 8, !tbaa !5
  %55 = load ptr, ptr %4, align 8, !tbaa !5
  %56 = getelementptr inbounds %struct.linkedlist1, ptr %55, i32 0, i32 0
  store ptr %54, ptr %56, align 8, !tbaa !14
  %57 = load ptr, ptr %7, align 8, !tbaa !5
  %58 = load ptr, ptr %4, align 8, !tbaa !5
  %59 = getelementptr inbounds %struct.linkedlist1, ptr %58, i32 0, i32 1
  store ptr %57, ptr %59, align 8, !tbaa !17
  br label %74

60:                                               ; preds = %48
  %61 = load ptr, ptr %4, align 8, !tbaa !5
  %62 = getelementptr inbounds %struct.linkedlist1, ptr %61, i32 0, i32 1
  %63 = load ptr, ptr %62, align 8, !tbaa !17
  %64 = load ptr, ptr %7, align 8, !tbaa !5
  %65 = getelementptr inbounds %struct.linkedlist1_node, ptr %64, i32 0, i32 2
  store ptr %63, ptr %65, align 8, !tbaa !18
  %66 = load ptr, ptr %7, align 8, !tbaa !5
  %67 = load ptr, ptr %4, align 8, !tbaa !5
  %68 = getelementptr inbounds %struct.linkedlist1, ptr %67, i32 0, i32 1
  %69 = load ptr, ptr %68, align 8, !tbaa !17
  %70 = getelementptr inbounds %struct.linkedlist1_node, ptr %69, i32 0, i32 1
  store ptr %66, ptr %70, align 8, !tbaa !21
  %71 = load ptr, ptr %7, align 8, !tbaa !5
  %72 = load ptr, ptr %4, align 8, !tbaa !5
  %73 = getelementptr inbounds %struct.linkedlist1, ptr %72, i32 0, i32 1
  store ptr %71, ptr %73, align 8, !tbaa !17
  br label %74

74:                                               ; preds = %60, %53
  %75 = load ptr, ptr %6, align 8, !tbaa !5
  %76 = getelementptr inbounds %struct.linkedlist1_node, ptr %75, i32 0, i32 1
  %77 = load ptr, ptr %76, align 8, !tbaa !21
  store ptr %77, ptr %6, align 8, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #2
  br label %23, !llvm.loop !22

78:                                               ; preds = %23
  %79 = load ptr, ptr %3, align 8, !tbaa !5
  %80 = getelementptr inbounds %struct.linkedlist1, ptr %79, i32 0, i32 2
  %81 = load i64, ptr %80, align 8, !tbaa !24
  %82 = load ptr, ptr %4, align 8, !tbaa !5
  %83 = getelementptr inbounds %struct.linkedlist1, ptr %82, i32 0, i32 2
  store i64 %81, ptr %83, align 8, !tbaa !24
  %84 = load ptr, ptr %3, align 8, !tbaa !5
  %85 = getelementptr inbounds %struct.linkedlist1, ptr %84, i32 0, i32 3
  store i32 0, ptr %85, align 8, !tbaa !25
  %86 = load ptr, ptr %4, align 8, !tbaa !5
  store ptr %86, ptr %2, align 8
  store i32 1, ptr %5, align 4
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #2
  br label %87

87:                                               ; preds = %78, %18
  call void @llvm.lifetime.end.p0(i64 8, ptr %4) #2
  %88 = load ptr, ptr %2, align 8
  ret ptr %88
}

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, !6, i64 32}
!10 = !{!"linkedlist1", !6, i64 0, !6, i64 8, !11, i64 16, !12, i64 24, !6, i64 32, !6, i64 40}
!11 = !{!"long", !7, i64 0}
!12 = !{!"int", !7, i64 0}
!13 = !{!10, !6, i64 40}
!14 = !{!10, !6, i64 0}
!15 = !{!16, !6, i64 8}
!16 = !{!"linkedlist1_fval", !6, i64 0, !6, i64 8, !6, i64 16, !6, i64 24, !6, i64 32, !6, i64 40}
!17 = !{!10, !6, i64 8}
!18 = !{!19, !6, i64 112}
!19 = !{!"linkedlist1_node", !20, i64 0, !6, i64 104, !6, i64 112}
!20 = !{!"struct_s", !12, i64 0, !12, i64 4, !6, i64 8, !6, i64 16, !7, i64 24}
!21 = !{!19, !6, i64 104}
!22 = distinct !{!22, !23}
!23 = !{!"llvm.loop.mustprogress"}
!24 = !{!10, !11, i64 16}
!25 = !{!10, !12, i64 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
declare dso_local ptr @ll1_new_custom(ptr noundef, ptr noundef, ptr noundef) local_unnamed_addr #0

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

; Function Attrs: nounwind uwtable
define dso_local ptr @ll1_copy_of(ptr noundef %0) local_unnamed_addr #0 {
  %2 = alloca %struct.struct_s, align 8
  %3 = getelementptr inbounds i8, ptr %0, i64 32
  %4 = load ptr, ptr %3, align 8, !tbaa !5
  %5 = getelementptr inbounds i8, ptr %0, i64 40
  %6 = load ptr, ptr %5, align 8, !tbaa !12
  %7 = tail call ptr @ll1_new_custom(ptr noundef %4, ptr noundef %6, ptr noundef null)
  %.not = icmp eq ptr %7, null
  br i1 %.not, label %27, label %.preheader

.preheader:                                       ; preds = %1
  %.02835 = load ptr, ptr %0, align 8, !tbaa !13
  %.not3236 = icmp eq ptr %.02835, null
  br i1 %.not3236, label %._crit_edge, label %.lr.ph

.lr.ph:                                           ; preds = %.preheader
  %8 = getelementptr inbounds i8, ptr %7, i64 8
  br label %9

9:                                                ; preds = %.lr.ph, %21
  %.02837 = phi ptr [ %.02835, %.lr.ph ], [ %.028, %21 ]
  %10 = load ptr, ptr %3, align 8, !tbaa !5
  %11 = getelementptr inbounds i8, ptr %10, i64 8
  %12 = load ptr, ptr %11, align 8, !tbaa !14
  %.not33 = icmp eq ptr %12, null
  br i1 %.not33, label %14, label %13

13:                                               ; preds = %9
  call void %12(ptr dead_on_unwind nonnull writable sret(%struct.struct_s) align 8 %2, ptr noundef nonnull byval(%struct.struct_s) align 8 %.02837) #1
  br label %14

14:                                               ; preds = %9, %13
  %.02837.sink = phi ptr [ %2, %13 ], [ %.02837, %9 ]
  %15 = call ptr @ll1_impl_new_node(ptr noundef nonnull %0, ptr noundef nonnull byval(%struct.struct_s) align 8 %.02837.sink)
  %16 = load ptr, ptr %7, align 8, !tbaa !16
  %.not34 = icmp eq ptr %16, null
  br i1 %.not34, label %21, label %17

17:                                               ; preds = %14
  %18 = load ptr, ptr %8, align 8, !tbaa !17
  %19 = getelementptr inbounds i8, ptr %15, i64 112
  store ptr %18, ptr %19, align 8, !tbaa !18
  %20 = getelementptr inbounds i8, ptr %18, i64 104
  br label %21

21:                                               ; preds = %14, %17
  %.sink = phi ptr [ %20, %17 ], [ %7, %14 ]
  store ptr %15, ptr %.sink, align 8, !tbaa !13
  store ptr %15, ptr %8, align 8, !tbaa !17
  %22 = getelementptr inbounds i8, ptr %.02837, i64 104
  %.028 = load ptr, ptr %22, align 8, !tbaa !13
  %.not32 = icmp eq ptr %.028, null
  br i1 %.not32, label %._crit_edge, label %9, !llvm.loop !21

._crit_edge:                                      ; preds = %21, %.preheader
  %23 = getelementptr inbounds i8, ptr %0, i64 16
  %24 = load i64, ptr %23, align 8, !tbaa !23
  %25 = getelementptr inbounds i8, ptr %7, i64 16
  store i64 %24, ptr %25, align 8, !tbaa !23
  %26 = getelementptr inbounds i8, ptr %0, i64 24
  store i32 0, ptr %26, align 8, !tbaa !24
  br label %27

27:                                               ; preds = %1, %._crit_edge
  ret ptr %7
}

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, !7, i64 32}
!6 = !{!"linkedlist1", !7, i64 0, !7, i64 8, !10, i64 16, !11, i64 24, !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, !7, i64 40}
!13 = !{!7, !7, i64 0}
!14 = !{!15, !7, i64 8}
!15 = !{!"linkedlist1_fval", !7, i64 0, !7, i64 8, !7, i64 16, !7, i64 24, !7, i64 32, !7, i64 40}
!16 = !{!6, !7, i64 0}
!17 = !{!6, !7, i64 8}
!18 = !{!19, !7, i64 112}
!19 = !{!"linkedlist1_node", !20, i64 0, !7, i64 104, !7, i64 112}
!20 = !{!"struct_s", !11, i64 0, !11, i64 4, !7, i64 8, !7, i64 16, !8, i64 24}
!21 = distinct !{!21, !22}
!22 = !{!"llvm.loop.mustprogress"}
!23 = !{!6, !10, i64 16}
!24 = !{!6, !11, i64 24}


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