; LLVM IR from openssl/openssl :: crypto (asn1_dsa)

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

; Function Attrs: nounwind uwtable
declare dso_local i32 @ossl_encode_der_length(ptr noundef, i64 noundef) #0

declare i32 @WPACKET_put_bytes__(ptr noundef, i64 noundef, i64 noundef) #1

; Function Attrs: nounwind uwtable
declare dso_local i32 @ossl_encode_der_integer(ptr noundef, ptr noundef) #0

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

declare i32 @WPACKET_start_sub_packet(ptr noundef) #1

declare i32 @WPACKET_close(ptr noundef) #1

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

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

18:                                               ; preds = %3
  store i32 0, ptr %4, align 4
  store i32 1, ptr %12, align 4
  br label %87

19:                                               ; preds = %3
  %20 = load i32, ptr %11, align 4, !tbaa !9
  %21 = icmp ne i32 %20, 0
  br i1 %21, label %27, label %22

22:                                               ; preds = %19
  %23 = call i32 @WPACKET_init_null(ptr noundef %8, i64 noundef 0)
  %24 = icmp ne i32 %23, 0
  br i1 %24, label %26, label %25

25:                                               ; preds = %22
  store i32 0, ptr %4, align 4
  store i32 1, ptr %12, align 4
  br label %87

26:                                               ; preds = %22
  store ptr %8, ptr %9, align 8, !tbaa !5
  br label %29

27:                                               ; preds = %19
  %28 = load ptr, ptr %5, align 8, !tbaa !5
  store ptr %28, ptr %9, align 8, !tbaa !5
  br label %29

29:                                               ; preds = %27, %26
  %30 = load ptr, ptr %9, align 8, !tbaa !5
  %31 = load ptr, ptr %6, align 8, !tbaa !5
  %32 = call i32 @ossl_encode_der_integer(ptr noundef %30, ptr noundef %31)
  %33 = icmp ne i32 %32, 0
  br i1 %33, label %34, label %50

34:                                               ; preds = %29
  %35 = load ptr, ptr %9, align 8, !tbaa !5
  %36 = load ptr, ptr %7, align 8, !tbaa !5
  %37 = call i32 @ossl_encode_der_integer(ptr noundef %35, ptr noundef %36)
  %38 = icmp ne i32 %37, 0
  br i1 %38, label %39, label %50

39:                                               ; preds = %34
  %40 = load ptr, ptr %9, align 8, !tbaa !5
  %41 = call i32 @WPACKET_get_length(ptr noundef %40, ptr noundef %10)
  %42 = icmp ne i32 %41, 0
  br i1 %42, label %43, label %50

43:                                               ; preds = %39
  %44 = load i32, ptr %11, align 4, !tbaa !9
  %45 = icmp ne i32 %44, 0
  br i1 %45, label %56, label %46

46:                                               ; preds = %43
  %47 = load ptr, ptr %9, align 8, !tbaa !5
  %48 = call i32 @WPACKET_finish(ptr noundef %47)
  %49 = icmp ne i32 %48, 0
  br i1 %49, label %56, label %50

50:                                               ; preds = %46, %39, %34, %29
  %51 = load i32, ptr %11, align 4, !tbaa !9
  %52 = icmp ne i32 %51, 0
  br i1 %52, label %55, label %53

53:                                               ; preds = %50
  %54 = load ptr, ptr %9, align 8, !tbaa !5
  call void @WPACKET_cleanup(ptr noundef %54)
  br label %55

55:                                               ; preds = %53, %50
  store i32 0, ptr %4, align 4
  store i32 1, ptr %12, align 4
  br label %87

56:                                               ; preds = %46, %43
  %57 = load ptr, ptr %5, align 8, !tbaa !5
  %58 = call i32 @WPACKET_put_bytes__(ptr noundef %57, i64 noundef 48, i64 noundef 1)
  %59 = icmp ne i32 %58, 0
  br i1 %59, label %60, label %85

60:                                               ; preds = %56
  %61 = load ptr, ptr %5, align 8, !tbaa !5
  %62 = load i64, ptr %10, align 8, !tbaa !11
  %63 = call i32 @ossl_encode_der_length(ptr noundef %61, i64 noundef %62)
  %64 = icmp ne i32 %63, 0
  br i1 %64, label %65, label %85

65:                                               ; preds = %60
  %66 = load i32, ptr %11, align 4, !tbaa !9
  %67 = icmp ne i32 %66, 0
  br i1 %67, label %73, label %68

68:                                               ; preds = %65
  %69 = load ptr, ptr %5, align 8, !tbaa !5
  %70 = load ptr, ptr %6, align 8, !tbaa !5
  %71 = call i32 @ossl_encode_der_integer(ptr noundef %69, ptr noundef %70)
  %72 = icmp ne i32 %71, 0
  br i1 %72, label %73, label %85

73:                                               ; preds = %68, %65
  %74 = load i32, ptr %11, align 4, !tbaa !9
  %75 = icmp ne i32 %74, 0
  br i1 %75, label %81, label %76

76:                                               ; preds = %73
  %77 = load ptr, ptr %5, align 8, !tbaa !5
  %78 = load ptr, ptr %7, align 8, !tbaa !5
  %79 = call i32 @ossl_encode_der_integer(ptr noundef %77, ptr noundef %78)
  %80 = icmp ne i32 %79, 0
  br i1 %80, label %81, label %85

81:                                               ; preds = %76, %73
  %82 = load ptr, ptr %5, align 8, !tbaa !5
  %83 = call i32 @WPACKET_close(ptr noundef %82)
  %84 = icmp ne i32 %83, 0
  br i1 %84, label %86, label %85

85:                                               ; preds = %81, %76, %68, %60, %56
  store i32 0, ptr %4, align 4
  store i32 1, ptr %12, align 4
  br label %87

86:                                               ; preds = %81
  store i32 1, ptr %4, align 4
  store i32 1, ptr %12, align 4
  br label %87

87:                                               ; preds = %86, %85, %55, %25, %18
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #3
  call void @llvm.lifetime.end.p0(i64 56, ptr %8) #3
  %88 = load i32, ptr %4, align 4
  ret i32 %88
}

declare i32 @WPACKET_is_null_buf(ptr noundef) #1

declare i32 @WPACKET_init_null(ptr noundef, i64 noundef) #1

declare i32 @WPACKET_get_length(ptr noundef, ptr noundef) #1

declare i32 @WPACKET_finish(ptr noundef) #1

declare void @WPACKET_cleanup(ptr noundef) #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 = { "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 nosync nounwind willreturn memory(argmem: readwrite) }
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, !12, i64 0}
!12 = !{!"long", !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.wpacket_st = type { ptr, ptr, i64, i64, i64, ptr, i8 }

; Function Attrs: nounwind uwtable
declare dso_local i32 @ossl_encode_der_length(ptr noundef, i64 noundef) local_unnamed_addr #0

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

; Function Attrs: nounwind uwtable
declare dso_local i32 @ossl_encode_der_integer(ptr noundef, ptr noundef) local_unnamed_addr #0

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

declare i32 @WPACKET_start_sub_packet(ptr noundef) local_unnamed_addr #1

declare i32 @WPACKET_close(ptr noundef) local_unnamed_addr #1

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

; Function Attrs: nounwind uwtable
define dso_local range(i32 0, 2) i32 @ossl_encode_der_dsa_sig(ptr noundef %0, ptr noundef %1, ptr noundef %2) local_unnamed_addr #0 {
  %4 = alloca %struct.wpacket_st, align 8
  %5 = alloca i64, align 8
  call void @llvm.lifetime.start.p0(i64 56, ptr nonnull %4) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %5) #3
  %6 = tail call i32 @WPACKET_is_null_buf(ptr noundef %0) #3
  %7 = tail call i32 @WPACKET_start_sub_packet(ptr noundef %0) #3
  %.not = icmp eq i32 %7, 0
  br i1 %.not, label %32, label %8

8:                                                ; preds = %3
  %.not23 = icmp eq i32 %6, 0
  br i1 %.not23, label %9, label %11

9:                                                ; preds = %8
  %10 = call i32 @WPACKET_init_null(ptr noundef nonnull %4, i64 noundef 0) #3
  %.not24 = icmp eq i32 %10, 0
  br i1 %.not24, label %32, label %11

11:                                               ; preds = %8, %9
  %.022 = phi ptr [ %4, %9 ], [ %0, %8 ]
  %12 = call i32 @ossl_encode_der_integer(ptr noundef %.022, ptr noundef %1)
  %.not25 = icmp eq i32 %12, 0
  br i1 %.not25, label %20, label %13

13:                                               ; preds = %11
  %14 = call i32 @ossl_encode_der_integer(ptr noundef %.022, ptr noundef %2)
  %.not26 = icmp eq i32 %14, 0
  br i1 %.not26, label %20, label %15

15:                                               ; preds = %13
  %16 = call i32 @WPACKET_get_length(ptr noundef %.022, ptr noundef nonnull %5) #3
  %.not27 = icmp eq i32 %16, 0
  br i1 %.not27, label %20, label %17

17:                                               ; preds = %15
  br i1 %.not23, label %18, label %21

18:                                               ; preds = %17
  %19 = call i32 @WPACKET_finish(ptr noundef %.022) #3
  %.not28 = icmp eq i32 %19, 0
  br i1 %.not28, label %.thread, label %21

20:                                               ; preds = %15, %13, %11
  br i1 %.not23, label %.thread, label %32

.thread:                                          ; preds = %18, %20
  call void @WPACKET_cleanup(ptr noundef %.022) #3
  br label %32

21:                                               ; preds = %18, %17
  %22 = call i32 @WPACKET_put_bytes__(ptr noundef %0, i64 noundef 48, i64 noundef 1) #3
  %.not29 = icmp eq i32 %22, 0
  br i1 %.not29, label %32, label %23

23:                                               ; preds = %21
  %24 = load i64, ptr %5, align 8, !tbaa !5
  %25 = call i32 @ossl_encode_der_length(ptr noundef %0, i64 noundef %24)
  %.not30 = icmp eq i32 %25, 0
  br i1 %.not30, label %32, label %26

26:                                               ; preds = %23
  br i1 %.not23, label %27, label %.critedge

27:                                               ; preds = %26
  %28 = call i32 @ossl_encode_der_integer(ptr noundef %0, ptr noundef %1)
  %.not31 = icmp eq i32 %28, 0
  br i1 %.not31, label %32, label %29

29:                                               ; preds = %27
  %30 = call i32 @ossl_encode_der_integer(ptr noundef %0, ptr noundef %2)
  %.not32 = icmp eq i32 %30, 0
  br i1 %.not32, label %32, label %.critedge

.critedge:                                        ; preds = %26, %29
  %31 = call i32 @WPACKET_close(ptr noundef %0) #3
  %.not33 = icmp ne i32 %31, 0
  %spec.select = zext i1 %.not33 to i32
  br label %32

32:                                               ; preds = %.critedge, %21, %23, %27, %29, %20, %.thread, %9, %3
  %.0 = phi i32 [ 0, %3 ], [ 0, %9 ], [ 0, %.thread ], [ 0, %20 ], [ 0, %29 ], [ 0, %27 ], [ 0, %23 ], [ 0, %21 ], [ %spec.select, %.critedge ]
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %5) #3
  call void @llvm.lifetime.end.p0(i64 56, ptr nonnull %4) #3
  ret i32 %.0
}

declare i32 @WPACKET_is_null_buf(ptr noundef) local_unnamed_addr #1

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

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

declare i32 @WPACKET_finish(ptr noundef) local_unnamed_addr #1

declare void @WPACKET_cleanup(ptr noundef) local_unnamed_addr #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 = { "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 nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 = !{!"long", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}


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