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

@.str = external hidden unnamed_addr constant [5 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 ptr @agoo_con_header_value(ptr noundef, i32 noundef, ptr noundef, ptr noundef) #1

; Function Attrs: nounwind uwtable
define dso_local i32 @agoo_req_port(ptr noundef %0) #2 {
  %2 = alloca i32, align 4
  %3 = alloca ptr, align 8
  %4 = alloca i32, align 4
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca i32, align 4
  store ptr %0, ptr %3, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #4
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #4
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #4
  %8 = load ptr, ptr %3, align 8, !tbaa !5
  %9 = getelementptr inbounds %struct._agooReq, ptr %8, i32 0, i32 7
  %10 = getelementptr inbounds %struct._agooStr, ptr %9, i32 0, i32 0
  %11 = load ptr, ptr %10, align 8, !tbaa !9
  %12 = load ptr, ptr %3, align 8, !tbaa !5
  %13 = getelementptr inbounds %struct._agooReq, ptr %12, i32 0, i32 7
  %14 = getelementptr inbounds %struct._agooStr, ptr %13, i32 0, i32 1
  %15 = load i32, ptr %14, align 8, !tbaa !14
  %16 = call ptr @agoo_con_header_value(ptr noundef %11, i32 noundef %15, ptr noundef @.str, ptr noundef %4)
  store ptr %16, ptr %5, align 8, !tbaa !5
  %17 = icmp eq ptr null, %16
  br i1 %17, label %18, label %19

18:                                               ; preds = %1
  store i32 0, ptr %2, align 4
  store i32 1, ptr %7, align 4
  br label %49

19:                                               ; preds = %1
  %20 = load ptr, ptr %5, align 8, !tbaa !5
  %21 = load i32, ptr %4, align 4, !tbaa !15
  %22 = sext i32 %21 to i64
  %23 = getelementptr inbounds i8, ptr %20, i64 %22
  %24 = getelementptr inbounds i8, ptr %23, i64 -1
  store ptr %24, ptr %6, align 8, !tbaa !5
  br label %25

25:                                               ; preds = %36, %19
  %26 = load ptr, ptr %5, align 8, !tbaa !5
  %27 = load ptr, ptr %6, align 8, !tbaa !5
  %28 = icmp ult ptr %26, %27
  br i1 %28, label %29, label %39

29:                                               ; preds = %25
  %30 = load ptr, ptr %6, align 8, !tbaa !5
  %31 = load i8, ptr %30, align 1, !tbaa !16
  %32 = sext i8 %31 to i32
  %33 = icmp eq i32 58, %32
  br i1 %33, label %34, label %35

34:                                               ; preds = %29
  br label %39

35:                                               ; preds = %29
  br label %36

36:                                               ; preds = %35
  %37 = load ptr, ptr %6, align 8, !tbaa !5
  %38 = getelementptr inbounds i8, ptr %37, i32 -1
  store ptr %38, ptr %6, align 8, !tbaa !5
  br label %25, !llvm.loop !17

39:                                               ; preds = %34, %25
  %40 = load ptr, ptr %5, align 8, !tbaa !5
  %41 = load ptr, ptr %6, align 8, !tbaa !5
  %42 = icmp eq ptr %40, %41
  br i1 %42, label %43, label %44

43:                                               ; preds = %39
  store i32 0, ptr %2, align 4
  store i32 1, ptr %7, align 4
  br label %49

44:                                               ; preds = %39
  %45 = load ptr, ptr %6, align 8, !tbaa !5
  %46 = getelementptr inbounds i8, ptr %45, i64 1
  %47 = call i64 @strtol(ptr noundef %46, ptr noundef null, i32 noundef 10) #4
  %48 = trunc i64 %47 to i32
  store i32 %48, ptr %2, align 4
  store i32 1, ptr %7, align 4
  br label %49

49:                                               ; preds = %44, %43, %18
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #4
  %50 = load i32, ptr %2, align 4
  ret i32 %50
}

; Function Attrs: nounwind
declare i64 @strtol(ptr noundef, ptr noundef, i32 noundef) #3

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 "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 #4 = { 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 80}
!10 = !{!"_agooReq", !11, i64 0, !6, i64 8, !11, i64 16, !6, i64 24, !12, i64 32, !12, i64 48, !12, i64 64, !12, i64 80, !12, i64 96, !7, i64 112, !6, i64 160, !6, i64 168, !13, i64 176, !7, i64 184}
!11 = !{!"int", !7, i64 0}
!12 = !{!"_agooStr", !6, i64 0, !11, i64 8}
!13 = !{!"long", !7, i64 0}
!14 = !{!10, !11, i64 88}
!15 = !{!11, !11, i64 0}
!16 = !{!7, !7, i64 0}
!17 = distinct !{!17, !18}
!18 = !{!"llvm.loop.mustprogress"}


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

@.str = external hidden unnamed_addr constant [5 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 ptr @agoo_con_header_value(ptr noundef, i32 noundef, ptr noundef, ptr noundef) local_unnamed_addr #1

; Function Attrs: nounwind uwtable
define dso_local i32 @agoo_req_port(ptr nocapture noundef readonly %0) local_unnamed_addr #2 {
  %2 = alloca i32, align 4
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %2) #4
  %3 = getelementptr inbounds i8, ptr %0, i64 80
  %4 = load ptr, ptr %3, align 8, !tbaa !5
  %5 = getelementptr inbounds i8, ptr %0, i64 88
  %6 = load i32, ptr %5, align 8, !tbaa !13
  %7 = call ptr @agoo_con_header_value(ptr noundef %4, i32 noundef %6, ptr noundef nonnull @.str, ptr noundef nonnull %2) #4
  %8 = icmp eq ptr %7, null
  br i1 %8, label %23, label %9

9:                                                ; preds = %1
  %10 = load i32, ptr %2, align 4, !tbaa !14
  %11 = sext i32 %10 to i64
  %12 = getelementptr inbounds i8, ptr %7, i64 %11
  br label %13

13:                                               ; preds = %15, %9
  %.pn = phi ptr [ %12, %9 ], [ %.0, %15 ]
  %.0 = getelementptr inbounds i8, ptr %.pn, i64 -1
  %14 = icmp ult ptr %7, %.0
  br i1 %14, label %15, label %18

15:                                               ; preds = %13
  %16 = load i8, ptr %.0, align 1, !tbaa !15
  %17 = icmp eq i8 %16, 58
  br i1 %17, label %18, label %13, !llvm.loop !16

18:                                               ; preds = %15, %13
  %19 = icmp eq ptr %7, %.0
  br i1 %19, label %23, label %20

20:                                               ; preds = %18
  %21 = call i64 @strtol(ptr nocapture noundef %.pn, ptr noundef null, i32 noundef 10) #4
  %22 = trunc i64 %21 to i32
  br label %23

23:                                               ; preds = %18, %1, %20
  %.010 = phi i32 [ %22, %20 ], [ 0, %1 ], [ 0, %18 ]
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %2) #4
  ret i32 %.010
}

; Function Attrs: mustprogress nofree nounwind willreturn
declare i64 @strtol(ptr noundef readonly, ptr nocapture noundef, i32 noundef) local_unnamed_addr #3

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 = { mustprogress nofree nounwind willreturn "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 #4 = { 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, !10, i64 80}
!6 = !{!"_agooReq", !7, i64 0, !10, i64 8, !7, i64 16, !10, i64 24, !11, i64 32, !11, i64 48, !11, i64 64, !11, i64 80, !11, i64 96, !8, i64 112, !10, i64 160, !10, i64 168, !12, i64 176, !8, i64 184}
!7 = !{!"int", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"any pointer", !8, i64 0}
!11 = !{!"_agooStr", !10, i64 0, !7, i64 8}
!12 = !{!"long", !8, i64 0}
!13 = !{!6, !7, i64 88}
!14 = !{!7, !7, i64 0}
!15 = !{!8, !8, i64 0}
!16 = distinct !{!16, !17}
!17 = !{!"llvm.loop.mustprogress"}


; Effective O3 passes: EarlyCSEPass,GVNPass,GlobalOptPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,LCSSAPass,LoopUnrollPass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass