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

; 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._agooRes = type { ptr, ptr, ptr, %union.pthread_mutex_t, i8, i32, i8, i8, i8 }
%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._agooCon = type { ptr, i32, ptr, ptr, i64, [46 x i8], [8192 x i8], i64, i64, i64, double, i8, i8, i8, ptr, ptr, ptr, %union.pthread_mutex_t, ptr, ptr, ptr }

; 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 signext i16 @agoo_con_http_events(ptr noundef %0) #1 {
  %2 = alloca ptr, align 8
  %3 = alloca i16, align 2
  %4 = alloca ptr, align 8
  store ptr %0, ptr %2, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 2, ptr %3) #2
  store i16 0, ptr %3, align 2, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %4) #2
  %5 = load ptr, ptr %2, align 8, !tbaa !5
  %6 = call ptr @agoo_con_res_peek(ptr noundef %5)
  store ptr %6, ptr %4, align 8, !tbaa !5
  %7 = load ptr, ptr %4, align 8, !tbaa !5
  %8 = icmp ne ptr null, %7
  br i1 %8, label %9, label %15

9:                                                ; preds = %1
  %10 = load ptr, ptr %4, align 8, !tbaa !5
  %11 = getelementptr inbounds %struct._agooRes, ptr %10, i32 0, i32 2
  %12 = load volatile ptr, ptr %11, align 8, !tbaa !11
  %13 = icmp ne ptr null, %12
  br i1 %13, label %14, label %15

14:                                               ; preds = %9
  store i16 5, ptr %3, align 2, !tbaa !9
  br label %22

15:                                               ; preds = %9, %1
  %16 = load ptr, ptr %2, align 8, !tbaa !5
  %17 = getelementptr inbounds %struct._agooCon, ptr %16, i32 0, i32 11
  %18 = load i8, ptr %17, align 8, !tbaa !15, !range !19, !noundef !20
  %19 = trunc i8 %18 to i1
  br i1 %19, label %21, label %20

20:                                               ; preds = %15
  store i16 1, ptr %3, align 2, !tbaa !9
  br label %21

21:                                               ; preds = %20, %15
  br label %22

22:                                               ; preds = %21, %14
  %23 = load i16, ptr %3, align 2, !tbaa !9
  call void @llvm.lifetime.end.p0(i64 8, ptr %4) #2
  call void @llvm.lifetime.end.p0(i64 2, ptr %3) #2
  ret i16 %23
}

; Function Attrs: nounwind uwtable
declare hidden ptr @agoo_con_res_peek(ptr noundef) #1

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 = { 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 = !{!"short", !7, i64 0}
!11 = !{!12, !6, i64 16}
!12 = !{!"_agooRes", !6, i64 0, !6, i64 8, !6, i64 16, !7, i64 24, !13, i64 64, !14, i64 68, !13, i64 72, !13, i64 73, !13, i64 74}
!13 = !{!"_Bool", !7, i64 0}
!14 = !{!"int", !7, i64 0}
!15 = !{!16, !13, i64 8312}
!16 = !{!"_agooCon", !6, i64 0, !14, i64 8, !6, i64 16, !6, i64 24, !17, i64 32, !7, i64 40, !7, i64 86, !17, i64 8280, !17, i64 8288, !17, i64 8296, !18, i64 8304, !13, i64 8312, !13, i64 8313, !13, i64 8314, !6, i64 8320, !6, i64 8328, !6, i64 8336, !7, i64 8344, !6, i64 8384, !6, i64 8392, !6, i64 8400}
!17 = !{!"long", !7, i64 0}
!18 = !{!"double", !7, i64 0}
!19 = !{i8 0, i8 2}
!20 = !{}


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

; Function Attrs: nounwind uwtable
define dso_local signext range(i16 0, 6) i16 @agoo_con_http_events(ptr noundef %0) local_unnamed_addr #0 {
  %2 = tail call ptr @agoo_con_res_peek(ptr noundef %0)
  %.not = icmp eq ptr %2, null
  br i1 %.not, label %6, label %3

3:                                                ; preds = %1
  %4 = getelementptr inbounds i8, ptr %2, i64 16
  %5 = load volatile ptr, ptr %4, align 8, !tbaa !5
  %.not5 = icmp eq ptr %5, null
  br i1 %.not5, label %6, label %10

6:                                                ; preds = %3, %1
  %7 = getelementptr inbounds i8, ptr %0, i64 8312
  %8 = load i8, ptr %7, align 8, !tbaa !12, !range !16, !noundef !17
  %9 = xor i8 %8, 1
  %not. = zext nneg i8 %9 to i16
  br label %10

10:                                               ; preds = %6, %3
  %.0 = phi i16 [ 5, %3 ], [ %not., %6 ]
  ret i16 %.0
}

; Function Attrs: nounwind uwtable
declare hidden ptr @agoo_con_res_peek(ptr noundef) local_unnamed_addr #0

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

!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 16}
!6 = !{!"_agooRes", !7, i64 0, !7, i64 8, !7, i64 16, !8, i64 24, !10, i64 64, !11, i64 68, !10, i64 72, !10, i64 73, !10, i64 74}
!7 = !{!"any pointer", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"_Bool", !8, i64 0}
!11 = !{!"int", !8, i64 0}
!12 = !{!13, !10, i64 8312}
!13 = !{!"_agooCon", !7, i64 0, !11, i64 8, !7, i64 16, !7, i64 24, !14, i64 32, !8, i64 40, !8, i64 86, !14, i64 8280, !14, i64 8288, !14, i64 8296, !15, i64 8304, !10, i64 8312, !10, i64 8313, !10, i64 8314, !7, i64 8320, !7, i64 8328, !7, i64 8336, !8, i64 8344, !7, i64 8384, !7, i64 8392, !7, i64 8400}
!14 = !{!"long", !8, i64 0}
!15 = !{!"double", !8, i64 0}
!16 = !{i8 0, i8 2}
!17 = !{}


; Effective O3 passes: GlobalOptPass,IPSCCPPass,InferFunctionAttrsPass,InstCombinePass,SROAPass,SimplifyCFGPass,TailCallElimPass