; 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 }
%struct.asn_TYPE_descriptor_s = type { ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, i32, ptr, i32, ptr, ptr, i32, ptr }

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

; Function Attrs: nounwind uwtable
define dso_local i32 @GeneralizedTime_constraint(ptr noundef %0, ptr noundef %1, ptr noundef %2, ptr noundef %3) #0 {
  %5 = alloca i32, align 4
  %6 = alloca ptr, align 8
  %7 = alloca ptr, align 8
  %8 = alloca ptr, align 8
  %9 = alloca ptr, align 8
  %10 = alloca ptr, align 8
  %11 = alloca i32, align 4
  store ptr %0, ptr %6, align 8, !tbaa !5
  store ptr %1, ptr %7, align 8, !tbaa !5
  store ptr %2, ptr %8, align 8, !tbaa !5
  store ptr %3, ptr %9, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #4
  %12 = load ptr, ptr %7, align 8, !tbaa !5
  store ptr %12, ptr %10, align 8, !tbaa !5
  %13 = load ptr, ptr %10, align 8, !tbaa !5
  %14 = getelementptr inbounds %struct.OCTET_STRING, ptr %13, i32 0, i32 1
  %15 = load i32, ptr %14, align 8, !tbaa !9
  %16 = icmp slt i32 %15, 15
  br i1 %16, label %40, label %17

17:                                               ; preds = %4
  %18 = load ptr, ptr %10, align 8, !tbaa !5
  %19 = getelementptr inbounds %struct.OCTET_STRING, ptr %18, i32 0, i32 0
  %20 = load ptr, ptr %19, align 8, !tbaa !15
  %21 = load ptr, ptr %10, align 8, !tbaa !5
  %22 = getelementptr inbounds %struct.OCTET_STRING, ptr %21, i32 0, i32 1
  %23 = load i32, ptr %22, align 8, !tbaa !9
  %24 = sub nsw i32 %23, 1
  %25 = sext i32 %24 to i64
  %26 = getelementptr inbounds i8, ptr %20, i64 %25
  %27 = load i8, ptr %26, align 1, !tbaa !16
  %28 = zext i8 %27 to i32
  %29 = icmp ne i32 %28, 90
  br i1 %29, label %40, label %30

30:                                               ; preds = %17
  %31 = load ptr, ptr %10, align 8, !tbaa !5
  %32 = getelementptr inbounds %struct.OCTET_STRING, ptr %31, i32 0, i32 1
  %33 = load i32, ptr %32, align 8, !tbaa !9
  %34 = icmp eq i32 %33, 16
  br i1 %34, label %40, label %35

35:                                               ; preds = %30
  %36 = load ptr, ptr %10, align 8, !tbaa !5
  %37 = getelementptr inbounds %struct.OCTET_STRING, ptr %36, i32 0, i32 1
  %38 = load i32, ptr %37, align 8, !tbaa !9
  %39 = icmp sgt i32 %38, 19
  br i1 %39, label %40, label %55

40:                                               ; preds = %35, %30, %17, %4
  %41 = load ptr, ptr %8, align 8, !tbaa !5
  %42 = icmp ne ptr %41, null
  br i1 %42, label %43, label %54

43:                                               ; preds = %40
  %44 = load ptr, ptr %8, align 8, !tbaa !5
  %45 = load ptr, ptr %9, align 8, !tbaa !5
  %46 = load ptr, ptr %6, align 8, !tbaa !5
  %47 = load ptr, ptr %7, align 8, !tbaa !5
  %48 = load ptr, ptr %6, align 8, !tbaa !5
  %49 = getelementptr inbounds %struct.asn_TYPE_descriptor_s, ptr %48, i32 0, i32 0
  %50 = load ptr, ptr %49, align 8, !tbaa !17
  %51 = call ptr @__errno_location() #5
  %52 = load i32, ptr %51, align 4, !tbaa !19
  %53 = call ptr @strerror(i32 noundef %52) #4
  call void (ptr, ptr, ptr, ptr, ...) %44(ptr noundef %45, ptr noundef %46, ptr noundef %47, ptr noundef @.str.1, ptr noundef %50, ptr noundef %53, ptr noundef @.str.2, i32 noundef 104)
  br label %54

54:                                               ; preds = %43, %40
  store i32 -1, ptr %5, align 4
  store i32 1, ptr %11, align 4
  br label %56

55:                                               ; preds = %35
  store i32 0, ptr %5, align 4
  store i32 1, ptr %11, align 4
  br label %56

56:                                               ; preds = %55, %54
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #4
  %57 = load i32, ptr %5, align 4
  ret i32 %57
}

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

; Function Attrs: nounwind
declare ptr @strerror(i32 noundef) #2

; Function Attrs: nounwind willreturn memory(none)
declare ptr @__errno_location() #3

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

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 willreturn memory(none) "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 }
attributes #5 = { nounwind willreturn memory(none) }

!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, !11, i64 8}
!10 = !{!"OCTET_STRING", !6, i64 0, !11, i64 8, !12, i64 16}
!11 = !{!"int", !7, i64 0}
!12 = !{!"asn_struct_ctx_s", !13, i64 0, !13, i64 2, !11, i64 4, !6, i64 8, !14, i64 16}
!13 = !{!"short", !7, i64 0}
!14 = !{!"long", !7, i64 0}
!15 = !{!10, !6, i64 0}
!16 = !{!7, !7, i64 0}
!17 = !{!18, !6, i64 0}
!18 = !{!"asn_TYPE_descriptor_s", !6, i64 0, !6, i64 8, !6, i64 16, !6, i64 24, !6, i64 32, !6, i64 40, !6, i64 48, !6, i64 56, !6, i64 64, !6, i64 72, !6, i64 80, !6, i64 88, !6, i64 96, !11, i64 104, !6, i64 112, !11, i64 120, !6, i64 128, !6, i64 136, !11, i64 144, !6, i64 152}
!19 = !{!11, !11, 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.1 = external hidden unnamed_addr constant [36 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [30 x i8], align 1

; Function Attrs: nounwind uwtable
define dso_local range(i32 -1, 1) i32 @GeneralizedTime_constraint(ptr noundef %0, ptr noundef %1, ptr noundef readonly %2, ptr noundef %3) local_unnamed_addr #0 {
  %5 = getelementptr inbounds i8, ptr %1, i64 8
  %6 = load i32, ptr %5, align 8, !tbaa !5
  %7 = icmp slt i32 %6, 15
  br i1 %7, label %16, label %8

8:                                                ; preds = %4
  %9 = load ptr, ptr %1, align 8, !tbaa !14
  %10 = zext nneg i32 %6 to i64
  %11 = getelementptr i8, ptr %9, i64 %10
  %12 = getelementptr i8, ptr %11, i64 -1
  %13 = load i8, ptr %12, align 1, !tbaa !15
  %.not = icmp ne i8 %13, 90
  %14 = icmp eq i32 %6, 16
  %or.cond = or i1 %14, %.not
  %15 = icmp ugt i32 %6, 19
  %or.cond15 = or i1 %15, %or.cond
  br i1 %or.cond15, label %16, label %22

16:                                               ; preds = %8, %4
  %.not14 = icmp eq ptr %2, null
  br i1 %.not14, label %22, label %17

17:                                               ; preds = %16
  %18 = load ptr, ptr %0, align 8, !tbaa !16
  %19 = tail call ptr @__errno_location() #3
  %20 = load i32, ptr %19, align 4, !tbaa !18
  %21 = tail call ptr @strerror(i32 noundef %20) #4
  tail call void (ptr, ptr, ptr, ptr, ...) %2(ptr noundef %3, ptr noundef nonnull %0, ptr noundef nonnull %1, ptr noundef nonnull @.str.1, ptr noundef %18, ptr noundef %21, ptr noundef nonnull @.str.2, i32 noundef 104) #4
  br label %22

22:                                               ; preds = %8, %16, %17
  %.0 = phi i32 [ -1, %17 ], [ -1, %16 ], [ 0, %8 ]
  ret i32 %.0
}

; Function Attrs: nounwind
declare ptr @strerror(i32 noundef) local_unnamed_addr #1

; Function Attrs: mustprogress nofree nosync nounwind willreturn memory(none)
declare ptr @__errno_location() 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 = { 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 #2 = { mustprogress nofree nosync nounwind willreturn memory(none) "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 willreturn memory(none) }
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, !10, i64 8}
!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, !7, i64 0}
!15 = !{!8, !8, i64 0}
!16 = !{!17, !7, i64 0}
!17 = !{!"asn_TYPE_descriptor_s", !7, i64 0, !7, i64 8, !7, i64 16, !7, i64 24, !7, i64 32, !7, i64 40, !7, i64 48, !7, i64 56, !7, i64 64, !7, i64 72, !7, i64 80, !7, i64 88, !7, i64 96, !10, i64 104, !7, i64 112, !10, i64 120, !7, i64 128, !7, i64 136, !10, i64 144, !7, i64 152}
!18 = !{!10, !10, i64 0}


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