; LLVM IR from DanEngelbrecht/longtail :: lib/bikeshed (longtail_bikeshed)

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

@.str.3 = external hidden unnamed_addr constant [3 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [90 x i8], align 1
@.str.5 = external hidden unnamed_addr constant [5 x i8], align 1
@.str.6 = external hidden unnamed_addr constant [4 x i8], align 1
@.str.7 = external hidden unnamed_addr constant [9 x i8], align 1
@.str.9 = external hidden unnamed_addr constant [13 x i8], align 1
@.str.10 = external hidden unnamed_addr constant [16 x i8], align 1
@.str.11 = external hidden unnamed_addr constant [3 x i8], align 1
@__func__.Longtail_CreateBikeshedJobAPI = external hidden unnamed_addr constant [30 x i8], align 1
@.str.12 = external hidden unnamed_addr constant [43 x i8], align 1
@.str.13 = external hidden unnamed_addr constant [46 x i8], align 1
@.str.14 = external hidden unnamed_addr constant [47 x i8], align 1
@.str.15 = external hidden unnamed_addr constant [31 x i8], align 1

; 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 void @Longtail_CallLogger(ptr noundef, ptr noundef, i32 noundef, ptr noundef, i32 noundef, ptr noundef, ...) #1

declare ptr @Longtail_Alloc(ptr noundef, i64 noundef) #1

; Function Attrs: nounwind uwtable
define dso_local ptr @Longtail_CreateBikeshedJobAPI(i32 noundef %0, i32 noundef %1) #2 {
  %3 = alloca ptr, align 8
  %4 = alloca i32, align 4
  %5 = alloca i32, align 4
  %6 = alloca [2 x %struct.Longtail_LogFieldFmt_Private], align 16
  %7 = alloca %struct.Longtail_LogContextFmt_Private, align 8
  %8 = alloca ptr, align 8
  %9 = alloca i32, align 4
  %10 = alloca ptr, align 8
  %11 = alloca ptr, align 8
  %12 = alloca i32, align 4
  store i32 %0, ptr %4, align 4, !tbaa !5
  store i32 %1, ptr %5, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 48, ptr %6) #3
  %13 = getelementptr inbounds %struct.Longtail_LogFieldFmt_Private, ptr %6, i32 0, i32 0
  store ptr @.str.9, ptr %13, align 8, !tbaa !9
  %14 = getelementptr inbounds %struct.Longtail_LogFieldFmt_Private, ptr %6, i32 0, i32 1
  store ptr @.str.3, ptr %14, align 8, !tbaa !12
  %15 = getelementptr inbounds %struct.Longtail_LogFieldFmt_Private, ptr %6, i32 0, i32 2
  %16 = load i32, ptr %4, align 4, !tbaa !5
  %17 = zext i32 %16 to i64
  %18 = inttoptr i64 %17 to ptr
  store ptr %18, ptr %15, align 8, !tbaa !13
  %19 = getelementptr inbounds %struct.Longtail_LogFieldFmt_Private, ptr %6, i64 1
  %20 = getelementptr inbounds %struct.Longtail_LogFieldFmt_Private, ptr %19, i32 0, i32 0
  store ptr @.str.10, ptr %20, align 8, !tbaa !9
  %21 = getelementptr inbounds %struct.Longtail_LogFieldFmt_Private, ptr %19, i32 0, i32 1
  store ptr @.str.11, ptr %21, align 8, !tbaa !12
  %22 = getelementptr inbounds %struct.Longtail_LogFieldFmt_Private, ptr %19, i32 0, i32 2
  %23 = load i32, ptr %5, align 4, !tbaa !5
  %24 = sext i32 %23 to i64
  %25 = inttoptr i64 %24 to ptr
  store ptr %25, ptr %22, align 8, !tbaa !13
  call void @llvm.lifetime.start.p0(i64 24, ptr %7) #3
  %26 = getelementptr inbounds %struct.Longtail_LogContextFmt_Private, ptr %7, i32 0, i32 0
  store ptr null, ptr %26, align 8, !tbaa !14
  %27 = getelementptr inbounds %struct.Longtail_LogContextFmt_Private, ptr %7, i32 0, i32 1
  %28 = getelementptr inbounds [2 x %struct.Longtail_LogFieldFmt_Private], ptr %6, i64 0, i64 0
  store ptr %28, ptr %27, align 8, !tbaa !17
  %29 = getelementptr inbounds %struct.Longtail_LogContextFmt_Private, ptr %7, i32 0, i32 2
  store i64 2, ptr %29, align 8, !tbaa !18
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #3
  store ptr %7, ptr %8, align 8, !tbaa !19
  %30 = load ptr, ptr %8, align 8, !tbaa !19
  call void (ptr, ptr, i32, ptr, i32, ptr, ...) @Longtail_CallLogger(ptr noundef @.str.4, ptr noundef @__func__.Longtail_CreateBikeshedJobAPI, i32 noundef 692, ptr noundef %30, i32 noundef 0, ptr noundef @.str.5, ptr noundef @.str.6)
  %31 = load i32, ptr %5, align 4, !tbaa !5
  %32 = icmp sge i32 %31, -1
  br i1 %32, label %33, label %36

33:                                               ; preds = %2
  %34 = load i32, ptr %5, align 4, !tbaa !5
  %35 = icmp sle i32 %34, 1
  br i1 %35, label %38, label %36

36:                                               ; preds = %33, %2
  %37 = load ptr, ptr %8, align 8, !tbaa !19
  call void (ptr, ptr, i32, ptr, i32, ptr, ...) @Longtail_CallLogger(ptr noundef @.str.4, ptr noundef @__func__.Longtail_CreateBikeshedJobAPI, i32 noundef 694, ptr noundef %37, i32 noundef 3, ptr noundef @.str.12, ptr noundef @.str.13)
  store ptr null, ptr %3, align 8
  store i32 1, ptr %9, align 4
  br label %58

38:                                               ; preds = %33
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #3
  %39 = call ptr @Longtail_Alloc(ptr noundef @.str.7, i64 noundef 120)
  store ptr %39, ptr %10, align 8, !tbaa !19
  %40 = load ptr, ptr %10, align 8, !tbaa !19
  %41 = icmp ne ptr %40, null
  br i1 %41, label %44, label %42

42:                                               ; preds = %38
  %43 = load ptr, ptr %8, align 8, !tbaa !19
  call void (ptr, ptr, i32, ptr, i32, ptr, ...) @Longtail_CallLogger(ptr noundef @.str.4, ptr noundef @__func__.Longtail_CreateBikeshedJobAPI, i32 noundef 698, ptr noundef %43, i32 noundef 3, ptr noundef @.str.14, i32 noundef 12)
  store ptr null, ptr %3, align 8
  store i32 1, ptr %9, align 4
  br label %57

44:                                               ; preds = %38
  call void @llvm.lifetime.start.p0(i64 8, ptr %11) #3
  call void @llvm.lifetime.start.p0(i64 4, ptr %12) #3
  %45 = load ptr, ptr %10, align 8, !tbaa !19
  %46 = load i32, ptr %4, align 4, !tbaa !5
  %47 = load i32, ptr %5, align 4, !tbaa !5
  %48 = call i32 @Bikeshed_Init(ptr noundef %45, i32 noundef %46, i32 noundef %47, ptr noundef %11)
  store i32 %48, ptr %12, align 4, !tbaa !5
  %49 = load i32, ptr %12, align 4, !tbaa !5
  %50 = icmp ne i32 %49, 0
  br i1 %50, label %51, label %54

51:                                               ; preds = %44
  %52 = load ptr, ptr %8, align 8, !tbaa !19
  %53 = load i32, ptr %12, align 4, !tbaa !5
  call void (ptr, ptr, i32, ptr, i32, ptr, ...) @Longtail_CallLogger(ptr noundef @.str.4, ptr noundef @__func__.Longtail_CreateBikeshedJobAPI, i32 noundef 705, ptr noundef %52, i32 noundef 3, ptr noundef @.str.15, i32 noundef %53)
  store ptr null, ptr %3, align 8
  store i32 1, ptr %9, align 4
  br label %56

54:                                               ; preds = %44
  %55 = load ptr, ptr %11, align 8, !tbaa !19
  store ptr %55, ptr %3, align 8
  store i32 1, ptr %9, align 4
  br label %56

56:                                               ; preds = %54, %51
  call void @llvm.lifetime.end.p0(i64 4, ptr %12) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #3
  br label %57

57:                                               ; preds = %56, %42
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #3
  br label %58

58:                                               ; preds = %57, %36
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #3
  call void @llvm.lifetime.end.p0(i64 24, ptr %7) #3
  call void @llvm.lifetime.end.p0(i64 48, ptr %6) #3
  %59 = load ptr, ptr %3, align 8
  ret ptr %59
}

; Function Attrs: nounwind uwtable
declare hidden i32 @Bikeshed_Init(ptr noundef, i32 noundef, i32 noundef, ptr noundef) #2

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 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !11, i64 0}
!10 = !{!"Longtail_LogFieldFmt_Private", !11, i64 0, !11, i64 8, !11, i64 16}
!11 = !{!"any pointer", !7, i64 0}
!12 = !{!10, !11, i64 8}
!13 = !{!10, !11, i64 16}
!14 = !{!15, !11, i64 0}
!15 = !{!"Longtail_LogContextFmt_Private", !11, i64 0, !11, i64 8, !16, i64 16}
!16 = !{!"long", !7, i64 0}
!17 = !{!15, !11, i64 8}
!18 = !{!15, !16, i64 16}
!19 = !{!11, !11, 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.Longtail_LogFieldFmt_Private = type { ptr, ptr, ptr }
%struct.Longtail_LogContextFmt_Private = type { ptr, ptr, i64 }

@.str.3 = external hidden unnamed_addr constant [3 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [90 x i8], align 1
@.str.5 = external hidden unnamed_addr constant [5 x i8], align 1
@.str.6 = external hidden unnamed_addr constant [4 x i8], align 1
@.str.7 = external hidden unnamed_addr constant [9 x i8], align 1
@.str.9 = external hidden unnamed_addr constant [13 x i8], align 1
@.str.10 = external hidden unnamed_addr constant [16 x i8], align 1
@.str.11 = external hidden unnamed_addr constant [3 x i8], align 1
@__func__.Longtail_CreateBikeshedJobAPI = external hidden unnamed_addr constant [30 x i8], align 1
@.str.12 = external hidden unnamed_addr constant [43 x i8], align 1
@.str.13 = external hidden unnamed_addr constant [46 x i8], align 1
@.str.14 = external hidden unnamed_addr constant [47 x i8], align 1
@.str.15 = external hidden unnamed_addr constant [31 x i8], align 1

; 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

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

declare ptr @Longtail_Alloc(ptr noundef, i64 noundef) local_unnamed_addr #1

; Function Attrs: nounwind uwtable
define dso_local ptr @Longtail_CreateBikeshedJobAPI(i32 noundef %0, i32 noundef %1) local_unnamed_addr #2 {
  %3 = alloca [2 x %struct.Longtail_LogFieldFmt_Private], align 16
  %4 = alloca %struct.Longtail_LogContextFmt_Private, align 8
  %5 = alloca ptr, align 8
  call void @llvm.lifetime.start.p0(i64 48, ptr nonnull %3) #3
  store ptr @.str.9, ptr %3, align 16, !tbaa !5
  %6 = getelementptr inbounds i8, ptr %3, i64 8
  store ptr @.str.3, ptr %6, align 8, !tbaa !10
  %7 = getelementptr inbounds i8, ptr %3, i64 16
  %8 = zext i32 %0 to i64
  %9 = inttoptr i64 %8 to ptr
  store ptr %9, ptr %7, align 16, !tbaa !11
  %10 = getelementptr inbounds i8, ptr %3, i64 24
  store ptr @.str.10, ptr %10, align 8, !tbaa !5
  %11 = getelementptr inbounds i8, ptr %3, i64 32
  store ptr @.str.11, ptr %11, align 16, !tbaa !10
  %12 = getelementptr inbounds i8, ptr %3, i64 40
  %13 = sext i32 %1 to i64
  %14 = inttoptr i64 %13 to ptr
  store ptr %14, ptr %12, align 8, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 24, ptr nonnull %4) #3
  store ptr null, ptr %4, align 8, !tbaa !12
  %15 = getelementptr inbounds i8, ptr %4, i64 8
  store ptr %3, ptr %15, align 8, !tbaa !15
  %16 = getelementptr inbounds i8, ptr %4, i64 16
  store i64 2, ptr %16, align 8, !tbaa !16
  call void (ptr, ptr, i32, ptr, i32, ptr, ...) @Longtail_CallLogger(ptr noundef nonnull @.str.4, ptr noundef nonnull @__func__.Longtail_CreateBikeshedJobAPI, i32 noundef 692, ptr noundef nonnull %4, i32 noundef 0, ptr noundef nonnull @.str.5, ptr noundef nonnull @.str.6) #3
  %17 = add i32 %1, 1
  %or.cond = icmp ult i32 %17, 3
  br i1 %or.cond, label %19, label %18

18:                                               ; preds = %2
  call void (ptr, ptr, i32, ptr, i32, ptr, ...) @Longtail_CallLogger(ptr noundef nonnull @.str.4, ptr noundef nonnull @__func__.Longtail_CreateBikeshedJobAPI, i32 noundef 694, ptr noundef nonnull %4, i32 noundef 3, ptr noundef nonnull @.str.12, ptr noundef nonnull @.str.13) #3
  br label %28

19:                                               ; preds = %2
  %20 = call ptr @Longtail_Alloc(ptr noundef nonnull @.str.7, i64 noundef 120) #3
  %.not = icmp eq ptr %20, null
  br i1 %.not, label %21, label %22

21:                                               ; preds = %19
  call void (ptr, ptr, i32, ptr, i32, ptr, ...) @Longtail_CallLogger(ptr noundef nonnull @.str.4, ptr noundef nonnull @__func__.Longtail_CreateBikeshedJobAPI, i32 noundef 698, ptr noundef nonnull %4, i32 noundef 3, ptr noundef nonnull @.str.14, i32 noundef 12) #3
  br label %28

22:                                               ; preds = %19
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %5) #3
  %23 = call i32 @Bikeshed_Init(ptr noundef nonnull %20, i32 noundef %0, i32 noundef %1, ptr noundef nonnull %5)
  %.not18 = icmp eq i32 %23, 0
  br i1 %.not18, label %25, label %24

24:                                               ; preds = %22
  call void (ptr, ptr, i32, ptr, i32, ptr, ...) @Longtail_CallLogger(ptr noundef nonnull @.str.4, ptr noundef nonnull @__func__.Longtail_CreateBikeshedJobAPI, i32 noundef 705, ptr noundef nonnull %4, i32 noundef 3, ptr noundef nonnull @.str.15, i32 noundef %23) #3
  br label %27

25:                                               ; preds = %22
  %26 = load ptr, ptr %5, align 8, !tbaa !17
  br label %27

27:                                               ; preds = %25, %24
  %.0 = phi ptr [ null, %24 ], [ %26, %25 ]
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %5) #3
  br label %28

28:                                               ; preds = %21, %27, %18
  %.2 = phi ptr [ null, %18 ], [ %.0, %27 ], [ null, %21 ]
  call void @llvm.lifetime.end.p0(i64 24, ptr nonnull %4) #3
  call void @llvm.lifetime.end.p0(i64 48, ptr nonnull %3) #3
  ret ptr %.2
}

; Function Attrs: nounwind uwtable
declare hidden i32 @Bikeshed_Init(ptr noundef, i32 noundef, i32 noundef, ptr noundef) local_unnamed_addr #2

attributes #0 = { mustprogress 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, !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 = !{!7, !7, i64 0}


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