; 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_push_front(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 zeroext i1 @ll0_push_at(ptr noundef %0, ptr noundef %1, i64 noundef %2) #1 {
  %4 = alloca i1, align 1
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca i64, align 8
  %8 = alloca ptr, align 8
  %9 = alloca i32, align 4
  %10 = alloca ptr, align 8
  store ptr %0, ptr %5, align 8, !tbaa !5
  store ptr %1, ptr %6, align 8, !tbaa !5
  store i64 %2, ptr %7, align 8, !tbaa !9
  %11 = load i64, ptr %7, align 8, !tbaa !9
  %12 = load ptr, ptr %5, align 8, !tbaa !5
  %13 = getelementptr inbounds %struct.linkedlist0, ptr %12, i32 0, i32 2
  %14 = load i64, ptr %13, align 8, !tbaa !11
  %15 = icmp ugt i64 %11, %14
  br i1 %15, label %16, label %19

16:                                               ; preds = %3
  %17 = load ptr, ptr %5, align 8, !tbaa !5
  %18 = getelementptr inbounds %struct.linkedlist0, ptr %17, i32 0, i32 3
  store i32 5, ptr %18, align 8, !tbaa !14
  store i1 false, ptr %4, align 1
  br label %74

19:                                               ; preds = %3
  %20 = load i64, ptr %7, align 8, !tbaa !9
  %21 = icmp eq i64 %20, 0
  br i1 %21, label %22, label %26

22:                                               ; preds = %19
  %23 = load ptr, ptr %5, align 8, !tbaa !5
  %24 = load ptr, ptr %6, align 8, !tbaa !5
  %25 = call zeroext i1 @ll0_push_front(ptr noundef %23, ptr noundef %24)
  store i1 %25, ptr %4, align 1
  br label %74

26:                                               ; preds = %19
  %27 = load i64, ptr %7, align 8, !tbaa !9
  %28 = load ptr, ptr %5, align 8, !tbaa !5
  %29 = getelementptr inbounds %struct.linkedlist0, ptr %28, i32 0, i32 2
  %30 = load i64, ptr %29, align 8, !tbaa !11
  %31 = icmp eq i64 %27, %30
  br i1 %31, label %32, label %36

32:                                               ; preds = %26
  %33 = load ptr, ptr %5, align 8, !tbaa !5
  %34 = load ptr, ptr %6, align 8, !tbaa !5
  %35 = call zeroext i1 @ll0_push_back(ptr noundef %33, ptr noundef %34)
  store i1 %35, ptr %4, align 1
  br label %74

36:                                               ; preds = %26
  br label %37

37:                                               ; preds = %36
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #2
  %38 = load ptr, ptr %5, align 8, !tbaa !5
  %39 = load ptr, ptr %6, align 8, !tbaa !5
  %40 = call ptr @ll0_impl_new_node(ptr noundef %38, ptr noundef %39)
  store ptr %40, ptr %8, align 8, !tbaa !5
  %41 = load ptr, ptr %8, align 8, !tbaa !5
  %42 = icmp ne ptr %41, null
  br i1 %42, label %44, label %43

43:                                               ; preds = %37
  store i1 false, ptr %4, align 1
  store i32 1, ptr %9, align 4
  br label %73

44:                                               ; preds = %37
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #2
  %45 = load ptr, ptr %5, align 8, !tbaa !5
  %46 = load i64, ptr %7, align 8, !tbaa !9
  %47 = sub i64 %46, 1
  %48 = call ptr @ll0_impl_get_node(ptr noundef %45, i64 noundef %47)
  store ptr %48, ptr %10, align 8, !tbaa !5
  %49 = load ptr, ptr %10, align 8, !tbaa !5
  %50 = getelementptr inbounds %struct.linkedlist0_node, ptr %49, i32 0, i32 1
  %51 = load ptr, ptr %50, align 8, !tbaa !15
  %52 = load ptr, ptr %8, align 8, !tbaa !5
  %53 = getelementptr inbounds %struct.linkedlist0_node, ptr %52, i32 0, i32 1
  store ptr %51, ptr %53, align 8, !tbaa !15
  %54 = load ptr, ptr %10, align 8, !tbaa !5
  %55 = load ptr, ptr %8, align 8, !tbaa !5
  %56 = getelementptr inbounds %struct.linkedlist0_node, ptr %55, i32 0, i32 2
  store ptr %54, ptr %56, align 8, !tbaa !17
  %57 = load ptr, ptr %8, align 8, !tbaa !5
  %58 = load ptr, ptr %8, align 8, !tbaa !5
  %59 = getelementptr inbounds %struct.linkedlist0_node, ptr %58, i32 0, i32 1
  %60 = load ptr, ptr %59, align 8, !tbaa !15
  %61 = getelementptr inbounds %struct.linkedlist0_node, ptr %60, i32 0, i32 2
  store ptr %57, ptr %61, align 8, !tbaa !17
  %62 = load ptr, ptr %8, align 8, !tbaa !5
  %63 = load ptr, ptr %8, align 8, !tbaa !5
  %64 = getelementptr inbounds %struct.linkedlist0_node, ptr %63, i32 0, i32 2
  %65 = load ptr, ptr %64, align 8, !tbaa !17
  %66 = getelementptr inbounds %struct.linkedlist0_node, ptr %65, i32 0, i32 1
  store ptr %62, ptr %66, align 8, !tbaa !15
  %67 = load ptr, ptr %5, align 8, !tbaa !5
  %68 = getelementptr inbounds %struct.linkedlist0, ptr %67, i32 0, i32 2
  %69 = load i64, ptr %68, align 8, !tbaa !11
  %70 = add i64 %69, 1
  store i64 %70, ptr %68, align 8, !tbaa !11
  %71 = load ptr, ptr %5, align 8, !tbaa !5
  %72 = getelementptr inbounds %struct.linkedlist0, ptr %71, i32 0, i32 3
  store i32 0, ptr %72, align 8, !tbaa !14
  store i1 true, ptr %4, align 1
  store i32 1, ptr %9, align 4
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #2
  br label %73

73:                                               ; preds = %44, %43
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #2
  br label %74

74:                                               ; preds = %73, %32, %22, %16
  %75 = load i1, ptr %4, align 1
  ret i1 %75
}

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

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

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, !10, i64 16}
!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, !13, i64 24}
!15 = !{!16, !6, i64 8}
!16 = !{!"linkedlist0_node", !6, i64 0, !6, i64 8, !6, i64 16}
!17 = !{!16, !6, i64 16}


; 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_push_front(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 zeroext i1 @ll0_push_at(ptr noundef %0, ptr noundef %1, i64 noundef %2) local_unnamed_addr #0 {
  %4 = getelementptr inbounds i8, ptr %0, i64 16
  %5 = load i64, ptr %4, align 8, !tbaa !5
  %6 = icmp ult i64 %5, %2
  br i1 %6, label %7, label %9

7:                                                ; preds = %3
  %8 = getelementptr inbounds i8, ptr %0, i64 24
  store i32 5, ptr %8, align 8, !tbaa !12
  br label %32

9:                                                ; preds = %3
  %10 = icmp eq i64 %2, 0
  br i1 %10, label %11, label %13

11:                                               ; preds = %9
  %12 = tail call zeroext i1 @ll0_push_front(ptr noundef nonnull %0, ptr noundef %1)
  br label %32

13:                                               ; preds = %9
  %14 = icmp eq i64 %5, %2
  br i1 %14, label %15, label %17

15:                                               ; preds = %13
  %16 = tail call zeroext i1 @ll0_push_back(ptr noundef nonnull %0, ptr noundef %1)
  br label %32

17:                                               ; preds = %13
  %18 = tail call ptr @ll0_impl_new_node(ptr noundef nonnull %0, ptr noundef %1)
  %.not.not = icmp eq ptr %18, null
  br i1 %.not.not, label %32, label %19

19:                                               ; preds = %17
  %20 = add i64 %2, -1
  %21 = tail call ptr @ll0_impl_get_node(ptr noundef nonnull %0, i64 noundef %20)
  %22 = getelementptr inbounds i8, ptr %21, i64 8
  %23 = load ptr, ptr %22, align 8, !tbaa !13
  %24 = getelementptr inbounds i8, ptr %18, i64 8
  store ptr %23, ptr %24, align 8, !tbaa !13
  %25 = getelementptr inbounds i8, ptr %18, i64 16
  store ptr %21, ptr %25, align 8, !tbaa !15
  %26 = getelementptr inbounds i8, ptr %23, i64 16
  store ptr %18, ptr %26, align 8, !tbaa !15
  %27 = load ptr, ptr %25, align 8, !tbaa !15
  %28 = getelementptr inbounds i8, ptr %27, i64 8
  store ptr %18, ptr %28, align 8, !tbaa !13
  %29 = load i64, ptr %4, align 8, !tbaa !5
  %30 = add i64 %29, 1
  store i64 %30, ptr %4, align 8, !tbaa !5
  %31 = getelementptr inbounds i8, ptr %0, i64 24
  store i32 0, ptr %31, align 8, !tbaa !12
  br label %32

32:                                               ; preds = %19, %17, %15, %11, %7
  %.1 = phi i1 [ false, %7 ], [ %12, %11 ], [ %16, %15 ], [ false, %17 ], [ true, %19 ]
  ret i1 %.1
}

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

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

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 = !{!6, !11, i64 24}
!13 = !{!14, !7, i64 8}
!14 = !{!"linkedlist0_node", !7, i64 0, !7, i64 8, !7, i64 16}
!15 = !{!14, !7, i64 16}


; Effective O3 passes: CorrelatedValuePropagationPass,EarlyCSEPass,GlobalOptPass,IPSCCPPass,InferFunctionAttrsPass,InstCombinePass,SROAPass,SimplifyCFGPass,TailCallElimPass