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

; 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.3 = external hidden unnamed_addr constant [4 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [4 x i8], align 1
@.str.5 = external hidden unnamed_addr constant [4 x i8], align 1
@.str.6 = external hidden unnamed_addr constant [4 x i8], align 1
@.str.7 = external hidden unnamed_addr constant [4 x i8], align 1
@.str.8 = external hidden unnamed_addr constant [4 x i8], align 1
@.str.9 = external hidden unnamed_addr constant [4 x i8], align 1
@.str.10 = external hidden unnamed_addr constant [4 x i8], align 1
@.str.11 = external hidden unnamed_addr constant [4 x i8], align 1
@.str.12 = external hidden unnamed_addr constant [4 x i8], align 1
@.str.13 = external hidden unnamed_addr constant [4 x i8], align 1
@.str.14 = external hidden unnamed_addr constant [4 x i8], align 1

; Function Attrs: mustprogress nounwind uwtable
define dso_local void @_ZN7CPMDate8m_to_strEv(ptr noundef nonnull align 4 dereferenceable(136) %0) #0 align 2 {
  %2 = alloca ptr, align 8
  %3 = alloca [30 x i8], align 16
  store ptr %0, ptr %2, align 8, !tbaa !5
  %4 = load ptr, ptr %2, align 8
  call void @llvm.lifetime.start.p0(i64 30, ptr %3) #3
  %5 = getelementptr inbounds %class.CPMDate, ptr %4, i32 0, i32 8
  %6 = load i32, ptr %5, align 4, !tbaa !9
  switch i32 %6, label %43 [
    i32 1, label %7
    i32 2, label %10
    i32 3, label %13
    i32 4, label %16
    i32 5, label %19
    i32 6, label %22
    i32 7, label %25
    i32 8, label %28
    i32 9, label %31
    i32 10, label %34
    i32 11, label %37
    i32 12, label %40
  ]

7:                                                ; preds = %1
  %8 = getelementptr inbounds [30 x i8], ptr %3, i64 0, i64 0
  %9 = call ptr @strcpy(ptr noundef %8, ptr noundef @.str.3) #3
  br label %43

10:                                               ; preds = %1
  %11 = getelementptr inbounds [30 x i8], ptr %3, i64 0, i64 0
  %12 = call ptr @strcpy(ptr noundef %11, ptr noundef @.str.4) #3
  br label %43

13:                                               ; preds = %1
  %14 = getelementptr inbounds [30 x i8], ptr %3, i64 0, i64 0
  %15 = call ptr @strcpy(ptr noundef %14, ptr noundef @.str.5) #3
  br label %43

16:                                               ; preds = %1
  %17 = getelementptr inbounds [30 x i8], ptr %3, i64 0, i64 0
  %18 = call ptr @strcpy(ptr noundef %17, ptr noundef @.str.6) #3
  br label %43

19:                                               ; preds = %1
  %20 = getelementptr inbounds [30 x i8], ptr %3, i64 0, i64 0
  %21 = call ptr @strcpy(ptr noundef %20, ptr noundef @.str.7) #3
  br label %43

22:                                               ; preds = %1
  %23 = getelementptr inbounds [30 x i8], ptr %3, i64 0, i64 0
  %24 = call ptr @strcpy(ptr noundef %23, ptr noundef @.str.8) #3
  br label %43

25:                                               ; preds = %1
  %26 = getelementptr inbounds [30 x i8], ptr %3, i64 0, i64 0
  %27 = call ptr @strcpy(ptr noundef %26, ptr noundef @.str.9) #3
  br label %43

28:                                               ; preds = %1
  %29 = getelementptr inbounds [30 x i8], ptr %3, i64 0, i64 0
  %30 = call ptr @strcpy(ptr noundef %29, ptr noundef @.str.10) #3
  br label %43

31:                                               ; preds = %1
  %32 = getelementptr inbounds [30 x i8], ptr %3, i64 0, i64 0
  %33 = call ptr @strcpy(ptr noundef %32, ptr noundef @.str.11) #3
  br label %43

34:                                               ; preds = %1
  %35 = getelementptr inbounds [30 x i8], ptr %3, i64 0, i64 0
  %36 = call ptr @strcpy(ptr noundef %35, ptr noundef @.str.12) #3
  br label %43

37:                                               ; preds = %1
  %38 = getelementptr inbounds [30 x i8], ptr %3, i64 0, i64 0
  %39 = call ptr @strcpy(ptr noundef %38, ptr noundef @.str.13) #3
  br label %43

40:                                               ; preds = %1
  %41 = getelementptr inbounds [30 x i8], ptr %3, i64 0, i64 0
  %42 = call ptr @strcpy(ptr noundef %41, ptr noundef @.str.14) #3
  br label %43

43:                                               ; preds = %40, %37, %34, %31, %28, %25, %22, %19, %16, %13, %10, %7, %1
  %44 = getelementptr inbounds %class.CPMDate, ptr %4, i32 0, i32 1
  %45 = getelementptr inbounds [30 x i8], ptr %44, i64 0, i64 0
  %46 = getelementptr inbounds [30 x i8], ptr %3, i64 0, i64 0
  %47 = call ptr @strcpy(ptr noundef %45, ptr noundef %46) #3
  call void @llvm.lifetime.end.p0(i64 30, 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 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 = !{!10, !11, i64 132}
!10 = !{!"_ZTS7CPMDate", !7, i64 0, !7, i64 20, !7, i64 50, !7, i64 70, !7, i64 110, !11, i64 120, !11, i64 124, !11, i64 128, !11, i64 132}
!11 = !{!"int", !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.3 = external hidden unnamed_addr constant [4 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [4 x i8], align 1
@.str.5 = external hidden unnamed_addr constant [4 x i8], align 1
@.str.6 = external hidden unnamed_addr constant [4 x i8], align 1
@.str.7 = external hidden unnamed_addr constant [4 x i8], align 1
@.str.8 = external hidden unnamed_addr constant [4 x i8], align 1
@.str.9 = external hidden unnamed_addr constant [4 x i8], align 1
@.str.10 = external hidden unnamed_addr constant [4 x i8], align 1
@.str.11 = external hidden unnamed_addr constant [4 x i8], align 1
@.str.12 = external hidden unnamed_addr constant [4 x i8], align 1
@.str.13 = external hidden unnamed_addr constant [4 x i8], align 1
@.str.14 = external hidden unnamed_addr constant [4 x i8], align 1
@switch.table._ZN7CPMDate8m_to_strEv = private unnamed_addr constant [12 x ptr] [ptr @.str.3, ptr @.str.4, ptr @.str.5, ptr @.str.6, ptr @.str.7, ptr @.str.8, ptr @.str.9, ptr @.str.10, ptr @.str.11, ptr @.str.12, ptr @.str.13, ptr @.str.14], align 8

; Function Attrs: mustprogress nofree nounwind willreturn memory(readwrite, inaccessiblemem: none) uwtable
define dso_local void @_ZN7CPMDate8m_to_strEv(ptr noundef nonnull align 4 dereferenceable(136) %0) local_unnamed_addr #0 align 2 {
  %2 = alloca [30 x i8], align 16
  call void @llvm.lifetime.start.p0(i64 30, ptr nonnull %2) #3
  %3 = getelementptr inbounds i8, ptr %0, i64 132
  %4 = load i32, ptr %3, align 4, !tbaa !5
  %switch.tableidx = add i32 %4, -1
  %5 = icmp ult i32 %switch.tableidx, 12
  br i1 %5, label %switch.lookup, label %8

switch.lookup:                                    ; preds = %1
  %6 = zext nneg i32 %switch.tableidx to i64
  %switch.gep = getelementptr inbounds [12 x ptr], ptr @switch.table._ZN7CPMDate8m_to_strEv, i64 0, i64 %6
  %switch.load = load ptr, ptr %switch.gep, align 8
  %7 = call ptr @strcpy(ptr noundef nonnull dereferenceable(1) %2, ptr noundef nonnull dereferenceable(1) %switch.load) #3
  br label %8

8:                                                ; preds = %1, %switch.lookup
  %9 = getelementptr inbounds i8, ptr %0, i64 20
  %10 = call ptr @strcpy(ptr noundef nonnull dereferenceable(1) %9, ptr noundef nonnull dereferenceable(1) %2) #3
  call void @llvm.lifetime.end.p0(i64 30, ptr nonnull %2) #3
  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: mustprogress nofree nounwind willreturn memory(argmem: readwrite)
declare ptr @strcpy(ptr noalias noundef returned writeonly, ptr noalias nocapture noundef readonly) local_unnamed_addr #2

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


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