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

; 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.IGDdatas = type { [128 x i8], [128 x i8], [128 x i8], i32, %struct.IGDdatas_service, %struct.IGDdatas_service, %struct.IGDdatas_service, %struct.IGDdatas_service, %struct.IGDdatas_service }
%struct.IGDdatas_service = type { [128 x i8], [128 x i8], [128 x i8], [128 x i8] }
%struct.xmlparser = type { ptr, ptr, ptr, i32, ptr, ptr, ptr, ptr, ptr }
%struct.UPNPUrls = type { ptr, ptr, ptr, ptr, ptr }

@.str.16 = external hidden unnamed_addr constant [30 x i8], align 1
@.str.17 = external hidden unnamed_addr constant [19 x i8], align 1
@.str.18 = external hidden unnamed_addr constant [17 x i8], align 1
@.str.19 = external hidden unnamed_addr constant [21 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: nounwind uwtable
declare dso_local i32 @compare_igd(ptr noundef, ptr noundef) #1

; Function Attrs: nounwind uwtable
define dso_local i32 @test_igd_desc_parse(ptr noundef %0, i32 noundef %1, ptr noundef %2) #1 {
  %4 = alloca ptr, align 8
  %5 = alloca i32, align 4
  %6 = alloca ptr, align 8
  %7 = alloca i32, align 4
  %8 = alloca %struct.IGDdatas, align 4
  %9 = alloca %struct.xmlparser, align 8
  %10 = alloca %struct.UPNPUrls, align 8
  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 4, ptr %7) #4
  call void @llvm.lifetime.start.p0(i64 2948, ptr %8) #4
  call void @llvm.lifetime.start.p0(i64 72, ptr %9) #4
  call void @llvm.lifetime.start.p0(i64 40, ptr %10) #4
  call void @llvm.memset.p0.i64(ptr align 4 %8, i8 0, i64 2948, i1 false)
  call void @llvm.memset.p0.i64(ptr align 8 %9, i8 0, i64 72, i1 false)
  %11 = load ptr, ptr %4, align 8, !tbaa !5
  %12 = getelementptr inbounds %struct.xmlparser, ptr %9, i32 0, i32 0
  store ptr %11, ptr %12, align 8, !tbaa !11
  %13 = load i32, ptr %5, align 4, !tbaa !9
  %14 = getelementptr inbounds %struct.xmlparser, ptr %9, i32 0, i32 3
  store i32 %13, ptr %14, align 8, !tbaa !13
  %15 = getelementptr inbounds %struct.xmlparser, ptr %9, i32 0, i32 4
  store ptr %8, ptr %15, align 8, !tbaa !14
  %16 = getelementptr inbounds %struct.xmlparser, ptr %9, i32 0, i32 5
  store ptr @IGDstartelt, ptr %16, align 8, !tbaa !15
  %17 = getelementptr inbounds %struct.xmlparser, ptr %9, i32 0, i32 6
  store ptr @IGDendelt, ptr %17, align 8, !tbaa !16
  %18 = getelementptr inbounds %struct.xmlparser, ptr %9, i32 0, i32 7
  store ptr @IGDdata, ptr %18, align 8, !tbaa !17
  call void @parsexml(ptr noundef %9)
  call void @GetUPNPUrls(ptr noundef %10, ptr noundef %8, ptr noundef @.str.16, i32 noundef 0)
  %19 = getelementptr inbounds %struct.UPNPUrls, ptr %10, i32 0, i32 1
  %20 = load ptr, ptr %19, align 8, !tbaa !18
  %21 = call i32 (ptr, ...) @printf(ptr noundef @.str.17, ptr noundef %20)
  %22 = getelementptr inbounds %struct.UPNPUrls, ptr %10, i32 0, i32 0
  %23 = load ptr, ptr %22, align 8, !tbaa !20
  %24 = call i32 (ptr, ...) @printf(ptr noundef @.str.18, ptr noundef %23)
  %25 = getelementptr inbounds %struct.UPNPUrls, ptr %10, i32 0, i32 2
  %26 = load ptr, ptr %25, align 8, !tbaa !21
  %27 = call i32 (ptr, ...) @printf(ptr noundef @.str.19, ptr noundef %26)
  %28 = load ptr, ptr %6, align 8, !tbaa !5
  %29 = icmp ne ptr %28, null
  br i1 %29, label %30, label %33

30:                                               ; preds = %3
  %31 = load ptr, ptr %6, align 8, !tbaa !5
  %32 = call i32 @compare_igd(ptr noundef %8, ptr noundef %31)
  br label %34

33:                                               ; preds = %3
  br label %34

34:                                               ; preds = %33, %30
  %35 = phi i32 [ %32, %30 ], [ 0, %33 ]
  store i32 %35, ptr %7, align 4, !tbaa !9
  call void @FreeUPNPUrls(ptr noundef %10)
  %36 = load i32, ptr %7, align 4, !tbaa !9
  call void @llvm.lifetime.end.p0(i64 40, ptr %10) #4
  call void @llvm.lifetime.end.p0(i64 72, ptr %9) #4
  call void @llvm.lifetime.end.p0(i64 2948, ptr %8) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #4
  ret i32 %36
}

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #2

declare void @IGDstartelt(ptr noundef, ptr noundef, i32 noundef) #3

declare void @IGDendelt(ptr noundef, ptr noundef, i32 noundef) #3

declare void @IGDdata(ptr noundef, ptr noundef, i32 noundef) #3

declare void @parsexml(ptr noundef) #3

declare void @GetUPNPUrls(ptr noundef, ptr noundef, ptr noundef, i32 noundef) #3

declare i32 @printf(ptr noundef, ...) #3

declare void @FreeUPNPUrls(ptr noundef) #3

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

!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 = !{!"xmlparser", !6, i64 0, !6, i64 8, !6, i64 16, !10, i64 24, !6, i64 32, !6, i64 40, !6, i64 48, !6, i64 56, !6, i64 64}
!13 = !{!12, !10, i64 24}
!14 = !{!12, !6, i64 32}
!15 = !{!12, !6, i64 40}
!16 = !{!12, !6, i64 48}
!17 = !{!12, !6, i64 56}
!18 = !{!19, !6, i64 8}
!19 = !{!"UPNPUrls", !6, i64 0, !6, i64 8, !6, i64 16, !6, i64 24, !6, i64 32}
!20 = !{!19, !6, i64 0}
!21 = !{!19, !6, i64 16}


; 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.IGDdatas = type { [128 x i8], [128 x i8], [128 x i8], i32, %struct.IGDdatas_service, %struct.IGDdatas_service, %struct.IGDdatas_service, %struct.IGDdatas_service, %struct.IGDdatas_service }
%struct.IGDdatas_service = type { [128 x i8], [128 x i8], [128 x i8], [128 x i8] }
%struct.xmlparser = type { ptr, ptr, ptr, i32, ptr, ptr, ptr, ptr, ptr }
%struct.UPNPUrls = type { ptr, ptr, ptr, ptr, ptr }

@.str.16 = external hidden unnamed_addr constant [30 x i8], align 1
@.str.17 = external hidden unnamed_addr constant [19 x i8], align 1
@.str.18 = external hidden unnamed_addr constant [17 x i8], align 1
@.str.19 = external hidden unnamed_addr constant [21 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: nounwind uwtable
declare dso_local i32 @compare_igd(ptr noundef, ptr noundef) local_unnamed_addr #1

; Function Attrs: nounwind uwtable
define dso_local i32 @test_igd_desc_parse(ptr noundef %0, i32 noundef %1, ptr noundef %2) local_unnamed_addr #1 {
  %4 = alloca %struct.IGDdatas, align 4
  %5 = alloca %struct.xmlparser, align 8
  %6 = alloca %struct.UPNPUrls, align 8
  call void @llvm.lifetime.start.p0(i64 2948, ptr nonnull %4) #5
  call void @llvm.lifetime.start.p0(i64 72, ptr nonnull %5) #5
  call void @llvm.lifetime.start.p0(i64 40, ptr nonnull %6) #5
  call void @llvm.memset.p0.i64(ptr noundef nonnull align 4 dereferenceable(2948) %4, i8 0, i64 2948, i1 false)
  %7 = getelementptr inbounds i8, ptr %5, i64 8
  call void @llvm.memset.p0.i64(ptr noundef nonnull align 8 dereferenceable(72) %7, i8 0, i64 64, i1 false)
  store ptr %0, ptr %5, align 8, !tbaa !5
  %8 = getelementptr inbounds i8, ptr %5, i64 24
  store i32 %1, ptr %8, align 8, !tbaa !11
  %9 = getelementptr inbounds i8, ptr %5, i64 32
  store ptr %4, ptr %9, align 8, !tbaa !12
  %10 = getelementptr inbounds i8, ptr %5, i64 40
  store ptr @IGDstartelt, ptr %10, align 8, !tbaa !13
  %11 = getelementptr inbounds i8, ptr %5, i64 48
  store ptr @IGDendelt, ptr %11, align 8, !tbaa !14
  %12 = getelementptr inbounds i8, ptr %5, i64 56
  store ptr @IGDdata, ptr %12, align 8, !tbaa !15
  call void @parsexml(ptr noundef nonnull %5) #5
  call void @GetUPNPUrls(ptr noundef nonnull %6, ptr noundef nonnull %4, ptr noundef nonnull @.str.16, i32 noundef 0) #5
  %13 = getelementptr inbounds i8, ptr %6, i64 8
  %14 = load ptr, ptr %13, align 8, !tbaa !16
  %15 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.17, ptr noundef %14)
  %16 = load ptr, ptr %6, align 8, !tbaa !18
  %17 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.18, ptr noundef %16)
  %18 = getelementptr inbounds i8, ptr %6, i64 16
  %19 = load ptr, ptr %18, align 8, !tbaa !19
  %20 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.19, ptr noundef %19)
  %.not = icmp eq ptr %2, null
  br i1 %.not, label %23, label %21

21:                                               ; preds = %3
  %22 = call i32 @compare_igd(ptr noundef nonnull %4, ptr noundef nonnull %2)
  br label %23

23:                                               ; preds = %3, %21
  %24 = phi i32 [ %22, %21 ], [ 0, %3 ]
  call void @FreeUPNPUrls(ptr noundef nonnull %6) #5
  call void @llvm.lifetime.end.p0(i64 40, ptr nonnull %6) #5
  call void @llvm.lifetime.end.p0(i64 72, ptr nonnull %5) #5
  call void @llvm.lifetime.end.p0(i64 2948, ptr nonnull %4) #5
  ret i32 %24
}

; Function Attrs: mustprogress nocallback nofree nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #2

declare void @IGDstartelt(ptr noundef, ptr noundef, i32 noundef) #3

declare void @IGDendelt(ptr noundef, ptr noundef, i32 noundef) #3

declare void @IGDdata(ptr noundef, ptr noundef, i32 noundef) #3

declare void @parsexml(ptr noundef) local_unnamed_addr #3

declare void @GetUPNPUrls(ptr noundef, ptr noundef, ptr noundef, i32 noundef) local_unnamed_addr #3

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

declare void @FreeUPNPUrls(ptr noundef) local_unnamed_addr #3

attributes #0 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { 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 #2 = { mustprogress nocallback nofree nounwind willreturn memory(argmem: write) }
attributes #3 = { "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 = { 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, !7, i64 0}
!6 = !{!"xmlparser", !7, i64 0, !7, i64 8, !7, i64 16, !10, i64 24, !7, i64 32, !7, i64 40, !7, i64 48, !7, i64 56, !7, i64 64}
!7 = !{!"any pointer", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"int", !8, i64 0}
!11 = !{!6, !10, i64 24}
!12 = !{!6, !7, i64 32}
!13 = !{!6, !7, i64 40}
!14 = !{!6, !7, i64 48}
!15 = !{!6, !7, i64 56}
!16 = !{!17, !7, i64 8}
!17 = !{!"UPNPUrls", !7, i64 0, !7, i64 8, !7, i64 16, !7, i64 24, !7, i64 32}
!18 = !{!17, !7, i64 0}
!19 = !{!17, !7, i64 16}


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