; LLVM IR from DanEngelbrecht/longtail :: cmd/lib/minifb (longtail_minifb)

; 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.Longtail_LogFieldFmt_Private = type { ptr, ptr, ptr }
%struct.Longtail_LogContextFmt_Private = type { ptr, ptr, i64 }
%struct.Longtail_FrameBufferAPI = type { %struct.Longtail_API, ptr, ptr, ptr }
%struct.Longtail_API = type { ptr }

@.str = external hidden unnamed_addr constant [4 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [3 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [13 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [10 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [11 x i8], align 1
@.str.5 = external hidden unnamed_addr constant [12 x i8], align 1
@.str.6 = external hidden unnamed_addr constant [90 x i8], align 1
@__func__.Longtail_MakeMiniFBFrameBufferAPI = external hidden unnamed_addr constant [34 x i8], align 1
@.str.7 = external hidden unnamed_addr constant [5 x i8], align 1
@.str.8 = external hidden unnamed_addr constant [4 x i8], align 1
@.str.9 = external hidden unnamed_addr constant [43 x i8], align 1
@.str.10 = external hidden unnamed_addr constant [9 x i8], align 1

; Function Attrs: nounwind uwtable
define dso_local ptr @Longtail_MakeMiniFBFrameBufferAPI(ptr noundef %0, ptr noundef %1, ptr noundef %2, ptr noundef %3, ptr noundef %4) #0 {
  %6 = alloca ptr, align 8
  %7 = alloca ptr, align 8
  %8 = alloca ptr, align 8
  %9 = alloca ptr, align 8
  %10 = alloca ptr, align 8
  %11 = alloca ptr, align 8
  %12 = alloca [5 x %struct.Longtail_LogFieldFmt_Private], align 16
  %13 = alloca %struct.Longtail_LogContextFmt_Private, align 8
  %14 = alloca ptr, align 8
  %15 = alloca i32, align 4
  %16 = alloca ptr, align 8
  store ptr %0, ptr %7, align 8, !tbaa !5
  store ptr %1, ptr %8, align 8, !tbaa !5
  store ptr %2, ptr %9, align 8, !tbaa !5
  store ptr %3, ptr %10, align 8, !tbaa !5
  store ptr %4, ptr %11, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 120, ptr %12) #3
  %17 = getelementptr inbounds %struct.Longtail_LogFieldFmt_Private, ptr %12, i32 0, i32 0
  store ptr @.str, ptr %17, align 8, !tbaa !9
  %18 = getelementptr inbounds %struct.Longtail_LogFieldFmt_Private, ptr %12, i32 0, i32 1
  store ptr @.str.1, ptr %18, align 8, !tbaa !11
  %19 = getelementptr inbounds %struct.Longtail_LogFieldFmt_Private, ptr %12, i32 0, i32 2
  %20 = load ptr, ptr %7, align 8, !tbaa !5
  %21 = ptrtoint ptr %20 to i64
  %22 = inttoptr i64 %21 to ptr
  store ptr %22, ptr %19, align 8, !tbaa !12
  %23 = getelementptr inbounds %struct.Longtail_LogFieldFmt_Private, ptr %12, i64 1
  %24 = getelementptr inbounds %struct.Longtail_LogFieldFmt_Private, ptr %23, i32 0, i32 0
  store ptr @.str.2, ptr %24, align 8, !tbaa !9
  %25 = getelementptr inbounds %struct.Longtail_LogFieldFmt_Private, ptr %23, i32 0, i32 1
  store ptr @.str.1, ptr %25, align 8, !tbaa !11
  %26 = getelementptr inbounds %struct.Longtail_LogFieldFmt_Private, ptr %23, i32 0, i32 2
  %27 = load ptr, ptr %8, align 8, !tbaa !5
  %28 = ptrtoint ptr %27 to i64
  %29 = inttoptr i64 %28 to ptr
  store ptr %29, ptr %26, align 8, !tbaa !12
  %30 = getelementptr inbounds %struct.Longtail_LogFieldFmt_Private, ptr %12, i64 2
  %31 = getelementptr inbounds %struct.Longtail_LogFieldFmt_Private, ptr %30, i32 0, i32 0
  store ptr @.str.3, ptr %31, align 8, !tbaa !9
  %32 = getelementptr inbounds %struct.Longtail_LogFieldFmt_Private, ptr %30, i32 0, i32 1
  store ptr @.str.1, ptr %32, align 8, !tbaa !11
  %33 = getelementptr inbounds %struct.Longtail_LogFieldFmt_Private, ptr %30, i32 0, i32 2
  %34 = load ptr, ptr %9, align 8, !tbaa !5
  %35 = ptrtoint ptr %34 to i64
  %36 = inttoptr i64 %35 to ptr
  store ptr %36, ptr %33, align 8, !tbaa !12
  %37 = getelementptr inbounds %struct.Longtail_LogFieldFmt_Private, ptr %12, i64 3
  %38 = getelementptr inbounds %struct.Longtail_LogFieldFmt_Private, ptr %37, i32 0, i32 0
  store ptr @.str.4, ptr %38, align 8, !tbaa !9
  %39 = getelementptr inbounds %struct.Longtail_LogFieldFmt_Private, ptr %37, i32 0, i32 1
  store ptr @.str.1, ptr %39, align 8, !tbaa !11
  %40 = getelementptr inbounds %struct.Longtail_LogFieldFmt_Private, ptr %37, i32 0, i32 2
  %41 = load ptr, ptr %10, align 8, !tbaa !5
  %42 = ptrtoint ptr %41 to i64
  %43 = inttoptr i64 %42 to ptr
  store ptr %43, ptr %40, align 8, !tbaa !12
  %44 = getelementptr inbounds %struct.Longtail_LogFieldFmt_Private, ptr %12, i64 4
  %45 = getelementptr inbounds %struct.Longtail_LogFieldFmt_Private, ptr %44, i32 0, i32 0
  store ptr @.str.5, ptr %45, align 8, !tbaa !9
  %46 = getelementptr inbounds %struct.Longtail_LogFieldFmt_Private, ptr %44, i32 0, i32 1
  store ptr @.str.1, ptr %46, align 8, !tbaa !11
  %47 = getelementptr inbounds %struct.Longtail_LogFieldFmt_Private, ptr %44, i32 0, i32 2
  %48 = load ptr, ptr %11, align 8, !tbaa !5
  %49 = ptrtoint ptr %48 to i64
  %50 = inttoptr i64 %49 to ptr
  store ptr %50, ptr %47, align 8, !tbaa !12
  call void @llvm.lifetime.start.p0(i64 24, ptr %13) #3
  %51 = getelementptr inbounds %struct.Longtail_LogContextFmt_Private, ptr %13, i32 0, i32 0
  store ptr null, ptr %51, align 8, !tbaa !13
  %52 = getelementptr inbounds %struct.Longtail_LogContextFmt_Private, ptr %13, i32 0, i32 1
  %53 = getelementptr inbounds [5 x %struct.Longtail_LogFieldFmt_Private], ptr %12, i64 0, i64 0
  store ptr %53, ptr %52, align 8, !tbaa !16
  %54 = getelementptr inbounds %struct.Longtail_LogContextFmt_Private, ptr %13, i32 0, i32 2
  store i64 5, ptr %54, align 8, !tbaa !17
  call void @llvm.lifetime.start.p0(i64 8, ptr %14) #3
  store ptr %13, ptr %14, align 8, !tbaa !5
  %55 = load ptr, ptr %14, align 8, !tbaa !5
  call void (ptr, ptr, i32, ptr, i32, ptr, ...) @Longtail_CallLogger(ptr noundef @.str.6, ptr noundef @__func__.Longtail_MakeMiniFBFrameBufferAPI, i32 noundef 40, ptr noundef %55, i32 noundef 0, ptr noundef @.str.7, ptr noundef @.str.8)
  %56 = load ptr, ptr %7, align 8, !tbaa !5
  %57 = icmp ne ptr %56, null
  br i1 %57, label %60, label %58

58:                                               ; preds = %5
  %59 = load ptr, ptr %14, align 8, !tbaa !5
  call void (ptr, ptr, i32, ptr, i32, ptr, ...) @Longtail_CallLogger(ptr noundef @.str.6, ptr noundef @__func__.Longtail_MakeMiniFBFrameBufferAPI, i32 noundef 42, ptr noundef %59, i32 noundef 3, ptr noundef @.str.9, ptr noundef @.str.10)
  store ptr null, ptr %6, align 8
  store i32 1, ptr %15, align 4
  br label %76

60:                                               ; preds = %5
  call void @llvm.lifetime.start.p0(i64 8, ptr %16) #3
  %61 = load ptr, ptr %7, align 8, !tbaa !5
  store ptr %61, ptr %16, align 8, !tbaa !5
  %62 = load ptr, ptr %8, align 8, !tbaa !5
  %63 = load ptr, ptr %16, align 8, !tbaa !5
  %64 = getelementptr inbounds %struct.Longtail_FrameBufferAPI, ptr %63, i32 0, i32 0
  %65 = getelementptr inbounds %struct.Longtail_API, ptr %64, i32 0, i32 0
  store ptr %62, ptr %65, align 8, !tbaa !18
  %66 = load ptr, ptr %9, align 8, !tbaa !5
  %67 = load ptr, ptr %16, align 8, !tbaa !5
  %68 = getelementptr inbounds %struct.Longtail_FrameBufferAPI, ptr %67, i32 0, i32 1
  store ptr %66, ptr %68, align 8, !tbaa !21
  %69 = load ptr, ptr %10, align 8, !tbaa !5
  %70 = load ptr, ptr %16, align 8, !tbaa !5
  %71 = getelementptr inbounds %struct.Longtail_FrameBufferAPI, ptr %70, i32 0, i32 2
  store ptr %69, ptr %71, align 8, !tbaa !22
  %72 = load ptr, ptr %11, align 8, !tbaa !5
  %73 = load ptr, ptr %16, align 8, !tbaa !5
  %74 = getelementptr inbounds %struct.Longtail_FrameBufferAPI, ptr %73, i32 0, i32 3
  store ptr %72, ptr %74, align 8, !tbaa !23
  %75 = load ptr, ptr %16, align 8, !tbaa !5
  store ptr %75, ptr %6, align 8
  store i32 1, ptr %15, align 4
  call void @llvm.lifetime.end.p0(i64 8, ptr %16) #3
  br label %76

76:                                               ; preds = %60, %58
  call void @llvm.lifetime.end.p0(i64 8, ptr %14) #3
  call void @llvm.lifetime.end.p0(i64 24, ptr %13) #3
  call void @llvm.lifetime.end.p0(i64 120, ptr %12) #3
  %77 = load ptr, ptr %6, align 8
  ret ptr %77
}

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

declare void @Longtail_CallLogger(ptr noundef, ptr noundef, i32 noundef, ptr noundef, i32 noundef, ptr noundef, ...) #2

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

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 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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, !6, i64 0}
!10 = !{!"Longtail_LogFieldFmt_Private", !6, i64 0, !6, i64 8, !6, i64 16}
!11 = !{!10, !6, i64 8}
!12 = !{!10, !6, i64 16}
!13 = !{!14, !6, i64 0}
!14 = !{!"Longtail_LogContextFmt_Private", !6, i64 0, !6, i64 8, !15, i64 16}
!15 = !{!"long", !7, i64 0}
!16 = !{!14, !6, i64 8}
!17 = !{!14, !15, i64 16}
!18 = !{!19, !6, i64 0}
!19 = !{!"Longtail_FrameBufferAPI", !20, i64 0, !6, i64 8, !6, i64 16, !6, i64 24}
!20 = !{!"Longtail_API", !6, i64 0}
!21 = !{!19, !6, i64 8}
!22 = !{!19, !6, i64 16}
!23 = !{!19, !6, i64 24}


; 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.Longtail_LogFieldFmt_Private = type { ptr, ptr, ptr }
%struct.Longtail_LogContextFmt_Private = type { ptr, ptr, i64 }

@.str = external hidden unnamed_addr constant [4 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [3 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [13 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [10 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [11 x i8], align 1
@.str.5 = external hidden unnamed_addr constant [12 x i8], align 1
@.str.6 = external hidden unnamed_addr constant [90 x i8], align 1
@__func__.Longtail_MakeMiniFBFrameBufferAPI = external hidden unnamed_addr constant [34 x i8], align 1
@.str.7 = external hidden unnamed_addr constant [5 x i8], align 1
@.str.8 = external hidden unnamed_addr constant [4 x i8], align 1
@.str.9 = external hidden unnamed_addr constant [43 x i8], align 1
@.str.10 = external hidden unnamed_addr constant [9 x i8], align 1

; Function Attrs: nounwind uwtable
define dso_local noundef ptr @Longtail_MakeMiniFBFrameBufferAPI(ptr noundef returned %0, ptr noundef %1, ptr noundef %2, ptr noundef %3, ptr noundef %4) local_unnamed_addr #0 {
  %6 = alloca [5 x %struct.Longtail_LogFieldFmt_Private], align 16
  %7 = alloca %struct.Longtail_LogContextFmt_Private, align 8
  call void @llvm.lifetime.start.p0(i64 120, ptr nonnull %6) #3
  store ptr @.str, ptr %6, align 16, !tbaa !5
  %8 = getelementptr inbounds i8, ptr %6, i64 8
  store ptr @.str.1, ptr %8, align 8, !tbaa !10
  %9 = getelementptr inbounds i8, ptr %6, i64 16
  store ptr %0, ptr %9, align 16, !tbaa !11
  %10 = getelementptr inbounds i8, ptr %6, i64 24
  store ptr @.str.2, ptr %10, align 8, !tbaa !5
  %11 = getelementptr inbounds i8, ptr %6, i64 32
  store ptr @.str.1, ptr %11, align 16, !tbaa !10
  %12 = getelementptr inbounds i8, ptr %6, i64 40
  store ptr %1, ptr %12, align 8, !tbaa !11
  %13 = getelementptr inbounds i8, ptr %6, i64 48
  store ptr @.str.3, ptr %13, align 16, !tbaa !5
  %14 = getelementptr inbounds i8, ptr %6, i64 56
  store ptr @.str.1, ptr %14, align 8, !tbaa !10
  %15 = getelementptr inbounds i8, ptr %6, i64 64
  store ptr %2, ptr %15, align 16, !tbaa !11
  %16 = getelementptr inbounds i8, ptr %6, i64 72
  store ptr @.str.4, ptr %16, align 8, !tbaa !5
  %17 = getelementptr inbounds i8, ptr %6, i64 80
  store ptr @.str.1, ptr %17, align 16, !tbaa !10
  %18 = getelementptr inbounds i8, ptr %6, i64 88
  store ptr %3, ptr %18, align 8, !tbaa !11
  %19 = getelementptr inbounds i8, ptr %6, i64 96
  store ptr @.str.5, ptr %19, align 16, !tbaa !5
  %20 = getelementptr inbounds i8, ptr %6, i64 104
  store ptr @.str.1, ptr %20, align 8, !tbaa !10
  %21 = getelementptr inbounds i8, ptr %6, i64 112
  store ptr %4, ptr %21, align 16, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 24, ptr nonnull %7) #3
  store ptr null, ptr %7, align 8, !tbaa !12
  %22 = getelementptr inbounds i8, ptr %7, i64 8
  store ptr %6, ptr %22, align 8, !tbaa !15
  %23 = getelementptr inbounds i8, ptr %7, i64 16
  store i64 5, ptr %23, align 8, !tbaa !16
  call void (ptr, ptr, i32, ptr, i32, ptr, ...) @Longtail_CallLogger(ptr noundef nonnull @.str.6, ptr noundef nonnull @__func__.Longtail_MakeMiniFBFrameBufferAPI, i32 noundef 40, ptr noundef nonnull %7, i32 noundef 0, ptr noundef nonnull @.str.7, ptr noundef nonnull @.str.8) #3
  %.not = icmp eq ptr %0, null
  br i1 %.not, label %24, label %25

24:                                               ; preds = %5
  call void (ptr, ptr, i32, ptr, i32, ptr, ...) @Longtail_CallLogger(ptr noundef nonnull @.str.6, ptr noundef nonnull @__func__.Longtail_MakeMiniFBFrameBufferAPI, i32 noundef 42, ptr noundef nonnull %7, i32 noundef 3, ptr noundef nonnull @.str.9, ptr noundef nonnull @.str.10) #3
  br label %29

25:                                               ; preds = %5
  store ptr %1, ptr %0, align 8, !tbaa !17
  %26 = getelementptr inbounds i8, ptr %0, i64 8
  store ptr %2, ptr %26, align 8, !tbaa !20
  %27 = getelementptr inbounds i8, ptr %0, i64 16
  store ptr %3, ptr %27, align 8, !tbaa !21
  %28 = getelementptr inbounds i8, ptr %0, i64 24
  store ptr %4, ptr %28, align 8, !tbaa !22
  br label %29

29:                                               ; preds = %25, %24
  call void @llvm.lifetime.end.p0(i64 24, ptr nonnull %7) #3
  call void @llvm.lifetime.end.p0(i64 120, ptr nonnull %6) #3
  ret ptr %0
}

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

declare void @Longtail_CallLogger(ptr noundef, ptr noundef, i32 noundef, ptr noundef, i32 noundef, ptr noundef, ...) local_unnamed_addr #2

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

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 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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, !7, i64 0}
!6 = !{!"Longtail_LogFieldFmt_Private", !7, i64 0, !7, i64 8, !7, i64 16}
!7 = !{!"any pointer", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!6, !7, i64 8}
!11 = !{!6, !7, i64 16}
!12 = !{!13, !7, i64 0}
!13 = !{!"Longtail_LogContextFmt_Private", !7, i64 0, !7, i64 8, !14, i64 16}
!14 = !{!"long", !8, i64 0}
!15 = !{!13, !7, i64 8}
!16 = !{!13, !14, i64 16}
!17 = !{!18, !7, i64 0}
!18 = !{!"Longtail_FrameBufferAPI", !19, i64 0, !7, i64 8, !7, i64 16, !7, i64 24}
!19 = !{!"Longtail_API", !7, i64 0}
!20 = !{!18, !7, i64 8}
!21 = !{!18, !7, i64 16}
!22 = !{!18, !7, i64 24}


; Effective O3 passes: CorrelatedValuePropagationPass,EarlyCSEPass,GlobalOptPass,InferAlignmentPass,InferFunctionAttrsPass,InstCombinePass,PostOrderFunctionAttrsPass,SROAPass