; LLVM IR from thalium/icebox :: third_party/virtualbox/src/VBox/Devices/EFI/Firmware/MdePkg/Library (DevPathFromTextIPv4)

; 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.IPv4_DEVICE_PATH = type <{ %struct.EFI_DEVICE_PATH_PROTOCOL, %struct.EFI_IPv4_ADDRESS, %struct.EFI_IPv4_ADDRESS, i16, i16, i16, i8, %struct.EFI_IPv4_ADDRESS, %struct.EFI_IPv4_ADDRESS }>
%struct.EFI_DEVICE_PATH_PROTOCOL = type { i8, i8, [2 x i8] }
%struct.EFI_IPv4_ADDRESS = type { [4 x i8] }

@.str.17 = external hidden unnamed_addr constant [7 x i32], align 4

; 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 ptr @GetNextParamStr(ptr noundef) #1

; Function Attrs: nounwind uwtable
declare dso_local void @StrToIPv4Addr(ptr noundef, ptr noundef) #1

declare ptr @CreateDeviceNode(i8 noundef zeroext, i8 noundef zeroext, i16 noundef zeroext) #2

declare i64 @StrCmp(ptr noundef, ptr noundef) #2

; Function Attrs: nounwind uwtable
declare dso_local i64 @NetworkProtocolFromText(ptr noundef) #1

; Function Attrs: nounwind uwtable
define dso_local ptr @DevPathFromTextIPv4(ptr noundef %0) #1 {
  %2 = alloca ptr, align 8
  %3 = alloca ptr, align 8
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca ptr, align 8
  %8 = alloca ptr, align 8
  %9 = alloca ptr, align 8
  store ptr %0, ptr %2, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %3) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr %4) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #3
  %10 = call ptr @GetNextParamStr(ptr noundef %2)
  store ptr %10, ptr %3, align 8, !tbaa !5
  %11 = call ptr @GetNextParamStr(ptr noundef %2)
  store ptr %11, ptr %4, align 8, !tbaa !5
  %12 = call ptr @GetNextParamStr(ptr noundef %2)
  store ptr %12, ptr %5, align 8, !tbaa !5
  %13 = call ptr @GetNextParamStr(ptr noundef %2)
  store ptr %13, ptr %6, align 8, !tbaa !5
  %14 = call ptr @GetNextParamStr(ptr noundef %2)
  store ptr %14, ptr %7, align 8, !tbaa !5
  %15 = call ptr @GetNextParamStr(ptr noundef %2)
  store ptr %15, ptr %8, align 8, !tbaa !5
  %16 = call ptr @CreateDeviceNode(i8 noundef zeroext 3, i8 noundef zeroext 12, i16 noundef zeroext 27)
  store ptr %16, ptr %9, align 8, !tbaa !5
  %17 = load ptr, ptr %9, align 8, !tbaa !5
  %18 = getelementptr inbounds %struct.IPv4_DEVICE_PATH, ptr %17, i32 0, i32 2
  call void @StrToIPv4Addr(ptr noundef %3, ptr noundef %18)
  %19 = load ptr, ptr %4, align 8, !tbaa !5
  %20 = call i64 @NetworkProtocolFromText(ptr noundef %19)
  %21 = trunc i64 %20 to i16
  %22 = load ptr, ptr %9, align 8, !tbaa !5
  %23 = getelementptr inbounds %struct.IPv4_DEVICE_PATH, ptr %22, i32 0, i32 5
  store i16 %21, ptr %23, align 1, !tbaa !9
  %24 = load ptr, ptr %5, align 8, !tbaa !5
  %25 = call i64 @StrCmp(ptr noundef %24, ptr noundef @.str.17)
  %26 = icmp eq i64 %25, 0
  br i1 %26, label %27, label %30

27:                                               ; preds = %1
  %28 = load ptr, ptr %9, align 8, !tbaa !5
  %29 = getelementptr inbounds %struct.IPv4_DEVICE_PATH, ptr %28, i32 0, i32 6
  store i8 1, ptr %29, align 1, !tbaa !14
  br label %33

30:                                               ; preds = %1
  %31 = load ptr, ptr %9, align 8, !tbaa !5
  %32 = getelementptr inbounds %struct.IPv4_DEVICE_PATH, ptr %31, i32 0, i32 6
  store i8 0, ptr %32, align 1, !tbaa !14
  br label %33

33:                                               ; preds = %30, %27
  %34 = load ptr, ptr %9, align 8, !tbaa !5
  %35 = getelementptr inbounds %struct.IPv4_DEVICE_PATH, ptr %34, i32 0, i32 1
  call void @StrToIPv4Addr(ptr noundef %6, ptr noundef %35)
  %36 = load ptr, ptr %7, align 8, !tbaa !5
  %37 = load i16, ptr %36, align 2, !tbaa !15
  %38 = zext i16 %37 to i32
  %39 = icmp eq i32 %38, 0
  br i1 %39, label %50, label %40

40:                                               ; preds = %33
  %41 = load ptr, ptr %8, align 8, !tbaa !5
  %42 = load i16, ptr %41, align 2, !tbaa !15
  %43 = zext i16 %42 to i32
  %44 = icmp eq i32 %43, 0
  br i1 %44, label %50, label %45

45:                                               ; preds = %40
  %46 = load ptr, ptr %9, align 8, !tbaa !5
  %47 = getelementptr inbounds %struct.IPv4_DEVICE_PATH, ptr %46, i32 0, i32 7
  call void @StrToIPv4Addr(ptr noundef %7, ptr noundef %47)
  %48 = load ptr, ptr %9, align 8, !tbaa !5
  %49 = getelementptr inbounds %struct.IPv4_DEVICE_PATH, ptr %48, i32 0, i32 8
  call void @StrToIPv4Addr(ptr noundef %8, ptr noundef %49)
  br label %57

50:                                               ; preds = %40, %33
  %51 = load ptr, ptr %9, align 8, !tbaa !5
  %52 = getelementptr inbounds %struct.IPv4_DEVICE_PATH, ptr %51, i32 0, i32 7
  %53 = call ptr @ZeroMem(ptr noundef %52, i64 noundef 4)
  %54 = load ptr, ptr %9, align 8, !tbaa !5
  %55 = getelementptr inbounds %struct.IPv4_DEVICE_PATH, ptr %54, i32 0, i32 8
  %56 = call ptr @ZeroMem(ptr noundef %55, i64 noundef 4)
  br label %57

57:                                               ; preds = %50, %45
  %58 = load ptr, ptr %9, align 8, !tbaa !5
  %59 = getelementptr inbounds %struct.IPv4_DEVICE_PATH, ptr %58, i32 0, i32 3
  store i16 0, ptr %59, align 1, !tbaa !16
  %60 = load ptr, ptr %9, align 8, !tbaa !5
  %61 = getelementptr inbounds %struct.IPv4_DEVICE_PATH, ptr %60, i32 0, i32 4
  store i16 0, ptr %61, align 1, !tbaa !17
  %62 = load ptr, ptr %9, align 8, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %4) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %3) #3
  ret ptr %62
}

declare ptr @ZeroMem(ptr noundef, i64 noundef) #2

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 = { "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 }

!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, !13, i64 16}
!10 = !{!"", !11, i64 0, !12, i64 4, !12, i64 8, !13, i64 12, !13, i64 14, !13, i64 16, !7, i64 18, !12, i64 19, !12, i64 23}
!11 = !{!"", !7, i64 0, !7, i64 1, !7, i64 2}
!12 = !{!"", !7, i64 0}
!13 = !{!"short", !7, i64 0}
!14 = !{!10, !7, i64 18}
!15 = !{!13, !13, i64 0}
!16 = !{!10, !13, i64 12}
!17 = !{!10, !13, i64 14}


; 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.17 = external hidden unnamed_addr constant [7 x i32], align 4

; 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 ptr @GetNextParamStr(ptr noundef) local_unnamed_addr #1

; Function Attrs: nounwind uwtable
declare dso_local void @StrToIPv4Addr(ptr noundef, ptr noundef) local_unnamed_addr #1

declare ptr @CreateDeviceNode(i8 noundef zeroext, i8 noundef zeroext, i16 noundef zeroext) local_unnamed_addr #2

declare i64 @StrCmp(ptr noundef, ptr noundef) local_unnamed_addr #2

; Function Attrs: nounwind uwtable
declare dso_local i64 @NetworkProtocolFromText(ptr noundef) local_unnamed_addr #1

; Function Attrs: nounwind uwtable
define dso_local ptr @DevPathFromTextIPv4(ptr noundef %0) local_unnamed_addr #1 {
  %2 = alloca ptr, align 8
  %3 = alloca ptr, align 8
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  store ptr %0, ptr %2, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %3) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %4) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %5) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %6) #3
  %7 = call ptr @GetNextParamStr(ptr noundef nonnull %2)
  store ptr %7, ptr %3, align 8, !tbaa !5
  %8 = call ptr @GetNextParamStr(ptr noundef nonnull %2)
  %9 = call ptr @GetNextParamStr(ptr noundef nonnull %2)
  %10 = call ptr @GetNextParamStr(ptr noundef nonnull %2)
  store ptr %10, ptr %4, align 8, !tbaa !5
  %11 = call ptr @GetNextParamStr(ptr noundef nonnull %2)
  store ptr %11, ptr %5, align 8, !tbaa !5
  %12 = call ptr @GetNextParamStr(ptr noundef nonnull %2)
  store ptr %12, ptr %6, align 8, !tbaa !5
  %13 = call ptr @CreateDeviceNode(i8 noundef zeroext 3, i8 noundef zeroext 12, i16 noundef zeroext 27) #3
  %14 = getelementptr inbounds i8, ptr %13, i64 8
  call void @StrToIPv4Addr(ptr noundef nonnull %3, ptr noundef nonnull %14)
  %15 = call i64 @NetworkProtocolFromText(ptr noundef %8)
  %16 = trunc i64 %15 to i16
  %17 = getelementptr inbounds i8, ptr %13, i64 16
  store i16 %16, ptr %17, align 1, !tbaa !9
  %18 = call i64 @StrCmp(ptr noundef %9, ptr noundef nonnull @.str.17) #3
  %19 = icmp eq i64 %18, 0
  %spec.select = zext i1 %19 to i8
  %20 = getelementptr inbounds i8, ptr %13, i64 18
  store i8 %spec.select, ptr %20, align 1
  %21 = getelementptr inbounds i8, ptr %13, i64 4
  call void @StrToIPv4Addr(ptr noundef nonnull %4, ptr noundef nonnull %21)
  %22 = load i16, ptr %11, align 2, !tbaa !14
  %23 = icmp eq i16 %22, 0
  br i1 %23, label %30, label %24

24:                                               ; preds = %1
  %25 = load i16, ptr %12, align 2, !tbaa !14
  %26 = icmp eq i16 %25, 0
  br i1 %26, label %30, label %27

27:                                               ; preds = %24
  %28 = getelementptr inbounds i8, ptr %13, i64 19
  call void @StrToIPv4Addr(ptr noundef nonnull %5, ptr noundef nonnull %28)
  %29 = getelementptr inbounds i8, ptr %13, i64 23
  call void @StrToIPv4Addr(ptr noundef nonnull %6, ptr noundef nonnull %29)
  br label %35

30:                                               ; preds = %24, %1
  %31 = getelementptr inbounds i8, ptr %13, i64 19
  %32 = call ptr @ZeroMem(ptr noundef nonnull %31, i64 noundef 4) #3
  %33 = getelementptr inbounds i8, ptr %13, i64 23
  %34 = call ptr @ZeroMem(ptr noundef nonnull %33, i64 noundef 4) #3
  br label %35

35:                                               ; preds = %30, %27
  %36 = getelementptr inbounds i8, ptr %13, i64 12
  store i16 0, ptr %36, align 1, !tbaa !15
  %37 = getelementptr inbounds i8, ptr %13, i64 14
  store i16 0, ptr %37, align 1, !tbaa !16
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %6) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %5) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %4) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %3) #3
  ret ptr %13
}

declare ptr @ZeroMem(ptr noundef, i64 noundef) local_unnamed_addr #2

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 = { "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 }

!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, !13, i64 16}
!10 = !{!"", !11, i64 0, !12, i64 4, !12, i64 8, !13, i64 12, !13, i64 14, !13, i64 16, !7, i64 18, !12, i64 19, !12, i64 23}
!11 = !{!"", !7, i64 0, !7, i64 1, !7, i64 2}
!12 = !{!"", !7, i64 0}
!13 = !{!"short", !7, i64 0}
!14 = !{!13, !13, i64 0}
!15 = !{!10, !13, i64 12}
!16 = !{!10, !13, i64 14}


; Effective O3 passes: GVNPass,GlobalOptPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,MergedLoadStoreMotionPass,SROAPass,SimplifyCFGPass