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

; 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.event = type { i32, ptr, i32 }
%struct.eventlist = type { i32, ptr }
%struct.xmlparser = type { ptr, ptr, ptr, i32, ptr, ptr, ptr, ptr, ptr }

@stderr = external global ptr, align 8
@.str.2 = external hidden unnamed_addr constant [26 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [11 x i8], align 1
@evtref = external hidden constant [17 x %struct.event], align 16

; Function Attrs: nounwind uwtable
declare dso_local i32 @evtlistcmp(ptr noundef, ptr noundef) #0

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

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

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

; Function Attrs: nounwind uwtable
declare dso_local void @startelt(ptr noundef, ptr noundef, i32 noundef) #0

; Function Attrs: nounwind uwtable
declare dso_local void @endelt(ptr noundef, ptr noundef, i32 noundef) #0

; Function Attrs: nounwind uwtable
declare dso_local void @chardata(ptr noundef, ptr noundef, i32 noundef) #0

; Function Attrs: nounwind uwtable
define dso_local i32 @testxmlparser(ptr noundef %0, i32 noundef %1) #0 {
  %3 = alloca i32, align 4
  %4 = alloca ptr, align 8
  %5 = alloca i32, align 4
  %6 = alloca i32, align 4
  %7 = alloca %struct.eventlist, align 8
  %8 = alloca %struct.eventlist, align 8
  %9 = alloca %struct.xmlparser, align 8
  %10 = alloca i32, align 4
  store ptr %0, ptr %4, align 8, !tbaa !5
  store i32 %1, ptr %5, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #6
  call void @llvm.lifetime.start.p0(i64 16, ptr %7) #6
  call void @llvm.lifetime.start.p0(i64 16, ptr %8) #6
  call void @llvm.lifetime.start.p0(i64 72, ptr %9) #6
  %11 = getelementptr inbounds %struct.eventlist, ptr %7, i32 0, i32 0
  store i32 0, ptr %11, align 8, !tbaa !11
  %12 = call noalias ptr @malloc(i64 noundef 2400) #7
  %13 = getelementptr inbounds %struct.eventlist, ptr %7, i32 0, i32 1
  store ptr %12, ptr %13, align 8, !tbaa !13
  %14 = getelementptr inbounds %struct.eventlist, ptr %7, i32 0, i32 1
  %15 = load ptr, ptr %14, align 8, !tbaa !13
  %16 = icmp eq ptr %15, null
  br i1 %16, label %17, label %20

17:                                               ; preds = %2
  %18 = load ptr, ptr @stderr, align 8, !tbaa !5
  %19 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %18, ptr noundef @.str.2) #6
  store i32 -1, ptr %3, align 4
  store i32 1, ptr %10, align 4
  br label %38

20:                                               ; preds = %2
  call void @llvm.memset.p0.i64(ptr align 8 %9, i8 0, i64 72, i1 false)
  %21 = load ptr, ptr %4, align 8, !tbaa !5
  %22 = getelementptr inbounds %struct.xmlparser, ptr %9, i32 0, i32 0
  store ptr %21, ptr %22, align 8, !tbaa !14
  %23 = load i32, ptr %5, align 4, !tbaa !9
  %24 = getelementptr inbounds %struct.xmlparser, ptr %9, i32 0, i32 3
  store i32 %23, ptr %24, align 8, !tbaa !16
  %25 = getelementptr inbounds %struct.xmlparser, ptr %9, i32 0, i32 4
  store ptr %7, ptr %25, align 8, !tbaa !17
  %26 = getelementptr inbounds %struct.xmlparser, ptr %9, i32 0, i32 5
  store ptr @startelt, ptr %26, align 8, !tbaa !18
  %27 = getelementptr inbounds %struct.xmlparser, ptr %9, i32 0, i32 6
  store ptr @endelt, ptr %27, align 8, !tbaa !19
  %28 = getelementptr inbounds %struct.xmlparser, ptr %9, i32 0, i32 7
  store ptr @chardata, ptr %28, align 8, !tbaa !20
  call void @parsexml(ptr noundef %9)
  %29 = getelementptr inbounds %struct.eventlist, ptr %7, i32 0, i32 0
  %30 = load i32, ptr %29, align 8, !tbaa !11
  %31 = call i32 (ptr, ...) @printf(ptr noundef @.str.3, i32 noundef %30)
  %32 = getelementptr inbounds %struct.eventlist, ptr %8, i32 0, i32 0
  store i32 17, ptr %32, align 8, !tbaa !11
  %33 = getelementptr inbounds %struct.eventlist, ptr %8, i32 0, i32 1
  store ptr @evtref, ptr %33, align 8, !tbaa !13
  %34 = call i32 @evtlistcmp(ptr noundef %8, ptr noundef %7)
  store i32 %34, ptr %6, align 4, !tbaa !9
  %35 = getelementptr inbounds %struct.eventlist, ptr %7, i32 0, i32 1
  %36 = load ptr, ptr %35, align 8, !tbaa !13
  call void @free(ptr noundef %36) #6
  %37 = load i32, ptr %6, align 4, !tbaa !9
  store i32 %37, ptr %3, align 4
  store i32 1, ptr %10, align 4
  br label %38

38:                                               ; preds = %20, %17
  call void @llvm.lifetime.end.p0(i64 72, ptr %9) #6
  call void @llvm.lifetime.end.p0(i64 16, ptr %8) #6
  call void @llvm.lifetime.end.p0(i64 16, ptr %7) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #6
  %39 = load i32, ptr %3, align 4
  ret i32 %39
}

; Function Attrs: nounwind allocsize(0)
declare noalias ptr @malloc(i64 noundef) #3

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

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

declare void @parsexml(ptr noundef) #2

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

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

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


; 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.event = type { i32, ptr, i32 }
%struct.eventlist = type { i32, ptr }
%struct.xmlparser = type { ptr, ptr, ptr, i32, ptr, ptr, ptr, ptr, ptr }

@stderr = external local_unnamed_addr global ptr, align 8
@.str.2 = external hidden unnamed_addr constant [26 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [11 x i8], align 1
@evtref = external hidden constant [17 x %struct.event], align 16

; Function Attrs: nounwind uwtable
declare dso_local i32 @evtlistcmp(ptr noundef, ptr noundef) local_unnamed_addr #0

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

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

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

; Function Attrs: nounwind uwtable
declare dso_local void @startelt(ptr noundef, ptr noundef, i32 noundef) #0

; Function Attrs: nounwind uwtable
declare dso_local void @endelt(ptr noundef, ptr noundef, i32 noundef) #0

; Function Attrs: nounwind uwtable
declare dso_local void @chardata(ptr noundef, ptr noundef, i32 noundef) #0

; Function Attrs: nounwind uwtable
define dso_local i32 @testxmlparser(ptr noundef %0, i32 noundef %1) local_unnamed_addr #0 {
  %3 = alloca %struct.eventlist, align 8
  %4 = alloca %struct.eventlist, align 8
  %5 = alloca %struct.xmlparser, align 8
  call void @llvm.lifetime.start.p0(i64 16, ptr nonnull %3) #7
  call void @llvm.lifetime.start.p0(i64 16, ptr nonnull %4) #7
  call void @llvm.lifetime.start.p0(i64 72, ptr nonnull %5) #7
  store i32 0, ptr %3, align 8, !tbaa !5
  %6 = tail call noalias dereferenceable_or_null(2400) ptr @malloc(i64 noundef 2400) #8
  %7 = getelementptr inbounds i8, ptr %3, i64 8
  store ptr %6, ptr %7, align 8, !tbaa !11
  %8 = icmp eq ptr %6, null
  br i1 %8, label %9, label %12

9:                                                ; preds = %2
  %10 = load ptr, ptr @stderr, align 8, !tbaa !12
  %11 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %10, ptr noundef nonnull @.str.2) #9
  br label %24

12:                                               ; preds = %2
  %13 = getelementptr inbounds i8, ptr %5, i64 8
  call void @llvm.memset.p0.i64(ptr noundef nonnull align 8 dereferenceable(72) %13, i8 0, i64 64, i1 false)
  store ptr %0, ptr %5, align 8, !tbaa !13
  %14 = getelementptr inbounds i8, ptr %5, i64 24
  store i32 %1, ptr %14, align 8, !tbaa !15
  %15 = getelementptr inbounds i8, ptr %5, i64 32
  store ptr %3, ptr %15, align 8, !tbaa !16
  %16 = getelementptr inbounds i8, ptr %5, i64 40
  store ptr @startelt, ptr %16, align 8, !tbaa !17
  %17 = getelementptr inbounds i8, ptr %5, i64 48
  store ptr @endelt, ptr %17, align 8, !tbaa !18
  %18 = getelementptr inbounds i8, ptr %5, i64 56
  store ptr @chardata, ptr %18, align 8, !tbaa !19
  call void @parsexml(ptr noundef nonnull %5) #7
  %19 = load i32, ptr %3, align 8, !tbaa !5
  %20 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.3, i32 noundef %19)
  store i32 17, ptr %4, align 8, !tbaa !5
  %21 = getelementptr inbounds i8, ptr %4, i64 8
  store ptr @evtref, ptr %21, align 8, !tbaa !11
  %22 = call i32 @evtlistcmp(ptr noundef nonnull %4, ptr noundef nonnull %3)
  %23 = load ptr, ptr %7, align 8, !tbaa !11
  call void @free(ptr noundef %23) #7
  br label %24

24:                                               ; preds = %12, %9
  %.0 = phi i32 [ -1, %9 ], [ %22, %12 ]
  call void @llvm.lifetime.end.p0(i64 72, ptr nonnull %5) #7
  call void @llvm.lifetime.end.p0(i64 16, ptr nonnull %4) #7
  call void @llvm.lifetime.end.p0(i64 16, ptr nonnull %3) #7
  ret i32 %.0
}

; Function Attrs: mustprogress nofree nounwind willreturn allockind("alloc,uninitialized") allocsize(0) memory(inaccessiblemem: readwrite)
declare noalias noundef ptr @malloc(i64 noundef) local_unnamed_addr #3

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

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

declare void @parsexml(ptr noundef) local_unnamed_addr #5

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

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


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