; LLVM IR from AngoraFuzzer/Angora :: llvm_mode/dfsan_rt/sanitizer_common/sanitizer_linux.ll/ZN11 (sanitizer6GetEnvEPKc)

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

@_ZZN11__sanitizer6GetEnvEPKcE7environ = external hidden global ptr, align 8
@_ZZN11__sanitizer6GetEnvEPKcE3len = external hidden global i64, align 8
@_ZZN11__sanitizer6GetEnvEPKcE6inited = external hidden global i8, align 1
@.str = external hidden unnamed_addr constant [19 x i8], align 1

; 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: mustprogress uwtable
define dso_local noundef ptr @_ZN11__sanitizer6GetEnvEPKc(ptr noundef %0) #1 {
  %2 = alloca ptr, align 8
  %3 = alloca ptr, align 8
  %4 = alloca i64, align 8
  %5 = alloca i64, align 8
  %6 = alloca ptr, align 8
  %7 = alloca ptr, align 8
  %8 = alloca i32, align 4
  store ptr %0, ptr %3, align 8, !tbaa !5
  %9 = load i8, ptr @_ZZN11__sanitizer6GetEnvEPKcE6inited, align 1, !tbaa !9, !range !11, !noundef !12
  %10 = trunc i8 %9 to i1
  br i1 %10, label %15, label %11

11:                                               ; preds = %1
  store i8 1, ptr @_ZZN11__sanitizer6GetEnvEPKcE6inited, align 1, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %4) #3
  %12 = call noundef zeroext i1 @_ZN11__sanitizer16ReadFileToBufferEPKcPPcPmS4_mPi(ptr noundef @.str, ptr noundef @_ZZN11__sanitizer6GetEnvEPKcE7environ, ptr noundef %4, ptr noundef @_ZZN11__sanitizer6GetEnvEPKcE3len, i64 noundef 67108864, ptr noundef null)
  br i1 %12, label %14, label %13

13:                                               ; preds = %11
  store ptr null, ptr @_ZZN11__sanitizer6GetEnvEPKcE7environ, align 8, !tbaa !5
  br label %14

14:                                               ; preds = %13, %11
  call void @llvm.lifetime.end.p0(i64 8, ptr %4) #3
  br label %15

15:                                               ; preds = %14, %1
  %16 = load ptr, ptr @_ZZN11__sanitizer6GetEnvEPKcE7environ, align 8, !tbaa !5
  %17 = icmp ne ptr %16, null
  br i1 %17, label %18, label %21

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

21:                                               ; preds = %18, %15
  store ptr null, ptr %2, align 8
  br label %71

22:                                               ; preds = %18
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #3
  %23 = load ptr, ptr %3, align 8, !tbaa !5
  %24 = call noundef i64 @_ZN11__sanitizer15internal_strlenEPKc(ptr noundef %23)
  store i64 %24, ptr %5, align 8, !tbaa !13
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #3
  %25 = load ptr, ptr @_ZZN11__sanitizer6GetEnvEPKcE7environ, align 8, !tbaa !5
  store ptr %25, ptr %6, align 8, !tbaa !5
  br label %26

26:                                               ; preds = %68, %22
  %27 = load ptr, ptr %6, align 8, !tbaa !5
  %28 = load i8, ptr %27, align 1, !tbaa !15
  %29 = sext i8 %28 to i32
  %30 = icmp ne i32 %29, 0
  br i1 %30, label %31, label %69

31:                                               ; preds = %26
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #3
  %32 = load ptr, ptr %6, align 8, !tbaa !5
  %33 = load i64, ptr @_ZZN11__sanitizer6GetEnvEPKcE3len, align 8, !tbaa !13
  %34 = load ptr, ptr %6, align 8, !tbaa !5
  %35 = load ptr, ptr @_ZZN11__sanitizer6GetEnvEPKcE7environ, align 8, !tbaa !5
  %36 = ptrtoint ptr %34 to i64
  %37 = ptrtoint ptr %35 to i64
  %38 = sub i64 %36, %37
  %39 = sub i64 %33, %38
  %40 = call noundef ptr @_ZN11__sanitizer15internal_memchrEPKvim(ptr noundef %32, i32 noundef 0, i64 noundef %39)
  store ptr %40, ptr %7, align 8, !tbaa !5
  %41 = load ptr, ptr %7, align 8, !tbaa !5
  %42 = icmp ne ptr %41, null
  br i1 %42, label %44, label %43

43:                                               ; preds = %31
  store ptr null, ptr %2, align 8
  store i32 1, ptr %8, align 4
  br label %66

44:                                               ; preds = %31
  %45 = load ptr, ptr %6, align 8, !tbaa !5
  %46 = load ptr, ptr %3, align 8, !tbaa !5
  %47 = load i64, ptr %5, align 8, !tbaa !13
  %48 = call noundef i32 @_ZN11__sanitizer15internal_memcmpEPKvS1_m(ptr noundef %45, ptr noundef %46, i64 noundef %47)
  %49 = icmp ne i32 %48, 0
  br i1 %49, label %62, label %50

50:                                               ; preds = %44
  %51 = load ptr, ptr %6, align 8, !tbaa !5
  %52 = load i64, ptr %5, align 8, !tbaa !13
  %53 = getelementptr inbounds i8, ptr %51, i64 %52
  %54 = load i8, ptr %53, align 1, !tbaa !15
  %55 = sext i8 %54 to i32
  %56 = icmp eq i32 %55, 61
  br i1 %56, label %57, label %62

57:                                               ; preds = %50
  %58 = load ptr, ptr %6, align 8, !tbaa !5
  %59 = load i64, ptr %5, align 8, !tbaa !13
  %60 = getelementptr inbounds i8, ptr %58, i64 %59
  %61 = getelementptr inbounds i8, ptr %60, i64 1
  store ptr %61, ptr %2, align 8
  store i32 1, ptr %8, align 4
  br label %66

62:                                               ; preds = %50, %44
  br label %63

63:                                               ; preds = %62
  %64 = load ptr, ptr %7, align 8, !tbaa !5
  %65 = getelementptr inbounds i8, ptr %64, i64 1
  store ptr %65, ptr %6, align 8, !tbaa !5
  store i32 0, ptr %8, align 4
  br label %66

66:                                               ; preds = %63, %57, %43
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #3
  %67 = load i32, ptr %8, align 4
  switch i32 %67, label %70 [
    i32 0, label %68
  ]

68:                                               ; preds = %66
  br label %26, !llvm.loop !16

69:                                               ; preds = %26
  store ptr null, ptr %2, align 8
  store i32 1, ptr %8, align 4
  br label %70

70:                                               ; preds = %69, %66
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #3
  br label %71

71:                                               ; preds = %70, %21
  %72 = load ptr, ptr %2, align 8
  ret ptr %72
}

declare noundef zeroext i1 @_ZN11__sanitizer16ReadFileToBufferEPKcPPcPmS4_mPi(ptr noundef, ptr noundef, ptr noundef, ptr noundef, i64 noundef, ptr noundef) #2

declare noundef i64 @_ZN11__sanitizer15internal_strlenEPKc(ptr noundef) #2

declare noundef ptr @_ZN11__sanitizer15internal_memchrEPKvim(ptr noundef, i32 noundef, i64 noundef) #2

declare noundef i32 @_ZN11__sanitizer15internal_memcmpEPKvS1_m(ptr noundef, ptr noundef, i64 noundef) #2

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { 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 #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 }

!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 = !{!"bool", !7, i64 0}
!11 = !{i8 0, i8 2}
!12 = !{}
!13 = !{!14, !14, i64 0}
!14 = !{!"long", !7, i64 0}
!15 = !{!7, !7, i64 0}
!16 = distinct !{!16, !17}
!17 = !{!"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"

@_ZZN11__sanitizer6GetEnvEPKcE7environ = external hidden global ptr, align 8
@_ZZN11__sanitizer6GetEnvEPKcE3len = external hidden global i64, align 8
@_ZZN11__sanitizer6GetEnvEPKcE6inited = external hidden local_unnamed_addr global i8, align 1
@.str = external hidden unnamed_addr constant [19 x i8], align 1

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

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

; Function Attrs: mustprogress uwtable
define dso_local noundef ptr @_ZN11__sanitizer6GetEnvEPKc(ptr noundef %0) local_unnamed_addr #1 {
  %2 = alloca i64, align 8
  %3 = load i8, ptr @_ZZN11__sanitizer6GetEnvEPKcE6inited, align 1, !tbaa !5, !range !9, !noundef !10
  %4 = trunc nuw i8 %3 to i1
  br i1 %4, label %9, label %5

5:                                                ; preds = %1
  store i8 1, ptr @_ZZN11__sanitizer6GetEnvEPKcE6inited, align 1, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %2) #3
  %6 = call noundef zeroext i1 @_ZN11__sanitizer16ReadFileToBufferEPKcPPcPmS4_mPi(ptr noundef nonnull @.str, ptr noundef nonnull @_ZZN11__sanitizer6GetEnvEPKcE7environ, ptr noundef nonnull %2, ptr noundef nonnull @_ZZN11__sanitizer6GetEnvEPKcE3len, i64 noundef 67108864, ptr noundef null)
  br i1 %6, label %8, label %7

7:                                                ; preds = %5
  store ptr null, ptr @_ZZN11__sanitizer6GetEnvEPKcE7environ, align 8, !tbaa !11
  br label %8

8:                                                ; preds = %7, %5
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %2) #3
  br label %9

9:                                                ; preds = %8, %1
  %10 = load ptr, ptr @_ZZN11__sanitizer6GetEnvEPKcE7environ, align 8, !tbaa !11
  %11 = icmp eq ptr %10, null
  %12 = load i64, ptr @_ZZN11__sanitizer6GetEnvEPKcE3len, align 8
  %13 = icmp eq i64 %12, 0
  %or.cond = select i1 %11, i1 true, i1 %13
  br i1 %or.cond, label %.thread, label %14

14:                                               ; preds = %9
  %15 = call noundef i64 @_ZN11__sanitizer15internal_strlenEPKc(ptr noundef %0)
  %16 = load ptr, ptr @_ZZN11__sanitizer6GetEnvEPKcE7environ, align 8, !tbaa !11
  %17 = load i8, ptr %16, align 1, !tbaa !13
  %.not25 = icmp eq i8 %17, 0
  br i1 %.not25, label %.thread, label %.lr.ph

.lr.ph:                                           ; preds = %14, %33
  %.01626 = phi ptr [ %34, %33 ], [ %16, %14 ]
  %18 = load i64, ptr @_ZZN11__sanitizer6GetEnvEPKcE3len, align 8, !tbaa !14
  %19 = load ptr, ptr @_ZZN11__sanitizer6GetEnvEPKcE7environ, align 8, !tbaa !11
  %20 = ptrtoint ptr %.01626 to i64
  %21 = ptrtoint ptr %19 to i64
  %.neg = sub i64 %18, %20
  %22 = add i64 %.neg, %21
  %23 = call noundef ptr @_ZN11__sanitizer15internal_memchrEPKvim(ptr noundef nonnull %.01626, i32 noundef 0, i64 noundef %22)
  %.not19 = icmp eq ptr %23, null
  br i1 %.not19, label %.thread, label %24

24:                                               ; preds = %.lr.ph
  %25 = call noundef i32 @_ZN11__sanitizer15internal_memcmpEPKvS1_m(ptr noundef nonnull %.01626, ptr noundef %0, i64 noundef %15)
  %.not20 = icmp eq i32 %25, 0
  br i1 %.not20, label %26, label %33

26:                                               ; preds = %24
  %27 = getelementptr inbounds i8, ptr %.01626, i64 %15
  %28 = load i8, ptr %27, align 1, !tbaa !13
  %29 = icmp eq i8 %28, 61
  br i1 %29, label %30, label %33

30:                                               ; preds = %26
  %31 = getelementptr inbounds i8, ptr %.01626, i64 %15
  %32 = getelementptr inbounds i8, ptr %31, i64 1
  br label %.thread

33:                                               ; preds = %26, %24
  %34 = getelementptr inbounds i8, ptr %23, i64 1
  %35 = load i8, ptr %34, align 1, !tbaa !13
  %.not = icmp eq i8 %35, 0
  br i1 %.not, label %.thread, label %.lr.ph, !llvm.loop !16

.thread:                                          ; preds = %33, %.lr.ph, %14, %30, %9
  %.3 = phi ptr [ null, %9 ], [ %32, %30 ], [ null, %14 ], [ null, %.lr.ph ], [ null, %33 ]
  ret ptr %.3
}

declare noundef zeroext i1 @_ZN11__sanitizer16ReadFileToBufferEPKcPPcPmS4_mPi(ptr noundef, ptr noundef, ptr noundef, ptr noundef, i64 noundef, ptr noundef) local_unnamed_addr #2

declare noundef i64 @_ZN11__sanitizer15internal_strlenEPKc(ptr noundef) local_unnamed_addr #2

declare noundef ptr @_ZN11__sanitizer15internal_memchrEPKvim(ptr noundef, i32 noundef, i64 noundef) local_unnamed_addr #2

declare noundef i32 @_ZN11__sanitizer15internal_memcmpEPKvS1_m(ptr noundef, ptr noundef, i64 noundef) local_unnamed_addr #2

attributes #0 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { 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 #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 }

!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 = !{!"bool", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{i8 0, i8 2}
!10 = !{}
!11 = !{!12, !12, i64 0}
!12 = !{!"any pointer", !7, i64 0}
!13 = !{!7, !7, i64 0}
!14 = !{!15, !15, i64 0}
!15 = !{!"long", !7, i64 0}
!16 = distinct !{!16, !17}
!17 = !{!"llvm.loop.mustprogress"}


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