; LLVM IR from USDA-ARS-ACSL/MAIZSIM :: Crop source/cpmdate.ll (ZN7CPMDate17make_digit_stringEv)

; 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"

%class.CPMDate = type { [20 x i8], [30 x i8], [20 x i8], [40 x i8], [9 x i8], i32, i32, i32, i32 }

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

; Function Attrs: mustprogress nounwind uwtable
define dso_local void @_ZN7CPMDate17make_digit_stringEv(ptr noundef nonnull align 4 dereferenceable(136) %0) #0 align 2 {
  %2 = alloca ptr, align 8
  %3 = alloca i32, align 4
  %4 = alloca [10 x i8], align 1
  %5 = alloca [10 x i8], align 1
  %6 = alloca [10 x i8], align 1
  %7 = alloca [10 x i8], align 1
  %8 = alloca [10 x i8], align 1
  %9 = alloca [10 x i8], align 1
  store ptr %0, ptr %2, align 8, !tbaa !5
  %10 = load ptr, ptr %2, align 8
  %11 = getelementptr inbounds %class.CPMDate, ptr %10, i32 0, i32 4
  %12 = getelementptr inbounds [9 x i8], ptr %11, i64 0, i64 0
  store i8 0, ptr %12, align 2, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %3) #3
  call void @llvm.lifetime.start.p0(i64 10, ptr %4) #3
  call void @llvm.lifetime.start.p0(i64 10, ptr %5) #3
  call void @llvm.lifetime.start.p0(i64 10, ptr %6) #3
  call void @llvm.lifetime.start.p0(i64 10, ptr %7) #3
  call void @llvm.lifetime.start.p0(i64 10, ptr %8) #3
  call void @llvm.lifetime.start.p0(i64 10, ptr %9) #3
  %13 = getelementptr inbounds [10 x i8], ptr %4, i64 0, i64 0
  store i8 0, ptr %13, align 1, !tbaa !9
  %14 = getelementptr inbounds [10 x i8], ptr %5, i64 0, i64 0
  store i8 0, ptr %14, align 1, !tbaa !9
  %15 = getelementptr inbounds [10 x i8], ptr %8, i64 0, i64 0
  store i8 0, ptr %15, align 1, !tbaa !9
  %16 = getelementptr inbounds [10 x i8], ptr %9, i64 0, i64 0
  store i8 0, ptr %16, align 1, !tbaa !9
  %17 = getelementptr inbounds [10 x i8], ptr %6, i64 0, i64 0
  store i8 0, ptr %17, align 1, !tbaa !9
  %18 = getelementptr inbounds [10 x i8], ptr %7, i64 0, i64 0
  store i8 0, ptr %18, align 1, !tbaa !9
  %19 = getelementptr inbounds %class.CPMDate, ptr %10, i32 0, i32 6
  %20 = load i32, ptr %19, align 4, !tbaa !10
  %21 = icmp sgt i32 %20, 1999
  br i1 %21, label %22, label %26

22:                                               ; preds = %1
  %23 = getelementptr inbounds %class.CPMDate, ptr %10, i32 0, i32 6
  %24 = load i32, ptr %23, align 4, !tbaa !10
  %25 = sub nsw i32 %24, 2000
  store i32 %25, ptr %3, align 4, !tbaa !13
  br label %30

26:                                               ; preds = %1
  %27 = getelementptr inbounds %class.CPMDate, ptr %10, i32 0, i32 6
  %28 = load i32, ptr %27, align 4, !tbaa !10
  %29 = sub nsw i32 %28, 1900
  store i32 %29, ptr %3, align 4, !tbaa !13
  br label %30

30:                                               ; preds = %26, %22
  %31 = getelementptr inbounds [10 x i8], ptr %4, i64 0, i64 0
  %32 = load i32, ptr %3, align 4, !tbaa !13
  %33 = call i32 (ptr, i64, ptr, ...) @snprintf(ptr noundef %31, i64 noundef 10, ptr noundef @.str, i32 noundef %32) #3
  %34 = load i32, ptr %3, align 4, !tbaa !13
  %35 = icmp slt i32 %34, 10
  br i1 %35, label %36, label %42

36:                                               ; preds = %30
  %37 = getelementptr inbounds [10 x i8], ptr %5, i64 0, i64 0
  %38 = call ptr @strcat(ptr noundef %37, ptr noundef @.str.1) #3
  %39 = getelementptr inbounds [10 x i8], ptr %5, i64 0, i64 0
  %40 = getelementptr inbounds [10 x i8], ptr %4, i64 0, i64 0
  %41 = call ptr @strcat(ptr noundef %39, ptr noundef %40) #3
  br label %46

42:                                               ; preds = %30
  %43 = getelementptr inbounds [10 x i8], ptr %5, i64 0, i64 0
  %44 = getelementptr inbounds [10 x i8], ptr %4, i64 0, i64 0
  %45 = call ptr @strcpy(ptr noundef %43, ptr noundef %44) #3
  br label %46

46:                                               ; preds = %42, %36
  %47 = getelementptr inbounds [10 x i8], ptr %8, i64 0, i64 0
  %48 = getelementptr inbounds %class.CPMDate, ptr %10, i32 0, i32 8
  %49 = load i32, ptr %48, align 4, !tbaa !14
  %50 = call i32 (ptr, i64, ptr, ...) @snprintf(ptr noundef %47, i64 noundef 10, ptr noundef @.str, i32 noundef %49) #3
  %51 = getelementptr inbounds %class.CPMDate, ptr %10, i32 0, i32 8
  %52 = load i32, ptr %51, align 4, !tbaa !14
  %53 = icmp slt i32 %52, 10
  br i1 %53, label %54, label %60

54:                                               ; preds = %46
  %55 = getelementptr inbounds [10 x i8], ptr %9, i64 0, i64 0
  %56 = call ptr @strcat(ptr noundef %55, ptr noundef @.str.1) #3
  %57 = getelementptr inbounds [10 x i8], ptr %9, i64 0, i64 0
  %58 = getelementptr inbounds [10 x i8], ptr %8, i64 0, i64 0
  %59 = call ptr @strcat(ptr noundef %57, ptr noundef %58) #3
  br label %64

60:                                               ; preds = %46
  %61 = getelementptr inbounds [10 x i8], ptr %9, i64 0, i64 0
  %62 = getelementptr inbounds [10 x i8], ptr %8, i64 0, i64 0
  %63 = call ptr @strcpy(ptr noundef %61, ptr noundef %62) #3
  br label %64

64:                                               ; preds = %60, %54
  %65 = getelementptr inbounds [10 x i8], ptr %6, i64 0, i64 0
  %66 = getelementptr inbounds %class.CPMDate, ptr %10, i32 0, i32 7
  %67 = load i32, ptr %66, align 4, !tbaa !15
  %68 = call i32 (ptr, i64, ptr, ...) @snprintf(ptr noundef %65, i64 noundef 10, ptr noundef @.str, i32 noundef %67) #3
  %69 = getelementptr inbounds %class.CPMDate, ptr %10, i32 0, i32 7
  %70 = load i32, ptr %69, align 4, !tbaa !15
  %71 = icmp slt i32 %70, 10
  br i1 %71, label %72, label %78

72:                                               ; preds = %64
  %73 = getelementptr inbounds [10 x i8], ptr %7, i64 0, i64 0
  %74 = call ptr @strcat(ptr noundef %73, ptr noundef @.str.1) #3
  %75 = getelementptr inbounds [10 x i8], ptr %7, i64 0, i64 0
  %76 = getelementptr inbounds [10 x i8], ptr %6, i64 0, i64 0
  %77 = call ptr @strcat(ptr noundef %75, ptr noundef %76) #3
  br label %82

78:                                               ; preds = %64
  %79 = getelementptr inbounds [10 x i8], ptr %7, i64 0, i64 0
  %80 = getelementptr inbounds [10 x i8], ptr %6, i64 0, i64 0
  %81 = call ptr @strcpy(ptr noundef %79, ptr noundef %80) #3
  br label %82

82:                                               ; preds = %78, %72
  %83 = getelementptr inbounds %class.CPMDate, ptr %10, i32 0, i32 4
  %84 = getelementptr inbounds [9 x i8], ptr %83, i64 0, i64 0
  %85 = getelementptr inbounds [10 x i8], ptr %9, i64 0, i64 0
  %86 = call ptr @strcat(ptr noundef %84, ptr noundef %85) #3
  %87 = getelementptr inbounds %class.CPMDate, ptr %10, i32 0, i32 4
  %88 = getelementptr inbounds [9 x i8], ptr %87, i64 0, i64 0
  %89 = call ptr @strcat(ptr noundef %88, ptr noundef @.str.2) #3
  %90 = getelementptr inbounds %class.CPMDate, ptr %10, i32 0, i32 4
  %91 = getelementptr inbounds [9 x i8], ptr %90, i64 0, i64 0
  %92 = getelementptr inbounds [10 x i8], ptr %7, i64 0, i64 0
  %93 = call ptr @strcat(ptr noundef %91, ptr noundef %92) #3
  %94 = getelementptr inbounds %class.CPMDate, ptr %10, i32 0, i32 4
  %95 = getelementptr inbounds [9 x i8], ptr %94, i64 0, i64 0
  %96 = call ptr @strcat(ptr noundef %95, ptr noundef @.str.2) #3
  %97 = getelementptr inbounds %class.CPMDate, ptr %10, i32 0, i32 4
  %98 = getelementptr inbounds [9 x i8], ptr %97, i64 0, i64 0
  %99 = getelementptr inbounds [10 x i8], ptr %5, i64 0, i64 0
  %100 = call ptr @strcat(ptr noundef %98, ptr noundef %99) #3
  call void @llvm.lifetime.end.p0(i64 10, ptr %9) #3
  call void @llvm.lifetime.end.p0(i64 10, ptr %8) #3
  call void @llvm.lifetime.end.p0(i64 10, ptr %7) #3
  call void @llvm.lifetime.end.p0(i64 10, ptr %6) #3
  call void @llvm.lifetime.end.p0(i64 10, ptr %5) #3
  call void @llvm.lifetime.end.p0(i64 10, ptr %4) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %3) #3
  ret void
}

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

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

; Function Attrs: nounwind
declare i32 @snprintf(ptr noundef, i64 noundef, ptr noundef, ...) #2

; Function Attrs: nounwind
declare ptr @strcat(ptr noundef, ptr noundef) #2

; Function Attrs: nounwind
declare ptr @strcpy(ptr noundef, ptr noundef) #2

attributes #0 = { mustprogress 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 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { nounwind "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++ TBAA"}
!9 = !{!7, !7, i64 0}
!10 = !{!11, !12, i64 124}
!11 = !{!"_ZTS7CPMDate", !7, i64 0, !7, i64 20, !7, i64 50, !7, i64 70, !7, i64 110, !12, i64 120, !12, i64 124, !12, i64 128, !12, i64 132}
!12 = !{!"int", !7, i64 0}
!13 = !{!12, !12, i64 0}
!14 = !{!11, !12, i64 132}
!15 = !{!11, !12, i64 128}


; 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 = external hidden unnamed_addr constant [3 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [2 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [2 x i8], align 1

; Function Attrs: mustprogress nofree nounwind uwtable
define dso_local void @_ZN7CPMDate17make_digit_stringEv(ptr noundef nonnull align 4 dereferenceable(136) %0) local_unnamed_addr #0 align 2 {
  %2 = alloca [10 x i8], align 1
  %3 = alloca [10 x i8], align 1
  %4 = alloca [10 x i8], align 1
  %5 = alloca [10 x i8], align 1
  %6 = alloca [10 x i8], align 1
  %7 = alloca [10 x i8], align 1
  %8 = getelementptr inbounds i8, ptr %0, i64 110
  store i8 0, ptr %8, align 2, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 10, ptr nonnull %2) #4
  call void @llvm.lifetime.start.p0(i64 10, ptr nonnull %3) #4
  call void @llvm.lifetime.start.p0(i64 10, ptr nonnull %4) #4
  call void @llvm.lifetime.start.p0(i64 10, ptr nonnull %5) #4
  call void @llvm.lifetime.start.p0(i64 10, ptr nonnull %6) #4
  call void @llvm.lifetime.start.p0(i64 10, ptr nonnull %7) #4
  store i8 0, ptr %2, align 1, !tbaa !5
  store i8 0, ptr %3, align 1, !tbaa !5
  store i8 0, ptr %6, align 1, !tbaa !5
  store i8 0, ptr %7, align 1, !tbaa !5
  store i8 0, ptr %4, align 1, !tbaa !5
  store i8 0, ptr %5, align 1, !tbaa !5
  %9 = getelementptr inbounds i8, ptr %0, i64 124
  %10 = load i32, ptr %9, align 4, !tbaa !8
  %11 = icmp sgt i32 %10, 1999
  %.0.v = select i1 %11, i32 -2000, i32 -1900
  %.0 = add nsw i32 %.0.v, %10
  %12 = call i32 (ptr, i64, ptr, ...) @snprintf(ptr noundef nonnull dereferenceable(1) %2, i64 noundef 10, ptr noundef nonnull @.str, i32 noundef %.0) #4
  %13 = icmp slt i32 %.0, 10
  br i1 %13, label %14, label %17

14:                                               ; preds = %1
  %15 = call ptr @strcat(ptr noundef nonnull dereferenceable(1) %3, ptr noundef nonnull dereferenceable(1) @.str.1) #4
  %16 = call ptr @strcat(ptr noundef nonnull dereferenceable(1) %3, ptr noundef nonnull dereferenceable(1) %2) #4
  br label %19

17:                                               ; preds = %1
  %18 = call ptr @strcpy(ptr noundef nonnull dereferenceable(1) %3, ptr noundef nonnull dereferenceable(1) %2) #4
  br label %19

19:                                               ; preds = %17, %14
  %20 = getelementptr inbounds i8, ptr %0, i64 132
  %21 = load i32, ptr %20, align 4, !tbaa !11
  %22 = call i32 (ptr, i64, ptr, ...) @snprintf(ptr noundef nonnull dereferenceable(1) %6, i64 noundef 10, ptr noundef nonnull @.str, i32 noundef %21) #4
  %23 = load i32, ptr %20, align 4, !tbaa !11
  %24 = icmp slt i32 %23, 10
  br i1 %24, label %25, label %28

25:                                               ; preds = %19
  %26 = call ptr @strcat(ptr noundef nonnull dereferenceable(1) %7, ptr noundef nonnull dereferenceable(1) @.str.1) #4
  %27 = call ptr @strcat(ptr noundef nonnull dereferenceable(1) %7, ptr noundef nonnull dereferenceable(1) %6) #4
  br label %30

28:                                               ; preds = %19
  %29 = call ptr @strcpy(ptr noundef nonnull dereferenceable(1) %7, ptr noundef nonnull dereferenceable(1) %6) #4
  br label %30

30:                                               ; preds = %28, %25
  %31 = getelementptr inbounds i8, ptr %0, i64 128
  %32 = load i32, ptr %31, align 4, !tbaa !12
  %33 = call i32 (ptr, i64, ptr, ...) @snprintf(ptr noundef nonnull dereferenceable(1) %4, i64 noundef 10, ptr noundef nonnull @.str, i32 noundef %32) #4
  %34 = load i32, ptr %31, align 4, !tbaa !12
  %35 = icmp slt i32 %34, 10
  br i1 %35, label %36, label %39

36:                                               ; preds = %30
  %37 = call ptr @strcat(ptr noundef nonnull dereferenceable(1) %5, ptr noundef nonnull dereferenceable(1) @.str.1) #4
  %38 = call ptr @strcat(ptr noundef nonnull dereferenceable(1) %5, ptr noundef nonnull dereferenceable(1) %4) #4
  br label %41

39:                                               ; preds = %30
  %40 = call ptr @strcpy(ptr noundef nonnull dereferenceable(1) %5, ptr noundef nonnull dereferenceable(1) %4) #4
  br label %41

41:                                               ; preds = %39, %36
  %42 = call ptr @strcat(ptr noundef nonnull dereferenceable(1) %8, ptr noundef nonnull dereferenceable(1) %7) #4
  %43 = call ptr @strcat(ptr noundef nonnull dereferenceable(1) %8, ptr noundef nonnull dereferenceable(1) @.str.2) #4
  %44 = call ptr @strcat(ptr noundef nonnull dereferenceable(1) %8, ptr noundef nonnull dereferenceable(1) %5) #4
  %45 = call ptr @strcat(ptr noundef nonnull dereferenceable(1) %8, ptr noundef nonnull dereferenceable(1) @.str.2) #4
  %46 = call ptr @strcat(ptr noundef nonnull dereferenceable(1) %8, ptr noundef nonnull dereferenceable(1) %3) #4
  call void @llvm.lifetime.end.p0(i64 10, ptr nonnull %7) #4
  call void @llvm.lifetime.end.p0(i64 10, ptr nonnull %6) #4
  call void @llvm.lifetime.end.p0(i64 10, ptr nonnull %5) #4
  call void @llvm.lifetime.end.p0(i64 10, ptr nonnull %4) #4
  call void @llvm.lifetime.end.p0(i64 10, ptr nonnull %3) #4
  call void @llvm.lifetime.end.p0(i64 10, ptr nonnull %2) #4
  ret void
}

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

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

; Function Attrs: nofree nounwind
declare noundef i32 @snprintf(ptr noalias nocapture noundef writeonly, i64 noundef, ptr nocapture noundef readonly, ...) local_unnamed_addr #2

; Function Attrs: mustprogress nofree nounwind willreturn memory(argmem: readwrite)
declare ptr @strcat(ptr noalias noundef returned, ptr noalias nocapture noundef readonly) local_unnamed_addr #3

; Function Attrs: mustprogress nofree nounwind willreturn memory(argmem: readwrite)
declare ptr @strcpy(ptr noalias noundef returned writeonly, ptr noalias nocapture noundef readonly) local_unnamed_addr #3

attributes #0 = { mustprogress nofree 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 nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { nofree nounwind "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 = { mustprogress nofree nounwind willreturn memory(argmem: readwrite) "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 #4 = { 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 = !{!"omnipotent char", !7, i64 0}
!7 = !{!"Simple C++ TBAA"}
!8 = !{!9, !10, i64 124}
!9 = !{!"_ZTS7CPMDate", !6, i64 0, !6, i64 20, !6, i64 50, !6, i64 70, !6, i64 110, !10, i64 120, !10, i64 124, !10, i64 128, !10, i64 132}
!10 = !{!"int", !6, i64 0}
!11 = !{!9, !10, i64 132}
!12 = !{!9, !10, i64 128}


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