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

; 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._cache = type { [1024 x ptr], [1024 x ptr], [64 x ptr], ptr, ptr, ptr }
%struct._headRule = type { ptr, ptr, ptr, ptr, ptr, i32 }

@.str.3 = external hidden unnamed_addr constant [62 x i8], align 1
@cache = external hidden global %struct._cache, align 8
@.str.17 = external hidden unnamed_addr constant [15 x i8], align 1
@.str.18 = external hidden unnamed_addr constant [48 x i8], align 1
@.str.19 = external hidden unnamed_addr constant [12 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: nounwind willreturn memory(read)
declare i64 @strlen(ptr noundef) #1

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

declare i32 @agoo_err_set(ptr noundef, i32 noundef, ptr noundef, ...) #2

; Function Attrs: nounwind
declare void @free(ptr noundef) #3

; Function Attrs: nounwind
declare noalias ptr @strdup(ptr noundef) #3

declare i32 @agoo_err_memory(ptr noundef, ptr noundef, ptr noundef, i32 noundef) #2

; Function Attrs: nounwind willreturn memory(read)
declare i32 @strcasecmp(ptr noundef, ptr noundef) #1

; Function Attrs: nounwind uwtable
define dso_local i32 @agoo_header_rule(ptr noundef %0, ptr noundef %1, ptr noundef %2, ptr noundef %3, ptr noundef %4) #4 {
  %6 = alloca i32, align 4
  %7 = alloca ptr, align 8
  %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
  store ptr %0, ptr %7, align 8, !tbaa !5
  store ptr %1, ptr %8, align 8, !tbaa !5
  store ptr %2, ptr %9, align 8, !tbaa !5
  store ptr %3, ptr %10, align 8, !tbaa !5
  store ptr %4, ptr %11, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %12) #6
  %14 = load ptr, ptr %10, align 8, !tbaa !5
  %15 = call i32 @strcasecmp(ptr noundef @.str.17, ptr noundef %14) #7
  %16 = icmp eq i32 0, %15
  br i1 %16, label %17, label %20

17:                                               ; preds = %5
  %18 = load ptr, ptr %7, align 8, !tbaa !5
  %19 = call i32 (ptr, i32, ptr, ...) @agoo_err_set(ptr noundef %18, i32 noundef 304, ptr noundef @.str.18)
  store i32 %19, ptr %6, align 4
  store i32 1, ptr %13, align 4
  br label %99

20:                                               ; preds = %5
  %21 = call noalias ptr @calloc(i64 noundef 1, i64 noundef 48) #8
  store ptr %21, ptr %12, align 8, !tbaa !5
  %22 = icmp eq ptr null, %21
  br i1 %22, label %23, label %26

23:                                               ; preds = %20
  %24 = load ptr, ptr %7, align 8, !tbaa !5
  %25 = call i32 @agoo_err_memory(ptr noundef %24, ptr noundef @.str.19, ptr noundef @.str.3, i32 noundef 1014)
  store i32 %25, ptr %6, align 4
  store i32 1, ptr %13, align 4
  br label %99

26:                                               ; preds = %20
  %27 = load ptr, ptr %8, align 8, !tbaa !5
  %28 = call noalias ptr @strdup(ptr noundef %27) #6
  %29 = load ptr, ptr %12, align 8, !tbaa !5
  %30 = getelementptr inbounds %struct._headRule, ptr %29, i32 0, i32 1
  store ptr %28, ptr %30, align 8, !tbaa !9
  %31 = icmp eq ptr null, %28
  br i1 %31, label %44, label %32

32:                                               ; preds = %26
  %33 = load ptr, ptr %10, align 8, !tbaa !5
  %34 = call noalias ptr @strdup(ptr noundef %33) #6
  %35 = load ptr, ptr %12, align 8, !tbaa !5
  %36 = getelementptr inbounds %struct._headRule, ptr %35, i32 0, i32 3
  store ptr %34, ptr %36, align 8, !tbaa !12
  %37 = icmp eq ptr null, %34
  br i1 %37, label %44, label %38

38:                                               ; preds = %32
  %39 = load ptr, ptr %11, align 8, !tbaa !5
  %40 = call noalias ptr @strdup(ptr noundef %39) #6
  %41 = load ptr, ptr %12, align 8, !tbaa !5
  %42 = getelementptr inbounds %struct._headRule, ptr %41, i32 0, i32 4
  store ptr %40, ptr %42, align 8, !tbaa !13
  %43 = icmp eq ptr null, %40
  br i1 %43, label %44, label %45

44:                                               ; preds = %38, %32, %26
  br label %86

45:                                               ; preds = %38
  %46 = load ptr, ptr %9, align 8, !tbaa !5
  %47 = load i8, ptr %46, align 1, !tbaa !14
  %48 = sext i8 %47 to i32
  %49 = icmp eq i32 42, %48
  br i1 %49, label %50, label %59

50:                                               ; preds = %45
  %51 = load ptr, ptr %9, align 8, !tbaa !5
  %52 = getelementptr inbounds i8, ptr %51, i64 1
  %53 = load i8, ptr %52, align 1, !tbaa !14
  %54 = sext i8 %53 to i32
  %55 = icmp eq i32 0, %54
  br i1 %55, label %56, label %59

56:                                               ; preds = %50
  %57 = load ptr, ptr %12, align 8, !tbaa !5
  %58 = getelementptr inbounds %struct._headRule, ptr %57, i32 0, i32 2
  store ptr null, ptr %58, align 8, !tbaa !15
  br label %67

59:                                               ; preds = %50, %45
  %60 = load ptr, ptr %9, align 8, !tbaa !5
  %61 = call noalias ptr @strdup(ptr noundef %60) #6
  %62 = load ptr, ptr %12, align 8, !tbaa !5
  %63 = getelementptr inbounds %struct._headRule, ptr %62, i32 0, i32 2
  store ptr %61, ptr %63, align 8, !tbaa !15
  %64 = icmp eq ptr null, %61
  br i1 %64, label %65, label %66

65:                                               ; preds = %59
  br label %86

66:                                               ; preds = %59
  br label %67

67:                                               ; preds = %66, %56
  %68 = load ptr, ptr %12, align 8, !tbaa !5
  %69 = getelementptr inbounds %struct._headRule, ptr %68, i32 0, i32 3
  %70 = load ptr, ptr %69, align 8, !tbaa !12
  %71 = call i64 @strlen(ptr noundef %70) #7
  %72 = trunc i64 %71 to i32
  %73 = load ptr, ptr %12, align 8, !tbaa !5
  %74 = getelementptr inbounds %struct._headRule, ptr %73, i32 0, i32 4
  %75 = load ptr, ptr %74, align 8, !tbaa !13
  %76 = call i64 @strlen(ptr noundef %75) #7
  %77 = trunc i64 %76 to i32
  %78 = add nsw i32 %72, %77
  %79 = add nsw i32 %78, 4
  %80 = load ptr, ptr %12, align 8, !tbaa !5
  %81 = getelementptr inbounds %struct._headRule, ptr %80, i32 0, i32 5
  store i32 %79, ptr %81, align 8, !tbaa !16
  %82 = load ptr, ptr getelementptr inbounds (%struct._cache, ptr @cache, i32 0, i32 5), align 8, !tbaa !17
  %83 = load ptr, ptr %12, align 8, !tbaa !5
  %84 = getelementptr inbounds %struct._headRule, ptr %83, i32 0, i32 0
  store ptr %82, ptr %84, align 8, !tbaa !19
  %85 = load ptr, ptr %12, align 8, !tbaa !5
  store ptr %85, ptr getelementptr inbounds (%struct._cache, ptr @cache, i32 0, i32 5), align 8, !tbaa !17
  store i32 0, ptr %6, align 4
  store i32 1, ptr %13, align 4
  br label %99

86:                                               ; preds = %65, %44
  %87 = load ptr, ptr %12, align 8, !tbaa !5
  %88 = getelementptr inbounds %struct._headRule, ptr %87, i32 0, i32 1
  %89 = load ptr, ptr %88, align 8, !tbaa !9
  call void @free(ptr noundef %89) #6
  %90 = load ptr, ptr %12, align 8, !tbaa !5
  %91 = getelementptr inbounds %struct._headRule, ptr %90, i32 0, i32 3
  %92 = load ptr, ptr %91, align 8, !tbaa !12
  call void @free(ptr noundef %92) #6
  %93 = load ptr, ptr %12, align 8, !tbaa !5
  %94 = getelementptr inbounds %struct._headRule, ptr %93, i32 0, i32 4
  %95 = load ptr, ptr %94, align 8, !tbaa !13
  call void @free(ptr noundef %95) #6
  %96 = load ptr, ptr %12, align 8, !tbaa !5
  call void @free(ptr noundef %96) #6
  %97 = load ptr, ptr %7, align 8, !tbaa !5
  %98 = call i32 @agoo_err_memory(ptr noundef %97, ptr noundef @.str.19, ptr noundef @.str.3, i32 noundef 1038)
  store i32 %98, ptr %6, align 4
  store i32 1, ptr %13, align 4
  br label %99

99:                                               ; preds = %86, %67, %23, %17
  call void @llvm.lifetime.end.p0(i64 8, ptr %12) #6
  %100 = load i32, ptr %6, align 4
  ret i32 %100
}

; Function Attrs: nounwind allocsize(0,1)
declare noalias ptr @calloc(i64 noundef, i64 noundef) #5

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { 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 #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 "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 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 #5 = { nounwind allocsize(0,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 #6 = { nounwind }
attributes #7 = { nounwind willreturn memory(read) }
attributes #8 = { nounwind allocsize(0,1) }

!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 8}
!10 = !{!"_headRule", !6, i64 0, !6, i64 8, !6, i64 16, !6, i64 24, !6, i64 32, !11, i64 40}
!11 = !{!"int", !7, i64 0}
!12 = !{!10, !6, i64 24}
!13 = !{!10, !6, i64 32}
!14 = !{!7, !7, i64 0}
!15 = !{!10, !6, i64 16}
!16 = !{!10, !11, i64 40}
!17 = !{!18, !6, i64 16912}
!18 = !{!"_cache", !7, i64 0, !7, i64 8192, !7, i64 16384, !6, i64 16896, !6, i64 16904, !6, i64 16912}
!19 = !{!10, !6, i64 0}


; 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._cache = type { [1024 x ptr], [1024 x ptr], [64 x ptr], ptr, ptr, ptr }

@.str.3 = external hidden unnamed_addr constant [62 x i8], align 1
@cache = external hidden local_unnamed_addr global %struct._cache, align 8
@.str.17 = external hidden unnamed_addr constant [15 x i8], align 1
@.str.18 = external hidden unnamed_addr constant [48 x i8], align 1
@.str.19 = external hidden unnamed_addr constant [12 x i8], align 1

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

declare i32 @agoo_err_set(ptr noundef, i32 noundef, ptr noundef, ...) local_unnamed_addr #1

; Function Attrs: mustprogress nounwind willreturn allockind("free") memory(argmem: readwrite, inaccessiblemem: readwrite)
declare void @free(ptr allocptr nocapture noundef) local_unnamed_addr #2

; Function Attrs: mustprogress nofree nounwind willreturn memory(argmem: readwrite, inaccessiblemem: readwrite)
declare noalias ptr @strdup(ptr nocapture noundef readonly) local_unnamed_addr #3

declare i32 @agoo_err_memory(ptr noundef, ptr noundef, ptr noundef, i32 noundef) local_unnamed_addr #1

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

; Function Attrs: nounwind uwtable
define dso_local i32 @agoo_header_rule(ptr noundef %0, ptr nocapture noundef readonly %1, ptr nocapture noundef readonly %2, ptr nocapture noundef readonly %3, ptr nocapture noundef readonly %4) local_unnamed_addr #5 {
  %6 = tail call i32 @strcasecmp(ptr noundef nonnull @.str.17, ptr noundef %3) #7
  %7 = icmp eq i32 %6, 0
  br i1 %7, label %8, label %10

8:                                                ; preds = %5
  %9 = tail call i32 (ptr, i32, ptr, ...) @agoo_err_set(ptr noundef %0, i32 noundef 304, ptr noundef nonnull @.str.18) #8
  br label %51

10:                                               ; preds = %5
  %11 = tail call noalias dereferenceable_or_null(48) ptr @calloc(i64 noundef 1, i64 noundef 48) #9
  %12 = icmp eq ptr %11, null
  br i1 %12, label %13, label %15

13:                                               ; preds = %10
  %14 = tail call i32 @agoo_err_memory(ptr noundef %0, ptr noundef nonnull @.str.19, ptr noundef nonnull @.str.3, i32 noundef 1014) #8
  br label %51

15:                                               ; preds = %10
  %16 = tail call noalias ptr @strdup(ptr noundef %1) #8
  %17 = getelementptr inbounds i8, ptr %11, i64 8
  store ptr %16, ptr %17, align 8, !tbaa !5
  %18 = icmp eq ptr %16, null
  br i1 %18, label %47, label %19

19:                                               ; preds = %15
  %20 = tail call noalias ptr @strdup(ptr noundef %3) #8
  %21 = getelementptr inbounds i8, ptr %11, i64 24
  store ptr %20, ptr %21, align 8, !tbaa !11
  %22 = icmp eq ptr %20, null
  br i1 %22, label %47, label %23

23:                                               ; preds = %19
  %24 = tail call noalias ptr @strdup(ptr noundef %4) #8
  %25 = getelementptr inbounds i8, ptr %11, i64 32
  store ptr %24, ptr %25, align 8, !tbaa !12
  %26 = icmp eq ptr %24, null
  br i1 %26, label %47, label %27

27:                                               ; preds = %23
  %28 = load i8, ptr %2, align 1, !tbaa !13
  %29 = icmp eq i8 %28, 42
  br i1 %29, label %30, label %34

30:                                               ; preds = %27
  %31 = getelementptr inbounds i8, ptr %2, i64 1
  %32 = load i8, ptr %31, align 1, !tbaa !13
  %33 = icmp eq i8 %32, 0
  br i1 %33, label %38, label %34

34:                                               ; preds = %30, %27
  %35 = tail call noalias ptr @strdup(ptr noundef nonnull %2) #8
  %36 = getelementptr inbounds i8, ptr %11, i64 16
  store ptr %35, ptr %36, align 8, !tbaa !14
  %37 = icmp eq ptr %35, null
  br i1 %37, label %47, label %38

38:                                               ; preds = %30, %34
  %39 = tail call i64 @strlen(ptr noundef nonnull dereferenceable(1) %20) #7
  %40 = trunc i64 %39 to i32
  %41 = tail call i64 @strlen(ptr noundef nonnull dereferenceable(1) %24) #7
  %42 = trunc i64 %41 to i32
  %43 = add i32 %40, 4
  %44 = add i32 %43, %42
  %45 = getelementptr inbounds i8, ptr %11, i64 40
  store i32 %44, ptr %45, align 8, !tbaa !15
  %46 = load ptr, ptr getelementptr inbounds (i8, ptr @cache, i64 16912), align 8, !tbaa !16
  store ptr %46, ptr %11, align 8, !tbaa !18
  store ptr %11, ptr getelementptr inbounds (i8, ptr @cache, i64 16912), align 8, !tbaa !16
  br label %51

47:                                               ; preds = %34, %15, %19, %23
  %48 = phi ptr [ %24, %34 ], [ null, %15 ], [ null, %19 ], [ null, %23 ]
  %49 = phi ptr [ %20, %34 ], [ null, %15 ], [ null, %19 ], [ %20, %23 ]
  tail call void @free(ptr noundef %16) #8
  tail call void @free(ptr noundef %49) #8
  tail call void @free(ptr noundef %48) #8
  tail call void @free(ptr noundef nonnull %11) #8
  %50 = tail call i32 @agoo_err_memory(ptr noundef %0, ptr noundef nonnull @.str.19, ptr noundef nonnull @.str.3, i32 noundef 1038) #8
  br label %51

51:                                               ; preds = %47, %38, %13, %8
  %.0 = phi i32 [ %9, %8 ], [ %14, %13 ], [ %50, %47 ], [ 0, %38 ]
  ret i32 %.0
}

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

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

!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 8}
!6 = !{!"_headRule", !7, i64 0, !7, i64 8, !7, i64 16, !7, i64 24, !7, i64 32, !10, i64 40}
!7 = !{!"any pointer", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"int", !8, i64 0}
!11 = !{!6, !7, i64 24}
!12 = !{!6, !7, i64 32}
!13 = !{!8, !8, i64 0}
!14 = !{!6, !7, i64 16}
!15 = !{!6, !10, i64 40}
!16 = !{!17, !7, i64 16912}
!17 = !{!"_cache", !8, i64 0, !8, i64 8192, !8, i64 16384, !7, i64 16896, !7, i64 16904, !7, i64 16912}
!18 = !{!6, !7, i64 0}


; Effective O3 passes: BDCEPass,CorrelatedValuePropagationPass,DSEPass,EarlyCSEPass,GVNPass,GlobalOptPass,InferFunctionAttrsPass,InstCombinePass,PostOrderFunctionAttrsPass,ReassociatePass,SROAPass,SimplifyCFGPass,TailCallElimPass