; LLVM IR from Montimage/mmt-security :: src/lib/expression.ll (parse_a_proto_name)

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

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

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

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

18:                                               ; preds = %4
  %19 = load i64, ptr %8, align 8, !tbaa !9
  %20 = icmp eq i64 %19, 0
  br i1 %20, label %21, label %22

21:                                               ; preds = %18, %4
  store i64 0, ptr %5, align 8
  store i32 1, ptr %13, align 4
  br label %96

22:                                               ; preds = %18
  %23 = load ptr, ptr %7, align 8, !tbaa !5
  %24 = load i64, ptr %8, align 8, !tbaa !9
  %25 = call i64 @_jump_space(ptr noundef %23, i64 noundef %24)
  store i64 %25, ptr %11, align 8, !tbaa !9
  %26 = load i64, ptr %11, align 8, !tbaa !9
  %27 = load i64, ptr %8, align 8, !tbaa !9
  %28 = icmp eq i64 %26, %27
  br i1 %28, label %29, label %31

29:                                               ; preds = %22
  %30 = load i64, ptr %11, align 8, !tbaa !9
  store i64 %30, ptr %5, align 8
  store i32 1, ptr %13, align 4
  br label %96

31:                                               ; preds = %22
  %32 = load ptr, ptr %7, align 8, !tbaa !5
  %33 = load i64, ptr %11, align 8, !tbaa !9
  %34 = getelementptr inbounds i8, ptr %32, i64 %33
  store ptr %34, ptr %12, align 8, !tbaa !5
  %35 = load i8, ptr %9, align 1, !tbaa !11, !range !13, !noundef !14
  %36 = trunc i8 %35 to i1
  br i1 %36, label %57, label %37

37:                                               ; preds = %31
  %38 = call ptr @__ctype_b_loc() #5
  %39 = load ptr, ptr %38, align 8, !tbaa !5
  %40 = load ptr, ptr %12, align 8, !tbaa !5
  %41 = load i8, ptr %40, align 1, !tbaa !15
  %42 = sext i8 %41 to i32
  %43 = sext i32 %42 to i64
  %44 = getelementptr inbounds i16, ptr %39, i64 %43
  %45 = load i16, ptr %44, align 2, !tbaa !16
  %46 = zext i16 %45 to i32
  %47 = and i32 %46, 1024
  %48 = icmp ne i32 %47, 0
  br i1 %48, label %56, label %49

49:                                               ; preds = %37
  %50 = load ptr, ptr %12, align 8, !tbaa !5
  %51 = load i8, ptr %50, align 1, !tbaa !15
  %52 = sext i8 %51 to i32
  %53 = icmp eq i32 %52, 95
  br i1 %53, label %56, label %54

54:                                               ; preds = %49
  %55 = load i64, ptr %11, align 8, !tbaa !9
  store i64 %55, ptr %5, align 8
  store i32 1, ptr %13, align 4
  br label %96

56:                                               ; preds = %49, %37
  br label %57

57:                                               ; preds = %56, %31
  br label %58

58:                                               ; preds = %85, %57
  %59 = call ptr @__ctype_b_loc() #5
  %60 = load ptr, ptr %59, align 8, !tbaa !5
  %61 = load ptr, ptr %12, align 8, !tbaa !5
  %62 = load i64, ptr %10, align 8, !tbaa !9
  %63 = getelementptr inbounds i8, ptr %61, i64 %62
  %64 = load i8, ptr %63, align 1, !tbaa !15
  %65 = sext i8 %64 to i32
  %66 = sext i32 %65 to i64
  %67 = getelementptr inbounds i16, ptr %60, i64 %66
  %68 = load i16, ptr %67, align 2, !tbaa !16
  %69 = zext i16 %68 to i32
  %70 = and i32 %69, 8
  %71 = icmp ne i32 %70, 0
  br i1 %71, label %79, label %72

72:                                               ; preds = %58
  %73 = load ptr, ptr %12, align 8, !tbaa !5
  %74 = load i64, ptr %10, align 8, !tbaa !9
  %75 = getelementptr inbounds i8, ptr %73, i64 %74
  %76 = load i8, ptr %75, align 1, !tbaa !15
  %77 = sext i8 %76 to i32
  %78 = icmp eq i32 %77, 95
  br i1 %78, label %79, label %83

79:                                               ; preds = %72, %58
  %80 = load i64, ptr %11, align 8, !tbaa !9
  %81 = load i64, ptr %8, align 8, !tbaa !9
  %82 = icmp ult i64 %80, %81
  br label %83

83:                                               ; preds = %79, %72
  %84 = phi i1 [ false, %72 ], [ %82, %79 ]
  br i1 %84, label %85, label %90

85:                                               ; preds = %83
  %86 = load i64, ptr %10, align 8, !tbaa !9
  %87 = add i64 %86, 1
  store i64 %87, ptr %10, align 8, !tbaa !9
  %88 = load i64, ptr %11, align 8, !tbaa !9
  %89 = add i64 %88, 1
  store i64 %89, ptr %11, align 8, !tbaa !9
  br label %58, !llvm.loop !18

90:                                               ; preds = %83
  %91 = load ptr, ptr %12, align 8, !tbaa !5
  %92 = load i64, ptr %10, align 8, !tbaa !9
  %93 = call ptr @mmt_mem_dup(ptr noundef %91, i64 noundef %92)
  %94 = load ptr, ptr %6, align 8, !tbaa !5
  store ptr %93, ptr %94, align 8, !tbaa !5
  %95 = load i64, ptr %11, align 8, !tbaa !9
  store i64 %95, ptr %5, align 8
  store i32 1, ptr %13, align 4
  br label %96

96:                                               ; preds = %90, %54, %29, %21
  call void @llvm.lifetime.end.p0(i64 8, ptr %12) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #4
  %97 = load i64, ptr %5, align 8
  ret i64 %97
}

; Function Attrs: inlinehint nounwind uwtable
declare hidden i64 @_jump_space(ptr noundef, i64 noundef) #2

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

; Function Attrs: inlinehint nounwind uwtable
declare hidden ptr @mmt_mem_dup(ptr noundef, i64 noundef) #2

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { 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 #2 = { inlinehint 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 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, !10, i64 0}
!10 = !{!"long", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"_Bool", !7, i64 0}
!13 = !{i8 0, i8 2}
!14 = !{}
!15 = !{!7, !7, i64 0}
!16 = !{!17, !17, i64 0}
!17 = !{!"short", !7, i64 0}
!18 = distinct !{!18, !19}
!19 = !{!"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"

; Function Attrs: nounwind uwtable
define dso_local i64 @_parse_a_proto_name(ptr nocapture noundef writeonly %0, ptr noundef %1, i64 noundef %2, i1 noundef zeroext %3) local_unnamed_addr #0 {
  store ptr null, ptr %0, align 8, !tbaa !5
  %5 = icmp eq ptr %1, null
  %6 = icmp eq i64 %2, 0
  %or.cond = or i1 %5, %6
  br i1 %or.cond, label %37, label %7

7:                                                ; preds = %4
  %8 = tail call i64 @_jump_space(ptr noundef nonnull %1, i64 noundef %2)
  %9 = icmp eq i64 %8, %2
  br i1 %9, label %37, label %10

10:                                               ; preds = %7
  %11 = getelementptr inbounds i8, ptr %1, i64 %8
  %.pre = load i8, ptr %11, align 1, !tbaa !9
  %.pre43 = tail call ptr @__ctype_b_loc() #3
  br i1 %3, label %._crit_edge, label %12

._crit_edge:                                      ; preds = %10
  %.pre44 = sext i8 %.pre to i64
  br label %19

12:                                               ; preds = %10
  %13 = load ptr, ptr %.pre43, align 8, !tbaa !5
  %14 = sext i8 %.pre to i64
  %15 = getelementptr inbounds i16, ptr %13, i64 %14
  %16 = load i16, ptr %15, align 2, !tbaa !10
  %17 = and i16 %16, 1024
  %.not = icmp ne i16 %17, 0
  %18 = icmp eq i8 %.pre, 95
  %or.cond33 = or i1 %18, %.not
  br i1 %or.cond33, label %19, label %37

19:                                               ; preds = %._crit_edge, %12
  %.pre-phi45 = phi i64 [ %.pre44, %._crit_edge ], [ %14, %12 ]
  %20 = load ptr, ptr %.pre43, align 8, !tbaa !5
  %21 = getelementptr inbounds i16, ptr %20, i64 %.pre-phi45
  %22 = load i16, ptr %21, align 2, !tbaa !10
  %23 = and i16 %22, 8
  %.not3236 = icmp ne i16 %23, 0
  %24 = icmp eq i8 %.pre, 95
  %or.cond3437 = or i1 %24, %.not3236
  %25 = icmp ult i64 %8, %2
  %or.cond3538 = and i1 %or.cond3437, %25
  br i1 %or.cond3538, label %.lr.ph, label %.critedge

.lr.ph:                                           ; preds = %19, %.lr.ph
  %.02740 = phi i64 [ %27, %.lr.ph ], [ %8, %19 ]
  %.02839 = phi i64 [ %26, %.lr.ph ], [ 0, %19 ]
  %26 = add i64 %.02839, 1
  %27 = add nuw i64 %.02740, 1
  %28 = getelementptr inbounds i8, ptr %11, i64 %26
  %29 = load i8, ptr %28, align 1, !tbaa !9
  %30 = sext i8 %29 to i64
  %31 = getelementptr inbounds i16, ptr %20, i64 %30
  %32 = load i16, ptr %31, align 2, !tbaa !10
  %33 = and i16 %32, 8
  %.not32 = icmp ne i16 %33, 0
  %34 = icmp eq i8 %29, 95
  %or.cond34 = or i1 %34, %.not32
  %35 = icmp ult i64 %27, %2
  %or.cond35 = select i1 %or.cond34, i1 %35, i1 false
  br i1 %or.cond35, label %.lr.ph, label %.critedge, !llvm.loop !12

.critedge:                                        ; preds = %.lr.ph, %19
  %.028.lcssa = phi i64 [ 0, %19 ], [ %26, %.lr.ph ]
  %.027.lcssa = phi i64 [ %8, %19 ], [ %27, %.lr.ph ]
  %36 = tail call ptr @mmt_mem_dup(ptr noundef nonnull %11, i64 noundef %.028.lcssa)
  store ptr %36, ptr %0, align 8, !tbaa !5
  br label %37

37:                                               ; preds = %12, %7, %4, %.critedge
  %.0 = phi i64 [ %.027.lcssa, %.critedge ], [ 0, %4 ], [ %2, %7 ], [ %8, %12 ]
  ret i64 %.0
}

; Function Attrs: inlinehint nounwind uwtable
declare hidden i64 @_jump_space(ptr noundef, i64 noundef) local_unnamed_addr #1

; Function Attrs: mustprogress nofree nosync nounwind willreturn memory(none)
declare ptr @__ctype_b_loc() local_unnamed_addr #2

; Function Attrs: inlinehint nounwind uwtable
declare hidden ptr @mmt_mem_dup(ptr noundef, i64 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 = { inlinehint 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 #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) }

!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 = !{!7, !7, i64 0}
!10 = !{!11, !11, i64 0}
!11 = !{!"short", !7, i64 0}
!12 = distinct !{!12, !13}
!13 = !{!"llvm.loop.mustprogress"}


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