; LLVM IR from AngoraFuzzer/Angora :: llvm_mode/dfsan_rt/sanitizer_common (sanitizer_libc)

; 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 = external hidden unnamed_addr constant [107 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [19 x i8], align 1

; Function Attrs: mustprogress uwtable
define dso_local noundef i64 @_ZN11__sanitizer23internal_simple_strtollEPKcPPci(ptr noundef %0, ptr noundef %1, i32 noundef %2) #0 {
  %4 = alloca i64, align 8
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca i32, align 4
  %8 = alloca i64, align 8
  %9 = alloca i64, align 8
  %10 = alloca i32, align 4
  %11 = alloca i64, align 8
  %12 = alloca i8, align 1
  %13 = alloca ptr, align 8
  %14 = alloca i32, align 4
  %15 = alloca i32, align 4
  store ptr %0, ptr %5, align 8, !tbaa !5
  store ptr %1, ptr %6, align 8, !tbaa !5
  store i32 %2, ptr %7, align 4, !tbaa !9
  br label %16

16:                                               ; preds = %3
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #6
  %17 = load i32, ptr %7, align 4, !tbaa !9
  %18 = sext i32 %17 to i64
  store i64 %18, ptr %8, align 8, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #6
  store i64 10, ptr %9, align 8, !tbaa !11
  %19 = load i64, ptr %8, align 8, !tbaa !11
  %20 = load i64, ptr %9, align 8, !tbaa !11
  %21 = icmp eq i64 %19, %20
  %22 = xor i1 %21, true
  %23 = xor i1 %22, true
  %24 = xor i1 %23, true
  %25 = zext i1 %24 to i64
  %26 = call i64 @llvm.expect.i64(i64 %25, i64 0)
  %27 = icmp ne i64 %26, 0
  br i1 %27, label %28, label %31

28:                                               ; preds = %16
  %29 = load i64, ptr %8, align 8, !tbaa !11
  %30 = load i64, ptr %9, align 8, !tbaa !11
  call void @_ZN11__sanitizer11CheckFailedEPKciS1_yy(ptr noundef @.str, i32 noundef 244, ptr noundef @.str.3, i64 noundef %29, i64 noundef %30) #7
  unreachable

31:                                               ; preds = %16
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #6
  br label %32

32:                                               ; preds = %31
  br label %33

33:                                               ; preds = %38, %32
  %34 = load ptr, ptr %5, align 8, !tbaa !5
  %35 = load i8, ptr %34, align 1, !tbaa !13
  %36 = sext i8 %35 to i32
  %37 = call noundef zeroext i1 @_ZN11__sanitizer7IsSpaceEi(i32 noundef %36)
  br i1 %37, label %38, label %41

38:                                               ; preds = %33
  %39 = load ptr, ptr %5, align 8, !tbaa !5
  %40 = getelementptr inbounds i8, ptr %39, i32 1
  store ptr %40, ptr %5, align 8, !tbaa !5
  br label %33, !llvm.loop !14

41:                                               ; preds = %33
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #6
  store i32 1, ptr %10, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %11) #6
  store i64 0, ptr %11, align 8, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 1, ptr %12) #6
  store i8 0, ptr %12, align 1, !tbaa !16
  call void @llvm.lifetime.start.p0(i64 8, ptr %13) #6
  %42 = load ptr, ptr %5, align 8, !tbaa !5
  store ptr %42, ptr %13, align 8, !tbaa !5
  %43 = load ptr, ptr %5, align 8, !tbaa !5
  %44 = load i8, ptr %43, align 1, !tbaa !13
  %45 = sext i8 %44 to i32
  %46 = icmp eq i32 %45, 43
  br i1 %46, label %47, label %50

47:                                               ; preds = %41
  store i32 1, ptr %10, align 4, !tbaa !9
  %48 = load ptr, ptr %5, align 8, !tbaa !5
  %49 = getelementptr inbounds i8, ptr %48, i32 1
  store ptr %49, ptr %5, align 8, !tbaa !5
  br label %59

50:                                               ; preds = %41
  %51 = load ptr, ptr %5, align 8, !tbaa !5
  %52 = load i8, ptr %51, align 1, !tbaa !13
  %53 = sext i8 %52 to i32
  %54 = icmp eq i32 %53, 45
  br i1 %54, label %55, label %58

55:                                               ; preds = %50
  store i32 -1, ptr %10, align 4, !tbaa !9
  %56 = load ptr, ptr %5, align 8, !tbaa !5
  %57 = getelementptr inbounds i8, ptr %56, i32 1
  store ptr %57, ptr %5, align 8, !tbaa !5
  br label %58

58:                                               ; preds = %55, %50
  br label %59

59:                                               ; preds = %58, %47
  br label %60

60:                                               ; preds = %89, %59
  %61 = load ptr, ptr %5, align 8, !tbaa !5
  %62 = load i8, ptr %61, align 1, !tbaa !13
  %63 = sext i8 %62 to i32
  %64 = call noundef zeroext i1 @_ZN11__sanitizer7IsDigitEi(i32 noundef %63)
  br i1 %64, label %65, label %93

65:                                               ; preds = %60
  %66 = load i64, ptr %11, align 8, !tbaa !11
  %67 = icmp ule i64 %66, 1844674407370955161
  br i1 %67, label %68, label %71

68:                                               ; preds = %65
  %69 = load i64, ptr %11, align 8, !tbaa !11
  %70 = mul i64 %69, 10
  br label %72

71:                                               ; preds = %65
  br label %72

72:                                               ; preds = %71, %68
  %73 = phi i64 [ %70, %68 ], [ -1, %71 ]
  store i64 %73, ptr %11, align 8, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 4, ptr %14) #6
  %74 = load ptr, ptr %5, align 8, !tbaa !5
  %75 = load i8, ptr %74, align 1, !tbaa !13
  %76 = sext i8 %75 to i32
  %77 = sub nsw i32 %76, 48
  store i32 %77, ptr %14, align 4, !tbaa !9
  %78 = load i64, ptr %11, align 8, !tbaa !11
  %79 = load i32, ptr %14, align 4, !tbaa !9
  %80 = sext i32 %79 to i64
  %81 = sub i64 -1, %80
  %82 = icmp ule i64 %78, %81
  br i1 %82, label %83, label %88

83:                                               ; preds = %72
  %84 = load i64, ptr %11, align 8, !tbaa !11
  %85 = load i32, ptr %14, align 4, !tbaa !9
  %86 = sext i32 %85 to i64
  %87 = add i64 %84, %86
  br label %89

88:                                               ; preds = %72
  br label %89

89:                                               ; preds = %88, %83
  %90 = phi i64 [ %87, %83 ], [ -1, %88 ]
  store i64 %90, ptr %11, align 8, !tbaa !11
  store i8 1, ptr %12, align 1, !tbaa !16
  %91 = load ptr, ptr %5, align 8, !tbaa !5
  %92 = getelementptr inbounds i8, ptr %91, i32 1
  store ptr %92, ptr %5, align 8, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 4, ptr %14) #6
  br label %60, !llvm.loop !18

93:                                               ; preds = %60
  %94 = load ptr, ptr %6, align 8, !tbaa !5
  %95 = icmp ne ptr %94, null
  br i1 %95, label %96, label %106

96:                                               ; preds = %93
  %97 = load i8, ptr %12, align 1, !tbaa !16, !range !19, !noundef !20
  %98 = trunc i8 %97 to i1
  br i1 %98, label %99, label %101

99:                                               ; preds = %96
  %100 = load ptr, ptr %5, align 8, !tbaa !5
  br label %103

101:                                              ; preds = %96
  %102 = load ptr, ptr %13, align 8, !tbaa !5
  br label %103

103:                                              ; preds = %101, %99
  %104 = phi ptr [ %100, %99 ], [ %102, %101 ]
  %105 = load ptr, ptr %6, align 8, !tbaa !5
  store ptr %104, ptr %105, align 8, !tbaa !5
  br label %106

106:                                              ; preds = %103, %93
  %107 = load i32, ptr %10, align 4, !tbaa !9
  %108 = icmp sgt i32 %107, 0
  br i1 %108, label %109, label %112

109:                                              ; preds = %106
  %110 = load i64, ptr %11, align 8, !tbaa !11
  %111 = call noundef i64 @_ZN11__sanitizer3MinIyEET_S1_S1_(i64 noundef 9223372036854775807, i64 noundef %110)
  store i64 %111, ptr %4, align 8
  store i32 1, ptr %15, align 4
  br label %121

112:                                              ; preds = %106
  %113 = load i64, ptr %11, align 8, !tbaa !11
  %114 = icmp ugt i64 %113, 9223372036854775807
  br i1 %114, label %115, label %116

115:                                              ; preds = %112
  br label %119

116:                                              ; preds = %112
  %117 = load i64, ptr %11, align 8, !tbaa !11
  %118 = mul nsw i64 %117, -1
  br label %119

119:                                              ; preds = %116, %115
  %120 = phi i64 [ -9223372036854775808, %115 ], [ %118, %116 ]
  store i64 %120, ptr %4, align 8
  store i32 1, ptr %15, align 4
  br label %121

121:                                              ; preds = %119, %109
  call void @llvm.lifetime.end.p0(i64 8, ptr %13) #6
  call void @llvm.lifetime.end.p0(i64 1, ptr %12) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #6
  %122 = load i64, ptr %4, align 8
  ret i64 %122
}

; 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

; Function Attrs: nocallback nofree nosync nounwind willreturn memory(none)
declare i64 @llvm.expect.i64(i64, i64) #2

; Function Attrs: noreturn
declare void @_ZN11__sanitizer11CheckFailedEPKciS1_yy(ptr noundef, i32 noundef, ptr noundef, i64 noundef, i64 noundef) #3

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef zeroext i1 @_ZN11__sanitizer7IsSpaceEi(i32 noundef) #4

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef zeroext i1 @_ZN11__sanitizer7IsDigitEi(i32 noundef) #4

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef i64 @_ZN11__sanitizer3MinIyEET_S1_S1_(i64 noundef, i64 noundef) #5

attributes #0 = { mustprogress 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 = { nocallback nofree nosync nounwind willreturn memory(none) }
attributes #3 = { noreturn "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 = { inlinehint mustprogress 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 #5 = { mustprogress 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 #6 = { nounwind }
attributes #7 = { noreturn }

!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++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"int", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"long long", !7, i64 0}
!13 = !{!7, !7, i64 0}
!14 = distinct !{!14, !15}
!15 = !{!"llvm.loop.mustprogress"}
!16 = !{!17, !17, i64 0}
!17 = !{!"bool", !7, i64 0}
!18 = distinct !{!18, !15}
!19 = !{i8 0, i8 2}
!20 = !{}


; 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 = external hidden unnamed_addr constant [107 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [19 x i8], align 1

; Function Attrs: mustprogress uwtable
define dso_local noundef i64 @_ZN11__sanitizer23internal_simple_strtollEPKcPPci(ptr noundef %0, ptr noundef writeonly %1, i32 noundef %2) local_unnamed_addr #0 {
  %.not = icmp eq i32 %2, 10
  br i1 %.not, label %.preheader, label %4, !prof !5

4:                                                ; preds = %3
  %5 = sext i32 %2 to i64
  tail call void @_ZN11__sanitizer11CheckFailedEPKciS1_yy(ptr noundef nonnull @.str, i32 noundef 244, ptr noundef nonnull @.str.3, i64 noundef %5, i64 noundef 10) #4
  unreachable

.preheader:                                       ; preds = %3, %.preheader
  %.030 = phi ptr [ %9, %.preheader ], [ %0, %3 ]
  %6 = load i8, ptr %.030, align 1, !tbaa !6
  %7 = sext i8 %6 to i32
  %8 = tail call noundef zeroext i1 @_ZN11__sanitizer7IsSpaceEi(i32 noundef %7)
  %9 = getelementptr inbounds i8, ptr %.030, i64 1
  br i1 %8, label %.preheader, label %10, !llvm.loop !9

10:                                               ; preds = %.preheader
  %11 = load i8, ptr %.030, align 1, !tbaa !6
  switch i8 %11, label %14 [
    i8 43, label %12
    i8 45, label %13
  ]

12:                                               ; preds = %10
  br label %14

13:                                               ; preds = %10
  br label %14

14:                                               ; preds = %10, %13, %12
  %15 = phi i1 [ true, %12 ], [ false, %13 ], [ true, %10 ]
  %.1 = phi ptr [ %9, %12 ], [ %9, %13 ], [ %.030, %10 ]
  %16 = load i8, ptr %.1, align 1, !tbaa !6
  %17 = sext i8 %16 to i32
  %18 = tail call noundef zeroext i1 @_ZN11__sanitizer7IsDigitEi(i32 noundef %17)
  br i1 %18, label %.lr.ph, label %._crit_edge

.lr.ph:                                           ; preds = %14, %.lr.ph
  %.239 = phi ptr [ %28, %.lr.ph ], [ %.1, %14 ]
  %.03238 = phi i64 [ %27, %.lr.ph ], [ 0, %14 ]
  %19 = icmp ult i64 %.03238, 1844674407370955162
  %20 = mul i64 %.03238, 10
  %21 = select i1 %19, i64 %20, i64 -1
  %22 = load i8, ptr %.239, align 1, !tbaa !6
  %23 = sext i8 %22 to i64
  %24 = sub nsw i64 47, %23
  %.not37 = icmp ugt i64 %21, %24
  %25 = add i64 %21, -48
  %26 = add i64 %25, %23
  %27 = select i1 %.not37, i64 -1, i64 %26
  %28 = getelementptr inbounds i8, ptr %.239, i64 1
  %29 = load i8, ptr %28, align 1, !tbaa !6
  %30 = sext i8 %29 to i32
  %31 = tail call noundef zeroext i1 @_ZN11__sanitizer7IsDigitEi(i32 noundef %30)
  br i1 %31, label %.lr.ph, label %._crit_edge, !llvm.loop !11

._crit_edge:                                      ; preds = %.lr.ph, %14
  %32 = phi ptr [ %.030, %14 ], [ %28, %.lr.ph ]
  %.032.lcssa = phi i64 [ 0, %14 ], [ %27, %.lr.ph ]
  %.not36 = icmp eq ptr %1, null
  br i1 %.not36, label %34, label %33

33:                                               ; preds = %._crit_edge
  store ptr %32, ptr %1, align 8, !tbaa !12
  br label %34

34:                                               ; preds = %33, %._crit_edge
  br i1 %15, label %35, label %37

35:                                               ; preds = %34
  %36 = tail call noundef i64 @_ZN11__sanitizer3MinIyEET_S1_S1_(i64 noundef 9223372036854775807, i64 noundef %.032.lcssa)
  br label %41

37:                                               ; preds = %34
  %38 = icmp slt i64 %.032.lcssa, 0
  %39 = sub nsw i64 0, %.032.lcssa
  %40 = select i1 %38, i64 -9223372036854775808, i64 %39
  br label %41

41:                                               ; preds = %37, %35
  %.0 = phi i64 [ %36, %35 ], [ %40, %37 ]
  ret i64 %.0
}

; Function Attrs: noreturn
declare void @_ZN11__sanitizer11CheckFailedEPKciS1_yy(ptr noundef, i32 noundef, ptr noundef, i64 noundef, i64 noundef) local_unnamed_addr #1

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef zeroext i1 @_ZN11__sanitizer7IsSpaceEi(i32 noundef) local_unnamed_addr #2

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef zeroext i1 @_ZN11__sanitizer7IsDigitEi(i32 noundef) local_unnamed_addr #2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef i64 @_ZN11__sanitizer3MinIyEET_S1_S1_(i64 noundef, i64 noundef) local_unnamed_addr #3

attributes #0 = { mustprogress 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 = { noreturn "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 mustprogress 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 = { mustprogress 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 = { noreturn }

!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 = !{!"branch_weights", !"expected", i32 2000, i32 1}
!6 = !{!7, !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = distinct !{!9, !10}
!10 = !{!"llvm.loop.mustprogress"}
!11 = distinct !{!11, !10}
!12 = !{!13, !13, i64 0}
!13 = !{!"any pointer", !7, i64 0}


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