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

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

@.str.39 = external hidden unnamed_addr constant [3 x i8], align 1
@.str.95 = external hidden unnamed_addr constant [7 x i8], align 1

; 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

declare i32 @list_append(ptr noundef, ptr noundef) #1

declare ptr @list_get_at(ptr noundef, i32 noundef) #1

declare ptr @bformat(ptr noundef, ...) #1

; Function Attrs: nounwind uwtable
define dso_local i32 @push_variable_to_output_list(ptr noundef %0, i32 noundef %1, ptr noundef %2, ptr noundef %3, ptr noundef %4) #2 {
  %6 = alloca ptr, align 8
  %7 = alloca i32, align 4
  %8 = alloca ptr, align 8
  %9 = alloca ptr, align 8
  %10 = alloca ptr, align 8
  %11 = alloca i32, align 4
  %12 = alloca %struct.VarTypePtr_t, align 8
  %13 = alloca ptr, align 8
  store ptr %0, ptr %6, align 8, !tbaa !5
  store i32 %1, ptr %7, align 4, !tbaa !9
  store ptr %2, ptr %8, align 8, !tbaa !5
  store ptr %3, ptr %9, align 8, !tbaa !5
  store ptr %4, ptr %10, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %11) #3
  store i32 0, ptr %11, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 40, ptr %12) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr %13) #3
  store ptr null, ptr %13, align 8, !tbaa !5
  %14 = load ptr, ptr %6, align 8, !tbaa !5
  %15 = getelementptr inbounds %struct.OutputList_t, ptr %14, i32 0, i32 1
  %16 = call i32 @list_append(ptr noundef %15, ptr noundef %12)
  %17 = load ptr, ptr %6, align 8, !tbaa !5
  %18 = getelementptr inbounds %struct.OutputList_t, ptr %17, i32 0, i32 1
  %19 = call i32 @list_size(ptr noundef %18)
  store i32 %19, ptr %11, align 4, !tbaa !9
  %20 = load ptr, ptr %6, align 8, !tbaa !5
  %21 = getelementptr inbounds %struct.OutputList_t, ptr %20, i32 0, i32 1
  %22 = load i32, ptr %11, align 4, !tbaa !9
  %23 = sub nsw i32 %22, 1
  %24 = call ptr @list_get_at(ptr noundef %21, i32 noundef %23)
  store ptr %24, ptr %13, align 8, !tbaa !5
  %25 = load ptr, ptr %8, align 8, !tbaa !5
  %26 = load ptr, ptr %13, align 8, !tbaa !5
  %27 = getelementptr inbounds %struct.VarTypePtr_t, ptr %26, i32 0, i32 2
  store ptr %25, ptr %27, align 8, !tbaa !11
  %28 = load i32, ptr %7, align 4, !tbaa !9
  %29 = icmp sge i32 %28, 0
  br i1 %29, label %30, label %36

30:                                               ; preds = %5
  %31 = load ptr, ptr %9, align 8, !tbaa !5
  %32 = load i32, ptr %7, align 4, !tbaa !9
  %33 = call ptr (ptr, ...) @bformat(ptr noundef @.str.95, ptr noundef %31, i32 noundef %32)
  %34 = load ptr, ptr %13, align 8, !tbaa !5
  %35 = getelementptr inbounds %struct.VarTypePtr_t, ptr %34, i32 0, i32 1
  store ptr %33, ptr %35, align 8, !tbaa !14
  br label %41

36:                                               ; preds = %5
  %37 = load ptr, ptr %9, align 8, !tbaa !5
  %38 = call ptr (ptr, ...) @bformat(ptr noundef %37)
  %39 = load ptr, ptr %13, align 8, !tbaa !5
  %40 = getelementptr inbounds %struct.VarTypePtr_t, ptr %39, i32 0, i32 1
  store ptr %38, ptr %40, align 8, !tbaa !14
  br label %41

41:                                               ; preds = %36, %30
  %42 = load ptr, ptr %10, align 8, !tbaa !5
  %43 = call ptr (ptr, ...) @bformat(ptr noundef @.str.39, ptr noundef %42)
  %44 = load ptr, ptr %13, align 8, !tbaa !5
  %45 = getelementptr inbounds %struct.VarTypePtr_t, ptr %44, i32 0, i32 0
  store ptr %43, ptr %45, align 8, !tbaa !15
  call void @llvm.lifetime.end.p0(i64 8, ptr %13) #3
  call void @llvm.lifetime.end.p0(i64 40, ptr %12) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #3
  ret i32 0
}

declare i32 @list_size(ptr noundef) #1

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { "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 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 #3 = { 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 = !{!"int", !7, i64 0}
!11 = !{!12, !6, i64 16}
!12 = !{!"VarTypePtr_t", !6, i64 0, !6, i64 8, !6, i64 16, !13, i64 24, !10, i64 28, !10, i64 32}
!13 = !{!"_Bool", !7, i64 0}
!14 = !{!12, !6, i64 8}
!15 = !{!12, !6, i64 0}


; 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.VarTypePtr_t = type { ptr, ptr, ptr, i8, i32, i32 }

@.str.39 = external hidden unnamed_addr constant [3 x i8], align 1
@.str.95 = external hidden unnamed_addr constant [7 x i8], align 1

; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture) #0

; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #0

declare i32 @list_append(ptr noundef, ptr noundef) local_unnamed_addr #1

declare ptr @list_get_at(ptr noundef, i32 noundef) local_unnamed_addr #1

declare ptr @bformat(ptr noundef, ...) local_unnamed_addr #1

; Function Attrs: nounwind uwtable
define dso_local noundef i32 @push_variable_to_output_list(ptr noundef %0, i32 noundef %1, ptr noundef %2, ptr noundef %3, ptr noundef %4) local_unnamed_addr #2 {
  %6 = alloca %struct.VarTypePtr_t, align 8
  call void @llvm.lifetime.start.p0(i64 40, ptr nonnull %6) #3
  %7 = getelementptr inbounds i8, ptr %0, i64 120
  %8 = call i32 @list_append(ptr noundef nonnull %7, ptr noundef nonnull %6) #3
  %9 = call i32 @list_size(ptr noundef nonnull %7) #3
  %10 = add nsw i32 %9, -1
  %11 = call ptr @list_get_at(ptr noundef nonnull %7, i32 noundef %10) #3
  %12 = getelementptr inbounds i8, ptr %11, i64 16
  store ptr %2, ptr %12, align 8, !tbaa !5
  %13 = icmp sgt i32 %1, -1
  br i1 %13, label %14, label %16

14:                                               ; preds = %5
  %15 = call ptr (ptr, ...) @bformat(ptr noundef nonnull @.str.95, ptr noundef %3, i32 noundef %1) #3
  br label %18

16:                                               ; preds = %5
  %17 = call ptr (ptr, ...) @bformat(ptr noundef %3) #3
  br label %18

18:                                               ; preds = %16, %14
  %.sink = phi ptr [ %15, %14 ], [ %17, %16 ]
  %19 = getelementptr inbounds i8, ptr %11, i64 8
  store ptr %.sink, ptr %19, align 8
  %20 = call ptr (ptr, ...) @bformat(ptr noundef nonnull @.str.39, ptr noundef %4) #3
  store ptr %20, ptr %11, align 8, !tbaa !12
  call void @llvm.lifetime.end.p0(i64 40, ptr nonnull %6) #3
  ret i32 0
}

declare i32 @list_size(ptr noundef) local_unnamed_addr #1

attributes #0 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { "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 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 #3 = { 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 16}
!6 = !{!"VarTypePtr_t", !7, i64 0, !7, i64 8, !7, i64 16, !10, i64 24, !11, i64 28, !11, i64 32}
!7 = !{!"any pointer", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"_Bool", !8, i64 0}
!11 = !{!"int", !8, i64 0}
!12 = !{!6, !7, i64 0}


; Effective O3 passes: EarlyCSEPass,GlobalOptPass,InferFunctionAttrsPass,InstCombinePass,MergedLoadStoreMotionPass,PostOrderFunctionAttrsPass,SROAPass