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

; 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 @agoo_con_header_value(ptr noundef %0, i32 noundef %1, ptr noundef %2, ptr noundef %3) #1 {
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca i32, align 4
  %8 = alloca ptr, align 8
  %9 = alloca ptr, align 8
  %10 = alloca ptr, align 8
  %11 = alloca ptr, align 8
  %12 = alloca ptr, align 8
  %13 = alloca i32, align 4
  %14 = alloca i32, align 4
  store ptr %0, ptr %6, align 8, !tbaa !5
  store i32 %1, ptr %7, align 4, !tbaa !9
  store ptr %2, ptr %8, align 8, !tbaa !5
  store ptr %3, ptr %9, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #3
  %15 = load ptr, ptr %6, align 8, !tbaa !5
  store ptr %15, ptr %10, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %11) #3
  %16 = load ptr, ptr %6, align 8, !tbaa !5
  %17 = load i32, ptr %7, align 4, !tbaa !9
  %18 = sext i32 %17 to i64
  %19 = getelementptr inbounds i8, ptr %16, i64 %18
  store ptr %19, ptr %11, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %12) #3
  call void @llvm.lifetime.start.p0(i64 4, ptr %13) #3
  %20 = load ptr, ptr %8, align 8, !tbaa !5
  %21 = call i64 @strlen(ptr noundef %20) #4
  %22 = trunc i64 %21 to i32
  store i32 %22, ptr %13, align 4, !tbaa !9
  br label %23

23:                                               ; preds = %107, %4
  %24 = load ptr, ptr %10, align 8, !tbaa !5
  %25 = load ptr, ptr %11, align 8, !tbaa !5
  %26 = icmp ult ptr %24, %25
  br i1 %26, label %27, label %108

27:                                               ; preds = %23
  %28 = load ptr, ptr %8, align 8, !tbaa !5
  %29 = load ptr, ptr %10, align 8, !tbaa !5
  %30 = load i32, ptr %13, align 4, !tbaa !9
  %31 = sext i32 %30 to i64
  %32 = call i32 @strncasecmp(ptr noundef %28, ptr noundef %29, i64 noundef %31) #4
  %33 = icmp eq i32 0, %32
  br i1 %33, label %34, label %84

34:                                               ; preds = %27
  %35 = load ptr, ptr %10, align 8, !tbaa !5
  %36 = load i32, ptr %13, align 4, !tbaa !9
  %37 = sext i32 %36 to i64
  %38 = getelementptr inbounds i8, ptr %35, i64 %37
  %39 = load i8, ptr %38, align 1, !tbaa !11
  %40 = sext i8 %39 to i32
  %41 = icmp eq i32 58, %40
  br i1 %41, label %42, label %84

42:                                               ; preds = %34
  %43 = load i32, ptr %13, align 4, !tbaa !9
  %44 = add nsw i32 %43, 1
  %45 = load ptr, ptr %10, align 8, !tbaa !5
  %46 = sext i32 %44 to i64
  %47 = getelementptr inbounds i8, ptr %45, i64 %46
  store ptr %47, ptr %10, align 8, !tbaa !5
  br label %48

48:                                               ; preds = %54, %42
  %49 = load ptr, ptr %10, align 8, !tbaa !5
  %50 = load i8, ptr %49, align 1, !tbaa !11
  %51 = sext i8 %50 to i32
  %52 = icmp eq i32 32, %51
  br i1 %52, label %53, label %57

53:                                               ; preds = %48
  br label %54

54:                                               ; preds = %53
  %55 = load ptr, ptr %10, align 8, !tbaa !5
  %56 = getelementptr inbounds i8, ptr %55, i32 1
  store ptr %56, ptr %10, align 8, !tbaa !5
  br label %48, !llvm.loop !12

57:                                               ; preds = %48
  %58 = load ptr, ptr %10, align 8, !tbaa !5
  store ptr %58, ptr %12, align 8, !tbaa !5
  br label %59

59:                                               ; preds = %72, %57
  %60 = load ptr, ptr %10, align 8, !tbaa !5
  %61 = load i8, ptr %60, align 1, !tbaa !11
  %62 = sext i8 %61 to i32
  %63 = icmp ne i32 13, %62
  br i1 %63, label %64, label %69

64:                                               ; preds = %59
  %65 = load ptr, ptr %10, align 8, !tbaa !5
  %66 = load i8, ptr %65, align 1, !tbaa !11
  %67 = sext i8 %66 to i32
  %68 = icmp ne i32 0, %67
  br label %69

69:                                               ; preds = %64, %59
  %70 = phi i1 [ false, %59 ], [ %68, %64 ]
  br i1 %70, label %71, label %75

71:                                               ; preds = %69
  br label %72

72:                                               ; preds = %71
  %73 = load ptr, ptr %10, align 8, !tbaa !5
  %74 = getelementptr inbounds i8, ptr %73, i32 1
  store ptr %74, ptr %10, align 8, !tbaa !5
  br label %59, !llvm.loop !14

75:                                               ; preds = %69
  %76 = load ptr, ptr %10, align 8, !tbaa !5
  %77 = load ptr, ptr %12, align 8, !tbaa !5
  %78 = ptrtoint ptr %76 to i64
  %79 = ptrtoint ptr %77 to i64
  %80 = sub i64 %78, %79
  %81 = trunc i64 %80 to i32
  %82 = load ptr, ptr %9, align 8, !tbaa !5
  store i32 %81, ptr %82, align 4, !tbaa !9
  %83 = load ptr, ptr %12, align 8, !tbaa !5
  store ptr %83, ptr %5, align 8
  store i32 1, ptr %14, align 4
  br label %109

84:                                               ; preds = %34, %27
  br label %85

85:                                               ; preds = %104, %84
  %86 = load ptr, ptr %10, align 8, !tbaa !5
  %87 = load ptr, ptr %11, align 8, !tbaa !5
  %88 = icmp ult ptr %86, %87
  br i1 %88, label %89, label %107

89:                                               ; preds = %85
  %90 = load ptr, ptr %10, align 8, !tbaa !5
  %91 = load i8, ptr %90, align 1, !tbaa !11
  %92 = sext i8 %91 to i32
  %93 = icmp eq i32 13, %92
  br i1 %93, label %94, label %103

94:                                               ; preds = %89
  %95 = load ptr, ptr %10, align 8, !tbaa !5
  %96 = getelementptr inbounds i8, ptr %95, i64 1
  %97 = load i8, ptr %96, align 1, !tbaa !11
  %98 = sext i8 %97 to i32
  %99 = icmp eq i32 10, %98
  br i1 %99, label %100, label %103

100:                                              ; preds = %94
  %101 = load ptr, ptr %10, align 8, !tbaa !5
  %102 = getelementptr inbounds i8, ptr %101, i64 2
  store ptr %102, ptr %10, align 8, !tbaa !5
  br label %107

103:                                              ; preds = %94, %89
  br label %104

104:                                              ; preds = %103
  %105 = load ptr, ptr %10, align 8, !tbaa !5
  %106 = getelementptr inbounds i8, ptr %105, i32 1
  store ptr %106, ptr %10, align 8, !tbaa !5
  br label %85, !llvm.loop !15

107:                                              ; preds = %100, %85
  br label %23, !llvm.loop !16

108:                                              ; preds = %23
  store ptr null, ptr %5, align 8
  store i32 1, ptr %14, align 4
  br label %109

109:                                              ; preds = %108, %75
  call void @llvm.lifetime.end.p0(i64 4, ptr %13) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %12) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #3
  %110 = load ptr, ptr %5, align 8
  ret ptr %110
}

; Function Attrs: nounwind willreturn memory(read)
declare i64 @strlen(ptr noundef) #2

; Function Attrs: nounwind willreturn memory(read)
declare i32 @strncasecmp(ptr noundef, ptr noundef, i64 noundef) #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 = { nounwind willreturn memory(read) "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 }
attributes #4 = { nounwind willreturn memory(read) }

!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 = !{!7, !7, i64 0}
!12 = distinct !{!12, !13}
!13 = !{!"llvm.loop.mustprogress"}
!14 = distinct !{!14, !13}
!15 = distinct !{!15, !13}
!16 = distinct !{!16, !13}


; 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: nofree nounwind memory(read, argmem: readwrite) uwtable
define dso_local noundef ptr @agoo_con_header_value(ptr noundef %0, i32 noundef %1, ptr nocapture noundef readonly %2, ptr nocapture noundef writeonly %3) local_unnamed_addr #0 {
  %5 = sext i32 %1 to i64
  %6 = getelementptr inbounds i8, ptr %0, i64 %5
  %7 = icmp sgt i32 %1, 0
  br i1 %7, label %.lr.ph39, label %.loopexit34

.lr.ph39:                                         ; preds = %4
  %8 = tail call i64 @strlen(ptr noundef nonnull dereferenceable(1) %2) #3
  %sext = shl i64 %8, 32
  %9 = ashr exact i64 %sext, 32
  br label %10

10:                                               ; preds = %.lr.ph39, %.loopexit
  %.02938 = phi ptr [ %0, %.lr.ph39 ], [ %.4, %.loopexit ]
  %11 = tail call i32 @strncasecmp(ptr noundef %2, ptr noundef %.02938, i64 noundef %9) #3
  %12 = icmp eq i32 %11, 0
  br i1 %12, label %13, label %31

13:                                               ; preds = %10
  %14 = getelementptr inbounds i8, ptr %.02938, i64 %9
  %15 = load i8, ptr %14, align 1, !tbaa !5
  %16 = icmp eq i8 %15, 58
  br i1 %16, label %17, label %31

17:                                               ; preds = %13
  %sext32 = add i64 %sext, 4294967296
  %18 = ashr exact i64 %sext32, 32
  %19 = getelementptr inbounds i8, ptr %.02938, i64 %18
  br label %20

20:                                               ; preds = %20, %17
  %.1 = phi ptr [ %19, %17 ], [ %23, %20 ]
  %21 = load i8, ptr %.1, align 1, !tbaa !5
  %22 = icmp eq i8 %21, 32
  %23 = getelementptr inbounds i8, ptr %.1, i64 1
  br i1 %22, label %20, label %.preheader, !llvm.loop !8

.preheader:                                       ; preds = %20, %25
  %24 = phi i8 [ %.pr, %25 ], [ %21, %20 ]
  %.2 = phi ptr [ %26, %25 ], [ %.1, %20 ]
  switch i8 %24, label %25 [
    i8 13, label %.critedge
    i8 0, label %.critedge
  ]

25:                                               ; preds = %.preheader
  %26 = getelementptr inbounds i8, ptr %.2, i64 1
  %.pr = load i8, ptr %26, align 1, !tbaa !5
  br label %.preheader, !llvm.loop !10

.critedge:                                        ; preds = %.preheader, %.preheader
  %27 = ptrtoint ptr %.2 to i64
  %28 = ptrtoint ptr %.1 to i64
  %29 = sub i64 %27, %28
  %30 = trunc i64 %29 to i32
  store i32 %30, ptr %3, align 4, !tbaa !11
  br label %.loopexit34

31:                                               ; preds = %13, %10
  %32 = icmp ult ptr %.02938, %6
  br i1 %32, label %.lr.ph, label %.loopexit

.lr.ph:                                           ; preds = %31, %41
  %.337 = phi ptr [ %42, %41 ], [ %.02938, %31 ]
  %33 = load i8, ptr %.337, align 1, !tbaa !5
  %34 = icmp eq i8 %33, 13
  br i1 %34, label %35, label %41

35:                                               ; preds = %.lr.ph
  %36 = getelementptr inbounds i8, ptr %.337, i64 1
  %37 = load i8, ptr %36, align 1, !tbaa !5
  %38 = icmp eq i8 %37, 10
  br i1 %38, label %39, label %41

39:                                               ; preds = %35
  %40 = getelementptr inbounds i8, ptr %.337, i64 2
  br label %.loopexit

41:                                               ; preds = %.lr.ph, %35
  %42 = getelementptr inbounds i8, ptr %.337, i64 1
  %43 = icmp ult ptr %42, %6
  br i1 %43, label %.lr.ph, label %.loopexit, !llvm.loop !13

.loopexit:                                        ; preds = %41, %31, %39
  %.4 = phi ptr [ %40, %39 ], [ %.02938, %31 ], [ %42, %41 ]
  %44 = icmp ult ptr %.4, %6
  br i1 %44, label %10, label %.loopexit34, !llvm.loop !14

.loopexit34:                                      ; preds = %.loopexit, %4, %.critedge
  %.0 = phi ptr [ %.1, %.critedge ], [ null, %4 ], [ null, %.loopexit ]
  ret ptr %.0
}

; Function Attrs: mustprogress nofree nounwind willreturn memory(argmem: read)
declare i64 @strlen(ptr nocapture noundef) local_unnamed_addr #1

; Function Attrs: mustprogress nofree nounwind willreturn memory(read)
declare i32 @strncasecmp(ptr nocapture noundef, ptr nocapture noundef, i64 noundef) local_unnamed_addr #2

attributes #0 = { nofree nounwind memory(read, argmem: readwrite) 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 = { mustprogress nofree nounwind willreturn memory(argmem: read) "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 = { mustprogress nofree nounwind willreturn memory(read) "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 willreturn memory(read) }

!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 = !{!"omnipotent char", !7, i64 0}
!7 = !{!"Simple C/C++ TBAA"}
!8 = distinct !{!8, !9}
!9 = !{!"llvm.loop.mustprogress"}
!10 = distinct !{!10, !9}
!11 = !{!12, !12, i64 0}
!12 = !{!"int", !6, i64 0}
!13 = distinct !{!13, !9}
!14 = distinct !{!14, !9}


; Effective O3 passes: EarlyCSEPass,GVNPass,GlobalOptPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,JumpThreadingPass,LCSSAPass,LICMPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass,TailCallElimPass