; LLVM IR from ohler55/agoo :: ext/agoo (req)

; 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._agooServer = type { i8, i8, i32, i8, i8, i8, i8, i64, %struct._agooQueue, ptr, ptr, ptr, %struct._agooQueue, ptr, i32, i32, %struct._agooAtom, ptr, ptr, %union.pthread_mutex_t, i32, ptr, ptr, %struct._agooAtom }
%struct._agooQueue = type { ptr, ptr, %struct._agooAtom, %struct._agooAtom, i8, i8, %struct._agooAtom, %struct._agooAtom, %struct._agooAtom, i32, i32 }
%union.pthread_mutex_t = type { %struct.__pthread_mutex_s }
%struct.__pthread_mutex_s = type { i32, i32, i32, i32, i32, i16, i16, %struct.__pthread_internal_list }
%struct.__pthread_internal_list = type { ptr, ptr }
%struct._agooAtom = type { ptr, %union.pthread_mutex_t }
%struct._agooReq = type { i32, ptr, i32, ptr, %struct._agooStr, %struct._agooStr, %struct._agooStr, %struct._agooStr, %struct._agooStr, [46 x i8], ptr, ptr, i64, [8 x i8] }
%struct._agooStr = type { ptr, i32 }

@agoo_server = external global %struct._agooServer, align 8

; Function Attrs: nounwind uwtable
define dso_local ptr @agoo_req_create(i64 noundef %0) #0 {
  %2 = alloca i64, align 8
  %3 = alloca i64, align 8
  %4 = alloca ptr, align 8
  store i64 %0, ptr %2, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %3) #4
  %5 = load i64, ptr %2, align 8, !tbaa !5
  %6 = add i64 %5, 192
  %7 = sub i64 %6, 7
  store i64 %7, ptr %3, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %4) #4
  %8 = load i64, ptr %3, align 8, !tbaa !5
  %9 = call noalias ptr @malloc(i64 noundef %8) #5
  store ptr %9, ptr %4, align 8, !tbaa !9
  %10 = load ptr, ptr %4, align 8, !tbaa !9
  %11 = icmp ne ptr null, %10
  br i1 %11, label %12, label %23

12:                                               ; preds = %1
  %13 = load ptr, ptr %4, align 8, !tbaa !9
  %14 = load i64, ptr %3, align 8, !tbaa !5
  call void @llvm.memset.p0.i64(ptr align 8 %13, i8 0, i64 %14, i1 false)
  %15 = load ptr, ptr getelementptr inbounds (%struct._agooServer, ptr @agoo_server, i32 0, i32 21), align 8, !tbaa !11
  %16 = load ptr, ptr %4, align 8, !tbaa !9
  %17 = getelementptr inbounds %struct._agooReq, ptr %16, i32 0, i32 10
  store ptr %15, ptr %17, align 8, !tbaa !17
  %18 = load i64, ptr %2, align 8, !tbaa !5
  %19 = load ptr, ptr %4, align 8, !tbaa !9
  %20 = getelementptr inbounds %struct._agooReq, ptr %19, i32 0, i32 12
  store i64 %18, ptr %20, align 8, !tbaa !20
  %21 = load ptr, ptr %4, align 8, !tbaa !9
  %22 = getelementptr inbounds %struct._agooReq, ptr %21, i32 0, i32 11
  store ptr null, ptr %22, align 8, !tbaa !21
  br label %23

23:                                               ; preds = %12, %1
  %24 = load ptr, ptr %4, align 8, !tbaa !9
  call void @llvm.lifetime.end.p0(i64 8, ptr %4) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %3) #4
  ret ptr %24
}

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

; Function Attrs: nounwind allocsize(0)
declare noalias ptr @malloc(i64 noundef) #2

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

; 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 = { nounwind allocsize(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 = { nocallback nofree nounwind willreturn memory(argmem: write) }
attributes #4 = { nounwind }
attributes #5 = { nounwind allocsize(0) }

!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 = !{!"long", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"any pointer", !7, i64 0}
!11 = !{!12, !10, i64 720}
!12 = !{!"_agooServer", !13, i64 0, !13, i64 1, !14, i64 4, !13, i64 8, !13, i64 9, !13, i64 10, !13, i64 11, !6, i64 16, !15, i64 24, !10, i64 296, !10, i64 304, !10, i64 312, !15, i64 320, !10, i64 592, !14, i64 600, !14, i64 604, !16, i64 608, !10, i64 656, !10, i64 664, !7, i64 672, !14, i64 712, !10, i64 720, !10, i64 728, !16, i64 736}
!13 = !{!"_Bool", !7, i64 0}
!14 = !{!"int", !7, i64 0}
!15 = !{!"_agooQueue", !10, i64 0, !10, i64 8, !16, i64 16, !16, i64 64, !13, i64 112, !13, i64 113, !16, i64 120, !16, i64 168, !16, i64 216, !14, i64 264, !14, i64 268}
!16 = !{!"_agooAtom", !10, i64 0, !7, i64 8}
!17 = !{!18, !10, i64 160}
!18 = !{!"_agooReq", !14, i64 0, !10, i64 8, !14, i64 16, !10, i64 24, !19, i64 32, !19, i64 48, !19, i64 64, !19, i64 80, !19, i64 96, !7, i64 112, !10, i64 160, !10, i64 168, !6, i64 176, !7, i64 184}
!19 = !{!"_agooStr", !10, i64 0, !14, i64 8}
!20 = !{!18, !6, i64 176}
!21 = !{!18, !10, i64 168}


; 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._agooServer = type { i8, i8, i32, i8, i8, i8, i8, i64, %struct._agooQueue, ptr, ptr, ptr, %struct._agooQueue, ptr, i32, i32, %struct._agooAtom, ptr, ptr, %union.pthread_mutex_t, i32, ptr, ptr, %struct._agooAtom }
%struct._agooQueue = type { ptr, ptr, %struct._agooAtom, %struct._agooAtom, i8, i8, %struct._agooAtom, %struct._agooAtom, %struct._agooAtom, i32, i32 }
%union.pthread_mutex_t = type { %struct.__pthread_mutex_s }
%struct.__pthread_mutex_s = type { i32, i32, i32, i32, i32, i16, i16, %struct.__pthread_internal_list }
%struct.__pthread_internal_list = type { ptr, ptr }
%struct._agooAtom = type { ptr, %union.pthread_mutex_t }

@agoo_server = external local_unnamed_addr global %struct._agooServer, align 8

; Function Attrs: mustprogress nofree nounwind willreturn memory(readwrite, argmem: none) uwtable
define dso_local noalias noundef ptr @agoo_req_create(i64 noundef %0) local_unnamed_addr #0 {
  %2 = add i64 %0, 185
  %calloc = tail call ptr @calloc(i64 1, i64 %2)
  %.not = icmp eq ptr %calloc, null
  br i1 %.not, label %7, label %3

3:                                                ; preds = %1
  %4 = load ptr, ptr getelementptr inbounds (i8, ptr @agoo_server, i64 720), align 8, !tbaa !5
  %5 = getelementptr inbounds i8, ptr %calloc, i64 160
  store ptr %4, ptr %5, align 8, !tbaa !15
  %6 = getelementptr inbounds i8, ptr %calloc, i64 176
  store i64 %0, ptr %6, align 8, !tbaa !18
  br label %7

7:                                                ; preds = %3, %1
  ret ptr %calloc
}

; Function Attrs: nofree nounwind willreturn allockind("alloc,zeroed") allocsize(0,1) memory(inaccessiblemem: readwrite)
declare noalias noundef ptr @calloc(i64 noundef, i64 noundef) local_unnamed_addr #1

attributes #0 = { mustprogress nofree nounwind willreturn memory(readwrite, argmem: none) 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 = { nofree nounwind willreturn allockind("alloc,zeroed") allocsize(0,1) memory(inaccessiblemem: readwrite) "alloc-family"="malloc" }

!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, !13, i64 720}
!6 = !{!"_agooServer", !7, i64 0, !7, i64 1, !10, i64 4, !7, i64 8, !7, i64 9, !7, i64 10, !7, i64 11, !11, i64 16, !12, i64 24, !13, i64 296, !13, i64 304, !13, i64 312, !12, i64 320, !13, i64 592, !10, i64 600, !10, i64 604, !14, i64 608, !13, i64 656, !13, i64 664, !8, i64 672, !10, i64 712, !13, i64 720, !13, i64 728, !14, i64 736}
!7 = !{!"_Bool", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"int", !8, i64 0}
!11 = !{!"long", !8, i64 0}
!12 = !{!"_agooQueue", !13, i64 0, !13, i64 8, !14, i64 16, !14, i64 64, !7, i64 112, !7, i64 113, !14, i64 120, !14, i64 168, !14, i64 216, !10, i64 264, !10, i64 268}
!13 = !{!"any pointer", !8, i64 0}
!14 = !{!"_agooAtom", !13, i64 0, !8, i64 8}
!15 = !{!16, !13, i64 160}
!16 = !{!"_agooReq", !10, i64 0, !13, i64 8, !10, i64 16, !13, i64 24, !17, i64 32, !17, i64 48, !17, i64 64, !17, i64 80, !17, i64 96, !8, i64 112, !13, i64 160, !13, i64 168, !11, i64 176, !8, i64 184}
!17 = !{!"_agooStr", !13, i64 0, !10, i64 8}
!18 = !{!16, !11, i64 176}


; Effective O3 passes: DSEPass,GlobalOptPass,InferFunctionAttrsPass,InstCombinePass,PostOrderFunctionAttrsPass,SROAPass,TailCallElimPass