; LLVM IR from thalium/icebox :: third_party/virtualbox/src/VBox/Devices/EFI/Firmware/ShellPkg/Application (CreateSimpleTextOutOnFile)

; 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.GUID = type { i32, i16, i16, [8 x i8] }
%struct.SHELL_EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL = type { %struct._EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL, ptr, ptr, ptr }
%struct._EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL = type { ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr }
%struct.EFI_SIMPLE_TEXT_OUTPUT_MODE = type { i32, i32, i32, i32, i32, i8 }
%struct.EFI_BOOT_SERVICES = type { %struct.EFI_TABLE_HEADER, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr }
%struct.EFI_TABLE_HEADER = type { i64, i32, i32, i32, i32 }

@gBS = external global ptr, align 8
@gEfiSimpleTextOutProtocolGuid = external global %struct.GUID, 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

declare ptr @AllocateZeroPool(i64 noundef) #1

declare void @FreePool(ptr noundef) #1

; Function Attrs: nounwind uwtable
declare dso_local i64 @FileBasedSimpleTextOutReset(ptr noundef, i8 noundef zeroext) #2

; Function Attrs: nounwind uwtable
declare dso_local i64 @FileBasedSimpleTextOutTestString(ptr noundef, ptr noundef) #2

; Function Attrs: nounwind uwtable
declare dso_local i64 @FileBasedSimpleTextOutQueryMode(ptr noundef, i64 noundef, ptr noundef, ptr noundef) #2

; Function Attrs: nounwind uwtable
declare dso_local i64 @FileBasedSimpleTextOutSetMode(ptr noundef, i64 noundef) #2

; Function Attrs: nounwind uwtable
declare dso_local i64 @FileBasedSimpleTextOutSetAttribute(ptr noundef, i64 noundef) #2

; Function Attrs: nounwind uwtable
declare dso_local i64 @FileBasedSimpleTextOutClearScreen(ptr noundef) #2

; Function Attrs: nounwind uwtable
declare dso_local i64 @FileBasedSimpleTextOutSetCursorPosition(ptr noundef, i64 noundef, i64 noundef) #2

; Function Attrs: nounwind uwtable
declare dso_local i64 @FileBasedSimpleTextOutEnableCursor(ptr noundef, i8 noundef zeroext) #2

; Function Attrs: nounwind uwtable
declare dso_local i64 @FileBasedSimpleTextOutOutputString(ptr noundef, ptr noundef) #2

; Function Attrs: nounwind uwtable
define dso_local ptr @CreateSimpleTextOutOnFile(ptr noundef %0, ptr noundef %1, ptr noundef %2) #2 {
  %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 i64, align 8
  %10 = alloca i32, align 4
  store ptr %0, ptr %5, align 8, !tbaa !5
  store ptr %1, ptr %6, align 8, !tbaa !5
  store ptr %2, ptr %7, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #3
  %11 = load ptr, ptr %6, align 8, !tbaa !5
  %12 = icmp eq ptr %11, null
  br i1 %12, label %16, label %13

13:                                               ; preds = %3
  %14 = load ptr, ptr %5, align 8, !tbaa !5
  %15 = icmp eq ptr %14, null
  br i1 %15, label %16, label %17

16:                                               ; preds = %13, %3
  store ptr null, ptr %4, align 8
  store i32 1, ptr %10, align 4
  br label %146

17:                                               ; preds = %13
  %18 = call ptr @AllocateZeroPool(i64 noundef 104)
  store ptr %18, ptr %8, align 8, !tbaa !5
  %19 = load ptr, ptr %8, align 8, !tbaa !5
  %20 = icmp eq ptr %19, null
  br i1 %20, label %21, label %22

21:                                               ; preds = %17
  store ptr null, ptr %4, align 8
  store i32 1, ptr %10, align 4
  br label %146

22:                                               ; preds = %17
  %23 = load ptr, ptr %5, align 8, !tbaa !5
  %24 = load ptr, ptr %8, align 8, !tbaa !5
  %25 = getelementptr inbounds %struct.SHELL_EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL, ptr %24, i32 0, i32 1
  store ptr %23, ptr %25, align 8, !tbaa !9
  %26 = load ptr, ptr %7, align 8, !tbaa !5
  %27 = load ptr, ptr %8, align 8, !tbaa !5
  %28 = getelementptr inbounds %struct.SHELL_EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL, ptr %27, i32 0, i32 3
  store ptr %26, ptr %28, align 8, !tbaa !12
  %29 = load ptr, ptr %8, align 8, !tbaa !5
  %30 = getelementptr inbounds %struct.SHELL_EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL, ptr %29, i32 0, i32 0
  %31 = getelementptr inbounds %struct._EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL, ptr %30, i32 0, i32 0
  store ptr @FileBasedSimpleTextOutReset, ptr %31, align 8, !tbaa !13
  %32 = load ptr, ptr %8, align 8, !tbaa !5
  %33 = getelementptr inbounds %struct.SHELL_EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL, ptr %32, i32 0, i32 0
  %34 = getelementptr inbounds %struct._EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL, ptr %33, i32 0, i32 2
  store ptr @FileBasedSimpleTextOutTestString, ptr %34, align 8, !tbaa !14
  %35 = load ptr, ptr %8, align 8, !tbaa !5
  %36 = getelementptr inbounds %struct.SHELL_EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL, ptr %35, i32 0, i32 0
  %37 = getelementptr inbounds %struct._EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL, ptr %36, i32 0, i32 3
  store ptr @FileBasedSimpleTextOutQueryMode, ptr %37, align 8, !tbaa !15
  %38 = load ptr, ptr %8, align 8, !tbaa !5
  %39 = getelementptr inbounds %struct.SHELL_EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL, ptr %38, i32 0, i32 0
  %40 = getelementptr inbounds %struct._EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL, ptr %39, i32 0, i32 4
  store ptr @FileBasedSimpleTextOutSetMode, ptr %40, align 8, !tbaa !16
  %41 = load ptr, ptr %8, align 8, !tbaa !5
  %42 = getelementptr inbounds %struct.SHELL_EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL, ptr %41, i32 0, i32 0
  %43 = getelementptr inbounds %struct._EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL, ptr %42, i32 0, i32 5
  store ptr @FileBasedSimpleTextOutSetAttribute, ptr %43, align 8, !tbaa !17
  %44 = load ptr, ptr %8, align 8, !tbaa !5
  %45 = getelementptr inbounds %struct.SHELL_EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL, ptr %44, i32 0, i32 0
  %46 = getelementptr inbounds %struct._EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL, ptr %45, i32 0, i32 6
  store ptr @FileBasedSimpleTextOutClearScreen, ptr %46, align 8, !tbaa !18
  %47 = load ptr, ptr %8, align 8, !tbaa !5
  %48 = getelementptr inbounds %struct.SHELL_EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL, ptr %47, i32 0, i32 0
  %49 = getelementptr inbounds %struct._EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL, ptr %48, i32 0, i32 7
  store ptr @FileBasedSimpleTextOutSetCursorPosition, ptr %49, align 8, !tbaa !19
  %50 = load ptr, ptr %8, align 8, !tbaa !5
  %51 = getelementptr inbounds %struct.SHELL_EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL, ptr %50, i32 0, i32 0
  %52 = getelementptr inbounds %struct._EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL, ptr %51, i32 0, i32 8
  store ptr @FileBasedSimpleTextOutEnableCursor, ptr %52, align 8, !tbaa !20
  %53 = load ptr, ptr %8, align 8, !tbaa !5
  %54 = getelementptr inbounds %struct.SHELL_EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL, ptr %53, i32 0, i32 0
  %55 = getelementptr inbounds %struct._EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL, ptr %54, i32 0, i32 1
  store ptr @FileBasedSimpleTextOutOutputString, ptr %55, align 8, !tbaa !21
  %56 = call ptr @AllocateZeroPool(i64 noundef 24)
  %57 = load ptr, ptr %8, align 8, !tbaa !5
  %58 = getelementptr inbounds %struct.SHELL_EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL, ptr %57, i32 0, i32 0
  %59 = getelementptr inbounds %struct._EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL, ptr %58, i32 0, i32 9
  store ptr %56, ptr %59, align 8, !tbaa !22
  %60 = load ptr, ptr %8, align 8, !tbaa !5
  %61 = getelementptr inbounds %struct.SHELL_EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL, ptr %60, i32 0, i32 0
  %62 = getelementptr inbounds %struct._EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL, ptr %61, i32 0, i32 9
  %63 = load ptr, ptr %62, align 8, !tbaa !22
  %64 = icmp eq ptr %63, null
  br i1 %64, label %65, label %67

65:                                               ; preds = %22
  %66 = load ptr, ptr %8, align 8, !tbaa !5
  call void @FreePool(ptr noundef %66)
  store ptr null, ptr %4, align 8
  store i32 1, ptr %10, align 4
  br label %146

67:                                               ; preds = %22
  %68 = load ptr, ptr %7, align 8, !tbaa !5
  %69 = getelementptr inbounds %struct._EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL, ptr %68, i32 0, i32 9
  %70 = load ptr, ptr %69, align 8, !tbaa !23
  %71 = getelementptr inbounds %struct.EFI_SIMPLE_TEXT_OUTPUT_MODE, ptr %70, i32 0, i32 0
  %72 = load i32, ptr %71, align 4, !tbaa !24
  %73 = load ptr, ptr %8, align 8, !tbaa !5
  %74 = getelementptr inbounds %struct.SHELL_EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL, ptr %73, i32 0, i32 0
  %75 = getelementptr inbounds %struct._EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL, ptr %74, i32 0, i32 9
  %76 = load ptr, ptr %75, align 8, !tbaa !22
  %77 = getelementptr inbounds %struct.EFI_SIMPLE_TEXT_OUTPUT_MODE, ptr %76, i32 0, i32 0
  store i32 %72, ptr %77, align 4, !tbaa !24
  %78 = load ptr, ptr %7, align 8, !tbaa !5
  %79 = getelementptr inbounds %struct._EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL, ptr %78, i32 0, i32 9
  %80 = load ptr, ptr %79, align 8, !tbaa !23
  %81 = getelementptr inbounds %struct.EFI_SIMPLE_TEXT_OUTPUT_MODE, ptr %80, i32 0, i32 1
  %82 = load i32, ptr %81, align 4, !tbaa !27
  %83 = load ptr, ptr %8, align 8, !tbaa !5
  %84 = getelementptr inbounds %struct.SHELL_EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL, ptr %83, i32 0, i32 0
  %85 = getelementptr inbounds %struct._EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL, ptr %84, i32 0, i32 9
  %86 = load ptr, ptr %85, align 8, !tbaa !22
  %87 = getelementptr inbounds %struct.EFI_SIMPLE_TEXT_OUTPUT_MODE, ptr %86, i32 0, i32 1
  store i32 %82, ptr %87, align 4, !tbaa !27
  %88 = load ptr, ptr %7, align 8, !tbaa !5
  %89 = getelementptr inbounds %struct._EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL, ptr %88, i32 0, i32 9
  %90 = load ptr, ptr %89, align 8, !tbaa !23
  %91 = getelementptr inbounds %struct.EFI_SIMPLE_TEXT_OUTPUT_MODE, ptr %90, i32 0, i32 2
  %92 = load i32, ptr %91, align 4, !tbaa !28
  %93 = load ptr, ptr %8, align 8, !tbaa !5
  %94 = getelementptr inbounds %struct.SHELL_EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL, ptr %93, i32 0, i32 0
  %95 = getelementptr inbounds %struct._EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL, ptr %94, i32 0, i32 9
  %96 = load ptr, ptr %95, align 8, !tbaa !22
  %97 = getelementptr inbounds %struct.EFI_SIMPLE_TEXT_OUTPUT_MODE, ptr %96, i32 0, i32 2
  store i32 %92, ptr %97, align 4, !tbaa !28
  %98 = load ptr, ptr %7, align 8, !tbaa !5
  %99 = getelementptr inbounds %struct._EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL, ptr %98, i32 0, i32 9
  %100 = load ptr, ptr %99, align 8, !tbaa !23
  %101 = getelementptr inbounds %struct.EFI_SIMPLE_TEXT_OUTPUT_MODE, ptr %100, i32 0, i32 3
  %102 = load i32, ptr %101, align 4, !tbaa !29
  %103 = load ptr, ptr %8, align 8, !tbaa !5
  %104 = getelementptr inbounds %struct.SHELL_EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL, ptr %103, i32 0, i32 0
  %105 = getelementptr inbounds %struct._EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL, ptr %104, i32 0, i32 9
  %106 = load ptr, ptr %105, align 8, !tbaa !22
  %107 = getelementptr inbounds %struct.EFI_SIMPLE_TEXT_OUTPUT_MODE, ptr %106, i32 0, i32 3
  store i32 %102, ptr %107, align 4, !tbaa !29
  %108 = load ptr, ptr %7, align 8, !tbaa !5
  %109 = getelementptr inbounds %struct._EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL, ptr %108, i32 0, i32 9
  %110 = load ptr, ptr %109, align 8, !tbaa !23
  %111 = getelementptr inbounds %struct.EFI_SIMPLE_TEXT_OUTPUT_MODE, ptr %110, i32 0, i32 4
  %112 = load i32, ptr %111, align 4, !tbaa !30
  %113 = load ptr, ptr %8, align 8, !tbaa !5
  %114 = getelementptr inbounds %struct.SHELL_EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL, ptr %113, i32 0, i32 0
  %115 = getelementptr inbounds %struct._EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL, ptr %114, i32 0, i32 9
  %116 = load ptr, ptr %115, align 8, !tbaa !22
  %117 = getelementptr inbounds %struct.EFI_SIMPLE_TEXT_OUTPUT_MODE, ptr %116, i32 0, i32 4
  store i32 %112, ptr %117, align 4, !tbaa !30
  %118 = load ptr, ptr %7, align 8, !tbaa !5
  %119 = getelementptr inbounds %struct._EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL, ptr %118, i32 0, i32 9
  %120 = load ptr, ptr %119, align 8, !tbaa !23
  %121 = getelementptr inbounds %struct.EFI_SIMPLE_TEXT_OUTPUT_MODE, ptr %120, i32 0, i32 5
  %122 = load i8, ptr %121, align 4, !tbaa !31
  %123 = load ptr, ptr %8, align 8, !tbaa !5
  %124 = getelementptr inbounds %struct.SHELL_EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL, ptr %123, i32 0, i32 0
  %125 = getelementptr inbounds %struct._EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL, ptr %124, i32 0, i32 9
  %126 = load ptr, ptr %125, align 8, !tbaa !22
  %127 = getelementptr inbounds %struct.EFI_SIMPLE_TEXT_OUTPUT_MODE, ptr %126, i32 0, i32 5
  store i8 %122, ptr %127, align 4, !tbaa !31
  %128 = load ptr, ptr @gBS, align 8, !tbaa !5
  %129 = getelementptr inbounds %struct.EFI_BOOT_SERVICES, ptr %128, i32 0, i32 14
  %130 = load ptr, ptr %129, align 8, !tbaa !32
  %131 = load ptr, ptr %8, align 8, !tbaa !5
  %132 = getelementptr inbounds %struct.SHELL_EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL, ptr %131, i32 0, i32 2
  %133 = load ptr, ptr %8, align 8, !tbaa !5
  %134 = getelementptr inbounds %struct.SHELL_EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL, ptr %133, i32 0, i32 0
  %135 = call i64 %130(ptr noundef %132, ptr noundef @gEfiSimpleTextOutProtocolGuid, i32 noundef 0, ptr noundef %134)
  store i64 %135, ptr %9, align 8, !tbaa !36
  %136 = load i64, ptr %9, align 8, !tbaa !36
  %137 = icmp slt i64 %136, 0
  br i1 %137, label %144, label %138

138:                                              ; preds = %67
  %139 = load ptr, ptr %8, align 8, !tbaa !5
  %140 = getelementptr inbounds %struct.SHELL_EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL, ptr %139, i32 0, i32 2
  %141 = load ptr, ptr %140, align 8, !tbaa !37
  %142 = load ptr, ptr %6, align 8, !tbaa !5
  store ptr %141, ptr %142, align 8, !tbaa !5
  %143 = load ptr, ptr %8, align 8, !tbaa !5
  store ptr %143, ptr %4, align 8
  store i32 1, ptr %10, align 4
  br label %146

144:                                              ; preds = %67
  %145 = load ptr, ptr %8, align 8, !tbaa !5
  call void @FreePool(ptr noundef %145)
  store ptr null, ptr %4, align 8
  store i32 1, ptr %10, align 4
  br label %146

146:                                              ; preds = %144, %138, %65, %21, %16
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #3
  %147 = load ptr, ptr %4, align 8
  ret ptr %147
}

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { "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 = { 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 #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, !6, i64 80}
!10 = !{!"", !11, i64 0, !6, i64 80, !6, i64 88, !6, i64 96}
!11 = !{!"_EFI_SIMPLE_TEXT_OUTPUT_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, !6, i64 64, !6, i64 72}
!12 = !{!10, !6, i64 96}
!13 = !{!10, !6, i64 0}
!14 = !{!10, !6, i64 16}
!15 = !{!10, !6, i64 24}
!16 = !{!10, !6, i64 32}
!17 = !{!10, !6, i64 40}
!18 = !{!10, !6, i64 48}
!19 = !{!10, !6, i64 56}
!20 = !{!10, !6, i64 64}
!21 = !{!10, !6, i64 8}
!22 = !{!10, !6, i64 72}
!23 = !{!11, !6, i64 72}
!24 = !{!25, !26, i64 0}
!25 = !{!"", !26, i64 0, !26, i64 4, !26, i64 8, !26, i64 12, !26, i64 16, !7, i64 20}
!26 = !{!"int", !7, i64 0}
!27 = !{!25, !26, i64 4}
!28 = !{!25, !26, i64 8}
!29 = !{!25, !26, i64 12}
!30 = !{!25, !26, i64 16}
!31 = !{!25, !7, i64 20}
!32 = !{!33, !6, i64 128}
!33 = !{!"", !34, i64 0, !6, i64 24, !6, i64 32, !6, i64 40, !6, i64 48, !6, i64 56, !6, i64 64, !6, i64 72, !6, i64 80, !6, i64 88, !6, i64 96, !6, i64 104, !6, i64 112, !6, i64 120, !6, i64 128, !6, i64 136, !6, i64 144, !6, i64 152, !6, i64 160, !6, i64 168, !6, i64 176, !6, i64 184, !6, i64 192, !6, i64 200, !6, i64 208, !6, i64 216, !6, i64 224, !6, i64 232, !6, i64 240, !6, i64 248, !6, i64 256, !6, i64 264, !6, i64 272, !6, i64 280, !6, i64 288, !6, i64 296, !6, i64 304, !6, i64 312, !6, i64 320, !6, i64 328, !6, i64 336, !6, i64 344, !6, i64 352, !6, i64 360, !6, i64 368}
!34 = !{!"", !35, i64 0, !26, i64 8, !26, i64 12, !26, i64 16, !26, i64 20}
!35 = !{!"long long", !7, i64 0}
!36 = !{!35, !35, i64 0}
!37 = !{!10, !6, i64 88}


; 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.GUID = type { i32, i16, i16, [8 x i8] }

@gBS = external local_unnamed_addr global ptr, align 8
@gEfiSimpleTextOutProtocolGuid = external global %struct.GUID, align 4

declare ptr @AllocateZeroPool(i64 noundef) local_unnamed_addr #0

declare void @FreePool(ptr noundef) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
declare dso_local i64 @FileBasedSimpleTextOutReset(ptr noundef, i8 noundef zeroext) #1

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

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

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

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

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

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

; Function Attrs: nounwind uwtable
declare dso_local i64 @FileBasedSimpleTextOutEnableCursor(ptr noundef, i8 noundef zeroext) #1

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

; Function Attrs: nounwind uwtable
define dso_local ptr @CreateSimpleTextOutOnFile(ptr noundef %0, ptr noundef writeonly %1, ptr noundef %2) local_unnamed_addr #1 {
  %4 = icmp eq ptr %1, null
  %5 = icmp eq ptr %0, null
  %or.cond = or i1 %5, %4
  br i1 %or.cond, label %43, label %6

6:                                                ; preds = %3
  %7 = tail call ptr @AllocateZeroPool(i64 noundef 104) #2
  %8 = icmp eq ptr %7, null
  br i1 %8, label %43, label %9

9:                                                ; preds = %6
  %10 = getelementptr inbounds i8, ptr %7, i64 80
  store ptr %0, ptr %10, align 8, !tbaa !5
  %11 = getelementptr inbounds i8, ptr %7, i64 96
  store ptr %2, ptr %11, align 8, !tbaa !11
  store ptr @FileBasedSimpleTextOutReset, ptr %7, align 8, !tbaa !12
  %12 = getelementptr inbounds i8, ptr %7, i64 16
  store ptr @FileBasedSimpleTextOutTestString, ptr %12, align 8, !tbaa !13
  %13 = getelementptr inbounds i8, ptr %7, i64 24
  store ptr @FileBasedSimpleTextOutQueryMode, ptr %13, align 8, !tbaa !14
  %14 = getelementptr inbounds i8, ptr %7, i64 32
  store ptr @FileBasedSimpleTextOutSetMode, ptr %14, align 8, !tbaa !15
  %15 = getelementptr inbounds i8, ptr %7, i64 40
  store ptr @FileBasedSimpleTextOutSetAttribute, ptr %15, align 8, !tbaa !16
  %16 = getelementptr inbounds i8, ptr %7, i64 48
  store ptr @FileBasedSimpleTextOutClearScreen, ptr %16, align 8, !tbaa !17
  %17 = getelementptr inbounds i8, ptr %7, i64 56
  store ptr @FileBasedSimpleTextOutSetCursorPosition, ptr %17, align 8, !tbaa !18
  %18 = getelementptr inbounds i8, ptr %7, i64 64
  store ptr @FileBasedSimpleTextOutEnableCursor, ptr %18, align 8, !tbaa !19
  %19 = getelementptr inbounds i8, ptr %7, i64 8
  store ptr @FileBasedSimpleTextOutOutputString, ptr %19, align 8, !tbaa !20
  %20 = tail call ptr @AllocateZeroPool(i64 noundef 24) #2
  %21 = getelementptr inbounds i8, ptr %7, i64 72
  store ptr %20, ptr %21, align 8, !tbaa !21
  %22 = icmp eq ptr %20, null
  br i1 %22, label %23, label %24

23:                                               ; preds = %9
  tail call void @FreePool(ptr noundef nonnull %7) #2
  br label %43

24:                                               ; preds = %9
  %25 = getelementptr inbounds i8, ptr %2, i64 72
  %26 = load ptr, ptr %25, align 8, !tbaa !22
  %27 = load <4 x i32>, ptr %26, align 4, !tbaa !23
  store <4 x i32> %27, ptr %20, align 4, !tbaa !23
  %28 = getelementptr inbounds i8, ptr %26, i64 16
  %29 = load i32, ptr %28, align 4, !tbaa !25
  %30 = getelementptr inbounds i8, ptr %20, i64 16
  store i32 %29, ptr %30, align 4, !tbaa !25
  %31 = getelementptr inbounds i8, ptr %26, i64 20
  %32 = load i8, ptr %31, align 4, !tbaa !27
  %33 = getelementptr inbounds i8, ptr %20, i64 20
  store i8 %32, ptr %33, align 4, !tbaa !27
  %34 = load ptr, ptr @gBS, align 8, !tbaa !28
  %35 = getelementptr inbounds i8, ptr %34, i64 128
  %36 = load ptr, ptr %35, align 8, !tbaa !29
  %37 = getelementptr inbounds i8, ptr %7, i64 88
  %38 = tail call i64 %36(ptr noundef nonnull %37, ptr noundef nonnull @gEfiSimpleTextOutProtocolGuid, i32 noundef 0, ptr noundef nonnull %7) #2
  %39 = icmp slt i64 %38, 0
  br i1 %39, label %42, label %40

40:                                               ; preds = %24
  %41 = load ptr, ptr %37, align 8, !tbaa !33
  store ptr %41, ptr %1, align 8, !tbaa !28
  br label %43

42:                                               ; preds = %24
  tail call void @FreePool(ptr noundef nonnull %7) #2
  br label %43

43:                                               ; preds = %6, %3, %42, %40, %23
  %.0 = phi ptr [ null, %23 ], [ null, %42 ], [ %7, %40 ], [ null, %3 ], [ null, %6 ]
  ret ptr %.0
}

attributes #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 = { 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 = { 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, !8, i64 80}
!6 = !{!"", !7, i64 0, !8, i64 80, !8, i64 88, !8, i64 96}
!7 = !{!"_EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL", !8, i64 0, !8, i64 8, !8, i64 16, !8, i64 24, !8, i64 32, !8, i64 40, !8, i64 48, !8, i64 56, !8, i64 64, !8, i64 72}
!8 = !{!"any pointer", !9, i64 0}
!9 = !{!"omnipotent char", !10, i64 0}
!10 = !{!"Simple C/C++ TBAA"}
!11 = !{!6, !8, i64 96}
!12 = !{!6, !8, i64 0}
!13 = !{!6, !8, i64 16}
!14 = !{!6, !8, i64 24}
!15 = !{!6, !8, i64 32}
!16 = !{!6, !8, i64 40}
!17 = !{!6, !8, i64 48}
!18 = !{!6, !8, i64 56}
!19 = !{!6, !8, i64 64}
!20 = !{!6, !8, i64 8}
!21 = !{!6, !8, i64 72}
!22 = !{!7, !8, i64 72}
!23 = !{!24, !24, i64 0}
!24 = !{!"int", !9, i64 0}
!25 = !{!26, !24, i64 16}
!26 = !{!"", !24, i64 0, !24, i64 4, !24, i64 8, !24, i64 12, !24, i64 16, !9, i64 20}
!27 = !{!26, !9, i64 20}
!28 = !{!8, !8, i64 0}
!29 = !{!30, !8, i64 128}
!30 = !{!"", !31, i64 0, !8, i64 24, !8, i64 32, !8, i64 40, !8, i64 48, !8, i64 56, !8, i64 64, !8, i64 72, !8, i64 80, !8, i64 88, !8, i64 96, !8, i64 104, !8, i64 112, !8, i64 120, !8, i64 128, !8, i64 136, !8, i64 144, !8, i64 152, !8, i64 160, !8, i64 168, !8, i64 176, !8, i64 184, !8, i64 192, !8, i64 200, !8, i64 208, !8, i64 216, !8, i64 224, !8, i64 232, !8, i64 240, !8, i64 248, !8, i64 256, !8, i64 264, !8, i64 272, !8, i64 280, !8, i64 288, !8, i64 296, !8, i64 304, !8, i64 312, !8, i64 320, !8, i64 328, !8, i64 336, !8, i64 344, !8, i64 352, !8, i64 360, !8, i64 368}
!31 = !{!"", !32, i64 0, !24, i64 8, !24, i64 12, !24, i64 16, !24, i64 20}
!32 = !{!"long long", !9, i64 0}
!33 = !{!6, !8, i64 88}


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