; 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.linkedlist0 = type { ptr, ptr, i64, i32, ptr, ptr }
%struct.linkedlist0_fval = type { ptr, ptr, ptr, ptr, ptr, ptr }
%struct.linkedlist0_node = type { 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
declare dso_local ptr @ll0_new_custom(ptr noundef, ptr noundef, ptr noundef) #1

; Function Attrs: nounwind uwtable
declare dso_local ptr @ll0_impl_new_node(ptr noundef, ptr noundef) #1

; Function Attrs: nounwind uwtable
define dso_local ptr @ll0_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
  store ptr %0, ptr %3, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %4) #2
  %8 = load ptr, ptr %3, align 8, !tbaa !5
  %9 = getelementptr inbounds %struct.linkedlist0, ptr %8, i32 0, i32 4
  %10 = load ptr, ptr %9, align 8, !tbaa !9
  %11 = load ptr, ptr %3, align 8, !tbaa !5
  %12 = getelementptr inbounds %struct.linkedlist0, ptr %11, i32 0, i32 5
  %13 = load ptr, ptr %12, align 8, !tbaa !13
  %14 = call ptr @ll0_new_custom(ptr noundef %10, ptr noundef %13, ptr noundef null)
  store ptr %14, ptr %4, align 8, !tbaa !5
  %15 = load ptr, ptr %4, align 8, !tbaa !5
  %16 = icmp ne ptr %15, null
  br i1 %16, label %18, label %17

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

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

22:                                               ; preds = %76, %18
  %23 = load ptr, ptr %6, align 8, !tbaa !5
  %24 = icmp ne ptr %23, null
  br i1 %24, label %25, label %80

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

32:                                               ; preds = %25
  %33 = load ptr, ptr %3, align 8, !tbaa !5
  %34 = load ptr, ptr %3, align 8, !tbaa !5
  %35 = getelementptr inbounds %struct.linkedlist0, ptr %34, i32 0, i32 4
  %36 = load ptr, ptr %35, align 8, !tbaa !9
  %37 = getelementptr inbounds %struct.linkedlist0_fval, ptr %36, i32 0, i32 1
  %38 = load ptr, ptr %37, align 8, !tbaa !15
  %39 = load ptr, ptr %6, align 8, !tbaa !5
  %40 = getelementptr inbounds %struct.linkedlist0_node, ptr %39, i32 0, i32 0
  %41 = load ptr, ptr %40, align 8, !tbaa !17
  %42 = call ptr %38(ptr noundef %41)
  %43 = call ptr @ll0_impl_new_node(ptr noundef %33, ptr noundef %42)
  store ptr %43, ptr %7, align 8, !tbaa !5
  br label %50

44:                                               ; preds = %25
  %45 = load ptr, ptr %3, align 8, !tbaa !5
  %46 = load ptr, ptr %6, align 8, !tbaa !5
  %47 = getelementptr inbounds %struct.linkedlist0_node, ptr %46, i32 0, i32 0
  %48 = load ptr, ptr %47, align 8, !tbaa !17
  %49 = call ptr @ll0_impl_new_node(ptr noundef %45, ptr noundef %48)
  store ptr %49, ptr %7, align 8, !tbaa !5
  br label %50

50:                                               ; preds = %44, %32
  %51 = load ptr, ptr %4, align 8, !tbaa !5
  %52 = getelementptr inbounds %struct.linkedlist0, ptr %51, i32 0, i32 0
  %53 = load ptr, ptr %52, align 8, !tbaa !14
  %54 = icmp ne ptr %53, null
  br i1 %54, label %62, label %55

55:                                               ; preds = %50
  %56 = load ptr, ptr %7, align 8, !tbaa !5
  %57 = load ptr, ptr %4, align 8, !tbaa !5
  %58 = getelementptr inbounds %struct.linkedlist0, ptr %57, i32 0, i32 0
  store ptr %56, ptr %58, align 8, !tbaa !14
  %59 = load ptr, ptr %7, align 8, !tbaa !5
  %60 = load ptr, ptr %4, align 8, !tbaa !5
  %61 = getelementptr inbounds %struct.linkedlist0, ptr %60, i32 0, i32 1
  store ptr %59, ptr %61, align 8, !tbaa !19
  br label %76

62:                                               ; preds = %50
  %63 = load ptr, ptr %4, align 8, !tbaa !5
  %64 = getelementptr inbounds %struct.linkedlist0, ptr %63, i32 0, i32 1
  %65 = load ptr, ptr %64, align 8, !tbaa !19
  %66 = load ptr, ptr %7, align 8, !tbaa !5
  %67 = getelementptr inbounds %struct.linkedlist0_node, ptr %66, i32 0, i32 2
  store ptr %65, ptr %67, align 8, !tbaa !20
  %68 = load ptr, ptr %7, align 8, !tbaa !5
  %69 = load ptr, ptr %4, align 8, !tbaa !5
  %70 = getelementptr inbounds %struct.linkedlist0, ptr %69, i32 0, i32 1
  %71 = load ptr, ptr %70, align 8, !tbaa !19
  %72 = getelementptr inbounds %struct.linkedlist0_node, ptr %71, i32 0, i32 1
  store ptr %68, ptr %72, align 8, !tbaa !21
  %73 = load ptr, ptr %7, align 8, !tbaa !5
  %74 = load ptr, ptr %4, align 8, !tbaa !5
  %75 = getelementptr inbounds %struct.linkedlist0, ptr %74, i32 0, i32 1
  store ptr %73, ptr %75, align 8, !tbaa !19
  br label %76

76:                                               ; preds = %62, %55
  %77 = load ptr, ptr %6, align 8, !tbaa !5
  %78 = getelementptr inbounds %struct.linkedlist0_node, ptr %77, i32 0, i32 1
  %79 = load ptr, ptr %78, align 8, !tbaa !21
  store ptr %79, ptr %6, align 8, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #2
  br label %22, !llvm.loop !22

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

89:                                               ; preds = %80, %17
  call void @llvm.lifetime.end.p0(i64 8, ptr %4) #2
  %90 = load ptr, ptr %2, align 8
  ret ptr %90
}

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 = !{!"linkedlist0", !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 = !{!"linkedlist0_fval", !6, i64 0, !6, i64 8, !6, i64 16, !6, i64 24, !6, i64 32, !6, i64 40}
!17 = !{!18, !6, i64 0}
!18 = !{!"linkedlist0_node", !6, i64 0, !6, i64 8, !6, i64 16}
!19 = !{!10, !6, i64 8}
!20 = !{!18, !6, i64 16}
!21 = !{!18, !6, i64 8}
!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"

; Function Attrs: nounwind uwtable
declare dso_local ptr @ll0_new_custom(ptr noundef, ptr noundef, ptr noundef) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
declare dso_local ptr @ll0_impl_new_node(ptr noundef, ptr noundef) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
define dso_local ptr @ll0_copy_of(ptr noundef %0) local_unnamed_addr #0 {
  %2 = getelementptr inbounds i8, ptr %0, i64 32
  %3 = load ptr, ptr %2, align 8, !tbaa !5
  %4 = getelementptr inbounds i8, ptr %0, i64 40
  %5 = load ptr, ptr %4, align 8, !tbaa !12
  %6 = tail call ptr @ll0_new_custom(ptr noundef %3, ptr noundef %5, ptr noundef null)
  %.not = icmp eq ptr %6, null
  br i1 %.not, label %28, 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
  %7 = getelementptr inbounds i8, ptr %6, i64 8
  br label %8

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

13:                                               ; preds = %8
  %14 = tail call ptr %11(ptr noundef %12) #1
  br label %15

15:                                               ; preds = %8, %13
  %.sink = phi ptr [ %14, %13 ], [ %12, %8 ]
  %16 = tail call ptr @ll0_impl_new_node(ptr noundef nonnull %0, ptr noundef %.sink)
  %17 = load ptr, ptr %6, align 8, !tbaa !18
  %.not34 = icmp eq ptr %17, null
  br i1 %.not34, label %22, label %18

18:                                               ; preds = %15
  %19 = load ptr, ptr %7, align 8, !tbaa !19
  %20 = getelementptr inbounds i8, ptr %16, i64 16
  store ptr %19, ptr %20, align 8, !tbaa !20
  %21 = getelementptr inbounds i8, ptr %19, i64 8
  br label %22

22:                                               ; preds = %15, %18
  %.sink38 = phi ptr [ %21, %18 ], [ %6, %15 ]
  store ptr %16, ptr %.sink38, align 8, !tbaa !13
  store ptr %16, ptr %7, align 8, !tbaa !19
  %23 = getelementptr inbounds i8, ptr %.02837, i64 8
  %.028 = load ptr, ptr %23, align 8, !tbaa !13
  %.not32 = icmp eq ptr %.028, null
  br i1 %.not32, label %._crit_edge, label %8, !llvm.loop !21

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

28:                                               ; preds = %1, %._crit_edge
  ret ptr %6
}

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 = !{!"linkedlist0", !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 = !{!"linkedlist0_fval", !7, i64 0, !7, i64 8, !7, i64 16, !7, i64 24, !7, i64 32, !7, i64 40}
!16 = !{!17, !7, i64 0}
!17 = !{!"linkedlist0_node", !7, i64 0, !7, i64 8, !7, i64 16}
!18 = !{!6, !7, i64 0}
!19 = !{!6, !7, i64 8}
!20 = !{!17, !7, i64 16}
!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