; LLVM IR from OpenFAST/openfast :: modules/map/src/simclist (simclist)

; 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.list_t = type { ptr, ptr, ptr, i32, ptr, i32, i32, i32, ptr, %struct.list_attributes_s }
%struct.list_attributes_s = type { ptr, ptr, ptr, i32, ptr, ptr, ptr }
%struct.list_entry_s = type { ptr, ptr, ptr }

; Function Attrs: nounwind uwtable
define dso_local i32 @list_init(ptr noalias noundef %0) #0 {
  %2 = alloca i32, align 4
  %3 = alloca ptr, align 8
  store ptr %0, ptr %3, align 8, !tbaa !5
  %4 = load ptr, ptr %3, align 8, !tbaa !5
  %5 = icmp eq ptr %4, null
  br i1 %5, label %6, label %7

6:                                                ; preds = %1
  store i32 -1, ptr %2, align 4
  br label %61

7:                                                ; preds = %1
  %8 = load ptr, ptr %3, align 8, !tbaa !5
  %9 = getelementptr inbounds %struct.list_t, ptr %8, i32 0, i32 3
  store i32 0, ptr %9, align 8, !tbaa !9
  %10 = call noalias ptr @malloc(i64 noundef 24) #2
  %11 = load ptr, ptr %3, align 8, !tbaa !5
  %12 = getelementptr inbounds %struct.list_t, ptr %11, i32 0, i32 0
  store ptr %10, ptr %12, align 8, !tbaa !13
  %13 = call noalias ptr @malloc(i64 noundef 24) #2
  %14 = load ptr, ptr %3, align 8, !tbaa !5
  %15 = getelementptr inbounds %struct.list_t, ptr %14, i32 0, i32 1
  store ptr %13, ptr %15, align 8, !tbaa !14
  %16 = load ptr, ptr %3, align 8, !tbaa !5
  %17 = getelementptr inbounds %struct.list_t, ptr %16, i32 0, i32 1
  %18 = load ptr, ptr %17, align 8, !tbaa !14
  %19 = load ptr, ptr %3, align 8, !tbaa !5
  %20 = getelementptr inbounds %struct.list_t, ptr %19, i32 0, i32 0
  %21 = load ptr, ptr %20, align 8, !tbaa !13
  %22 = getelementptr inbounds %struct.list_entry_s, ptr %21, i32 0, i32 1
  store ptr %18, ptr %22, align 8, !tbaa !15
  %23 = load ptr, ptr %3, align 8, !tbaa !5
  %24 = getelementptr inbounds %struct.list_t, ptr %23, i32 0, i32 0
  %25 = load ptr, ptr %24, align 8, !tbaa !13
  %26 = load ptr, ptr %3, align 8, !tbaa !5
  %27 = getelementptr inbounds %struct.list_t, ptr %26, i32 0, i32 1
  %28 = load ptr, ptr %27, align 8, !tbaa !14
  %29 = getelementptr inbounds %struct.list_entry_s, ptr %28, i32 0, i32 2
  store ptr %25, ptr %29, align 8, !tbaa !17
  %30 = load ptr, ptr %3, align 8, !tbaa !5
  %31 = getelementptr inbounds %struct.list_t, ptr %30, i32 0, i32 2
  store ptr null, ptr %31, align 8, !tbaa !18
  %32 = load ptr, ptr %3, align 8, !tbaa !5
  %33 = getelementptr inbounds %struct.list_t, ptr %32, i32 0, i32 1
  %34 = load ptr, ptr %33, align 8, !tbaa !14
  %35 = getelementptr inbounds %struct.list_entry_s, ptr %34, i32 0, i32 1
  store ptr null, ptr %35, align 8, !tbaa !15
  %36 = load ptr, ptr %3, align 8, !tbaa !5
  %37 = getelementptr inbounds %struct.list_t, ptr %36, i32 0, i32 0
  %38 = load ptr, ptr %37, align 8, !tbaa !13
  %39 = getelementptr inbounds %struct.list_entry_s, ptr %38, i32 0, i32 2
  store ptr null, ptr %39, align 8, !tbaa !17
  %40 = load ptr, ptr %3, align 8, !tbaa !5
  %41 = getelementptr inbounds %struct.list_t, ptr %40, i32 0, i32 1
  %42 = load ptr, ptr %41, align 8, !tbaa !14
  %43 = getelementptr inbounds %struct.list_entry_s, ptr %42, i32 0, i32 0
  store ptr null, ptr %43, align 8, !tbaa !19
  %44 = load ptr, ptr %3, align 8, !tbaa !5
  %45 = getelementptr inbounds %struct.list_t, ptr %44, i32 0, i32 0
  %46 = load ptr, ptr %45, align 8, !tbaa !13
  %47 = getelementptr inbounds %struct.list_entry_s, ptr %46, i32 0, i32 0
  store ptr null, ptr %47, align 8, !tbaa !19
  %48 = load ptr, ptr %3, align 8, !tbaa !5
  %49 = getelementptr inbounds %struct.list_t, ptr %48, i32 0, i32 6
  store i32 0, ptr %49, align 4, !tbaa !20
  %50 = load ptr, ptr %3, align 8, !tbaa !5
  %51 = getelementptr inbounds %struct.list_t, ptr %50, i32 0, i32 7
  store i32 0, ptr %51, align 8, !tbaa !21
  %52 = load ptr, ptr %3, align 8, !tbaa !5
  %53 = getelementptr inbounds %struct.list_t, ptr %52, i32 0, i32 8
  store ptr null, ptr %53, align 8, !tbaa !22
  %54 = call noalias ptr @malloc(i64 noundef 40) #2
  %55 = load ptr, ptr %3, align 8, !tbaa !5
  %56 = getelementptr inbounds %struct.list_t, ptr %55, i32 0, i32 4
  store ptr %54, ptr %56, align 8, !tbaa !23
  %57 = load ptr, ptr %3, align 8, !tbaa !5
  %58 = getelementptr inbounds %struct.list_t, ptr %57, i32 0, i32 5
  store i32 0, ptr %58, align 8, !tbaa !24
  %59 = load ptr, ptr %3, align 8, !tbaa !5
  %60 = call i32 @list_attributes_setdefaults(ptr noundef %59)
  store i32 0, ptr %2, align 4
  br label %61

61:                                               ; preds = %7, %6
  %62 = load i32, ptr %2, align 4
  ret i32 %62
}

; Function Attrs: nounwind allocsize(0)
declare noalias ptr @malloc(i64 noundef) #1

; Function Attrs: nounwind uwtable
declare hidden i32 @list_attributes_setdefaults(ptr noalias noundef) #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" }
attributes #1 = { nounwind allocsize(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 allocsize(0) }

!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, !11, i64 24}
!10 = !{!"", !6, i64 0, !6, i64 8, !6, i64 16, !11, i64 24, !6, i64 32, !11, i64 40, !11, i64 44, !11, i64 48, !6, i64 56, !12, i64 64}
!11 = !{!"int", !7, i64 0}
!12 = !{!"list_attributes_s", !6, i64 0, !6, i64 8, !6, i64 16, !11, i64 24, !6, i64 32, !6, i64 40, !6, i64 48}
!13 = !{!10, !6, i64 0}
!14 = !{!10, !6, i64 8}
!15 = !{!16, !6, i64 8}
!16 = !{!"list_entry_s", !6, i64 0, !6, i64 8, !6, i64 16}
!17 = !{!16, !6, i64 16}
!18 = !{!10, !6, i64 16}
!19 = !{!16, !6, i64 0}
!20 = !{!10, !11, i64 44}
!21 = !{!10, !11, i64 48}
!22 = !{!10, !6, i64 56}
!23 = !{!10, !6, i64 32}
!24 = !{!10, !11, i64 40}


; 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
define dso_local range(i32 -1, 1) i32 @list_init(ptr noalias noundef %0) local_unnamed_addr #0 {
  %2 = icmp eq ptr %0, null
  br i1 %2, label %20, label %3

3:                                                ; preds = %1
  %4 = getelementptr inbounds i8, ptr %0, i64 24
  store i32 0, ptr %4, align 8, !tbaa !5
  %5 = tail call noalias dereferenceable_or_null(24) ptr @malloc(i64 noundef 24) #2
  store ptr %5, ptr %0, align 8, !tbaa !12
  %6 = tail call noalias dereferenceable_or_null(24) ptr @malloc(i64 noundef 24) #2
  %7 = getelementptr inbounds i8, ptr %0, i64 8
  store ptr %6, ptr %7, align 8, !tbaa !13
  %8 = getelementptr inbounds i8, ptr %5, i64 8
  store ptr %6, ptr %8, align 8, !tbaa !14
  %9 = getelementptr inbounds i8, ptr %6, i64 16
  store ptr %5, ptr %9, align 8, !tbaa !16
  %10 = getelementptr inbounds i8, ptr %0, i64 16
  store ptr null, ptr %10, align 8, !tbaa !17
  %11 = getelementptr inbounds i8, ptr %6, i64 8
  store ptr null, ptr %11, align 8, !tbaa !14
  %12 = getelementptr inbounds i8, ptr %5, i64 16
  store ptr null, ptr %12, align 8, !tbaa !16
  store ptr null, ptr %6, align 8, !tbaa !18
  store ptr null, ptr %5, align 8, !tbaa !18
  %13 = getelementptr inbounds i8, ptr %0, i64 44
  store i32 0, ptr %13, align 4, !tbaa !19
  %14 = getelementptr inbounds i8, ptr %0, i64 48
  store i32 0, ptr %14, align 8, !tbaa !20
  %15 = getelementptr inbounds i8, ptr %0, i64 56
  store ptr null, ptr %15, align 8, !tbaa !21
  %16 = tail call noalias dereferenceable_or_null(40) ptr @malloc(i64 noundef 40) #2
  %17 = getelementptr inbounds i8, ptr %0, i64 32
  store ptr %16, ptr %17, align 8, !tbaa !22
  %18 = getelementptr inbounds i8, ptr %0, i64 40
  store i32 0, ptr %18, align 8, !tbaa !23
  %19 = tail call i32 @list_attributes_setdefaults(ptr noundef nonnull %0)
  br label %20

20:                                               ; preds = %1, %3
  %.0 = phi i32 [ 0, %3 ], [ -1, %1 ]
  ret i32 %.0
}

; Function Attrs: mustprogress nofree nounwind willreturn allockind("alloc,uninitialized") allocsize(0) memory(inaccessiblemem: readwrite)
declare noalias noundef ptr @malloc(i64 noundef) local_unnamed_addr #1

; Function Attrs: nounwind uwtable
declare hidden i32 @list_attributes_setdefaults(ptr noalias 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" }
attributes #1 = { mustprogress nofree nounwind willreturn allockind("alloc,uninitialized") allocsize(0) memory(inaccessiblemem: readwrite) "alloc-family"="malloc" "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 allocsize(0) }

!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 24}
!6 = !{!"", !7, i64 0, !7, i64 8, !7, i64 16, !10, i64 24, !7, i64 32, !10, i64 40, !10, i64 44, !10, i64 48, !7, i64 56, !11, i64 64}
!7 = !{!"any pointer", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"int", !8, i64 0}
!11 = !{!"list_attributes_s", !7, i64 0, !7, i64 8, !7, i64 16, !10, i64 24, !7, i64 32, !7, i64 40, !7, i64 48}
!12 = !{!6, !7, i64 0}
!13 = !{!6, !7, i64 8}
!14 = !{!15, !7, i64 8}
!15 = !{!"list_entry_s", !7, i64 0, !7, i64 8, !7, i64 16}
!16 = !{!15, !7, i64 16}
!17 = !{!6, !7, i64 16}
!18 = !{!15, !7, i64 0}
!19 = !{!6, !10, i64 44}
!20 = !{!6, !10, i64 48}
!21 = !{!6, !7, i64 56}
!22 = !{!6, !7, i64 32}
!23 = !{!6, !10, i64 40}


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