; 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._mimeSlot = type { ptr, [16 x i8], ptr, i64, i32 }

; Function Attrs: nounwind uwtable
define dso_local ptr @mime_get(ptr noundef %0) #0 {
  %2 = alloca ptr, align 8
  %3 = alloca i32, align 4
  %4 = alloca i32, align 4
  %5 = alloca i64, align 8
  %6 = alloca ptr, align 8
  %7 = alloca ptr, align 8
  %8 = alloca ptr, align 8
  store ptr %0, ptr %2, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %3) #3
  %9 = load ptr, ptr %2, align 8, !tbaa !5
  %10 = call i64 @strlen(ptr noundef %9) #4
  %11 = trunc i64 %10 to i32
  store i32 %11, ptr %3, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #3
  %12 = load i32, ptr %3, align 4, !tbaa !9
  store i32 %12, ptr %4, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #3
  %13 = load ptr, ptr %2, align 8, !tbaa !5
  %14 = call i64 @calc_hash(ptr noundef %13, ptr noundef %4)
  store i64 %14, ptr %5, align 8, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #3
  %15 = load i64, ptr %5, align 8, !tbaa !11
  %16 = call ptr @get_mime_bucketp(i64 noundef %15)
  store ptr %16, ptr %6, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #3
  store ptr null, ptr %8, align 8, !tbaa !5
  %17 = load ptr, ptr %6, align 8, !tbaa !5
  %18 = load ptr, ptr %17, align 8, !tbaa !5
  store ptr %18, ptr %7, align 8, !tbaa !5
  br label %19

19:                                               ; preds = %54, %1
  %20 = load ptr, ptr %7, align 8, !tbaa !5
  %21 = icmp ne ptr null, %20
  br i1 %21, label %22, label %58

22:                                               ; preds = %19
  %23 = load i64, ptr %5, align 8, !tbaa !11
  %24 = load ptr, ptr %7, align 8, !tbaa !5
  %25 = getelementptr inbounds %struct._mimeSlot, ptr %24, i32 0, i32 3
  %26 = load i64, ptr %25, align 8, !tbaa !13
  %27 = icmp eq i64 %23, %26
  br i1 %27, label %28, label %53

28:                                               ; preds = %22
  %29 = load i32, ptr %4, align 4, !tbaa !9
  %30 = load ptr, ptr %7, align 8, !tbaa !5
  %31 = getelementptr inbounds %struct._mimeSlot, ptr %30, i32 0, i32 4
  %32 = load i32, ptr %31, align 8, !tbaa !15
  %33 = icmp eq i32 %29, %32
  br i1 %33, label %34, label %53

34:                                               ; preds = %28
  %35 = load i32, ptr %4, align 4, !tbaa !9
  %36 = icmp sle i32 0, %35
  br i1 %36, label %37, label %40

37:                                               ; preds = %34
  %38 = load i32, ptr %4, align 4, !tbaa !9
  %39 = icmp sle i32 %38, 9
  br i1 %39, label %49, label %40

40:                                               ; preds = %37, %34
  %41 = load ptr, ptr %7, align 8, !tbaa !5
  %42 = getelementptr inbounds %struct._mimeSlot, ptr %41, i32 0, i32 1
  %43 = getelementptr inbounds [16 x i8], ptr %42, i64 0, i64 0
  %44 = load ptr, ptr %2, align 8, !tbaa !5
  %45 = load i32, ptr %3, align 4, !tbaa !9
  %46 = sext i32 %45 to i64
  %47 = call i32 @strncmp(ptr noundef %43, ptr noundef %44, i64 noundef %46) #4
  %48 = icmp eq i32 0, %47
  br i1 %48, label %49, label %53

49:                                               ; preds = %40, %37
  %50 = load ptr, ptr %7, align 8, !tbaa !5
  %51 = getelementptr inbounds %struct._mimeSlot, ptr %50, i32 0, i32 2
  %52 = load ptr, ptr %51, align 8, !tbaa !16
  store ptr %52, ptr %8, align 8, !tbaa !5
  br label %58

53:                                               ; preds = %40, %28, %22
  br label %54

54:                                               ; preds = %53
  %55 = load ptr, ptr %7, align 8, !tbaa !5
  %56 = getelementptr inbounds %struct._mimeSlot, ptr %55, i32 0, i32 0
  %57 = load ptr, ptr %56, align 8, !tbaa !17
  store ptr %57, ptr %7, align 8, !tbaa !5
  br label %19, !llvm.loop !18

58:                                               ; preds = %49, %19
  %59 = load ptr, ptr %8, align 8, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %3) #3
  ret ptr %59
}

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

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

; Function Attrs: nounwind uwtable
declare hidden i64 @calc_hash(ptr noundef, ptr noundef) #0

; Function Attrs: nounwind uwtable
declare hidden ptr @get_mime_bucketp(i64 noundef) #0

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

; 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 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 = !{!12, !12, i64 0}
!12 = !{!"long", !7, i64 0}
!13 = !{!14, !12, i64 32}
!14 = !{!"_mimeSlot", !6, i64 0, !7, i64 8, !6, i64 24, !12, i64 32, !10, i64 40}
!15 = !{!14, !10, i64 40}
!16 = !{!14, !6, i64 24}
!17 = !{!14, !6, i64 0}
!18 = distinct !{!18, !19}
!19 = !{!"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"

; Function Attrs: nounwind uwtable
define dso_local ptr @mime_get(ptr noundef %0) local_unnamed_addr #0 {
  %2 = alloca i32, align 4
  %3 = tail call i64 @strlen(ptr noundef nonnull dereferenceable(1) %0) #3
  %4 = trunc i64 %3 to i32
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %2) #4
  store i32 %4, ptr %2, align 4, !tbaa !5
  %5 = call i64 @calc_hash(ptr noundef %0, ptr noundef nonnull %2)
  %6 = call ptr @get_mime_bucketp(i64 noundef %5)
  %.01518 = load ptr, ptr %6, align 8, !tbaa !9
  %.not19 = icmp eq ptr %.01518, null
  br i1 %.not19, label %.loopexit, label %.lr.ph

.lr.ph:                                           ; preds = %1
  %7 = load i32, ptr %2, align 4
  %.fr = freeze i32 %7
  %or.cond = icmp ult i32 %.fr, 10
  %sext = shl i64 %3, 32
  %8 = ashr exact i64 %sext, 32
  br i1 %or.cond, label %.lr.ph.split.us, label %.lr.ph.split

.lr.ph.split.us:                                  ; preds = %.lr.ph, %16
  %.01520.us = phi ptr [ %.015.us, %16 ], [ %.01518, %.lr.ph ]
  %9 = getelementptr inbounds i8, ptr %.01520.us, i64 32
  %10 = load i64, ptr %9, align 8, !tbaa !11
  %11 = icmp eq i64 %5, %10
  br i1 %11, label %12, label %16

12:                                               ; preds = %.lr.ph.split.us
  %13 = getelementptr inbounds i8, ptr %.01520.us, i64 40
  %14 = load i32, ptr %13, align 8, !tbaa !14
  %15 = icmp eq i32 %.fr, %14
  br i1 %15, label %.split.us, label %16

16:                                               ; preds = %12, %.lr.ph.split.us
  %.015.us = load ptr, ptr %.01520.us, align 8, !tbaa !9
  %.not.us = icmp eq ptr %.015.us, null
  br i1 %.not.us, label %.loopexit, label %.lr.ph.split.us, !llvm.loop !15

.lr.ph.split:                                     ; preds = %.lr.ph, %30
  %.01520 = phi ptr [ %.015, %30 ], [ %.01518, %.lr.ph ]
  %17 = getelementptr inbounds i8, ptr %.01520, i64 32
  %18 = load i64, ptr %17, align 8, !tbaa !11
  %19 = icmp eq i64 %5, %18
  br i1 %19, label %20, label %30

20:                                               ; preds = %.lr.ph.split
  %21 = getelementptr inbounds i8, ptr %.01520, i64 40
  %22 = load i32, ptr %21, align 8, !tbaa !14
  %23 = icmp eq i32 %.fr, %22
  br i1 %23, label %24, label %30

24:                                               ; preds = %20
  %25 = getelementptr inbounds i8, ptr %.01520, i64 8
  %26 = call i32 @strncmp(ptr noundef nonnull %25, ptr noundef %0, i64 noundef %8) #3
  %27 = icmp eq i32 %26, 0
  br i1 %27, label %.split.us, label %30

.split.us:                                        ; preds = %24, %12
  %.us-phi = phi ptr [ %.01520.us, %12 ], [ %.01520, %24 ]
  %28 = getelementptr inbounds i8, ptr %.us-phi, i64 24
  %29 = load ptr, ptr %28, align 8, !tbaa !17
  br label %.loopexit

30:                                               ; preds = %.lr.ph.split, %20, %24
  %.015 = load ptr, ptr %.01520, align 8, !tbaa !9
  %.not = icmp eq ptr %.015, null
  br i1 %.not, label %.loopexit, label %.lr.ph.split, !llvm.loop !15

.loopexit:                                        ; preds = %30, %16, %1, %.split.us
  %.0 = phi ptr [ %29, %.split.us ], [ null, %1 ], [ null, %16 ], [ null, %30 ]
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %2) #4
  ret ptr %.0
}

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

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

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

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

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

; Function Attrs: mustprogress 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 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { 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 #3 = { nounwind willreturn memory(read) }
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 = !{!"int", !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, !13, i64 32}
!12 = !{!"_mimeSlot", !10, i64 0, !7, i64 8, !10, i64 24, !13, i64 32, !6, i64 40}
!13 = !{!"long", !7, i64 0}
!14 = !{!12, !6, i64 40}
!15 = distinct !{!15, !16}
!16 = !{!"llvm.loop.mustprogress"}
!17 = !{!12, !10, i64 24}


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