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

; 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.asn_enc_rval_s = type { i64, ptr, ptr }

; Function Attrs: nounwind uwtable
define dso_local void @BOOLEAN_encode_der(ptr dead_on_unwind noalias writable sret(%struct.asn_enc_rval_s) align 8 %0, ptr noundef %1, ptr noundef %2, i32 noundef %3, i32 noundef %4, ptr noundef %5, ptr noundef %6) #0 {
  %8 = alloca ptr, align 8
  %9 = alloca ptr, align 8
  %10 = alloca i32, align 4
  %11 = alloca i32, align 4
  %12 = alloca ptr, align 8
  %13 = alloca ptr, align 8
  %14 = alloca ptr, align 8
  %15 = alloca i32, align 4
  %16 = alloca i8, align 1
  store ptr %1, ptr %8, align 8, !tbaa !5
  store ptr %2, ptr %9, align 8, !tbaa !5
  store i32 %3, ptr %10, align 4, !tbaa !9
  store i32 %4, ptr %11, align 4, !tbaa !9
  store ptr %5, ptr %12, align 8, !tbaa !5
  store ptr %6, ptr %13, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %14) #3
  %17 = load ptr, ptr %9, align 8, !tbaa !5
  store ptr %17, ptr %14, align 8, !tbaa !5
  %18 = load ptr, ptr %8, align 8, !tbaa !5
  %19 = load i32, ptr %10, align 4, !tbaa !9
  %20 = load i32, ptr %11, align 4, !tbaa !9
  %21 = load ptr, ptr %12, align 8, !tbaa !5
  %22 = load ptr, ptr %13, align 8, !tbaa !5
  %23 = call i64 @der_write_tags(ptr noundef %18, i64 noundef 1, i32 noundef %19, i32 noundef 0, i32 noundef %20, ptr noundef %21, ptr noundef %22)
  %24 = getelementptr inbounds %struct.asn_enc_rval_s, ptr %0, i32 0, i32 0
  store i64 %23, ptr %24, align 8, !tbaa !11
  %25 = getelementptr inbounds %struct.asn_enc_rval_s, ptr %0, i32 0, i32 0
  %26 = load i64, ptr %25, align 8, !tbaa !11
  %27 = icmp eq i64 %26, -1
  br i1 %27, label %28, label %33

28:                                               ; preds = %7
  %29 = load ptr, ptr %8, align 8, !tbaa !5
  %30 = getelementptr inbounds %struct.asn_enc_rval_s, ptr %0, i32 0, i32 1
  store ptr %29, ptr %30, align 8, !tbaa !14
  %31 = load ptr, ptr %9, align 8, !tbaa !5
  %32 = getelementptr inbounds %struct.asn_enc_rval_s, ptr %0, i32 0, i32 2
  store ptr %31, ptr %32, align 8, !tbaa !15
  store i32 1, ptr %15, align 4
  br label %66

33:                                               ; preds = %7
  %34 = load ptr, ptr %12, align 8, !tbaa !5
  %35 = icmp ne ptr %34, null
  br i1 %35, label %36, label %57

36:                                               ; preds = %33
  call void @llvm.lifetime.start.p0(i64 1, ptr %16) #3
  %37 = load ptr, ptr %14, align 8, !tbaa !5
  %38 = load i32, ptr %37, align 4, !tbaa !9
  %39 = icmp ne i32 %38, 0
  %40 = zext i1 %39 to i64
  %41 = select i1 %39, i32 255, i32 0
  %42 = trunc i32 %41 to i8
  store i8 %42, ptr %16, align 1, !tbaa !16
  %43 = load ptr, ptr %12, align 8, !tbaa !5
  %44 = load ptr, ptr %13, align 8, !tbaa !5
  %45 = call i32 %43(ptr noundef %16, i64 noundef 1, ptr noundef %44)
  %46 = icmp slt i32 %45, 0
  br i1 %46, label %47, label %53

47:                                               ; preds = %36
  %48 = getelementptr inbounds %struct.asn_enc_rval_s, ptr %0, i32 0, i32 0
  store i64 -1, ptr %48, align 8, !tbaa !11
  %49 = load ptr, ptr %8, align 8, !tbaa !5
  %50 = getelementptr inbounds %struct.asn_enc_rval_s, ptr %0, i32 0, i32 1
  store ptr %49, ptr %50, align 8, !tbaa !14
  %51 = load ptr, ptr %9, align 8, !tbaa !5
  %52 = getelementptr inbounds %struct.asn_enc_rval_s, ptr %0, i32 0, i32 2
  store ptr %51, ptr %52, align 8, !tbaa !15
  store i32 1, ptr %15, align 4
  br label %54

53:                                               ; preds = %36
  store i32 0, ptr %15, align 4
  br label %54

54:                                               ; preds = %53, %47
  call void @llvm.lifetime.end.p0(i64 1, ptr %16) #3
  %55 = load i32, ptr %15, align 4
  switch i32 %55, label %66 [
    i32 0, label %56
  ]

56:                                               ; preds = %54
  br label %57

57:                                               ; preds = %56, %33
  %58 = getelementptr inbounds %struct.asn_enc_rval_s, ptr %0, i32 0, i32 0
  %59 = load i64, ptr %58, align 8, !tbaa !11
  %60 = add nsw i64 %59, 1
  store i64 %60, ptr %58, align 8, !tbaa !11
  br label %61

61:                                               ; preds = %57
  %62 = getelementptr inbounds %struct.asn_enc_rval_s, ptr %0, i32 0, i32 2
  store ptr null, ptr %62, align 8, !tbaa !15
  %63 = getelementptr inbounds %struct.asn_enc_rval_s, ptr %0, i32 0, i32 1
  store ptr null, ptr %63, align 8, !tbaa !14
  store i32 1, ptr %15, align 4
  br label %66

64:                                               ; No predecessors!
  br label %65

65:                                               ; preds = %64
  store i32 0, ptr %15, align 4
  br label %66

66:                                               ; preds = %65, %61, %54, %28
  call void @llvm.lifetime.end.p0(i64 8, ptr %14) #3
  %67 = load i32, ptr %15, align 4
  switch i32 %67, label %69 [
    i32 0, label %68
    i32 1, label %68
  ]

68:                                               ; preds = %66, %66
  ret void

69:                                               ; preds = %66
  unreachable
}

; 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

declare i64 @der_write_tags(ptr noundef, i64 noundef, i32 noundef, i32 noundef, i32 noundef, ptr 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 = { "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, !13, i64 0}
!12 = !{!"asn_enc_rval_s", !13, i64 0, !6, i64 8, !6, i64 16}
!13 = !{!"long", !7, i64 0}
!14 = !{!12, !6, i64 8}
!15 = !{!12, !6, i64 16}
!16 = !{!7, !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"

%struct.asn_enc_rval_s = type { i64, ptr, ptr }

; Function Attrs: nounwind uwtable
define dso_local void @BOOLEAN_encode_der(ptr dead_on_unwind noalias nocapture writable writeonly sret(%struct.asn_enc_rval_s) align 8 %0, ptr noundef %1, ptr noundef %2, i32 noundef %3, i32 noundef %4, ptr noundef %5, ptr noundef %6) local_unnamed_addr #0 {
  %8 = alloca i8, align 1
  %9 = tail call i64 @der_write_tags(ptr noundef %1, i64 noundef 1, i32 noundef %3, i32 noundef 0, i32 noundef %4, ptr noundef %5, ptr noundef %6) #4
  store i64 %9, ptr %0, align 8, !tbaa !5
  %10 = icmp eq i64 %9, -1
  br i1 %10, label %11, label %14

11:                                               ; preds = %7
  %12 = getelementptr inbounds i8, ptr %0, i64 8
  store ptr %1, ptr %12, align 8, !tbaa !11
  %13 = getelementptr inbounds i8, ptr %0, i64 16
  store ptr %2, ptr %13, align 8, !tbaa !12
  br label %26

14:                                               ; preds = %7
  %.not = icmp eq ptr %5, null
  br i1 %.not, label %23, label %15

15:                                               ; preds = %14
  call void @llvm.lifetime.start.p0(i64 1, ptr nonnull %8) #4
  %16 = load i32, ptr %2, align 4, !tbaa !13
  %.not15 = icmp ne i32 %16, 0
  %17 = sext i1 %.not15 to i8
  store i8 %17, ptr %8, align 1, !tbaa !15
  %18 = call i32 %5(ptr noundef nonnull %8, i64 noundef 1, ptr noundef %6) #4
  %19 = icmp sgt i32 %18, -1
  br i1 %19, label %.critedge, label %20

20:                                               ; preds = %15
  store i64 -1, ptr %0, align 8, !tbaa !5
  %21 = getelementptr inbounds i8, ptr %0, i64 8
  store ptr %1, ptr %21, align 8, !tbaa !11
  %22 = getelementptr inbounds i8, ptr %0, i64 16
  store ptr %2, ptr %22, align 8, !tbaa !12
  call void @llvm.lifetime.end.p0(i64 1, ptr nonnull %8) #4
  br label %26

.critedge:                                        ; preds = %15
  call void @llvm.lifetime.end.p0(i64 1, ptr nonnull %8) #4
  br label %23

23:                                               ; preds = %.critedge, %14
  %24 = add nuw nsw i64 %9, 1
  store i64 %24, ptr %0, align 8, !tbaa !5
  %25 = getelementptr inbounds i8, ptr %0, i64 8
  call void @llvm.memset.p0.i64(ptr noundef nonnull align 8 dereferenceable(16) %25, i8 0, i64 16, i1 false)
  br label %26

26:                                               ; preds = %20, %23, %11
  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

declare i64 @der_write_tags(ptr noundef, i64 noundef, i32 noundef, i32 noundef, i32 noundef, ptr noundef, ptr noundef) local_unnamed_addr #2

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #3

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 = { "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 = { nocallback nofree nounwind willreturn memory(argmem: write) }
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, !7, i64 0}
!6 = !{!"asn_enc_rval_s", !7, i64 0, !10, i64 8, !10, i64 16}
!7 = !{!"long", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"any pointer", !8, i64 0}
!11 = !{!6, !10, i64 8}
!12 = !{!6, !10, i64 16}
!13 = !{!14, !14, i64 0}
!14 = !{!"int", !8, i64 0}
!15 = !{!8, !8, i64 0}


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