; LLVM IR from thalium/icebox :: third_party/virtualbox/src/VBox/Devices/EFI/Firmware/MdeModulePkg/Universal (Mtftp4SetTimeout)

; 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._MTFTP4_PROTOCOL = type { i32, %struct._LIST_ENTRY, %struct._EFI_MTFTP4_PROTOCOL, i64, i8, ptr, ptr, %struct.EFI_MTFTP4_CONFIG_DATA, ptr, %struct.MTFTP4_OPTION, i16, i16, i16, %struct._LIST_ENTRY, i32, i16, i16, i32, ptr, ptr, i32, i32, i32, i32, i32, i16, i8, ptr }
%struct._EFI_MTFTP4_PROTOCOL = type { ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr }
%struct.EFI_MTFTP4_CONFIG_DATA = type { i8, %struct.EFI_IPv4_ADDRESS, %struct.EFI_IPv4_ADDRESS, i16, %struct.EFI_IPv4_ADDRESS, %struct.EFI_IPv4_ADDRESS, i16, i16, i16 }
%struct.EFI_IPv4_ADDRESS = type { [4 x i8] }
%struct.MTFTP4_OPTION = type { i16, i8, i32, i32, i16, i8, i32 }
%struct._LIST_ENTRY = type { ptr, ptr }

; Function Attrs: nounwind uwtable
define dso_local void @Mtftp4SetTimeout(ptr noundef %0) #0 {
  %2 = alloca ptr, align 8
  store ptr %0, ptr %2, align 8, !tbaa !5
  %3 = load ptr, ptr %2, align 8, !tbaa !5
  %4 = getelementptr inbounds %struct._MTFTP4_PROTOCOL, ptr %3, i32 0, i32 26
  %5 = load i8, ptr %4, align 2, !tbaa !9
  %6 = icmp ne i8 %5, 0
  br i1 %6, label %7, label %13

7:                                                ; preds = %1
  %8 = load ptr, ptr %2, align 8, !tbaa !5
  %9 = getelementptr inbounds %struct._MTFTP4_PROTOCOL, ptr %8, i32 0, i32 23
  %10 = load i32, ptr %9, align 4, !tbaa !19
  %11 = load ptr, ptr %2, align 8, !tbaa !5
  %12 = getelementptr inbounds %struct._MTFTP4_PROTOCOL, ptr %11, i32 0, i32 20
  store i32 %10, ptr %12, align 8, !tbaa !20
  br label %20

13:                                               ; preds = %1
  %14 = load ptr, ptr %2, align 8, !tbaa !5
  %15 = getelementptr inbounds %struct._MTFTP4_PROTOCOL, ptr %14, i32 0, i32 23
  %16 = load i32, ptr %15, align 4, !tbaa !19
  %17 = mul i32 %16, 2
  %18 = load ptr, ptr %2, align 8, !tbaa !5
  %19 = getelementptr inbounds %struct._MTFTP4_PROTOCOL, ptr %18, i32 0, i32 20
  store i32 %17, ptr %19, align 8, !tbaa !20
  br label %20

20:                                               ; preds = %13, %7
  ret void
}

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

!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, !7, i64 262}
!10 = !{!"_MTFTP4_PROTOCOL", !11, i64 0, !12, i64 8, !13, i64 24, !14, i64 88, !7, i64 96, !6, i64 104, !6, i64 112, !15, i64 120, !6, i64 152, !18, i64 160, !17, i64 180, !17, i64 182, !17, i64 184, !12, i64 192, !11, i64 208, !17, i64 212, !17, i64 214, !11, i64 216, !6, i64 224, !6, i64 232, !11, i64 240, !11, i64 244, !11, i64 248, !11, i64 252, !11, i64 256, !17, i64 260, !7, i64 262, !6, i64 264}
!11 = !{!"int", !7, i64 0}
!12 = !{!"_LIST_ENTRY", !6, i64 0, !6, i64 8}
!13 = !{!"_EFI_MTFTP4_PROTOCOL", !6, i64 0, !6, i64 8, !6, i64 16, !6, i64 24, !6, i64 32, !6, i64 40, !6, i64 48, !6, i64 56}
!14 = !{!"long long", !7, i64 0}
!15 = !{!"", !7, i64 0, !16, i64 1, !16, i64 5, !17, i64 10, !16, i64 12, !16, i64 16, !17, i64 20, !17, i64 22, !17, i64 24}
!16 = !{!"", !7, i64 0}
!17 = !{!"short", !7, i64 0}
!18 = !{!"", !17, i64 0, !7, i64 2, !11, i64 4, !11, i64 8, !17, i64 12, !7, i64 14, !11, i64 16}
!19 = !{!10, !11, i64 252}
!20 = !{!10, !11, i64 240}


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

; Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn memory(argmem: readwrite) uwtable
define dso_local void @Mtftp4SetTimeout(ptr nocapture noundef %0) local_unnamed_addr #0 {
  %2 = getelementptr inbounds i8, ptr %0, i64 262
  %3 = load i8, ptr %2, align 2, !tbaa !5
  %.not = icmp eq i8 %3, 0
  %4 = getelementptr inbounds i8, ptr %0, i64 252
  %5 = load i32, ptr %4, align 4, !tbaa !18
  %6 = zext i1 %.not to i32
  %.sink = shl i32 %5, %6
  %7 = getelementptr inbounds i8, ptr %0, i64 240
  store i32 %.sink, ptr %7, align 8
  ret void
}

attributes #0 = { mustprogress nofree norecurse nosync 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" }

!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, !8, i64 262}
!6 = !{!"_MTFTP4_PROTOCOL", !7, i64 0, !10, i64 8, !12, i64 24, !13, i64 88, !8, i64 96, !11, i64 104, !11, i64 112, !14, i64 120, !11, i64 152, !17, i64 160, !16, i64 180, !16, i64 182, !16, i64 184, !10, i64 192, !7, i64 208, !16, i64 212, !16, i64 214, !7, i64 216, !11, i64 224, !11, i64 232, !7, i64 240, !7, i64 244, !7, i64 248, !7, i64 252, !7, i64 256, !16, i64 260, !8, i64 262, !11, i64 264}
!7 = !{!"int", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"_LIST_ENTRY", !11, i64 0, !11, i64 8}
!11 = !{!"any pointer", !8, i64 0}
!12 = !{!"_EFI_MTFTP4_PROTOCOL", !11, i64 0, !11, i64 8, !11, i64 16, !11, i64 24, !11, i64 32, !11, i64 40, !11, i64 48, !11, i64 56}
!13 = !{!"long long", !8, i64 0}
!14 = !{!"", !8, i64 0, !15, i64 1, !15, i64 5, !16, i64 10, !15, i64 12, !15, i64 16, !16, i64 20, !16, i64 22, !16, i64 24}
!15 = !{!"", !8, i64 0}
!16 = !{!"short", !8, i64 0}
!17 = !{!"", !16, i64 0, !8, i64 2, !7, i64 4, !7, i64 8, !16, i64 12, !8, i64 14, !7, i64 16}
!18 = !{!6, !7, i64 252}


; Effective O3 passes: GlobalOptPass,InstCombinePass,MergedLoadStoreMotionPass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass