; 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.22 = external hidden unnamed_addr constant [14 x i8], align 1
@.str.23 = external hidden unnamed_addr constant [16 x i8], align 1
@.str.24 = external hidden unnamed_addr constant [12 x i8], align 1
@.str.36 = external hidden unnamed_addr constant [18 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

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) #3

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

21:                                               ; preds = %5
  %22 = load ptr, ptr %10, align 8, !tbaa !5
  %23 = icmp ne ptr %22, null
  br i1 %23, label %25, label %24

24:                                               ; preds = %21, %5
  store i32 -2, ptr %6, align 4
  store i32 1, ptr %18, align 4
  br label %73

25:                                               ; preds = %21
  %26 = call noalias ptr @calloc(i64 noundef 4, i64 noundef 16) #6
  store ptr %26, ptr %12, align 8, !tbaa !5
  %27 = load ptr, ptr %12, align 8, !tbaa !5
  %28 = icmp eq ptr %27, null
  br i1 %28, label %29, label %30

29:                                               ; preds = %25
  store i32 -5, ptr %6, align 4
  store i32 1, ptr %18, align 4
  br label %73

30:                                               ; preds = %25
  %31 = load ptr, ptr %12, align 8, !tbaa !5
  %32 = getelementptr inbounds %struct.UPNParg, ptr %31, i64 0
  %33 = getelementptr inbounds %struct.UPNParg, ptr %32, i32 0, i32 0
  store ptr @.str.22, ptr %33, align 8, !tbaa !9
  %34 = load ptr, ptr %11, align 8, !tbaa !5
  %35 = load ptr, ptr %12, align 8, !tbaa !5
  %36 = getelementptr inbounds %struct.UPNParg, ptr %35, i64 0
  %37 = getelementptr inbounds %struct.UPNParg, ptr %36, i32 0, i32 1
  store ptr %34, ptr %37, align 8, !tbaa !11
  %38 = load ptr, ptr %12, align 8, !tbaa !5
  %39 = getelementptr inbounds %struct.UPNParg, ptr %38, i64 1
  %40 = getelementptr inbounds %struct.UPNParg, ptr %39, i32 0, i32 0
  store ptr @.str.23, ptr %40, align 8, !tbaa !9
  %41 = load ptr, ptr %9, align 8, !tbaa !5
  %42 = load ptr, ptr %12, align 8, !tbaa !5
  %43 = getelementptr inbounds %struct.UPNParg, ptr %42, i64 1
  %44 = getelementptr inbounds %struct.UPNParg, ptr %43, i32 0, i32 1
  store ptr %41, ptr %44, align 8, !tbaa !11
  %45 = load ptr, ptr %12, align 8, !tbaa !5
  %46 = getelementptr inbounds %struct.UPNParg, ptr %45, i64 2
  %47 = getelementptr inbounds %struct.UPNParg, ptr %46, i32 0, i32 0
  store ptr @.str.24, ptr %47, align 8, !tbaa !9
  %48 = load ptr, ptr %10, align 8, !tbaa !5
  %49 = load ptr, ptr %12, align 8, !tbaa !5
  %50 = getelementptr inbounds %struct.UPNParg, ptr %49, i64 2
  %51 = getelementptr inbounds %struct.UPNParg, ptr %50, i32 0, i32 1
  store ptr %48, ptr %51, align 8, !tbaa !11
  %52 = load ptr, ptr %7, align 8, !tbaa !5
  %53 = load ptr, ptr %8, align 8, !tbaa !5
  %54 = load ptr, ptr %12, align 8, !tbaa !5
  %55 = call ptr @simpleUPnPcommand(i32 noundef -1, ptr noundef %52, ptr noundef %53, ptr noundef @.str.36, ptr noundef %54, ptr noundef %14)
  store ptr %55, ptr %13, align 8, !tbaa !5
  %56 = load ptr, ptr %12, align 8, !tbaa !5
  call void @free(ptr noundef %56) #5
  %57 = load ptr, ptr %13, align 8, !tbaa !5
  %58 = icmp ne ptr %57, null
  br i1 %58, label %60, label %59

59:                                               ; preds = %30
  store i32 -3, ptr %6, align 4
  store i32 1, ptr %18, align 4
  br label %73

60:                                               ; preds = %30
  %61 = load ptr, ptr %13, align 8, !tbaa !5
  %62 = load i32, ptr %14, align 4, !tbaa !12
  call void @ParseNameValue(ptr noundef %61, i32 noundef %62, ptr noundef %15)
  %63 = load ptr, ptr %13, align 8, !tbaa !5
  call void @free(ptr noundef %63) #5
  %64 = call ptr @GetValueFromNameValueList(ptr noundef %15, ptr noundef @.str.13)
  store ptr %64, ptr %16, align 8, !tbaa !5
  %65 = load ptr, ptr %16, align 8, !tbaa !5
  %66 = icmp ne ptr %65, null
  br i1 %66, label %67, label %70

67:                                               ; preds = %60
  store i32 -1, ptr %17, align 4, !tbaa !12
  %68 = load ptr, ptr %16, align 8, !tbaa !5
  %69 = call i32 (ptr, ptr, ...) @__isoc99_sscanf(ptr noundef %68, ptr noundef @.str.14, ptr noundef %17) #5
  br label %71

70:                                               ; preds = %60
  store i32 0, ptr %17, align 4, !tbaa !12
  br label %71

71:                                               ; preds = %70, %67
  call void @ClearNameValueList(ptr noundef %15)
  %72 = load i32, ptr %17, align 4, !tbaa !12
  store i32 %72, ptr %6, align 4
  store i32 1, ptr %18, align 4
  br label %73

73:                                               ; preds = %71, %59, %29, %24
  call void @llvm.lifetime.end.p0(i64 4, ptr %17) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %16) #5
  call void @llvm.lifetime.end.p0(i64 104, ptr %15) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %14) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %13) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %12) #5
  %74 = load i32, ptr %6, align 4
  ret i32 %74
}

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


; 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.22 = external hidden unnamed_addr constant [14 x i8], align 1
@.str.23 = external hidden unnamed_addr constant [16 x i8], align 1
@.str.24 = external hidden unnamed_addr constant [12 x i8], align 1
@.str.36 = external hidden unnamed_addr constant [18 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

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 #3

; 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 #4

; Function Attrs: nounwind uwtable
define dso_local i32 @UPNP_DeletePortMapping(ptr noundef %0, ptr noundef %1, ptr noundef %2, ptr noundef %3, ptr noundef %4) local_unnamed_addr #5 {
  %6 = alloca i32, align 4
  %7 = alloca %struct.NameValueParserData, align 8
  %8 = alloca i32, align 4
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %6) #6
  call void @llvm.lifetime.start.p0(i64 104, ptr nonnull %7) #6
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %8) #6
  %9 = icmp ne ptr %2, null
  %10 = icmp ne ptr %3, null
  %or.cond = and i1 %9, %10
  br i1 %or.cond, label %11, label %29

11:                                               ; preds = %5
  %12 = tail call noalias dereferenceable_or_null(64) ptr @calloc(i64 noundef 4, i64 noundef 16) #7
  %13 = icmp eq ptr %12, null
  br i1 %13, label %29, label %14

14:                                               ; preds = %11
  store ptr @.str.22, ptr %12, align 8, !tbaa !5
  %15 = getelementptr inbounds i8, ptr %12, i64 8
  store ptr %4, ptr %15, align 8, !tbaa !10
  %16 = getelementptr inbounds i8, ptr %12, i64 16
  store ptr @.str.23, ptr %16, align 8, !tbaa !5
  %17 = getelementptr inbounds i8, ptr %12, i64 24
  store ptr %2, ptr %17, align 8, !tbaa !10
  %18 = getelementptr inbounds i8, ptr %12, i64 32
  store ptr @.str.24, ptr %18, align 8, !tbaa !5
  %19 = getelementptr inbounds i8, ptr %12, i64 40
  store ptr %3, ptr %19, align 8, !tbaa !10
  %20 = call ptr @simpleUPnPcommand(i32 noundef -1, ptr noundef %0, ptr noundef %1, ptr noundef nonnull @.str.36, ptr noundef nonnull %12, ptr noundef nonnull %6) #6
  call void @free(ptr noundef nonnull %12) #6
  %.not = icmp eq ptr %20, null
  br i1 %.not, label %29, label %21

21:                                               ; preds = %14
  %22 = load i32, ptr %6, align 4, !tbaa !11
  call void @ParseNameValue(ptr noundef nonnull %20, i32 noundef %22, ptr noundef nonnull %7) #6
  call void @free(ptr noundef nonnull %20) #6
  %23 = call ptr @GetValueFromNameValueList(ptr noundef nonnull %7, ptr noundef nonnull @.str.13) #6
  %.not27 = icmp eq ptr %23, null
  br i1 %.not27, label %26, label %24

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

26:                                               ; preds = %21
  store i32 0, ptr %8, align 4, !tbaa !11
  br label %27

27:                                               ; preds = %26, %24
  call void @ClearNameValueList(ptr noundef nonnull %7) #6
  %28 = load i32, ptr %8, align 4, !tbaa !11
  br label %29

29:                                               ; preds = %14, %11, %5, %27
  %.0 = phi i32 [ %28, %27 ], [ -2, %5 ], [ -5, %11 ], [ -3, %14 ]
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %8) #6
  call void @llvm.lifetime.end.p0(i64 104, ptr nonnull %7) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %6) #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 = { 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 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 #5 = { 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 = { 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, !7, i64 0}
!6 = !{!"UPNParg", !7, i64 0, !7, i64 8}
!7 = !{!"any pointer", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!6, !7, i64 8}
!11 = !{!12, !12, i64 0}
!12 = !{!"int", !8, i64 0}


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