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

@.str = external hidden unnamed_addr constant [8 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [3 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [10 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [3 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [90 x i8], align 1
@__func__.CreateJobGroup = external hidden unnamed_addr constant [15 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.8 = external hidden unnamed_addr constant [32 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

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

42:                                               ; preds = %2
  %43 = load ptr, ptr %7, align 8, !tbaa !5
  %44 = load i32, ptr %8, align 4, !tbaa !9
  call void (ptr, ptr, i32, ptr, i32, ptr, ...) @Longtail_CallLogger(ptr noundef @.str.4, ptr noundef @__func__.CreateJobGroup, i32 noundef 218, ptr noundef %43, i32 noundef 3, ptr noundef @.str.8, i32 noundef %44)
  store i32 12, ptr %8, align 4, !tbaa !9
  br label %83

45:                                               ; preds = %2
  %46 = load ptr, ptr %11, align 8, !tbaa !5
  %47 = getelementptr inbounds %struct.Bikeshed_JobAPI_Group, ptr %46, i64 1
  store ptr %47, ptr %9, align 8, !tbaa !5
  %48 = load ptr, ptr %9, align 8, !tbaa !5
  %49 = load ptr, ptr %11, align 8, !tbaa !5
  %50 = getelementptr inbounds %struct.Bikeshed_JobAPI_Group, ptr %49, i32 0, i32 1
  store ptr %48, ptr %50, align 8, !tbaa !21
  %51 = load i32, ptr %4, align 4, !tbaa !9
  %52 = zext i32 %51 to i64
  %53 = mul i64 24, %52
  %54 = load ptr, ptr %9, align 8, !tbaa !5
  %55 = getelementptr inbounds i8, ptr %54, i64 %53
  store ptr %55, ptr %9, align 8, !tbaa !5
  %56 = load ptr, ptr %9, align 8, !tbaa !5
  %57 = load ptr, ptr %11, align 8, !tbaa !5
  %58 = getelementptr inbounds %struct.Bikeshed_JobAPI_Group, ptr %57, i32 0, i32 2
  store ptr %56, ptr %58, align 8, !tbaa !23
  %59 = load i32, ptr %4, align 4, !tbaa !9
  %60 = zext i32 %59 to i64
  %61 = mul i64 4, %60
  %62 = load ptr, ptr %9, align 8, !tbaa !5
  %63 = getelementptr inbounds i8, ptr %62, i64 %61
  store ptr %63, ptr %9, align 8, !tbaa !5
  %64 = load ptr, ptr %3, align 8, !tbaa !5
  %65 = load ptr, ptr %11, align 8, !tbaa !5
  %66 = getelementptr inbounds %struct.Bikeshed_JobAPI_Group, ptr %65, i32 0, i32 0
  store ptr %64, ptr %66, align 8, !tbaa !24
  %67 = call i64 (...) @Longtail_GetCurrentThreadId()
  %68 = load ptr, ptr %11, align 8, !tbaa !5
  %69 = getelementptr inbounds %struct.Bikeshed_JobAPI_Group, ptr %68, i32 0, i32 3
  store i64 %67, ptr %69, align 8, !tbaa !25
  %70 = load i32, ptr %4, align 4, !tbaa !9
  %71 = load ptr, ptr %11, align 8, !tbaa !5
  %72 = getelementptr inbounds %struct.Bikeshed_JobAPI_Group, ptr %71, i32 0, i32 4
  store i32 %70, ptr %72, align 8, !tbaa !26
  %73 = load ptr, ptr %11, align 8, !tbaa !5
  %74 = getelementptr inbounds %struct.Bikeshed_JobAPI_Group, ptr %73, i32 0, i32 5
  store volatile i32 0, ptr %74, align 4, !tbaa !27
  %75 = load ptr, ptr %11, align 8, !tbaa !5
  %76 = getelementptr inbounds %struct.Bikeshed_JobAPI_Group, ptr %75, i32 0, i32 7
  store volatile i32 0, ptr %76, align 4, !tbaa !28
  %77 = load ptr, ptr %11, align 8, !tbaa !5
  %78 = getelementptr inbounds %struct.Bikeshed_JobAPI_Group, ptr %77, i32 0, i32 6
  store volatile i32 0, ptr %78, align 8, !tbaa !29
  %79 = load ptr, ptr %11, align 8, !tbaa !5
  %80 = getelementptr inbounds %struct.Bikeshed_JobAPI_Group, ptr %79, i32 0, i32 8
  store volatile i32 0, ptr %80, align 8, !tbaa !30
  br label %81

81:                                               ; preds = %83, %45
  %82 = load ptr, ptr %11, align 8, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #3
  call void @llvm.lifetime.end.p0(i64 24, ptr %6) #3
  call void @llvm.lifetime.end.p0(i64 48, ptr %5) #3
  ret ptr %82

83:                                               ; preds = %42
  br label %81
}

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

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

declare i64 @Longtail_GetCurrentThreadId(...) #2

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 = { "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, !10, i64 0}
!10 = !{!"int", !7, i64 0}
!11 = !{!12, !6, i64 0}
!12 = !{!"Longtail_LogFieldFmt_Private", !6, i64 0, !6, i64 8, !6, i64 16}
!13 = !{!12, !6, i64 8}
!14 = !{!12, !6, i64 16}
!15 = !{!16, !6, i64 0}
!16 = !{!"Longtail_LogContextFmt_Private", !6, i64 0, !6, i64 8, !17, i64 16}
!17 = !{!"long", !7, i64 0}
!18 = !{!16, !6, i64 8}
!19 = !{!16, !17, i64 16}
!20 = !{!17, !17, i64 0}
!21 = !{!22, !6, i64 8}
!22 = !{!"Bikeshed_JobAPI_Group", !6, i64 0, !6, i64 8, !6, i64 16, !17, i64 24, !10, i64 32, !10, i64 36, !10, i64 40, !10, i64 44, !10, i64 48}
!23 = !{!22, !6, i64 16}
!24 = !{!22, !6, i64 0}
!25 = !{!22, !17, i64 24}
!26 = !{!22, !10, i64 32}
!27 = !{!22, !10, i64 36}
!28 = !{!22, !10, i64 44}
!29 = !{!22, !10, i64 40}
!30 = !{!22, !10, i64 48}


; 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 [8 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [3 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [10 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [3 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [90 x i8], align 1
@__func__.CreateJobGroup = external hidden unnamed_addr constant [15 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.8 = external hidden unnamed_addr constant [32 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

; Function Attrs: nounwind uwtable
define dso_local ptr @CreateJobGroup(ptr noundef %0, i32 noundef %1) local_unnamed_addr #1 {
  %3 = alloca [2 x %struct.Longtail_LogFieldFmt_Private], align 16
  %4 = alloca %struct.Longtail_LogContextFmt_Private, align 8
  call void @llvm.lifetime.start.p0(i64 48, ptr nonnull %3) #3
  store ptr @.str, ptr %3, align 16, !tbaa !5
  %5 = getelementptr inbounds i8, ptr %3, i64 8
  store ptr @.str.1, ptr %5, align 8, !tbaa !10
  %6 = getelementptr inbounds i8, ptr %3, i64 16
  store ptr %0, ptr %6, align 16, !tbaa !11
  %7 = getelementptr inbounds i8, ptr %3, i64 24
  store ptr @.str.2, ptr %7, align 8, !tbaa !5
  %8 = getelementptr inbounds i8, ptr %3, i64 32
  store ptr @.str.3, ptr %8, align 16, !tbaa !10
  %9 = getelementptr inbounds i8, ptr %3, i64 40
  %10 = zext i32 %1 to i64
  %11 = inttoptr i64 %10 to ptr
  store ptr %11, ptr %9, 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
  %12 = getelementptr inbounds i8, ptr %4, i64 8
  store ptr %3, ptr %12, align 8, !tbaa !15
  %13 = getelementptr inbounds i8, ptr %4, i64 16
  store i64 2, ptr %13, align 8, !tbaa !16
  call void (ptr, ptr, i32, ptr, i32, ptr, ...) @Longtail_CallLogger(ptr noundef nonnull @.str.4, ptr noundef nonnull @__func__.CreateJobGroup, i32 noundef 207, ptr noundef nonnull %4, i32 noundef 0, ptr noundef nonnull @.str.5, ptr noundef nonnull @.str.6) #3
  %14 = mul nuw nsw i64 %10, 24
  %15 = add nuw nsw i64 %14, 56
  %16 = shl nuw nsw i64 %10, 2
  %17 = add nuw nsw i64 %15, %16
  %18 = call ptr @Longtail_Alloc(ptr noundef nonnull @.str.7, i64 noundef %17) #3
  %.not = icmp eq ptr %18, null
  br i1 %.not, label %19, label %20

19:                                               ; preds = %2
  call void (ptr, ptr, i32, ptr, i32, ptr, ...) @Longtail_CallLogger(ptr noundef nonnull @.str.4, ptr noundef nonnull @__func__.CreateJobGroup, i32 noundef 218, ptr noundef nonnull %4, i32 noundef 3, ptr noundef nonnull @.str.8, i32 noundef 22) #3
  br label %32

20:                                               ; preds = %2
  %21 = getelementptr inbounds i8, ptr %18, i64 56
  %22 = getelementptr inbounds i8, ptr %18, i64 8
  store ptr %21, ptr %22, align 8, !tbaa !17
  %23 = getelementptr inbounds i8, ptr %21, i64 %14
  %24 = getelementptr inbounds i8, ptr %18, i64 16
  store ptr %23, ptr %24, align 8, !tbaa !20
  store ptr %0, ptr %18, align 8, !tbaa !21
  %25 = call i64 (...) @Longtail_GetCurrentThreadId() #3
  %26 = getelementptr inbounds i8, ptr %18, i64 24
  store i64 %25, ptr %26, align 8, !tbaa !22
  %27 = getelementptr inbounds i8, ptr %18, i64 32
  store i32 %1, ptr %27, align 8, !tbaa !23
  %28 = getelementptr inbounds i8, ptr %18, i64 36
  store volatile i32 0, ptr %28, align 4, !tbaa !24
  %29 = getelementptr inbounds i8, ptr %18, i64 44
  store volatile i32 0, ptr %29, align 4, !tbaa !25
  %30 = getelementptr inbounds i8, ptr %18, i64 40
  store volatile i32 0, ptr %30, align 8, !tbaa !26
  %31 = getelementptr inbounds i8, ptr %18, i64 48
  store volatile i32 0, ptr %31, align 8, !tbaa !27
  br label %32

32:                                               ; preds = %19, %20
  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 %18
}

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

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

declare i64 @Longtail_GetCurrentThreadId(...) local_unnamed_addr #2

attributes #0 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 = { "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 8}
!18 = !{!"Bikeshed_JobAPI_Group", !7, i64 0, !7, i64 8, !7, i64 16, !14, i64 24, !19, i64 32, !19, i64 36, !19, i64 40, !19, i64 44, !19, i64 48}
!19 = !{!"int", !8, i64 0}
!20 = !{!18, !7, i64 16}
!21 = !{!18, !7, i64 0}
!22 = !{!18, !14, i64 24}
!23 = !{!18, !19, i64 32}
!24 = !{!18, !19, i64 36}
!25 = !{!18, !19, i64 44}
!26 = !{!18, !19, i64 40}
!27 = !{!18, !19, i64 48}


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