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

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

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

21:                                               ; preds = %18
  %22 = load ptr, ptr %5, align 8, !tbaa !5
  %23 = call zeroext i1 @ll1_push_front(ptr noundef %22, ptr noundef byval(%struct.struct_s) align 8 %1)
  store i1 %23, ptr %4, align 1
  br label %70

24:                                               ; preds = %18
  %25 = load i64, ptr %6, align 8, !tbaa !9
  %26 = load ptr, ptr %5, align 8, !tbaa !5
  %27 = getelementptr inbounds %struct.linkedlist1, ptr %26, i32 0, i32 2
  %28 = load i64, ptr %27, align 8, !tbaa !11
  %29 = icmp eq i64 %25, %28
  br i1 %29, label %30, label %33

30:                                               ; preds = %24
  %31 = load ptr, ptr %5, align 8, !tbaa !5
  %32 = call zeroext i1 @ll1_push_back(ptr noundef %31, ptr noundef byval(%struct.struct_s) align 8 %1)
  store i1 %32, ptr %4, align 1
  br label %70

33:                                               ; preds = %24
  br label %34

34:                                               ; preds = %33
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #2
  %35 = load ptr, ptr %5, align 8, !tbaa !5
  %36 = call ptr @ll1_impl_new_node(ptr noundef %35, ptr noundef byval(%struct.struct_s) align 8 %1)
  store ptr %36, ptr %7, align 8, !tbaa !5
  %37 = load ptr, ptr %7, align 8, !tbaa !5
  %38 = icmp ne ptr %37, null
  br i1 %38, label %40, label %39

39:                                               ; preds = %34
  store i1 false, ptr %4, align 1
  store i32 1, ptr %8, align 4
  br label %69

40:                                               ; preds = %34
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #2
  %41 = load ptr, ptr %5, align 8, !tbaa !5
  %42 = load i64, ptr %6, align 8, !tbaa !9
  %43 = sub i64 %42, 1
  %44 = call ptr @ll1_impl_get_node(ptr noundef %41, i64 noundef %43)
  store ptr %44, ptr %9, align 8, !tbaa !5
  %45 = load ptr, ptr %9, align 8, !tbaa !5
  %46 = getelementptr inbounds %struct.linkedlist1_node, ptr %45, i32 0, i32 1
  %47 = load ptr, ptr %46, align 8, !tbaa !15
  %48 = load ptr, ptr %7, align 8, !tbaa !5
  %49 = getelementptr inbounds %struct.linkedlist1_node, ptr %48, i32 0, i32 1
  store ptr %47, ptr %49, align 8, !tbaa !15
  %50 = load ptr, ptr %9, align 8, !tbaa !5
  %51 = load ptr, ptr %7, align 8, !tbaa !5
  %52 = getelementptr inbounds %struct.linkedlist1_node, ptr %51, i32 0, i32 2
  store ptr %50, ptr %52, align 8, !tbaa !18
  %53 = load ptr, ptr %7, align 8, !tbaa !5
  %54 = load ptr, ptr %7, align 8, !tbaa !5
  %55 = getelementptr inbounds %struct.linkedlist1_node, ptr %54, i32 0, i32 1
  %56 = load ptr, ptr %55, align 8, !tbaa !15
  %57 = getelementptr inbounds %struct.linkedlist1_node, ptr %56, i32 0, i32 2
  store ptr %53, ptr %57, align 8, !tbaa !18
  %58 = load ptr, ptr %7, align 8, !tbaa !5
  %59 = load ptr, ptr %7, align 8, !tbaa !5
  %60 = getelementptr inbounds %struct.linkedlist1_node, ptr %59, i32 0, i32 2
  %61 = load ptr, ptr %60, align 8, !tbaa !18
  %62 = getelementptr inbounds %struct.linkedlist1_node, ptr %61, i32 0, i32 1
  store ptr %58, ptr %62, align 8, !tbaa !15
  %63 = load ptr, ptr %5, align 8, !tbaa !5
  %64 = getelementptr inbounds %struct.linkedlist1, ptr %63, i32 0, i32 2
  %65 = load i64, ptr %64, align 8, !tbaa !11
  %66 = add i64 %65, 1
  store i64 %66, ptr %64, align 8, !tbaa !11
  %67 = load ptr, ptr %5, align 8, !tbaa !5
  %68 = getelementptr inbounds %struct.linkedlist1, ptr %67, i32 0, i32 3
  store i32 0, ptr %68, align 8, !tbaa !14
  store i1 true, ptr %4, align 1
  store i32 1, ptr %8, align 4
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #2
  br label %69

69:                                               ; preds = %40, %39
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #2
  br label %70

70:                                               ; preds = %69, %30, %21, %15
  %71 = load i1, ptr %4, align 1
  ret i1 %71
}

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

; Function Attrs: nounwind uwtable
declare dso_local ptr @ll1_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 = !{!"linkedlist1", !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 104}
!16 = !{!"linkedlist1_node", !17, i64 0, !6, i64 104, !6, i64 112}
!17 = !{!"struct_s", !13, i64 0, !13, i64 4, !6, i64 8, !6, i64 16, !7, i64 24}
!18 = !{!16, !6, i64 112}


; 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 zeroext i1 @ll1_push_front(ptr noundef, ptr noundef byval(%struct.struct_s) align 8) 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 zeroext i1 @ll1_push_at(ptr noundef %0, ptr noundef byval(%struct.struct_s) align 8 %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 @ll1_push_front(ptr noundef nonnull %0, ptr noundef nonnull byval(%struct.struct_s) align 8 %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 @ll1_push_back(ptr noundef nonnull %0, ptr noundef nonnull byval(%struct.struct_s) align 8 %1)
  br label %32

17:                                               ; preds = %13
  %18 = tail call ptr @ll1_impl_new_node(ptr noundef nonnull %0, ptr noundef nonnull byval(%struct.struct_s) align 8 %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 @ll1_impl_get_node(ptr noundef nonnull %0, i64 noundef %20)
  %22 = getelementptr inbounds i8, ptr %21, i64 104
  %23 = load ptr, ptr %22, align 8, !tbaa !13
  %24 = getelementptr inbounds i8, ptr %18, i64 104
  store ptr %23, ptr %24, align 8, !tbaa !13
  %25 = getelementptr inbounds i8, ptr %18, i64 112
  store ptr %21, ptr %25, align 8, !tbaa !16
  %26 = getelementptr inbounds i8, ptr %23, i64 112
  store ptr %18, ptr %26, align 8, !tbaa !16
  %27 = load ptr, ptr %25, align 8, !tbaa !16
  %28 = getelementptr inbounds i8, ptr %27, i64 104
  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 @ll1_push_back(ptr noundef, ptr noundef byval(%struct.struct_s) align 8) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
declare dso_local ptr @ll1_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 = !{!"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, !11, i64 24}
!13 = !{!14, !7, i64 104}
!14 = !{!"linkedlist1_node", !15, i64 0, !7, i64 104, !7, i64 112}
!15 = !{!"struct_s", !11, i64 0, !11, i64 4, !7, i64 8, !7, i64 16, !8, i64 24}
!16 = !{!14, !7, i64 112}


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