; LLVM IR from specinfo-ua/UAPKI :: library/common/pkix (uapki-ns-util)

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

@.str = external hidden unnamed_addr constant [30 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

declare void @stacktrace_add(ptr noundef, i64 noundef, i32 noundef) #1

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

; Function Attrs: mustprogress uwtable
declare dso_local noundef i32 @_ZN7UapkiNS4Util13encodeGenTimeEmPP12ByteArray_st(i64 noundef, ptr noundef) #2

; Function Attrs: mustprogress uwtable
define dso_local noundef i32 @_ZN7UapkiNS4Util14encodePkixTimeE11PKIXTime_PRmPP12ByteArray_st(i32 noundef %0, i64 noundef %1, ptr noundef %2) #2 {
  %4 = alloca i32, align 4
  %5 = alloca i32, align 4
  %6 = alloca i64, align 8
  %7 = alloca ptr, align 8
  %8 = alloca i32, align 4
  %9 = alloca i32, align 4
  %10 = alloca i32, align 4
  store i32 %0, ptr %5, align 4, !tbaa !5
  store i64 %1, ptr %6, align 8, !tbaa !9
  store ptr %2, ptr %7, align 8, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #3
  store i32 0, ptr %8, align 4, !tbaa !13
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #3
  %11 = load i32, ptr %5, align 4, !tbaa !5
  store i32 %11, ptr %9, align 4, !tbaa !5
  %12 = load ptr, ptr %7, align 8, !tbaa !11
  %13 = icmp ne ptr %12, null
  br i1 %13, label %15, label %14

14:                                               ; preds = %3
  store i32 4101, ptr %4, align 4
  store i32 1, ptr %10, align 4
  br label %53

15:                                               ; preds = %3
  %16 = load i32, ptr %9, align 4, !tbaa !5
  %17 = icmp eq i32 %16, 0
  br i1 %17, label %18, label %23

18:                                               ; preds = %15
  %19 = load i64, ptr %6, align 8, !tbaa !9
  %20 = icmp ult i64 %19, 2524608000000
  %21 = zext i1 %20 to i64
  %22 = select i1 %20, i32 1, i32 2
  store i32 %22, ptr %9, align 4, !tbaa !5
  br label %23

23:                                               ; preds = %18, %15
  %24 = load i32, ptr %9, align 4, !tbaa !5
  switch i32 %24, label %49 [
    i32 1, label %25
    i32 2, label %37
  ]

25:                                               ; preds = %23
  br label %26

26:                                               ; preds = %25
  %27 = load i64, ptr %6, align 8, !tbaa !9
  %28 = load ptr, ptr %7, align 8, !tbaa !11
  %29 = call noundef i32 @_ZN7UapkiNS4Util13encodeUtcTimeEmPP12ByteArray_st(i64 noundef %27, ptr noundef %28)
  store i32 %29, ptr %8, align 4, !tbaa !13
  %30 = load i32, ptr %8, align 4, !tbaa !13
  %31 = icmp ne i32 %30, 0
  br i1 %31, label %32, label %34

32:                                               ; preds = %26
  %33 = load i32, ptr %8, align 4, !tbaa !13
  call void @stacktrace_add(ptr noundef @.str, i64 noundef 463, i32 noundef %33)
  br label %51

34:                                               ; preds = %26
  br label %35

35:                                               ; preds = %34
  br label %36

36:                                               ; preds = %35
  br label %50

37:                                               ; preds = %23
  br label %38

38:                                               ; preds = %37
  %39 = load i64, ptr %6, align 8, !tbaa !9
  %40 = load ptr, ptr %7, align 8, !tbaa !11
  %41 = call noundef i32 @_ZN7UapkiNS4Util13encodeGenTimeEmPP12ByteArray_st(i64 noundef %39, ptr noundef %40)
  store i32 %41, ptr %8, align 4, !tbaa !13
  %42 = load i32, ptr %8, align 4, !tbaa !13
  %43 = icmp ne i32 %42, 0
  br i1 %43, label %44, label %46

44:                                               ; preds = %38
  %45 = load i32, ptr %8, align 4, !tbaa !13
  call void @stacktrace_add(ptr noundef @.str, i64 noundef 466, i32 noundef %45)
  br label %51

46:                                               ; preds = %38
  br label %47

47:                                               ; preds = %46
  br label %48

48:                                               ; preds = %47
  br label %50

49:                                               ; preds = %23
  br label %50

50:                                               ; preds = %49, %48, %36
  br label %51

51:                                               ; preds = %50, %44, %32
  %52 = load i32, ptr %8, align 4, !tbaa !13
  store i32 %52, ptr %4, align 4
  store i32 1, ptr %10, align 4
  br label %53

53:                                               ; preds = %51, %14
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #3
  %54 = load i32, ptr %4, align 4
  ret i32 %54
}

; Function Attrs: mustprogress uwtable
declare dso_local noundef i32 @_ZN7UapkiNS4Util13encodeUtcTimeEmPP12ByteArray_st(i64 noundef, ptr noundef) #2

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 = { mustprogress 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 = !{!"_ZTS11PKIXTime_PR", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"long", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"any pointer", !7, i64 0}
!13 = !{!14, !14, i64 0}
!14 = !{!"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 = external hidden unnamed_addr constant [30 x i8], align 1

declare void @stacktrace_add(ptr noundef, i64 noundef, i32 noundef) local_unnamed_addr #0

; Function Attrs: mustprogress uwtable
declare dso_local noundef i32 @_ZN7UapkiNS4Util13encodeGenTimeEmPP12ByteArray_st(i64 noundef, ptr noundef) local_unnamed_addr #1

; Function Attrs: mustprogress uwtable
define dso_local noundef i32 @_ZN7UapkiNS4Util14encodePkixTimeE11PKIXTime_PRmPP12ByteArray_st(i32 noundef %0, i64 noundef %1, ptr noundef %2) local_unnamed_addr #1 {
  %.not = icmp eq ptr %2, null
  br i1 %.not, label %14, label %4

4:                                                ; preds = %3
  %5 = icmp eq i32 %0, 0
  %6 = icmp ult i64 %1, 2524608000000
  %7 = select i1 %6, i32 1, i32 2
  %.0 = select i1 %5, i32 %7, i32 %0
  switch i32 %.0, label %14 [
    i32 1, label %8
    i32 2, label %11
  ]

8:                                                ; preds = %4
  %9 = tail call noundef i32 @_ZN7UapkiNS4Util13encodeUtcTimeEmPP12ByteArray_st(i64 noundef %1, ptr noundef nonnull %2)
  %.not22 = icmp eq i32 %9, 0
  br i1 %.not22, label %14, label %10

10:                                               ; preds = %8
  tail call void @stacktrace_add(ptr noundef nonnull @.str, i64 noundef 463, i32 noundef %9)
  br label %14

11:                                               ; preds = %4
  %12 = tail call noundef i32 @_ZN7UapkiNS4Util13encodeGenTimeEmPP12ByteArray_st(i64 noundef %1, ptr noundef nonnull %2)
  %.not21 = icmp eq i32 %12, 0
  br i1 %.not21, label %14, label %13

13:                                               ; preds = %11
  tail call void @stacktrace_add(ptr noundef nonnull @.str, i64 noundef 466, i32 noundef %12)
  br label %14

14:                                               ; preds = %10, %13, %4, %11, %8, %3
  %.015 = phi i32 [ 4101, %3 ], [ 0, %4 ], [ %12, %13 ], [ 0, %11 ], [ %9, %10 ], [ 0, %8 ]
  ret i32 %.015
}

; Function Attrs: mustprogress uwtable
declare dso_local noundef i32 @_ZN7UapkiNS4Util13encodeUtcTimeEmPP12ByteArray_st(i64 noundef, ptr noundef) local_unnamed_addr #1

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 = { mustprogress 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" }

!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)"}


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