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

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

@.str.17 = external hidden unnamed_addr constant [7 x i32], align 4
@.str.18 = external hidden unnamed_addr constant [23 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 i64 @Strtoi(ptr noundef) #1

; Function Attrs: nounwind uwtable
declare dso_local void @StrToIPv6Addr(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

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

; Function Attrs: nounwind uwtable
define dso_local ptr @DevPathFromTextIPv6(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 %8, align 8, !tbaa !5
  %15 = call ptr @GetNextParamStr(ptr noundef %2)
  store ptr %15, ptr %7, align 8, !tbaa !5
  %16 = call ptr @CreateDeviceNode(i8 noundef zeroext 3, i8 noundef zeroext 13, i16 noundef zeroext 60)
  store ptr %16, ptr %9, align 8, !tbaa !5
  %17 = load ptr, ptr %9, align 8, !tbaa !5
  %18 = getelementptr inbounds %struct.IPv6_DEVICE_PATH, ptr %17, i32 0, i32 2
  call void @StrToIPv6Addr(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.IPv6_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.IPv6_DEVICE_PATH, ptr %28, i32 0, i32 6
  store i8 0, ptr %29, align 1, !tbaa !14
  br label %41

30:                                               ; preds = %1
  %31 = load ptr, ptr %5, align 8, !tbaa !5
  %32 = call i64 @StrCmp(ptr noundef %31, ptr noundef @.str.18)
  %33 = icmp eq i64 %32, 0
  br i1 %33, label %34, label %37

34:                                               ; preds = %30
  %35 = load ptr, ptr %9, align 8, !tbaa !5
  %36 = getelementptr inbounds %struct.IPv6_DEVICE_PATH, ptr %35, i32 0, i32 6
  store i8 1, ptr %36, align 1, !tbaa !14
  br label %40

37:                                               ; preds = %30
  %38 = load ptr, ptr %9, align 8, !tbaa !5
  %39 = getelementptr inbounds %struct.IPv6_DEVICE_PATH, ptr %38, i32 0, i32 6
  store i8 2, ptr %39, align 1, !tbaa !14
  br label %40

40:                                               ; preds = %37, %34
  br label %41

41:                                               ; preds = %40, %27
  %42 = load ptr, ptr %9, align 8, !tbaa !5
  %43 = getelementptr inbounds %struct.IPv6_DEVICE_PATH, ptr %42, i32 0, i32 1
  call void @StrToIPv6Addr(ptr noundef %6, ptr noundef %43)
  %44 = load ptr, ptr %7, align 8, !tbaa !5
  %45 = load i16, ptr %44, align 2, !tbaa !15
  %46 = zext i16 %45 to i32
  %47 = icmp eq i32 %46, 0
  br i1 %47, label %61, label %48

48:                                               ; preds = %41
  %49 = load ptr, ptr %8, align 8, !tbaa !5
  %50 = load i16, ptr %49, align 2, !tbaa !15
  %51 = zext i16 %50 to i32
  %52 = icmp eq i32 %51, 0
  br i1 %52, label %61, label %53

53:                                               ; preds = %48
  %54 = load ptr, ptr %9, align 8, !tbaa !5
  %55 = getelementptr inbounds %struct.IPv6_DEVICE_PATH, ptr %54, i32 0, i32 8
  call void @StrToIPv6Addr(ptr noundef %7, ptr noundef %55)
  %56 = load ptr, ptr %8, align 8, !tbaa !5
  %57 = call i64 @Strtoi(ptr noundef %56)
  %58 = trunc i64 %57 to i8
  %59 = load ptr, ptr %9, align 8, !tbaa !5
  %60 = getelementptr inbounds %struct.IPv6_DEVICE_PATH, ptr %59, i32 0, i32 7
  store i8 %58, ptr %60, align 1, !tbaa !16
  br label %67

61:                                               ; preds = %48, %41
  %62 = load ptr, ptr %9, align 8, !tbaa !5
  %63 = getelementptr inbounds %struct.IPv6_DEVICE_PATH, ptr %62, i32 0, i32 8
  %64 = call ptr @ZeroMem(ptr noundef %63, i64 noundef 16)
  %65 = load ptr, ptr %9, align 8, !tbaa !5
  %66 = getelementptr inbounds %struct.IPv6_DEVICE_PATH, ptr %65, i32 0, i32 7
  store i8 0, ptr %66, align 1, !tbaa !16
  br label %67

67:                                               ; preds = %61, %53
  %68 = load ptr, ptr %9, align 8, !tbaa !5
  %69 = getelementptr inbounds %struct.IPv6_DEVICE_PATH, ptr %68, i32 0, i32 3
  store i16 0, ptr %69, align 1, !tbaa !17
  %70 = load ptr, ptr %9, align 8, !tbaa !5
  %71 = getelementptr inbounds %struct.IPv6_DEVICE_PATH, ptr %70, i32 0, i32 4
  store i16 0, ptr %71, align 1, !tbaa !18
  %72 = 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 %72
}

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 40}
!10 = !{!"", !11, i64 0, !12, i64 4, !12, i64 20, !13, i64 36, !13, i64 38, !13, i64 40, !7, i64 42, !7, i64 43, !12, i64 44}
!11 = !{!"", !7, i64 0, !7, i64 1, !7, i64 2}
!12 = !{!"", !7, i64 0}
!13 = !{!"short", !7, i64 0}
!14 = !{!10, !7, i64 42}
!15 = !{!13, !13, i64 0}
!16 = !{!10, !7, i64 43}
!17 = !{!10, !13, i64 36}
!18 = !{!10, !13, i64 38}


; 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
@.str.18 = external hidden unnamed_addr constant [23 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 i64 @Strtoi(ptr noundef) local_unnamed_addr #1

; Function Attrs: nounwind uwtable
declare dso_local void @StrToIPv6Addr(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

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

; Function Attrs: nounwind uwtable
define dso_local ptr @DevPathFromTextIPv6(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
  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
  %6 = call ptr @GetNextParamStr(ptr noundef nonnull %2)
  store ptr %6, ptr %3, align 8, !tbaa !5
  %7 = call ptr @GetNextParamStr(ptr noundef nonnull %2)
  %8 = call ptr @GetNextParamStr(ptr noundef nonnull %2)
  %9 = call ptr @GetNextParamStr(ptr noundef nonnull %2)
  store ptr %9, ptr %4, align 8, !tbaa !5
  %10 = call ptr @GetNextParamStr(ptr noundef nonnull %2)
  %11 = call ptr @GetNextParamStr(ptr noundef nonnull %2)
  store ptr %11, ptr %5, align 8, !tbaa !5
  %12 = call ptr @CreateDeviceNode(i8 noundef zeroext 3, i8 noundef zeroext 13, i16 noundef zeroext 60) #3
  %13 = getelementptr inbounds i8, ptr %12, i64 20
  call void @StrToIPv6Addr(ptr noundef nonnull %3, ptr noundef nonnull %13)
  %14 = call i64 @NetworkProtocolFromText(ptr noundef %7)
  %15 = trunc i64 %14 to i16
  %16 = getelementptr inbounds i8, ptr %12, i64 40
  store i16 %15, ptr %16, align 1, !tbaa !9
  %17 = call i64 @StrCmp(ptr noundef %8, ptr noundef nonnull @.str.17) #3
  %18 = icmp eq i64 %17, 0
  br i1 %18, label %19, label %21

19:                                               ; preds = %1
  %20 = getelementptr inbounds i8, ptr %12, i64 42
  store i8 0, ptr %20, align 1, !tbaa !14
  br label %27

21:                                               ; preds = %1
  %22 = call i64 @StrCmp(ptr noundef %8, ptr noundef nonnull @.str.18) #3
  %23 = icmp eq i64 %22, 0
  %24 = getelementptr inbounds i8, ptr %12, i64 42
  br i1 %23, label %25, label %26

25:                                               ; preds = %21
  store i8 1, ptr %24, align 1, !tbaa !14
  br label %27

26:                                               ; preds = %21
  store i8 2, ptr %24, align 1, !tbaa !14
  br label %27

27:                                               ; preds = %25, %26, %19
  %28 = getelementptr inbounds i8, ptr %12, i64 4
  call void @StrToIPv6Addr(ptr noundef nonnull %4, ptr noundef nonnull %28)
  %29 = load i16, ptr %11, align 2, !tbaa !15
  %30 = icmp eq i16 %29, 0
  br i1 %30, label %38, label %31

31:                                               ; preds = %27
  %32 = load i16, ptr %10, align 2, !tbaa !15
  %33 = icmp eq i16 %32, 0
  br i1 %33, label %38, label %34

34:                                               ; preds = %31
  %35 = getelementptr inbounds i8, ptr %12, i64 44
  call void @StrToIPv6Addr(ptr noundef nonnull %5, ptr noundef nonnull %35)
  %36 = call i64 @Strtoi(ptr noundef nonnull %10)
  %37 = trunc i64 %36 to i8
  br label %41

38:                                               ; preds = %31, %27
  %39 = getelementptr inbounds i8, ptr %12, i64 44
  %40 = call ptr @ZeroMem(ptr noundef nonnull %39, i64 noundef 16) #3
  br label %41

41:                                               ; preds = %38, %34
  %.sink = phi i8 [ 0, %38 ], [ %37, %34 ]
  %42 = getelementptr inbounds i8, ptr %12, i64 43
  store i8 %.sink, ptr %42, align 1, !tbaa !16
  %43 = getelementptr inbounds i8, ptr %12, i64 36
  store i16 0, ptr %43, align 1, !tbaa !17
  %44 = getelementptr inbounds i8, ptr %12, i64 38
  store i16 0, ptr %44, align 1, !tbaa !18
  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 %12
}

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 40}
!10 = !{!"", !11, i64 0, !12, i64 4, !12, i64 20, !13, i64 36, !13, i64 38, !13, i64 40, !7, i64 42, !7, i64 43, !12, i64 44}
!11 = !{!"", !7, i64 0, !7, i64 1, !7, i64 2}
!12 = !{!"", !7, i64 0}
!13 = !{!"short", !7, i64 0}
!14 = !{!10, !7, i64 42}
!15 = !{!13, !13, i64 0}
!16 = !{!10, !7, i64 43}
!17 = !{!10, !13, i64 36}
!18 = !{!10, !13, i64 38}


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