; 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_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 zeroext i1 @ll0_empty(ptr noundef) #1

; Function Attrs: nounwind uwtable
define dso_local ptr @ll0_impl_get_node(ptr noundef %0, i64 noundef %1) #1 {
  %3 = alloca ptr, align 8
  %4 = alloca ptr, align 8
  %5 = alloca i64, align 8
  %6 = alloca ptr, align 8
  %7 = alloca i64, align 8
  %8 = alloca i64, align 8
  store ptr %0, ptr %4, align 8, !tbaa !5
  store i64 %1, ptr %5, align 8, !tbaa !9
  %9 = load ptr, ptr %4, align 8, !tbaa !5
  %10 = call zeroext i1 @ll0_empty(ptr noundef %9)
  br i1 %10, label %11, label %14

11:                                               ; preds = %2
  %12 = load ptr, ptr %4, align 8, !tbaa !5
  %13 = getelementptr inbounds %struct.linkedlist0, ptr %12, i32 0, i32 3
  store i32 2, ptr %13, align 8, !tbaa !11
  store ptr null, ptr %3, align 8
  br label %72

14:                                               ; preds = %2
  %15 = load i64, ptr %5, align 8, !tbaa !9
  %16 = load ptr, ptr %4, align 8, !tbaa !5
  %17 = getelementptr inbounds %struct.linkedlist0, ptr %16, i32 0, i32 2
  %18 = load i64, ptr %17, align 8, !tbaa !14
  %19 = icmp uge i64 %15, %18
  br i1 %19, label %20, label %23

20:                                               ; preds = %14
  %21 = load ptr, ptr %4, align 8, !tbaa !5
  %22 = getelementptr inbounds %struct.linkedlist0, ptr %21, i32 0, i32 3
  store i32 5, ptr %22, align 8, !tbaa !11
  store ptr null, ptr %3, align 8
  br label %72

23:                                               ; preds = %14
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #2
  store ptr null, ptr %6, align 8, !tbaa !5
  %24 = load i64, ptr %5, align 8, !tbaa !9
  %25 = load ptr, ptr %4, align 8, !tbaa !5
  %26 = getelementptr inbounds %struct.linkedlist0, ptr %25, i32 0, i32 2
  %27 = load i64, ptr %26, align 8, !tbaa !14
  %28 = udiv i64 %27, 2
  %29 = icmp ule i64 %24, %28
  br i1 %29, label %30, label %47

30:                                               ; preds = %23
  %31 = load ptr, ptr %4, align 8, !tbaa !5
  %32 = getelementptr inbounds %struct.linkedlist0, ptr %31, i32 0, i32 0
  %33 = load ptr, ptr %32, align 8, !tbaa !15
  store ptr %33, ptr %6, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #2
  store i64 0, ptr %7, align 8, !tbaa !9
  br label %34

34:                                               ; preds = %43, %30
  %35 = load i64, ptr %7, align 8, !tbaa !9
  %36 = load i64, ptr %5, align 8, !tbaa !9
  %37 = icmp ult i64 %35, %36
  br i1 %37, label %39, label %38

38:                                               ; preds = %34
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #2
  br label %46

39:                                               ; preds = %34
  %40 = load ptr, ptr %6, align 8, !tbaa !5
  %41 = getelementptr inbounds %struct.linkedlist0_node, ptr %40, i32 0, i32 1
  %42 = load ptr, ptr %41, align 8, !tbaa !16
  store ptr %42, ptr %6, align 8, !tbaa !5
  br label %43

43:                                               ; preds = %39
  %44 = load i64, ptr %7, align 8, !tbaa !9
  %45 = add i64 %44, 1
  store i64 %45, ptr %7, align 8, !tbaa !9
  br label %34, !llvm.loop !18

46:                                               ; preds = %38
  br label %68

47:                                               ; preds = %23
  %48 = load ptr, ptr %4, align 8, !tbaa !5
  %49 = getelementptr inbounds %struct.linkedlist0, ptr %48, i32 0, i32 1
  %50 = load ptr, ptr %49, align 8, !tbaa !20
  store ptr %50, ptr %6, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #2
  %51 = load ptr, ptr %4, align 8, !tbaa !5
  %52 = getelementptr inbounds %struct.linkedlist0, ptr %51, i32 0, i32 2
  %53 = load i64, ptr %52, align 8, !tbaa !14
  %54 = sub i64 %53, 1
  store i64 %54, ptr %8, align 8, !tbaa !9
  br label %55

55:                                               ; preds = %64, %47
  %56 = load i64, ptr %8, align 8, !tbaa !9
  %57 = load i64, ptr %5, align 8, !tbaa !9
  %58 = icmp ugt i64 %56, %57
  br i1 %58, label %60, label %59

59:                                               ; preds = %55
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #2
  br label %67

60:                                               ; preds = %55
  %61 = load ptr, ptr %6, align 8, !tbaa !5
  %62 = getelementptr inbounds %struct.linkedlist0_node, ptr %61, i32 0, i32 2
  %63 = load ptr, ptr %62, align 8, !tbaa !21
  store ptr %63, ptr %6, align 8, !tbaa !5
  br label %64

64:                                               ; preds = %60
  %65 = load i64, ptr %8, align 8, !tbaa !9
  %66 = add i64 %65, -1
  store i64 %66, ptr %8, align 8, !tbaa !9
  br label %55, !llvm.loop !22

67:                                               ; preds = %59
  br label %68

68:                                               ; preds = %67, %46
  %69 = load ptr, ptr %4, align 8, !tbaa !5
  %70 = getelementptr inbounds %struct.linkedlist0, ptr %69, i32 0, i32 3
  store i32 0, ptr %70, align 8, !tbaa !11
  %71 = load ptr, ptr %6, align 8, !tbaa !5
  store ptr %71, ptr %3, align 8
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #2
  br label %72

72:                                               ; preds = %68, %20, %11
  %73 = load ptr, ptr %3, align 8
  ret ptr %73
}

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


; 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 zeroext i1 @ll0_empty(ptr noundef) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
define dso_local ptr @ll0_impl_get_node(ptr noundef %0, i64 noundef %1) local_unnamed_addr #0 {
  %3 = tail call zeroext i1 @ll0_empty(ptr noundef %0)
  br i1 %3, label %.loopexit, label %4

4:                                                ; preds = %2
  %5 = getelementptr inbounds i8, ptr %0, i64 16
  %6 = load i64, ptr %5, align 8, !tbaa !5
  %.not = icmp ugt i64 %6, %1
  br i1 %.not, label %7, label %.loopexit

7:                                                ; preds = %4
  %8 = lshr i64 %6, 1
  %.not25 = icmp ult i64 %8, %1
  br i1 %.not25, label %18, label %.preheader

.preheader:                                       ; preds = %7
  %.02127 = load ptr, ptr %0, align 8, !tbaa !12
  %.not30 = icmp eq i64 %1, 0
  br i1 %.not30, label %.loopexit, label %.lr.ph.preheader

.lr.ph.preheader:                                 ; preds = %.preheader
  %xtraiter = and i64 %1, 7
  %9 = icmp ult i64 %1, 8
  br i1 %9, label %.loopexit.loopexit35.unr-lcssa, label %.lr.ph.preheader.new

.lr.ph.preheader.new:                             ; preds = %.lr.ph.preheader
  %unroll_iter = and i64 %1, -8
  br label %.lr.ph

.lr.ph:                                           ; preds = %.lr.ph, %.lr.ph.preheader.new
  %.02129 = phi ptr [ %.02127, %.lr.ph.preheader.new ], [ %.021.7, %.lr.ph ]
  %niter = phi i64 [ 0, %.lr.ph.preheader.new ], [ %niter.next.7, %.lr.ph ]
  %10 = getelementptr inbounds i8, ptr %.02129, i64 8
  %.021 = load ptr, ptr %10, align 8, !tbaa !12
  %11 = getelementptr inbounds i8, ptr %.021, i64 8
  %.021.1 = load ptr, ptr %11, align 8, !tbaa !12
  %12 = getelementptr inbounds i8, ptr %.021.1, i64 8
  %.021.2 = load ptr, ptr %12, align 8, !tbaa !12
  %13 = getelementptr inbounds i8, ptr %.021.2, i64 8
  %.021.3 = load ptr, ptr %13, align 8, !tbaa !12
  %14 = getelementptr inbounds i8, ptr %.021.3, i64 8
  %.021.4 = load ptr, ptr %14, align 8, !tbaa !12
  %15 = getelementptr inbounds i8, ptr %.021.4, i64 8
  %.021.5 = load ptr, ptr %15, align 8, !tbaa !12
  %16 = getelementptr inbounds i8, ptr %.021.5, i64 8
  %.021.6 = load ptr, ptr %16, align 8, !tbaa !12
  %17 = getelementptr inbounds i8, ptr %.021.6, i64 8
  %.021.7 = load ptr, ptr %17, align 8, !tbaa !12
  %niter.next.7 = add i64 %niter, 8
  %niter.ncmp.7 = icmp eq i64 %niter.next.7, %unroll_iter
  br i1 %niter.ncmp.7, label %.loopexit.loopexit35.unr-lcssa, label %.lr.ph, !llvm.loop !13

18:                                               ; preds = %7
  %19 = getelementptr inbounds i8, ptr %0, i64 8
  %20 = sub i64 %6, %1
  %xtraiter37 = and i64 %20, 7
  %lcmp.mod38.not = icmp eq i64 %xtraiter37, 0
  br i1 %lcmp.mod38.not, label %.prol.loopexit, label %.prol.preheader

.prol.preheader:                                  ; preds = %18, %.prol.preheader
  %.1.in.prol = phi ptr [ %21, %.prol.preheader ], [ %19, %18 ]
  %.0.in.prol = phi i64 [ %.0.prol, %.prol.preheader ], [ %6, %18 ]
  %prol.iter = phi i64 [ %prol.iter.next, %.prol.preheader ], [ 0, %18 ]
  %.0.prol = add i64 %.0.in.prol, -1
  %.1.prol = load ptr, ptr %.1.in.prol, align 8, !tbaa !12
  %21 = getelementptr inbounds i8, ptr %.1.prol, i64 16
  %prol.iter.next = add i64 %prol.iter, 1
  %prol.iter.cmp.not = icmp eq i64 %prol.iter.next, %xtraiter37
  br i1 %prol.iter.cmp.not, label %.prol.loopexit, label %.prol.preheader, !llvm.loop !15

.prol.loopexit:                                   ; preds = %.prol.preheader, %18
  %.1.in.unr = phi ptr [ %19, %18 ], [ %21, %.prol.preheader ]
  %.0.in.unr = phi i64 [ %6, %18 ], [ %.0.prol, %.prol.preheader ]
  %.1.lcssa.unr = phi ptr [ poison, %18 ], [ %.1.prol, %.prol.preheader ]
  %22 = sub i64 %1, %6
  %23 = icmp ugt i64 %22, -8
  br i1 %23, label %.loopexit, label %.new

.new:                                             ; preds = %.prol.loopexit, %.new
  %.1.in = phi ptr [ %32, %.new ], [ %.1.in.unr, %.prol.loopexit ]
  %.0.in = phi i64 [ %.0.7, %.new ], [ %.0.in.unr, %.prol.loopexit ]
  %.1 = load ptr, ptr %.1.in, align 8, !tbaa !12
  %24 = getelementptr inbounds i8, ptr %.1, i64 16
  %.1.1 = load ptr, ptr %24, align 8, !tbaa !12
  %25 = getelementptr inbounds i8, ptr %.1.1, i64 16
  %.1.2 = load ptr, ptr %25, align 8, !tbaa !12
  %26 = getelementptr inbounds i8, ptr %.1.2, i64 16
  %.1.3 = load ptr, ptr %26, align 8, !tbaa !12
  %27 = getelementptr inbounds i8, ptr %.1.3, i64 16
  %.1.4 = load ptr, ptr %27, align 8, !tbaa !12
  %28 = getelementptr inbounds i8, ptr %.1.4, i64 16
  %.1.5 = load ptr, ptr %28, align 8, !tbaa !12
  %29 = getelementptr inbounds i8, ptr %.1.5, i64 16
  %.1.6 = load ptr, ptr %29, align 8, !tbaa !12
  %30 = getelementptr inbounds i8, ptr %.1.6, i64 16
  %.0.7 = add i64 %.0.in, -8
  %.1.7 = load ptr, ptr %30, align 8, !tbaa !12
  %31 = icmp ugt i64 %.0.7, %1
  %32 = getelementptr inbounds i8, ptr %.1.7, i64 16
  br i1 %31, label %.new, label %.loopexit, !llvm.loop !17

.loopexit.loopexit35.unr-lcssa:                   ; preds = %.lr.ph, %.lr.ph.preheader
  %.021.lcssa.ph = phi ptr [ poison, %.lr.ph.preheader ], [ %.021.7, %.lr.ph ]
  %.02129.unr = phi ptr [ %.02127, %.lr.ph.preheader ], [ %.021.7, %.lr.ph ]
  %lcmp.mod.not = icmp eq i64 %xtraiter, 0
  br i1 %lcmp.mod.not, label %.loopexit, label %.lr.ph.epil

.lr.ph.epil:                                      ; preds = %.loopexit.loopexit35.unr-lcssa, %.lr.ph.epil
  %.02129.epil = phi ptr [ %.021.epil, %.lr.ph.epil ], [ %.02129.unr, %.loopexit.loopexit35.unr-lcssa ]
  %epil.iter = phi i64 [ %epil.iter.next, %.lr.ph.epil ], [ 0, %.loopexit.loopexit35.unr-lcssa ]
  %33 = getelementptr inbounds i8, ptr %.02129.epil, i64 8
  %.021.epil = load ptr, ptr %33, align 8, !tbaa !12
  %epil.iter.next = add i64 %epil.iter, 1
  %epil.iter.cmp.not = icmp eq i64 %epil.iter.next, %xtraiter
  br i1 %epil.iter.cmp.not, label %.loopexit, label %.lr.ph.epil, !llvm.loop !18

.loopexit:                                        ; preds = %.loopexit.loopexit35.unr-lcssa, %.lr.ph.epil, %.prol.loopexit, %.new, %.preheader, %4, %2
  %.sink = phi i32 [ 2, %2 ], [ 5, %4 ], [ 0, %.preheader ], [ 0, %.new ], [ 0, %.prol.loopexit ], [ 0, %.lr.ph.epil ], [ 0, %.loopexit.loopexit35.unr-lcssa ]
  %.022 = phi ptr [ null, %2 ], [ null, %4 ], [ %.02127, %.preheader ], [ %.1.lcssa.unr, %.prol.loopexit ], [ %.1.7, %.new ], [ %.021.lcssa.ph, %.loopexit.loopexit35.unr-lcssa ], [ %.021.epil, %.lr.ph.epil ]
  %34 = getelementptr inbounds i8, ptr %0, i64 24
  store i32 %.sink, ptr %34, align 8, !tbaa !19
  ret ptr %.022
}

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" }

!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 16}
!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 = !{!7, !7, i64 0}
!13 = distinct !{!13, !14}
!14 = !{!"llvm.loop.mustprogress"}
!15 = distinct !{!15, !16}
!16 = !{!"llvm.loop.unroll.disable"}
!17 = distinct !{!17, !14}
!18 = distinct !{!18, !16}
!19 = !{!6, !11, i64 24}


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