; LLVM IR from xing1357/SimpleOS :: src (vesa)

; 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.VBE20_INFOBLOCK = type <{ [4 x i8], i16, ptr, i32, ptr, i16, i16, i32, i32, i32, [222 x i8], [256 x i8] }>
%struct.REGISTERS16 = type { i16, i16, i16, i16, i16, i16, i16, i16, i16, i16, i16, i16, i16, i16 }

@.str = external hidden unnamed_addr constant [2 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [2 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [2 x i8], align 1
@g_vbe_infoblock = external dso_local global %struct.VBE20_INFOBLOCK, align 1

; Function Attrs: nounwind uwtable
define dso_local i32 @get_vbe_info() #0 {
  %1 = alloca %struct.REGISTERS16, align 2
  %2 = alloca %struct.REGISTERS16, align 2
  call void (ptr, ...) @printf(ptr noundef @.str)
  call void @llvm.lifetime.start.p0(i64 28, ptr %1) #4
  call void @llvm.memset.p0.i64(ptr align 2 %1, i8 0, i64 28, i1 false)
  call void @llvm.lifetime.start.p0(i64 28, ptr %2) #4
  call void @llvm.memset.p0.i64(ptr align 2 %2, i8 0, i64 28, i1 false)
  %3 = getelementptr inbounds %struct.REGISTERS16, ptr %1, i32 0, i32 7
  store i16 20224, ptr %3, align 2, !tbaa !5
  call void (ptr, ...) @printf(ptr noundef @.str.1)
  %4 = getelementptr inbounds %struct.REGISTERS16, ptr %1, i32 0, i32 0
  store i16 32256, ptr %4, align 2, !tbaa !10
  call void @int86(i8 noundef zeroext 16, ptr noundef %1, ptr noundef %2)
  call void (ptr, ...) @printf(ptr noundef @.str.2)
  %5 = call ptr @memcpy(ptr noundef @g_vbe_infoblock, ptr noundef inttoptr (i64 32256 to ptr), i32 noundef 520)
  %6 = getelementptr inbounds %struct.REGISTERS16, ptr %2, i32 0, i32 7
  %7 = load i16, ptr %6, align 2, !tbaa !5
  %8 = zext i16 %7 to i32
  %9 = icmp eq i32 %8, 79
  %10 = zext i1 %9 to i32
  call void @llvm.lifetime.end.p0(i64 28, ptr %2) #4
  call void @llvm.lifetime.end.p0(i64 28, ptr %1) #4
  ret i32 %10
}

declare void @printf(ptr noundef, ...) #1

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

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #3

declare void @int86(i8 noundef zeroext, ptr noundef, ptr noundef) #1

declare ptr @memcpy(ptr noundef, ptr noundef, i32 noundef) #1

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

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 = { "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 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #3 = { nocallback nofree nounwind willreturn memory(argmem: write) }
attributes #4 = { 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, !7, i64 14}
!6 = !{!"", !7, i64 0, !7, i64 2, !7, i64 4, !7, i64 6, !7, i64 8, !7, i64 10, !7, i64 12, !7, i64 14, !7, i64 16, !7, i64 18, !7, i64 20, !7, i64 22, !7, i64 24, !7, i64 26}
!7 = !{!"short", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!6, !7, i64 0}


; 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.VBE20_INFOBLOCK = type <{ [4 x i8], i16, ptr, i32, ptr, i16, i16, i32, i32, i32, [222 x i8], [256 x i8] }>
%struct.REGISTERS16 = type { i16, i16, i16, i16, i16, i16, i16, i16, i16, i16, i16, i16, i16, i16 }

@.str = external hidden unnamed_addr constant [2 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [2 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [2 x i8], align 1
@g_vbe_infoblock = external dso_local global %struct.VBE20_INFOBLOCK, align 1

; Function Attrs: nounwind uwtable
define dso_local range(i32 0, 2) i32 @get_vbe_info() local_unnamed_addr #0 {
  %1 = alloca %struct.REGISTERS16, align 2
  %2 = alloca %struct.REGISTERS16, align 2
  tail call void (ptr, ...) @printf(ptr noundef nonnull @.str) #4
  call void @llvm.lifetime.start.p0(i64 28, ptr nonnull %1) #4
  %3 = getelementptr inbounds i8, ptr %1, i64 2
  call void @llvm.memset.p0.i64(ptr noundef nonnull align 2 dereferenceable(28) %3, i8 0, i64 26, i1 false)
  call void @llvm.lifetime.start.p0(i64 28, ptr nonnull %2) #4
  call void @llvm.memset.p0.i64(ptr noundef nonnull align 2 dereferenceable(28) %2, i8 0, i64 28, i1 false)
  %4 = getelementptr inbounds i8, ptr %1, i64 14
  store i16 20224, ptr %4, align 2, !tbaa !5
  tail call void (ptr, ...) @printf(ptr noundef nonnull @.str.1) #4
  store i16 32256, ptr %1, align 2, !tbaa !10
  call void @int86(i8 noundef zeroext 16, ptr noundef nonnull %1, ptr noundef nonnull %2) #4
  call void (ptr, ...) @printf(ptr noundef nonnull @.str.2) #4
  %5 = call ptr @memcpy(ptr noundef nonnull @g_vbe_infoblock, ptr noundef nonnull inttoptr (i64 32256 to ptr), i32 noundef 520) #4
  %6 = getelementptr inbounds i8, ptr %2, i64 14
  %7 = load i16, ptr %6, align 2, !tbaa !5
  %8 = icmp eq i16 %7, 79
  %9 = zext i1 %8 to i32
  call void @llvm.lifetime.end.p0(i64 28, ptr nonnull %2) #4
  call void @llvm.lifetime.end.p0(i64 28, ptr nonnull %1) #4
  ret i32 %9
}

declare void @printf(ptr noundef, ...) local_unnamed_addr #1

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

; Function Attrs: mustprogress nocallback nofree nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #3

declare void @int86(i8 noundef zeroext, ptr noundef, ptr noundef) local_unnamed_addr #1

declare ptr @memcpy(ptr noundef, ptr noundef, i32 noundef) local_unnamed_addr #1

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

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 = { "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 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #3 = { mustprogress nocallback nofree nounwind willreturn memory(argmem: write) }
attributes #4 = { 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, !7, i64 14}
!6 = !{!"", !7, i64 0, !7, i64 2, !7, i64 4, !7, i64 6, !7, i64 8, !7, i64 10, !7, i64 12, !7, i64 14, !7, i64 16, !7, i64 18, !7, i64 20, !7, i64 22, !7, i64 24, !7, i64 26}
!7 = !{!"short", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!6, !7, i64 0}


; Effective O3 passes: DSEPass,EarlyCSEPass,GlobalOptPass,IPSCCPPass,InferFunctionAttrsPass,InstCombinePass,TailCallElimPass