; 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.tagbstring = type { i32, i32, ptr }
%struct.MAP_InitOutputType = type { ptr, [99 x i8], [99 x i8], [24 x i8], ptr, i32, ptr, i32 }

@.str.112 = external hidden unnamed_addr constant [5 x i8], align 1
@.str.113 = external hidden unnamed_addr constant [8 x i8], align 1
@.str.114 = external hidden unnamed_addr constant [23 x i8], align 1
@.str.115 = external hidden unnamed_addr constant [12 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 ptr @bformat(ptr noundef, ...) #1

declare i32 @bdestroy(ptr noundef) #1

; Function Attrs: nounwind uwtable
declare dso_local void @copy_target_string(ptr noundef, ptr noundef) #2

; Function Attrs: nounwind uwtable
define dso_local i32 @map_get_version(ptr noundef %0) #2 {
  %2 = alloca i32, align 4
  %3 = alloca ptr, align 8
  %4 = alloca ptr, align 8
  %5 = alloca i32, align 4
  %6 = alloca i32, align 4
  store ptr %0, ptr %3, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %4) #3
  store ptr null, ptr %4, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #3
  store i32 0, ptr %5, align 4, !tbaa !9
  %7 = call ptr (ptr, ...) @bformat(ptr noundef @.str.112, ptr noundef @.str.113)
  store ptr %7, ptr %4, align 8, !tbaa !5
  %8 = load ptr, ptr %4, align 8, !tbaa !5
  %9 = getelementptr inbounds %struct.tagbstring, ptr %8, i32 0, i32 1
  %10 = load i32, ptr %9, align 4, !tbaa !11
  %11 = icmp sgt i32 %10, 99
  br i1 %11, label %12, label %13

12:                                               ; preds = %1
  store i32 3, ptr %2, align 4
  store i32 1, ptr %6, align 4
  br label %53

13:                                               ; preds = %1
  %14 = load ptr, ptr %3, align 8, !tbaa !5
  %15 = getelementptr inbounds %struct.MAP_InitOutputType, ptr %14, i32 0, i32 2
  %16 = getelementptr inbounds [99 x i8], ptr %15, i64 0, i64 0
  %17 = load ptr, ptr %4, align 8, !tbaa !5
  %18 = getelementptr inbounds %struct.tagbstring, ptr %17, i32 0, i32 2
  %19 = load ptr, ptr %18, align 8, !tbaa !13
  call void @copy_target_string(ptr noundef %16, ptr noundef %19)
  %20 = load ptr, ptr %4, align 8, !tbaa !5
  %21 = call i32 @bdestroy(ptr noundef %20)
  store i32 %21, ptr %5, align 4, !tbaa !9
  %22 = load i8, ptr @.str.115, align 1, !tbaa !14
  %23 = sext i8 %22 to i32
  %24 = load i8, ptr getelementptr inbounds ([12 x i8], ptr @.str.115, i64 0, i64 1), align 1, !tbaa !14
  %25 = sext i8 %24 to i32
  %26 = load i8, ptr getelementptr inbounds ([12 x i8], ptr @.str.115, i64 0, i64 2), align 1, !tbaa !14
  %27 = sext i8 %26 to i32
  %28 = load i8, ptr getelementptr inbounds ([12 x i8], ptr @.str.115, i64 0, i64 5), align 1, !tbaa !14
  %29 = sext i8 %28 to i32
  %30 = load i8, ptr getelementptr inbounds ([12 x i8], ptr @.str.115, i64 0, i64 7), align 1, !tbaa !14
  %31 = sext i8 %30 to i32
  %32 = load i8, ptr getelementptr inbounds ([12 x i8], ptr @.str.115, i64 0, i64 8), align 1, !tbaa !14
  %33 = sext i8 %32 to i32
  %34 = load i8, ptr getelementptr inbounds ([12 x i8], ptr @.str.115, i64 0, i64 9), align 1, !tbaa !14
  %35 = sext i8 %34 to i32
  %36 = load i8, ptr getelementptr inbounds ([12 x i8], ptr @.str.115, i64 0, i64 10), align 1, !tbaa !14
  %37 = sext i8 %36 to i32
  %38 = call ptr (ptr, ...) @bformat(ptr noundef @.str.114, i32 noundef %23, i32 noundef %25, i32 noundef %27, i32 noundef 48, i32 noundef %29, i32 noundef %31, i32 noundef %33, i32 noundef %35, i32 noundef %37)
  store ptr %38, ptr %4, align 8, !tbaa !5
  %39 = load ptr, ptr %4, align 8, !tbaa !5
  %40 = getelementptr inbounds %struct.tagbstring, ptr %39, i32 0, i32 1
  %41 = load i32, ptr %40, align 4, !tbaa !11
  %42 = icmp sgt i32 %41, 25
  br i1 %42, label %43, label %44

43:                                               ; preds = %13
  store i32 3, ptr %2, align 4
  store i32 1, ptr %6, align 4
  br label %53

44:                                               ; preds = %13
  %45 = load ptr, ptr %3, align 8, !tbaa !5
  %46 = getelementptr inbounds %struct.MAP_InitOutputType, ptr %45, i32 0, i32 3
  %47 = getelementptr inbounds [24 x i8], ptr %46, i64 0, i64 0
  %48 = load ptr, ptr %4, align 8, !tbaa !5
  %49 = getelementptr inbounds %struct.tagbstring, ptr %48, i32 0, i32 2
  %50 = load ptr, ptr %49, align 8, !tbaa !13
  call void @copy_target_string(ptr noundef %47, ptr noundef %50)
  %51 = load ptr, ptr %4, align 8, !tbaa !5
  %52 = call i32 @bdestroy(ptr noundef %51)
  store i32 %52, ptr %5, align 4, !tbaa !9
  store i32 0, ptr %2, align 4
  store i32 1, ptr %6, align 4
  br label %53

53:                                               ; preds = %44, %43, %12
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %4) #3
  %54 = load i32, ptr %2, align 4
  ret i32 %54
}

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, !10, i64 4}
!12 = !{!"tagbstring", !10, i64 0, !10, i64 4, !6, i64 8}
!13 = !{!12, !6, i64 8}
!14 = !{!7, !7, 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"

@.str.112 = external hidden unnamed_addr constant [5 x i8], align 1
@.str.113 = external hidden unnamed_addr constant [8 x i8], align 1
@.str.114 = external hidden unnamed_addr constant [23 x i8], align 1
@.str.115 = external hidden unnamed_addr constant [12 x i8], align 1

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

declare i32 @bdestroy(ptr noundef) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
declare dso_local void @copy_target_string(ptr noundef, ptr noundef) local_unnamed_addr #1

; Function Attrs: nounwind uwtable
define dso_local range(i32 0, 4) i32 @map_get_version(ptr noundef %0) local_unnamed_addr #1 {
  %2 = tail call ptr (ptr, ...) @bformat(ptr noundef nonnull @.str.112, ptr noundef nonnull @.str.113) #2
  %3 = getelementptr inbounds i8, ptr %2, i64 4
  %4 = load i32, ptr %3, align 4, !tbaa !5
  %5 = icmp sgt i32 %4, 99
  br i1 %5, label %36, label %6

6:                                                ; preds = %1
  %7 = getelementptr inbounds i8, ptr %0, i64 107
  %8 = getelementptr inbounds i8, ptr %2, i64 8
  %9 = load ptr, ptr %8, align 8, !tbaa !11
  tail call void @copy_target_string(ptr noundef nonnull %7, ptr noundef %9)
  %10 = tail call i32 @bdestroy(ptr noundef nonnull %2) #2
  %11 = load i8, ptr @.str.115, align 1, !tbaa !12
  %12 = sext i8 %11 to i32
  %13 = load i8, ptr getelementptr inbounds (i8, ptr @.str.115, i64 1), align 1, !tbaa !12
  %14 = sext i8 %13 to i32
  %15 = load i8, ptr getelementptr inbounds (i8, ptr @.str.115, i64 2), align 1, !tbaa !12
  %16 = sext i8 %15 to i32
  %17 = load i8, ptr getelementptr inbounds (i8, ptr @.str.115, i64 5), align 1, !tbaa !12
  %18 = sext i8 %17 to i32
  %19 = load i8, ptr getelementptr inbounds (i8, ptr @.str.115, i64 7), align 1, !tbaa !12
  %20 = sext i8 %19 to i32
  %21 = load i8, ptr getelementptr inbounds (i8, ptr @.str.115, i64 8), align 1, !tbaa !12
  %22 = sext i8 %21 to i32
  %23 = load i8, ptr getelementptr inbounds (i8, ptr @.str.115, i64 9), align 1, !tbaa !12
  %24 = sext i8 %23 to i32
  %25 = load i8, ptr getelementptr inbounds (i8, ptr @.str.115, i64 10), align 1, !tbaa !12
  %26 = sext i8 %25 to i32
  %27 = tail call ptr (ptr, ...) @bformat(ptr noundef nonnull @.str.114, i32 noundef %12, i32 noundef %14, i32 noundef %16, i32 noundef 48, i32 noundef %18, i32 noundef %20, i32 noundef %22, i32 noundef %24, i32 noundef %26) #2
  %28 = getelementptr inbounds i8, ptr %27, i64 4
  %29 = load i32, ptr %28, align 4, !tbaa !5
  %30 = icmp sgt i32 %29, 25
  br i1 %30, label %36, label %31

31:                                               ; preds = %6
  %32 = getelementptr inbounds i8, ptr %0, i64 206
  %33 = getelementptr inbounds i8, ptr %27, i64 8
  %34 = load ptr, ptr %33, align 8, !tbaa !11
  tail call void @copy_target_string(ptr noundef nonnull %32, ptr noundef %34)
  %35 = tail call i32 @bdestroy(ptr noundef nonnull %27) #2
  br label %36

36:                                               ; preds = %6, %1, %31
  %.0 = phi i32 [ 0, %31 ], [ 3, %1 ], [ 3, %6 ]
  ret i32 %.0
}

attributes #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 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, !7, i64 4}
!6 = !{!"tagbstring", !7, i64 0, !7, i64 4, !10, i64 8}
!7 = !{!"int", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"any pointer", !8, i64 0}
!11 = !{!6, !10, i64 8}
!12 = !{!8, !8, i64 0}


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