; LLVM IR from guanzhi/GmSSL :: src (asn1)

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

@.str.39 = external hidden unnamed_addr constant [2 x i8], align 1
@.str.41 = external hidden unnamed_addr constant [7 x i8], align 1
@.str.42 = external hidden unnamed_addr constant [10 x i8], align 1
@.str.43 = external hidden unnamed_addr constant [3 x i8], align 1
@.str.44 = external hidden unnamed_addr constant [4 x i8], align 1
@.str.45 = external hidden unnamed_addr constant [4 x i8], align 1

; Function Attrs: nounwind
declare i32 @fprintf(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) #1

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

declare i32 @format_print(ptr noundef, i32 noundef, i32 noundef, ptr noundef, ...) #2

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

22:                                               ; preds = %7
  %23 = load ptr, ptr %12, align 8, !tbaa !5
  br label %25

24:                                               ; preds = %7
  br label %25

25:                                               ; preds = %24, %22
  %26 = phi ptr [ %23, %22 ], [ @.str.42, %24 ]
  %27 = call i32 (ptr, i32, i32, ptr, ...) @format_print(ptr noundef %16, i32 noundef %17, i32 noundef %18, ptr noundef @.str.41, ptr noundef %19, ptr noundef %26)
  %28 = load ptr, ptr %13, align 8, !tbaa !5
  %29 = icmp ne ptr %28, null
  br i1 %29, label %30, label %55

30:                                               ; preds = %25
  %31 = load ptr, ptr %8, align 8, !tbaa !5
  %32 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %31, ptr noundef @.str.43) #4
  store i64 0, ptr %15, align 8, !tbaa !11
  br label %33

33:                                               ; preds = %45, %30
  %34 = load i64, ptr %15, align 8, !tbaa !11
  %35 = load i64, ptr %14, align 8, !tbaa !11
  %36 = sub i64 %35, 1
  %37 = icmp ult i64 %34, %36
  br i1 %37, label %38, label %48

38:                                               ; preds = %33
  %39 = load ptr, ptr %8, align 8, !tbaa !5
  %40 = load ptr, ptr %13, align 8, !tbaa !5
  %41 = load i64, ptr %15, align 8, !tbaa !11
  %42 = getelementptr inbounds i32, ptr %40, i64 %41
  %43 = load i32, ptr %42, align 4, !tbaa !9
  %44 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %39, ptr noundef @.str.44, i32 noundef %43) #4
  br label %45

45:                                               ; preds = %38
  %46 = load i64, ptr %15, align 8, !tbaa !11
  %47 = add i64 %46, 1
  store i64 %47, ptr %15, align 8, !tbaa !11
  br label %33, !llvm.loop !13

48:                                               ; preds = %33
  %49 = load ptr, ptr %8, align 8, !tbaa !5
  %50 = load ptr, ptr %13, align 8, !tbaa !5
  %51 = load i64, ptr %15, align 8, !tbaa !11
  %52 = getelementptr inbounds i32, ptr %50, i64 %51
  %53 = load i32, ptr %52, align 4, !tbaa !9
  %54 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %49, ptr noundef @.str.45, i32 noundef %53) #4
  br label %55

55:                                               ; preds = %48, %25
  %56 = load ptr, ptr %8, align 8, !tbaa !5
  %57 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %56, ptr noundef @.str.39) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %15) #4
  ret i32 1
}

attributes #0 = { 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 #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 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 #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, !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}
!13 = distinct !{!13, !14}
!14 = !{!"llvm.loop.mustprogress"}


; 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.39 = external hidden unnamed_addr constant [2 x i8], align 1
@.str.41 = external hidden unnamed_addr constant [7 x i8], align 1
@.str.42 = external hidden unnamed_addr constant [10 x i8], align 1
@.str.43 = external hidden unnamed_addr constant [3 x i8], align 1
@.str.44 = external hidden unnamed_addr constant [4 x i8], align 1
@.str.45 = external hidden unnamed_addr constant [4 x i8], align 1

; Function Attrs: nofree nounwind
declare noundef i32 @fprintf(ptr nocapture noundef, ptr nocapture noundef readonly, ...) local_unnamed_addr #0

declare i32 @format_print(ptr noundef, i32 noundef, i32 noundef, ptr noundef, ...) local_unnamed_addr #1

; Function Attrs: nounwind uwtable
define dso_local noundef i32 @asn1_object_identifier_print(ptr noundef %0, i32 noundef %1, i32 noundef %2, ptr noundef %3, ptr noundef %4, ptr noundef readonly %5, i64 noundef %6) local_unnamed_addr #2 {
  %.not = icmp eq ptr %4, null
  %8 = select i1 %.not, ptr @.str.42, ptr %4
  %9 = tail call i32 (ptr, i32, i32, ptr, ...) @format_print(ptr noundef %0, i32 noundef %1, i32 noundef %2, ptr noundef nonnull @.str.41, ptr noundef %3, ptr noundef nonnull %8) #3
  %.not18 = icmp eq ptr %5, null
  br i1 %.not18, label %20, label %10

10:                                               ; preds = %7
  %11 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %0, ptr noundef nonnull @.str.43) #3
  %12 = add i64 %6, -1
  %.not20 = icmp eq i64 %12, 0
  br i1 %.not20, label %._crit_edge, label %.lr.ph

.lr.ph:                                           ; preds = %10, %.lr.ph
  %.019 = phi i64 [ %16, %.lr.ph ], [ 0, %10 ]
  %13 = getelementptr inbounds i32, ptr %5, i64 %.019
  %14 = load i32, ptr %13, align 4, !tbaa !5
  %15 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %0, ptr noundef nonnull @.str.44, i32 noundef %14) #3
  %16 = add nuw i64 %.019, 1
  %exitcond.not = icmp eq i64 %16, %12
  br i1 %exitcond.not, label %._crit_edge, label %.lr.ph, !llvm.loop !9

._crit_edge:                                      ; preds = %.lr.ph, %10
  %17 = getelementptr inbounds i32, ptr %5, i64 %12
  %18 = load i32, ptr %17, align 4, !tbaa !5
  %19 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %0, ptr noundef nonnull @.str.45, i32 noundef %18) #3
  br label %20

20:                                               ; preds = %._crit_edge, %7
  %21 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %0, ptr noundef nonnull @.str.39) #3
  ret i32 1
}

attributes #0 = { 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 #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 = { 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 #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 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = distinct !{!9, !10}
!10 = !{!"llvm.loop.mustprogress"}


; Effective O3 passes: CorrelatedValuePropagationPass,GVNPass,GlobalOptPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,LCSSAPass,LICMPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass,TailCallElimPass