; LLVM IR from specinfo-ua/UAPKI :: library/uapkif/src/asn1 (GeneralizedTime)

; 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.OCTET_STRING = type { ptr, i32, %struct.asn_struct_ctx_s }
%struct.asn_struct_ctx_s = type { i16, i16, i32, ptr, i64 }

@.str.3 = external hidden unnamed_addr constant [12 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [5 x i8], align 1
@.str.5 = external hidden unnamed_addr constant [9 x i8], align 1

; Function Attrs: nounwind uwtable
define dso_local i32 @GeneralizedTime_print(ptr noundef %0, ptr noundef %1, i32 noundef %2, ptr noundef %3, ptr noundef %4) #0 {
  %6 = alloca i32, align 4
  %7 = alloca ptr, align 8
  %8 = alloca ptr, align 8
  %9 = alloca i32, align 4
  %10 = alloca ptr, align 8
  %11 = alloca ptr, align 8
  %12 = alloca ptr, align 8
  %13 = alloca [32 x i8], align 16
  %14 = alloca i32, align 4
  %15 = alloca i32, align 4
  store ptr %0, ptr %7, align 8, !tbaa !5
  store ptr %1, ptr %8, align 8, !tbaa !5
  store i32 %2, ptr %9, align 4, !tbaa !9
  store ptr %3, ptr %10, align 8, !tbaa !5
  store ptr %4, ptr %11, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %12) #3
  %16 = load ptr, ptr %8, align 8, !tbaa !5
  store ptr %16, ptr %12, align 8, !tbaa !5
  %17 = load ptr, ptr %7, align 8, !tbaa !5
  %18 = load i32, ptr %9, align 4, !tbaa !9
  %19 = load ptr, ptr %12, align 8, !tbaa !5
  %20 = icmp ne ptr %19, null
  br i1 %20, label %21, label %62

21:                                               ; preds = %5
  %22 = load ptr, ptr %12, align 8, !tbaa !5
  %23 = getelementptr inbounds %struct.OCTET_STRING, ptr %22, i32 0, i32 0
  %24 = load ptr, ptr %23, align 8, !tbaa !11
  %25 = icmp ne ptr %24, null
  br i1 %25, label %26, label %62

26:                                               ; preds = %21
  call void @llvm.lifetime.start.p0(i64 32, ptr %13) #3
  call void @llvm.lifetime.start.p0(i64 4, ptr %14) #3
  %27 = load ptr, ptr %12, align 8, !tbaa !5
  %28 = getelementptr inbounds %struct.OCTET_STRING, ptr %27, i32 0, i32 1
  %29 = load i32, ptr %28, align 8, !tbaa !16
  %30 = icmp slt i32 %29, 15
  br i1 %30, label %36, label %31

31:                                               ; preds = %26
  %32 = load ptr, ptr %12, align 8, !tbaa !5
  %33 = getelementptr inbounds %struct.OCTET_STRING, ptr %32, i32 0, i32 1
  %34 = load i32, ptr %33, align 8, !tbaa !16
  %35 = icmp sgt i32 %34, 19
  br i1 %35, label %36, label %43

36:                                               ; preds = %31, %26
  %37 = load ptr, ptr %10, align 8, !tbaa !5
  %38 = load ptr, ptr %11, align 8, !tbaa !5
  %39 = call i32 %37(ptr noundef @.str.3, i64 noundef 11, ptr noundef %38)
  %40 = icmp slt i32 %39, 0
  %41 = zext i1 %40 to i64
  %42 = select i1 %40, i32 -1, i32 0
  store i32 %42, ptr %6, align 4
  store i32 1, ptr %15, align 4
  br label %61

43:                                               ; preds = %31
  %44 = getelementptr inbounds [32 x i8], ptr %13, i64 0, i64 0
  %45 = load ptr, ptr %12, align 8, !tbaa !5
  %46 = getelementptr inbounds %struct.OCTET_STRING, ptr %45, i32 0, i32 1
  %47 = load i32, ptr %46, align 8, !tbaa !16
  %48 = load ptr, ptr %12, align 8, !tbaa !5
  %49 = getelementptr inbounds %struct.OCTET_STRING, ptr %48, i32 0, i32 0
  %50 = load ptr, ptr %49, align 8, !tbaa !11
  %51 = call i32 (ptr, i64, ptr, ...) @snprintf(ptr noundef %44, i64 noundef 32, ptr noundef @.str.4, i32 noundef %47, ptr noundef %50) #3
  store i32 %51, ptr %14, align 4, !tbaa !9
  %52 = load ptr, ptr %10, align 8, !tbaa !5
  %53 = getelementptr inbounds [32 x i8], ptr %13, i64 0, i64 0
  %54 = load i32, ptr %14, align 4, !tbaa !9
  %55 = sext i32 %54 to i64
  %56 = load ptr, ptr %11, align 8, !tbaa !5
  %57 = call i32 %52(ptr noundef %53, i64 noundef %55, ptr noundef %56)
  %58 = icmp slt i32 %57, 0
  %59 = zext i1 %58 to i64
  %60 = select i1 %58, i32 -1, i32 0
  store i32 %60, ptr %6, align 4
  store i32 1, ptr %15, align 4
  br label %61

61:                                               ; preds = %43, %36
  call void @llvm.lifetime.end.p0(i64 4, ptr %14) #3
  call void @llvm.lifetime.end.p0(i64 32, ptr %13) #3
  br label %69

62:                                               ; preds = %21, %5
  %63 = load ptr, ptr %10, align 8, !tbaa !5
  %64 = load ptr, ptr %11, align 8, !tbaa !5
  %65 = call i32 %63(ptr noundef @.str.5, i64 noundef 8, ptr noundef %64)
  %66 = icmp slt i32 %65, 0
  %67 = zext i1 %66 to i64
  %68 = select i1 %66, i32 -1, i32 0
  store i32 %68, ptr %6, align 4
  store i32 1, ptr %15, align 4
  br label %69

69:                                               ; preds = %62, %61
  call void @llvm.lifetime.end.p0(i64 8, ptr %12) #3
  %70 = load i32, ptr %6, align 4
  ret i32 %70
}

; 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

attributes #0 = { 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/C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"int", !7, i64 0}
!11 = !{!12, !6, i64 0}
!12 = !{!"OCTET_STRING", !6, i64 0, !10, i64 8, !13, i64 16}
!13 = !{!"asn_struct_ctx_s", !14, i64 0, !14, i64 2, !10, i64 4, !6, i64 8, !15, i64 16}
!14 = !{!"short", !7, i64 0}
!15 = !{!"long", !7, i64 0}
!16 = !{!12, !10, i64 8}


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

; Function Attrs: nounwind uwtable
define dso_local range(i32 -1, 1) i32 @GeneralizedTime_print(ptr nocapture noundef readnone %0, ptr noundef readonly %1, i32 noundef %2, ptr nocapture noundef readonly %3, ptr noundef %4) local_unnamed_addr #0 {
  %6 = alloca [32 x i8], align 16
  %.not = icmp eq ptr %1, null
  br i1 %.not, label %20, label %7

7:                                                ; preds = %5
  %8 = load ptr, ptr %1, align 8, !tbaa !5
  %.not18 = icmp eq ptr %8, null
  br i1 %.not18, label %20, label %9

9:                                                ; preds = %7
  call void @llvm.lifetime.start.p0(i64 32, ptr nonnull %6) #3
  %10 = getelementptr inbounds i8, ptr %1, i64 8
  %11 = load i32, ptr %10, align 8, !tbaa !14
  %12 = add i32 %11, -20
  %or.cond = icmp ult i32 %12, -5
  br i1 %or.cond, label %13, label %15

13:                                               ; preds = %9
  %14 = tail call i32 %3(ptr noundef nonnull @.str.3, i64 noundef 11, ptr noundef %4) #3
  br label %19

15:                                               ; preds = %9
  %16 = call i32 (ptr, i64, ptr, ...) @snprintf(ptr noundef nonnull dereferenceable(1) %6, i64 noundef 32, ptr noundef nonnull @.str.4, i32 noundef %11, ptr noundef nonnull %8) #3
  %17 = sext i32 %16 to i64
  %18 = call i32 %3(ptr noundef nonnull %6, i64 noundef %17, ptr noundef %4) #3
  br label %19

19:                                               ; preds = %15, %13
  %.0.in = phi i32 [ %14, %13 ], [ %18, %15 ]
  call void @llvm.lifetime.end.p0(i64 32, ptr nonnull %6) #3
  br label %22

20:                                               ; preds = %7, %5
  %21 = tail call i32 %3(ptr noundef nonnull @.str.5, i64 noundef 8, ptr noundef %4) #3
  br label %22

22:                                               ; preds = %20, %19
  %.1.in = phi i32 [ %.0.in, %19 ], [ %21, %20 ]
  %.1 = ashr i32 %.1.in, 31
  ret i32 %.1
}

; 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

attributes #0 = { 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 = { 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 0}
!6 = !{!"OCTET_STRING", !7, i64 0, !10, i64 8, !11, i64 16}
!7 = !{!"any pointer", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"int", !8, i64 0}
!11 = !{!"asn_struct_ctx_s", !12, i64 0, !12, i64 2, !10, i64 4, !7, i64 8, !13, i64 16}
!12 = !{!"short", !8, i64 0}
!13 = !{!"long", !8, i64 0}
!14 = !{!6, !10, i64 8}


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