; LLVM IR from dynexcoin/Dynex :: external/miniupnpc (testupnpreplyparse)

; 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.NameValueParserData = type { ptr, [64 x i8], ptr, i32, i32, ptr, i32 }

@stderr = external global ptr, align 8
@.str = external hidden unnamed_addr constant [41 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [47 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [14 x i8], align 1

; Function Attrs: nounwind uwtable
define dso_local i32 @test_parsing(ptr noundef %0, i32 noundef %1, ptr noundef %2) #0 {
  %4 = alloca ptr, align 8
  %5 = alloca i32, align 4
  %6 = alloca ptr, align 8
  %7 = alloca [1024 x i8], align 16
  %8 = alloca %struct.NameValueParserData, align 8
  %9 = alloca i32, align 4
  %10 = alloca ptr, align 8
  %11 = alloca ptr, align 8
  %12 = alloca ptr, align 8
  %13 = alloca i32, align 4
  %14 = alloca i32, align 4
  store ptr %0, ptr %4, align 8, !tbaa !5
  store i32 %1, ptr %5, align 4, !tbaa !9
  store ptr %2, ptr %6, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 1024, ptr %7) #5
  call void @llvm.lifetime.start.p0(i64 104, ptr %8) #5
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #5
  store i32 1, ptr %9, align 4, !tbaa !9
  %15 = load ptr, ptr %4, align 8, !tbaa !5
  %16 = load i32, ptr %5, align 4, !tbaa !9
  call void @ParseNameValue(ptr noundef %15, i32 noundef %16, ptr noundef %8)
  %17 = load ptr, ptr %6, align 8, !tbaa !5
  %18 = icmp ne ptr %17, null
  br i1 %18, label %19, label %100

19:                                               ; preds = %3
  br label %20

20:                                               ; preds = %98, %96, %19
  %21 = getelementptr inbounds [1024 x i8], ptr %7, i64 0, i64 0
  %22 = load ptr, ptr %6, align 8, !tbaa !5
  %23 = call ptr @fgets(ptr noundef %21, i32 noundef 1024, ptr noundef %22)
  %24 = icmp ne ptr %23, null
  br i1 %24, label %25, label %99

25:                                               ; preds = %20
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #5
  call void @llvm.lifetime.start.p0(i64 8, ptr %11) #5
  call void @llvm.lifetime.start.p0(i64 8, ptr %12) #5
  call void @llvm.lifetime.start.p0(i64 4, ptr %13) #5
  %26 = getelementptr inbounds [1024 x i8], ptr %7, i64 0, i64 0
  %27 = call i64 @strlen(ptr noundef %26) #6
  %28 = trunc i64 %27 to i32
  store i32 %28, ptr %13, align 4, !tbaa !9
  br label %29

29:                                               ; preds = %52, %25
  %30 = load i32, ptr %13, align 4, !tbaa !9
  %31 = icmp sgt i32 %30, 0
  br i1 %31, label %32, label %50

32:                                               ; preds = %29
  %33 = load i32, ptr %13, align 4, !tbaa !9
  %34 = sub nsw i32 %33, 1
  %35 = sext i32 %34 to i64
  %36 = getelementptr inbounds [1024 x i8], ptr %7, i64 0, i64 %35
  %37 = load i8, ptr %36, align 1, !tbaa !11
  %38 = sext i8 %37 to i32
  %39 = icmp eq i32 %38, 13
  br i1 %39, label %48, label %40

40:                                               ; preds = %32
  %41 = load i32, ptr %13, align 4, !tbaa !9
  %42 = sub nsw i32 %41, 1
  %43 = sext i32 %42 to i64
  %44 = getelementptr inbounds [1024 x i8], ptr %7, i64 0, i64 %43
  %45 = load i8, ptr %44, align 1, !tbaa !11
  %46 = sext i8 %45 to i32
  %47 = icmp eq i32 %46, 10
  br label %48

48:                                               ; preds = %40, %32
  %49 = phi i1 [ true, %32 ], [ %47, %40 ]
  br label %50

50:                                               ; preds = %48, %29
  %51 = phi i1 [ false, %29 ], [ %49, %48 ]
  br i1 %51, label %52, label %57

52:                                               ; preds = %50
  %53 = load i32, ptr %13, align 4, !tbaa !9
  %54 = add nsw i32 %53, -1
  store i32 %54, ptr %13, align 4, !tbaa !9
  %55 = sext i32 %54 to i64
  %56 = getelementptr inbounds [1024 x i8], ptr %7, i64 0, i64 %55
  store i8 0, ptr %56, align 1, !tbaa !11
  br label %29, !llvm.loop !12

57:                                               ; preds = %50
  %58 = load i32, ptr %13, align 4, !tbaa !9
  %59 = icmp eq i32 %58, 0
  br i1 %59, label %60, label %61

60:                                               ; preds = %57
  store i32 2, ptr %14, align 4
  br label %96, !llvm.loop !14

61:                                               ; preds = %57
  %62 = getelementptr inbounds [1024 x i8], ptr %7, i64 0, i64 0
  %63 = call ptr @strchr(ptr noundef %62, i32 noundef 61) #6
  store ptr %63, ptr %11, align 8, !tbaa !5
  %64 = load ptr, ptr %11, align 8, !tbaa !5
  %65 = icmp eq ptr %64, null
  br i1 %65, label %66, label %70

66:                                               ; preds = %61
  %67 = load ptr, ptr @stderr, align 8, !tbaa !5
  %68 = getelementptr inbounds [1024 x i8], ptr %7, i64 0, i64 0
  %69 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %67, ptr noundef @.str, ptr noundef %68) #5
  store i32 2, ptr %14, align 4
  br label %96, !llvm.loop !14

70:                                               ; preds = %61
  %71 = load ptr, ptr %11, align 8, !tbaa !5
  store i8 0, ptr %71, align 1, !tbaa !11
  %72 = load ptr, ptr %11, align 8, !tbaa !5
  %73 = getelementptr inbounds i8, ptr %72, i64 1
  store ptr %73, ptr %10, align 8, !tbaa !5
  %74 = getelementptr inbounds [1024 x i8], ptr %7, i64 0, i64 0
  %75 = call ptr @GetValueFromNameValueList(ptr noundef %8, ptr noundef %74)
  store ptr %75, ptr %12, align 8, !tbaa !5
  %76 = load ptr, ptr %12, align 8, !tbaa !5
  %77 = icmp eq ptr %76, null
  br i1 %77, label %83, label %78

78:                                               ; preds = %70
  %79 = load ptr, ptr %12, align 8, !tbaa !5
  %80 = load ptr, ptr %10, align 8, !tbaa !5
  %81 = call i32 @strcmp(ptr noundef %79, ptr noundef %80) #6
  %82 = icmp ne i32 %81, 0
  br i1 %82, label %83, label %95

83:                                               ; preds = %78, %70
  %84 = load ptr, ptr @stderr, align 8, !tbaa !5
  %85 = getelementptr inbounds [1024 x i8], ptr %7, i64 0, i64 0
  %86 = load ptr, ptr %10, align 8, !tbaa !5
  %87 = load ptr, ptr %12, align 8, !tbaa !5
  %88 = icmp ne ptr %87, null
  br i1 %88, label %89, label %91

89:                                               ; preds = %83
  %90 = load ptr, ptr %12, align 8, !tbaa !5
  br label %92

91:                                               ; preds = %83
  br label %92

92:                                               ; preds = %91, %89
  %93 = phi ptr [ %90, %89 ], [ @.str.2, %91 ]
  %94 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %84, ptr noundef @.str.1, ptr noundef %85, ptr noundef %86, ptr noundef %93) #5
  store i32 0, ptr %9, align 4, !tbaa !9
  br label %95

95:                                               ; preds = %92, %78
  store i32 0, ptr %14, align 4
  br label %96

96:                                               ; preds = %95, %66, %60
  call void @llvm.lifetime.end.p0(i64 4, ptr %13) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %12) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #5
  %97 = load i32, ptr %14, align 4
  switch i32 %97, label %102 [
    i32 0, label %98
    i32 2, label %20
  ]

98:                                               ; preds = %96
  br label %20, !llvm.loop !14

99:                                               ; preds = %20
  br label %100

100:                                              ; preds = %99, %3
  call void @ClearNameValueList(ptr noundef %8)
  %101 = load i32, ptr %9, align 4, !tbaa !9
  store i32 1, ptr %14, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #5
  call void @llvm.lifetime.end.p0(i64 104, ptr %8) #5
  call void @llvm.lifetime.end.p0(i64 1024, ptr %7) #5
  ret i32 %101

102:                                              ; preds = %96
  unreachable
}

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

declare void @ParseNameValue(ptr noundef, i32 noundef, ptr noundef) #2

declare ptr @fgets(ptr noundef, i32 noundef, ptr noundef) #2

; Function Attrs: nounwind willreturn memory(read)
declare i64 @strlen(ptr noundef) #3

; Function Attrs: nounwind willreturn memory(read)
declare ptr @strchr(ptr noundef, i32 noundef) #3

; Function Attrs: nounwind
declare i32 @fprintf(ptr noundef, ptr noundef, ...) #4

declare ptr @GetValueFromNameValueList(ptr noundef, ptr noundef) #2

; Function Attrs: nounwind willreturn memory(read)
declare i32 @strcmp(ptr noundef, ptr noundef) #3

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

declare void @ClearNameValueList(ptr noundef) #2

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 = { 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 willreturn memory(read) "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 "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 = { nounwind }
attributes #6 = { nounwind willreturn memory(read) }

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


; 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.NameValueParserData = type { ptr, [64 x i8], ptr, i32, i32, ptr, i32 }

@stderr = external local_unnamed_addr global ptr, align 8
@.str = external hidden unnamed_addr constant [41 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [47 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [14 x i8], align 1

; Function Attrs: nounwind uwtable
define dso_local range(i32 0, 2) i32 @test_parsing(ptr noundef %0, i32 noundef %1, ptr noundef %2) local_unnamed_addr #0 {
  %4 = alloca [1024 x i8], align 16
  %5 = alloca %struct.NameValueParserData, align 8
  call void @llvm.lifetime.start.p0(i64 1024, ptr nonnull %4) #5
  call void @llvm.lifetime.start.p0(i64 104, ptr nonnull %5) #5
  call void @ParseNameValue(ptr noundef %0, i32 noundef %1, ptr noundef nonnull %5) #5
  %.not = icmp eq ptr %2, null
  br i1 %.not, label %.loopexit, label %.preheader

.preheader:                                       ; preds = %3
  %6 = call ptr @fgets(ptr noundef nonnull %4, i32 noundef 1024, ptr noundef nonnull %2)
  %.not2429 = icmp eq ptr %6, null
  br i1 %.not2429, label %.loopexit, label %.lr.ph31

.lr.ph31:                                         ; preds = %.preheader, %31
  %.02030 = phi i32 [ %.2, %31 ], [ 1, %.preheader ]
  %7 = call i64 @strlen(ptr noundef nonnull dereferenceable(1) %4) #6
  %8 = trunc i64 %7 to i32
  %9 = icmp sgt i32 %8, 0
  br i1 %9, label %.lr.ph.preheader, label %.critedge

.lr.ph.preheader:                                 ; preds = %.lr.ph31
  %10 = and i64 %7, 2147483647
  br label %.lr.ph

.lr.ph:                                           ; preds = %.lr.ph.preheader, %.critedge2
  %indvars.iv = phi i64 [ %10, %.lr.ph.preheader ], [ %indvars.iv.next, %.critedge2 ]
  %indvars.iv.next = add nsw i64 %indvars.iv, -1
  %11 = getelementptr inbounds [1024 x i8], ptr %4, i64 0, i64 %indvars.iv.next
  %12 = load i8, ptr %11, align 1, !tbaa !5
  switch i8 %12, label %.critedge.thread [
    i8 13, label %.critedge2
    i8 10, label %.critedge2
  ]

.critedge2:                                       ; preds = %.lr.ph, %.lr.ph
  store i8 0, ptr %11, align 1, !tbaa !5
  %13 = icmp ugt i64 %indvars.iv, 1
  br i1 %13, label %.lr.ph, label %.critedge.loopexit, !llvm.loop !8

.critedge.loopexit:                               ; preds = %.critedge2
  %14 = trunc nuw nsw i64 %indvars.iv.next to i32
  br label %.critedge

.critedge:                                        ; preds = %.critedge.loopexit, %.lr.ph31
  %.0.lcssa = phi i32 [ %8, %.lr.ph31 ], [ %14, %.critedge.loopexit ]
  %15 = icmp eq i32 %.0.lcssa, 0
  br i1 %15, label %31, label %.critedge.thread, !llvm.loop !10

.critedge.thread:                                 ; preds = %.lr.ph, %.critedge
  %16 = call ptr @strchr(ptr noundef nonnull dereferenceable(1) %4, i32 noundef 61) #6
  %17 = icmp eq ptr %16, null
  br i1 %17, label %18, label %21

18:                                               ; preds = %.critedge.thread
  %19 = load ptr, ptr @stderr, align 8, !tbaa !11
  %20 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %19, ptr noundef nonnull @.str, ptr noundef nonnull %4) #7
  br label %31, !llvm.loop !10

21:                                               ; preds = %.critedge.thread
  store i8 0, ptr %16, align 1, !tbaa !5
  %22 = getelementptr inbounds i8, ptr %16, i64 1
  %23 = call ptr @GetValueFromNameValueList(ptr noundef nonnull %5, ptr noundef nonnull %4) #5
  %24 = icmp eq ptr %23, null
  br i1 %24, label %27, label %25

25:                                               ; preds = %21
  %26 = call i32 @strcmp(ptr noundef nonnull dereferenceable(1) %23, ptr noundef nonnull dereferenceable(1) %22) #6
  %.not25 = icmp eq i32 %26, 0
  br i1 %.not25, label %31, label %27

27:                                               ; preds = %25, %21
  %28 = phi ptr [ %23, %25 ], [ @.str.2, %21 ]
  %29 = load ptr, ptr @stderr, align 8, !tbaa !11
  %30 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %29, ptr noundef nonnull @.str.1, ptr noundef nonnull %4, ptr noundef nonnull %22, ptr noundef nonnull %28) #7
  br label %31

31:                                               ; preds = %25, %27, %.critedge, %18
  %.2 = phi i32 [ %.02030, %18 ], [ %.02030, %.critedge ], [ 0, %27 ], [ %.02030, %25 ]
  %32 = call ptr @fgets(ptr noundef nonnull %4, i32 noundef 1024, ptr noundef nonnull %2)
  %.not24 = icmp eq ptr %32, null
  br i1 %.not24, label %.loopexit, label %.lr.ph31

.loopexit:                                        ; preds = %31, %.preheader, %3
  %.3 = phi i32 [ 1, %3 ], [ 1, %.preheader ], [ %.2, %31 ]
  call void @ClearNameValueList(ptr noundef nonnull %5) #5
  call void @llvm.lifetime.end.p0(i64 104, ptr nonnull %5) #5
  call void @llvm.lifetime.end.p0(i64 1024, ptr nonnull %4) #5
  ret i32 %.3
}

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

declare void @ParseNameValue(ptr noundef, i32 noundef, ptr noundef) local_unnamed_addr #2

; Function Attrs: nofree nounwind
declare noundef ptr @fgets(ptr noundef, i32 noundef, ptr nocapture noundef) local_unnamed_addr #3

; Function Attrs: mustprogress nofree nounwind willreturn memory(argmem: read)
declare i64 @strlen(ptr nocapture noundef) local_unnamed_addr #4

; Function Attrs: mustprogress nofree nounwind willreturn memory(argmem: read)
declare ptr @strchr(ptr noundef, i32 noundef) local_unnamed_addr #4

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

declare ptr @GetValueFromNameValueList(ptr noundef, ptr noundef) local_unnamed_addr #2

; Function Attrs: mustprogress nofree nounwind willreturn memory(argmem: read)
declare i32 @strcmp(ptr nocapture noundef, ptr nocapture noundef) local_unnamed_addr #4

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

declare void @ClearNameValueList(ptr noundef) local_unnamed_addr #2

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 = { mustprogress 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 = { 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 #4 = { mustprogress nofree nounwind willreturn memory(argmem: read) "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 = { nounwind }
attributes #6 = { nounwind willreturn memory(read) }
attributes #7 = { cold 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 = !{!"omnipotent char", !7, i64 0}
!7 = !{!"Simple C/C++ TBAA"}
!8 = distinct !{!8, !9}
!9 = !{!"llvm.loop.mustprogress"}
!10 = distinct !{!10, !9}
!11 = !{!12, !12, i64 0}
!12 = !{!"any pointer", !6, i64 0}


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