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

; 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 }
%struct.UPNParg = type { ptr, ptr }

@.str.13 = external hidden unnamed_addr constant [10 x i8], align 1
@.str.14 = external hidden unnamed_addr constant [3 x i8], align 1
@.str.63 = external hidden unnamed_addr constant [9 x i8], align 1
@.str.67 = external hidden unnamed_addr constant [20 x i8], align 1
@.str.68 = external hidden unnamed_addr constant [10 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

declare ptr @simpleUPnPcommand(i32 noundef, ptr noundef, ptr noundef, ptr noundef, ptr noundef, ptr noundef) #1

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

; Function Attrs: nounwind
declare void @free(ptr noundef) #2

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

; Function Attrs: nounwind uwtable
declare hidden i64 @my_atoui(ptr noundef) #3

declare void @ClearNameValueList(ptr noundef) #1

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

; Function Attrs: nounwind
declare i32 @__isoc99_sscanf(ptr noundef, ptr noundef, ...) #2

; Function Attrs: nounwind allocsize(0,1)
declare noalias ptr @calloc(i64 noundef, i64 noundef) #4

; Function Attrs: nounwind uwtable
define dso_local i32 @UPNP_CheckPinholeWorking(ptr noundef %0, ptr noundef %1, ptr noundef %2, ptr noundef %3) #3 {
  %5 = alloca i32, align 4
  %6 = alloca ptr, align 8
  %7 = alloca ptr, align 8
  %8 = alloca ptr, align 8
  %9 = alloca ptr, align 8
  %10 = alloca %struct.NameValueParserData, align 8
  %11 = alloca ptr, align 8
  %12 = alloca ptr, align 8
  %13 = alloca i32, align 4
  %14 = alloca ptr, align 8
  %15 = alloca i32, align 4
  %16 = alloca i32, align 4
  store ptr %0, ptr %6, align 8, !tbaa !5
  store ptr %1, ptr %7, align 8, !tbaa !5
  store ptr %2, ptr %8, align 8, !tbaa !5
  store ptr %3, ptr %9, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 104, 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
  call void @llvm.lifetime.start.p0(i64 8, ptr %14) #5
  call void @llvm.lifetime.start.p0(i64 4, ptr %15) #5
  store i32 -1, ptr %15, align 4, !tbaa !9
  %17 = load ptr, ptr %8, align 8, !tbaa !5
  %18 = icmp ne ptr %17, null
  br i1 %18, label %20, label %19

19:                                               ; preds = %4
  store i32 -2, ptr %5, align 4
  store i32 1, ptr %16, align 4
  br label %64

20:                                               ; preds = %4
  %21 = call noalias ptr @calloc(i64 noundef 4, i64 noundef 16) #6
  store ptr %21, ptr %11, align 8, !tbaa !5
  %22 = load ptr, ptr %11, align 8, !tbaa !5
  %23 = icmp eq ptr %22, null
  br i1 %23, label %24, label %25

24:                                               ; preds = %20
  store i32 -5, ptr %5, align 4
  store i32 1, ptr %16, align 4
  br label %64

25:                                               ; preds = %20
  %26 = load ptr, ptr %11, align 8, !tbaa !5
  %27 = getelementptr inbounds %struct.UPNParg, ptr %26, i64 0
  %28 = getelementptr inbounds %struct.UPNParg, ptr %27, i32 0, i32 0
  store ptr @.str.63, ptr %28, align 8, !tbaa !11
  %29 = load ptr, ptr %8, align 8, !tbaa !5
  %30 = load ptr, ptr %11, align 8, !tbaa !5
  %31 = getelementptr inbounds %struct.UPNParg, ptr %30, i64 0
  %32 = getelementptr inbounds %struct.UPNParg, ptr %31, i32 0, i32 1
  store ptr %29, ptr %32, align 8, !tbaa !13
  %33 = load ptr, ptr %6, align 8, !tbaa !5
  %34 = load ptr, ptr %7, align 8, !tbaa !5
  %35 = load ptr, ptr %11, align 8, !tbaa !5
  %36 = call ptr @simpleUPnPcommand(i32 noundef -1, ptr noundef %33, ptr noundef %34, ptr noundef @.str.67, ptr noundef %35, ptr noundef %13)
  store ptr %36, ptr %12, align 8, !tbaa !5
  %37 = load ptr, ptr %11, align 8, !tbaa !5
  call void @free(ptr noundef %37) #5
  %38 = load ptr, ptr %12, align 8, !tbaa !5
  %39 = icmp ne ptr %38, null
  br i1 %39, label %41, label %40

40:                                               ; preds = %25
  store i32 -3, ptr %5, align 4
  store i32 1, ptr %16, align 4
  br label %64

41:                                               ; preds = %25
  %42 = load ptr, ptr %12, align 8, !tbaa !5
  %43 = load i32, ptr %13, align 4, !tbaa !9
  call void @ParseNameValue(ptr noundef %42, i32 noundef %43, ptr noundef %10)
  %44 = load ptr, ptr %12, align 8, !tbaa !5
  call void @free(ptr noundef %44) #5
  %45 = call ptr @GetValueFromNameValueList(ptr noundef %10, ptr noundef @.str.68)
  store ptr %45, ptr %14, align 8, !tbaa !5
  %46 = load ptr, ptr %14, align 8, !tbaa !5
  %47 = icmp ne ptr %46, null
  br i1 %47, label %48, label %53

48:                                               ; preds = %41
  %49 = load ptr, ptr %14, align 8, !tbaa !5
  %50 = call i64 @my_atoui(ptr noundef %49)
  %51 = trunc i64 %50 to i32
  %52 = load ptr, ptr %9, align 8, !tbaa !5
  store i32 %51, ptr %52, align 4, !tbaa !9
  store i32 0, ptr %15, align 4, !tbaa !9
  br label %55

53:                                               ; preds = %41
  %54 = load ptr, ptr %9, align 8, !tbaa !5
  store i32 0, ptr %54, align 4, !tbaa !9
  br label %55

55:                                               ; preds = %53, %48
  %56 = call ptr @GetValueFromNameValueList(ptr noundef %10, ptr noundef @.str.13)
  store ptr %56, ptr %14, align 8, !tbaa !5
  %57 = load ptr, ptr %14, align 8, !tbaa !5
  %58 = icmp ne ptr %57, null
  br i1 %58, label %59, label %62

59:                                               ; preds = %55
  store i32 -1, ptr %15, align 4, !tbaa !9
  %60 = load ptr, ptr %14, align 8, !tbaa !5
  %61 = call i32 (ptr, ptr, ...) @__isoc99_sscanf(ptr noundef %60, ptr noundef @.str.14, ptr noundef %15) #5
  br label %62

62:                                               ; preds = %59, %55
  call void @ClearNameValueList(ptr noundef %10)
  %63 = load i32, ptr %15, align 4, !tbaa !9
  store i32 %63, ptr %5, align 4
  store i32 1, ptr %16, align 4
  br label %64

64:                                               ; preds = %62, %40, %24, %19
  call void @llvm.lifetime.end.p0(i64 4, ptr %15) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %14) #5
  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 104, ptr %10) #5
  %65 = load i32, ptr %5, align 4
  ret i32 %65
}

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

!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, !6, i64 0}
!12 = !{!"UPNParg", !6, i64 0, !6, i64 8}
!13 = !{!12, !6, i64 8}


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

@.str.13 = external hidden unnamed_addr constant [10 x i8], align 1
@.str.14 = external hidden unnamed_addr constant [3 x i8], align 1
@.str.63 = external hidden unnamed_addr constant [9 x i8], align 1
@.str.67 = external hidden unnamed_addr constant [20 x i8], align 1
@.str.68 = external hidden unnamed_addr constant [10 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

declare ptr @simpleUPnPcommand(i32 noundef, ptr noundef, ptr noundef, ptr noundef, ptr noundef, ptr noundef) local_unnamed_addr #1

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

; Function Attrs: mustprogress nounwind willreturn allockind("free") memory(argmem: readwrite, inaccessiblemem: readwrite)
declare void @free(ptr allocptr nocapture noundef) local_unnamed_addr #2

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

; Function Attrs: nounwind uwtable
declare hidden i64 @my_atoui(ptr noundef) local_unnamed_addr #3

declare void @ClearNameValueList(ptr noundef) local_unnamed_addr #1

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

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

; Function Attrs: mustprogress nofree nounwind willreturn allockind("alloc,zeroed") allocsize(0,1) memory(inaccessiblemem: readwrite)
declare noalias noundef ptr @calloc(i64 noundef, i64 noundef) local_unnamed_addr #5

; Function Attrs: nounwind uwtable
define dso_local i32 @UPNP_CheckPinholeWorking(ptr noundef %0, ptr noundef %1, ptr noundef %2, ptr nocapture noundef writeonly %3) local_unnamed_addr #3 {
  %5 = alloca %struct.NameValueParserData, align 8
  %6 = alloca i32, align 4
  %7 = alloca i32, align 4
  call void @llvm.lifetime.start.p0(i64 104, ptr nonnull %5) #6
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %6) #6
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %7) #6
  store i32 -1, ptr %7, align 4, !tbaa !5
  %.not = icmp eq ptr %2, null
  br i1 %.not, label %26, label %8

8:                                                ; preds = %4
  %9 = tail call noalias dereferenceable_or_null(64) ptr @calloc(i64 noundef 4, i64 noundef 16) #7
  %10 = icmp eq ptr %9, null
  br i1 %10, label %26, label %11

11:                                               ; preds = %8
  store ptr @.str.63, ptr %9, align 8, !tbaa !9
  %12 = getelementptr inbounds i8, ptr %9, i64 8
  store ptr %2, ptr %12, align 8, !tbaa !12
  %13 = call ptr @simpleUPnPcommand(i32 noundef -1, ptr noundef %0, ptr noundef %1, ptr noundef nonnull @.str.67, ptr noundef nonnull %9, ptr noundef nonnull %6) #6
  call void @free(ptr noundef nonnull %9) #6
  %.not23 = icmp eq ptr %13, null
  br i1 %.not23, label %26, label %14

14:                                               ; preds = %11
  %15 = load i32, ptr %6, align 4, !tbaa !5
  call void @ParseNameValue(ptr noundef nonnull %13, i32 noundef %15, ptr noundef nonnull %5) #6
  call void @free(ptr noundef nonnull %13) #6
  %16 = call ptr @GetValueFromNameValueList(ptr noundef nonnull %5, ptr noundef nonnull @.str.68) #6
  %.not24 = icmp eq ptr %16, null
  br i1 %.not24, label %20, label %17

17:                                               ; preds = %14
  %18 = call i64 @my_atoui(ptr noundef nonnull %16)
  %19 = trunc i64 %18 to i32
  store i32 0, ptr %7, align 4, !tbaa !5
  br label %20

20:                                               ; preds = %14, %17
  %.sink = phi i32 [ %19, %17 ], [ 0, %14 ]
  store i32 %.sink, ptr %3, align 4
  %21 = call ptr @GetValueFromNameValueList(ptr noundef nonnull %5, ptr noundef nonnull @.str.13) #6
  %.not25 = icmp eq ptr %21, null
  br i1 %.not25, label %24, label %22

22:                                               ; preds = %20
  store i32 -1, ptr %7, align 4, !tbaa !5
  %23 = call i32 (ptr, ptr, ...) @__isoc99_sscanf(ptr noundef nonnull %21, ptr noundef nonnull @.str.14, ptr noundef nonnull %7) #6
  br label %24

24:                                               ; preds = %22, %20
  call void @ClearNameValueList(ptr noundef nonnull %5) #6
  %25 = load i32, ptr %7, align 4, !tbaa !5
  br label %26

26:                                               ; preds = %11, %8, %4, %24
  %.0 = phi i32 [ %25, %24 ], [ -2, %4 ], [ -5, %8 ], [ -3, %11 ]
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %7) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %6) #6
  call void @llvm.lifetime.end.p0(i64 104, ptr nonnull %5) #6
  ret i32 %.0
}

attributes #0 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 = { mustprogress nounwind willreturn allockind("free") memory(argmem: readwrite, inaccessiblemem: readwrite) "alloc-family"="malloc" "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 = { 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 #5 = { mustprogress nofree nounwind willreturn allockind("alloc,zeroed") allocsize(0,1) memory(inaccessiblemem: readwrite) "alloc-family"="malloc" "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 = { nounwind allocsize(0,1) }

!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 = !{!10, !11, i64 0}
!10 = !{!"UPNParg", !11, i64 0, !11, i64 8}
!11 = !{!"any pointer", !7, i64 0}
!12 = !{!10, !11, i64 8}


; Effective O3 passes: CorrelatedValuePropagationPass,EarlyCSEPass,GlobalOptPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,MergedLoadStoreMotionPass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass,TailCallElimPass