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

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

@.str = external hidden unnamed_addr constant [8 x i8], align 1

; Function Attrs: nounwind uwtable
define dso_local void @IGDstartelt(ptr noundef %0, ptr noundef %1, i32 noundef %2) #0 {
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca i32, align 4
  %7 = alloca ptr, align 8
  store ptr %0, ptr %4, align 8, !tbaa !5
  store ptr %1, ptr %5, align 8, !tbaa !5
  store i32 %2, ptr %6, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #4
  %8 = load ptr, ptr %4, align 8, !tbaa !5
  store ptr %8, ptr %7, align 8, !tbaa !5
  %9 = load i32, ptr %6, align 4, !tbaa !9
  %10 = icmp sge i32 %9, 128
  br i1 %10, label %11, label %12

11:                                               ; preds = %3
  store i32 127, ptr %6, align 4, !tbaa !9
  br label %12

12:                                               ; preds = %11, %3
  %13 = load ptr, ptr %7, align 8, !tbaa !5
  %14 = getelementptr inbounds %struct.IGDdatas, ptr %13, i32 0, i32 0
  %15 = getelementptr inbounds [128 x i8], ptr %14, i64 0, i64 0
  %16 = load ptr, ptr %5, align 8, !tbaa !5
  %17 = load i32, ptr %6, align 4, !tbaa !9
  %18 = sext i32 %17 to i64
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %15, ptr align 1 %16, i64 %18, i1 false)
  %19 = load ptr, ptr %7, align 8, !tbaa !5
  %20 = getelementptr inbounds %struct.IGDdatas, ptr %19, i32 0, i32 0
  %21 = load i32, ptr %6, align 4, !tbaa !9
  %22 = sext i32 %21 to i64
  %23 = getelementptr inbounds [128 x i8], ptr %20, i64 0, i64 %22
  store i8 0, ptr %23, align 1, !tbaa !11
  %24 = load ptr, ptr %7, align 8, !tbaa !5
  %25 = getelementptr inbounds %struct.IGDdatas, ptr %24, i32 0, i32 3
  %26 = load i32, ptr %25, align 4, !tbaa !12
  %27 = add nsw i32 %26, 1
  store i32 %27, ptr %25, align 4, !tbaa !12
  %28 = load i32, ptr %6, align 4, !tbaa !9
  %29 = icmp eq i32 %28, 7
  br i1 %29, label %30, label %53

30:                                               ; preds = %12
  %31 = load ptr, ptr %5, align 8, !tbaa !5
  %32 = load i32, ptr %6, align 4, !tbaa !9
  %33 = sext i32 %32 to i64
  %34 = call i32 @memcmp(ptr noundef %31, ptr noundef @.str, i64 noundef %33) #5
  %35 = icmp ne i32 %34, 0
  br i1 %35, label %53, label %36

36:                                               ; preds = %30
  %37 = load ptr, ptr %7, align 8, !tbaa !5
  %38 = getelementptr inbounds %struct.IGDdatas, ptr %37, i32 0, i32 8
  %39 = getelementptr inbounds %struct.IGDdatas_service, ptr %38, i32 0, i32 0
  %40 = getelementptr inbounds [128 x i8], ptr %39, i64 0, i64 0
  store i8 0, ptr %40, align 4, !tbaa !11
  %41 = load ptr, ptr %7, align 8, !tbaa !5
  %42 = getelementptr inbounds %struct.IGDdatas, ptr %41, i32 0, i32 8
  %43 = getelementptr inbounds %struct.IGDdatas_service, ptr %42, i32 0, i32 1
  %44 = getelementptr inbounds [128 x i8], ptr %43, i64 0, i64 0
  store i8 0, ptr %44, align 4, !tbaa !11
  %45 = load ptr, ptr %7, align 8, !tbaa !5
  %46 = getelementptr inbounds %struct.IGDdatas, ptr %45, i32 0, i32 8
  %47 = getelementptr inbounds %struct.IGDdatas_service, ptr %46, i32 0, i32 2
  %48 = getelementptr inbounds [128 x i8], ptr %47, i64 0, i64 0
  store i8 0, ptr %48, align 4, !tbaa !11
  %49 = load ptr, ptr %7, align 8, !tbaa !5
  %50 = getelementptr inbounds %struct.IGDdatas, ptr %49, i32 0, i32 8
  %51 = getelementptr inbounds %struct.IGDdatas_service, ptr %50, i32 0, i32 3
  %52 = getelementptr inbounds [128 x i8], ptr %51, i64 0, i64 0
  store i8 0, ptr %52, align 4, !tbaa !11
  br label %53

53:                                               ; preds = %36, %30, %12
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #4
  ret void
}

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

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: readwrite)
declare void @llvm.memcpy.p0.p0.i64(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i64, i1 immarg) #2

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

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

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 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
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 }
attributes #5 = { 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 = !{!13, !10, i64 384}
!13 = !{!"IGDdatas", !7, i64 0, !7, i64 128, !7, i64 256, !10, i64 384, !14, i64 388, !14, i64 900, !14, i64 1412, !14, i64 1924, !14, i64 2436}
!14 = !{!"IGDdatas_service", !7, i64 0, !7, i64 128, !7, i64 256, !7, i64 384}


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

@.str = external hidden unnamed_addr constant [8 x i8], align 1

; Function Attrs: mustprogress nofree nounwind willreturn memory(argmem: readwrite) uwtable
define dso_local void @IGDstartelt(ptr nocapture noundef %0, ptr nocapture noundef readonly %1, i32 noundef %2) local_unnamed_addr #0 {
  %spec.store.select = tail call i32 @llvm.smin.i32(i32 %2, i32 127)
  %4 = sext i32 %spec.store.select to i64
  tail call void @llvm.memcpy.p0.p0.i64(ptr align 4 %0, ptr align 1 %1, i64 %4, i1 false)
  %5 = getelementptr inbounds [128 x i8], ptr %0, i64 0, i64 %4
  store i8 0, ptr %5, align 1, !tbaa !5
  %6 = getelementptr inbounds i8, ptr %0, i64 384
  %7 = load i32, ptr %6, align 4, !tbaa !8
  %8 = add nsw i32 %7, 1
  store i32 %8, ptr %6, align 4, !tbaa !8
  %9 = icmp eq i32 %2, 7
  br i1 %9, label %10, label %16

10:                                               ; preds = %3
  %bcmp = tail call i32 @bcmp(ptr %1, ptr nonnull @.str, i64 %4)
  %.not = icmp eq i32 %bcmp, 0
  br i1 %.not, label %11, label %16

11:                                               ; preds = %10
  %12 = getelementptr inbounds i8, ptr %0, i64 2436
  store i8 0, ptr %12, align 4, !tbaa !5
  %13 = getelementptr inbounds i8, ptr %0, i64 2564
  store i8 0, ptr %13, align 4, !tbaa !5
  %14 = getelementptr inbounds i8, ptr %0, i64 2692
  store i8 0, ptr %14, align 4, !tbaa !5
  %15 = getelementptr inbounds i8, ptr %0, i64 2820
  store i8 0, ptr %15, align 4, !tbaa !5
  br label %16

16:                                               ; preds = %11, %10, %3
  ret void
}

; Function Attrs: mustprogress nocallback nofree nounwind willreturn memory(argmem: readwrite)
declare void @llvm.memcpy.p0.p0.i64(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i64, i1 immarg) #1

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare i32 @llvm.smin.i32(i32, i32) #2

; Function Attrs: nofree nounwind willreturn memory(argmem: read)
declare i32 @bcmp(ptr nocapture, ptr nocapture, i64) local_unnamed_addr #3

attributes #0 = { mustprogress nofree nounwind willreturn memory(argmem: readwrite) 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 nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #3 = { nofree nounwind willreturn memory(argmem: 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 = !{!"omnipotent char", !7, i64 0}
!7 = !{!"Simple C/C++ TBAA"}
!8 = !{!9, !10, i64 384}
!9 = !{!"IGDdatas", !6, i64 0, !6, i64 128, !6, i64 256, !10, i64 384, !11, i64 388, !11, i64 900, !11, i64 1412, !11, i64 1924, !11, i64 2436}
!10 = !{!"int", !6, i64 0}
!11 = !{!"IGDdatas_service", !6, i64 0, !6, i64 128, !6, i64 256, !6, i64 384}


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