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

@.str.1 = external hidden unnamed_addr constant [22 x i8], align 1

; Function Attrs: nounwind uwtable
define dso_local void @BOOLEAN_encode_uper(ptr dead_on_unwind noalias writable sret(%struct.asn_enc_rval_s) align 8 %0, ptr noundef %1, ptr noundef %2, ptr noundef %3, ptr noundef %4) #0 {
  %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 %struct.asn_enc_rval_s, align 8
  %12 = alloca i32, align 4
  store ptr %1, ptr %6, align 8, !tbaa !5
  store ptr %2, ptr %7, align 8, !tbaa !5
  store ptr %3, ptr %8, align 8, !tbaa !5
  store ptr %4, ptr %9, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #5
  %13 = load ptr, ptr %8, align 8, !tbaa !5
  store ptr %13, ptr %10, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 24, ptr %11) #5
  call void @llvm.memset.p0.i64(ptr align 8 %11, i8 0, i64 24, i1 false)
  %14 = load ptr, ptr %7, align 8, !tbaa !5
  %15 = load ptr, ptr %10, align 8, !tbaa !5
  %16 = icmp ne ptr %15, null
  br i1 %16, label %26, label %17

17:                                               ; preds = %5
  br label %18

18:                                               ; preds = %17
  %19 = getelementptr inbounds %struct.asn_enc_rval_s, ptr %0, i32 0, i32 0
  store i64 -1, ptr %19, align 8, !tbaa !9
  %20 = load ptr, ptr %6, align 8, !tbaa !5
  %21 = getelementptr inbounds %struct.asn_enc_rval_s, ptr %0, i32 0, i32 1
  store ptr %20, ptr %21, align 8, !tbaa !12
  %22 = load ptr, ptr %8, align 8, !tbaa !5
  %23 = getelementptr inbounds %struct.asn_enc_rval_s, ptr %0, i32 0, i32 2
  store ptr %22, ptr %23, align 8, !tbaa !13
  call void @stacktrace_create(ptr noundef @.str.1, i64 noundef 332, i32 noundef 101, ptr noundef null)
  store i32 1, ptr %12, align 4
  br label %50

24:                                               ; No predecessors!
  br label %25

25:                                               ; preds = %24
  br label %26

26:                                               ; preds = %25, %5
  %27 = load ptr, ptr %9, align 8, !tbaa !5
  %28 = load ptr, ptr %10, align 8, !tbaa !5
  %29 = load i32, ptr %28, align 4, !tbaa !14
  %30 = icmp ne i32 %29, 0
  %31 = zext i1 %30 to i64
  %32 = select i1 %30, i32 1, i32 0
  %33 = call i32 @per_put_few_bits(ptr noundef %27, i32 noundef %32, i32 noundef 1)
  %34 = icmp ne i32 %33, 0
  br i1 %34, label %35, label %44

35:                                               ; preds = %26
  br label %36

36:                                               ; preds = %35
  %37 = getelementptr inbounds %struct.asn_enc_rval_s, ptr %0, i32 0, i32 0
  store i64 -1, ptr %37, align 8, !tbaa !9
  %38 = load ptr, ptr %6, align 8, !tbaa !5
  %39 = getelementptr inbounds %struct.asn_enc_rval_s, ptr %0, i32 0, i32 1
  store ptr %38, ptr %39, align 8, !tbaa !12
  %40 = load ptr, ptr %8, align 8, !tbaa !5
  %41 = getelementptr inbounds %struct.asn_enc_rval_s, ptr %0, i32 0, i32 2
  store ptr %40, ptr %41, align 8, !tbaa !13
  call void @stacktrace_create(ptr noundef @.str.1, i64 noundef 336, i32 noundef 101, ptr noundef null)
  store i32 1, ptr %12, align 4
  br label %50

42:                                               ; No predecessors!
  br label %43

43:                                               ; preds = %42
  br label %44

44:                                               ; preds = %43, %26
  br label %45

45:                                               ; preds = %44
  %46 = getelementptr inbounds %struct.asn_enc_rval_s, ptr %11, i32 0, i32 2
  store ptr null, ptr %46, align 8, !tbaa !13
  %47 = getelementptr inbounds %struct.asn_enc_rval_s, ptr %11, i32 0, i32 1
  store ptr null, ptr %47, align 8, !tbaa !12
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %0, ptr align 8 %11, i64 24, i1 false), !tbaa.struct !16
  store i32 1, ptr %12, align 4
  br label %50

48:                                               ; No predecessors!
  br label %49

49:                                               ; preds = %48
  store i32 0, ptr %12, align 4
  br label %50

50:                                               ; preds = %49, %45, %36, %18
  call void @llvm.lifetime.end.p0(i64 24, ptr %11) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #5
  %51 = load i32, ptr %12, align 4
  switch i32 %51, label %53 [
    i32 0, label %52
    i32 1, label %52
  ]

52:                                               ; preds = %50, %50
  ret void

53:                                               ; preds = %50
  unreachable
}

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

declare void @stacktrace_create(ptr noundef, i64 noundef, i32 noundef, ptr noundef) #2

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: readwrite)
declare void @llvm.memcpy.p0.p0.i64(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i64, i1 immarg) #3

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

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

declare i32 @per_put_few_bits(ptr noundef, i32 noundef, i32 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 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #4 = { nocallback nofree nounwind willreturn memory(argmem: write) }
attributes #5 = { 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, !11, i64 0}
!10 = !{!"asn_enc_rval_s", !11, i64 0, !6, i64 8, !6, i64 16}
!11 = !{!"long", !7, i64 0}
!12 = !{!10, !6, i64 8}
!13 = !{!10, !6, i64 16}
!14 = !{!15, !15, i64 0}
!15 = !{!"int", !7, i64 0}
!16 = !{i64 0, i64 8, !17, i64 8, i64 8, !5, i64 16, i64 8, !5}
!17 = !{!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"

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

@.str.1 = external hidden unnamed_addr constant [22 x i8], align 1

; Function Attrs: nounwind uwtable
define dso_local void @BOOLEAN_encode_uper(ptr dead_on_unwind noalias nocapture writable writeonly sret(%struct.asn_enc_rval_s) align 8 %0, ptr noundef %1, ptr nocapture noundef readnone %2, ptr noundef %3, ptr noundef %4) local_unnamed_addr #0 {
  %.not = icmp eq ptr %3, null
  br i1 %.not, label %6, label %9

6:                                                ; preds = %5
  store i64 -1, ptr %0, align 8, !tbaa !5
  %7 = getelementptr inbounds i8, ptr %0, i64 8
  store ptr %1, ptr %7, align 8, !tbaa !11
  %8 = getelementptr inbounds i8, ptr %0, i64 16
  store ptr null, ptr %8, align 8, !tbaa !12
  tail call void @stacktrace_create(ptr noundef nonnull @.str.1, i64 noundef 332, i32 noundef 101, ptr noundef null) #3
  br label %17

9:                                                ; preds = %5
  %10 = load i32, ptr %3, align 4, !tbaa !13
  %.not9 = icmp ne i32 %10, 0
  %11 = zext i1 %.not9 to i32
  %12 = tail call i32 @per_put_few_bits(ptr noundef %4, i32 noundef %11, i32 noundef 1) #3
  %.not10 = icmp eq i32 %12, 0
  br i1 %.not10, label %16, label %13

13:                                               ; preds = %9
  store i64 -1, ptr %0, align 8, !tbaa !5
  %14 = getelementptr inbounds i8, ptr %0, i64 8
  store ptr %1, ptr %14, align 8, !tbaa !11
  %15 = getelementptr inbounds i8, ptr %0, i64 16
  store ptr %3, ptr %15, align 8, !tbaa !12
  tail call void @stacktrace_create(ptr noundef nonnull @.str.1, i64 noundef 336, i32 noundef 101, ptr noundef null) #3
  br label %17

16:                                               ; preds = %9
  tail call void @llvm.memset.p0.i64(ptr noundef nonnull align 8 dereferenceable(24) %0, i8 0, i64 24, i1 false)
  br label %17

17:                                               ; preds = %16, %13, %6
  ret void
}

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

declare i32 @per_put_few_bits(ptr noundef, i32 noundef, i32 noundef) local_unnamed_addr #1

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #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 = { "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 = { nocallback nofree nounwind willreturn memory(argmem: write) }
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 = !{!"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}


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