; LLVM IR from xtaci/algorithms :: src (hash_string_demo)

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

@__const.main.strs = external hidden unnamed_addr constant [8 x ptr], align 16
@.str.8 = external hidden unnamed_addr constant [17 x i8], align 1
@.str.9 = external hidden unnamed_addr constant [22 x i8], align 1
@.str.10 = external hidden unnamed_addr constant [16 x i8], align 1
@.str.11 = external hidden unnamed_addr constant [21 x i8], align 1

; Function Attrs: mustprogress norecurse uwtable
define dso_local noundef i32 @main() #0 {
  %1 = alloca i32, align 4
  %2 = alloca [8 x ptr], align 16
  %3 = alloca i32, align 4
  %4 = alloca i32, align 4
  store i32 0, ptr %1, align 4
  call void @llvm.lifetime.start.p0(i64 64, ptr %2) #6
  call void @llvm.memcpy.p0.p0.i64(ptr align 16 %2, ptr align 16 @__const.main.strs, i64 64, i1 false)
  %5 = call i32 (ptr, ...) @printf(ptr noundef @.str.8)
  call void @llvm.lifetime.start.p0(i64 4, ptr %3) #6
  store i32 0, ptr %3, align 4, !tbaa !5
  br label %6

6:                                                ; preds = %28, %0
  %7 = load i32, ptr %3, align 4, !tbaa !5
  %8 = zext i32 %7 to i64
  %9 = icmp ult i64 %8, 8
  br i1 %9, label %11, label %10

10:                                               ; preds = %6
  call void @llvm.lifetime.end.p0(i64 4, ptr %3) #6
  br label %31

11:                                               ; preds = %6
  %12 = load i32, ptr %3, align 4, !tbaa !5
  %13 = zext i32 %12 to i64
  %14 = getelementptr inbounds [8 x ptr], ptr %2, i64 0, i64 %13
  %15 = load ptr, ptr %14, align 8, !tbaa !9
  %16 = load i32, ptr %3, align 4, !tbaa !5
  %17 = zext i32 %16 to i64
  %18 = getelementptr inbounds [8 x ptr], ptr %2, i64 0, i64 %17
  %19 = load ptr, ptr %18, align 8, !tbaa !9
  %20 = load i32, ptr %3, align 4, !tbaa !5
  %21 = zext i32 %20 to i64
  %22 = getelementptr inbounds [8 x ptr], ptr %2, i64 0, i64 %21
  %23 = load ptr, ptr %22, align 8, !tbaa !9
  %24 = call i64 @strlen(ptr noundef %23) #7
  %25 = trunc i64 %24 to i32
  %26 = call noundef i32 @_ZN3algL11hash_stringEPKcj(ptr noundef %19, i32 noundef %25)
  %27 = call i32 (ptr, ...) @printf(ptr noundef @.str.9, ptr noundef %15, i32 noundef %26)
  br label %28

28:                                               ; preds = %11
  %29 = load i32, ptr %3, align 4, !tbaa !5
  %30 = add i32 %29, 1
  store i32 %30, ptr %3, align 4, !tbaa !5
  br label %6, !llvm.loop !11

31:                                               ; preds = %10
  %32 = call i32 (ptr, ...) @printf(ptr noundef @.str.10)
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #6
  store i32 0, ptr %4, align 4, !tbaa !5
  br label %33

33:                                               ; preds = %55, %31
  %34 = load i32, ptr %4, align 4, !tbaa !5
  %35 = zext i32 %34 to i64
  %36 = icmp ult i64 %35, 8
  br i1 %36, label %38, label %37

37:                                               ; preds = %33
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #6
  br label %58

38:                                               ; preds = %33
  %39 = load i32, ptr %4, align 4, !tbaa !5
  %40 = zext i32 %39 to i64
  %41 = getelementptr inbounds [8 x ptr], ptr %2, i64 0, i64 %40
  %42 = load ptr, ptr %41, align 8, !tbaa !9
  %43 = load i32, ptr %4, align 4, !tbaa !5
  %44 = zext i32 %43 to i64
  %45 = getelementptr inbounds [8 x ptr], ptr %2, i64 0, i64 %44
  %46 = load ptr, ptr %45, align 8, !tbaa !9
  %47 = load i32, ptr %4, align 4, !tbaa !5
  %48 = zext i32 %47 to i64
  %49 = getelementptr inbounds [8 x ptr], ptr %2, i64 0, i64 %48
  %50 = load ptr, ptr %49, align 8, !tbaa !9
  %51 = call i64 @strlen(ptr noundef %50) #7
  %52 = trunc i64 %51 to i32
  %53 = call noundef i32 @_ZN3algL10hash_fnv1aEPKcj(ptr noundef %46, i32 noundef %52)
  %54 = call i32 (ptr, ...) @printf(ptr noundef @.str.11, ptr noundef %42, i32 noundef %53)
  br label %55

55:                                               ; preds = %38
  %56 = load i32, ptr %4, align 4, !tbaa !5
  %57 = add i32 %56, 1
  store i32 %57, ptr %4, align 4, !tbaa !5
  br label %33, !llvm.loop !13

58:                                               ; preds = %37
  call void @llvm.lifetime.end.p0(i64 64, ptr %2) #6
  ret i32 0
}

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

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: readwrite)
declare void @llvm.memcpy.p0.p0.i64(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i64, i1 immarg) #2

declare i32 @printf(ptr noundef, ...) #3

; Function Attrs: mustprogress nounwind uwtable
declare hidden noundef i32 @_ZN3algL11hash_stringEPKcj(ptr noundef, i32 noundef) #4

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

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

; Function Attrs: mustprogress nounwind uwtable
declare hidden noundef i32 @_ZN3algL10hash_fnv1aEPKcj(ptr noundef, i32 noundef) #4

attributes #0 = { mustprogress norecurse 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 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #3 = { "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 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 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 #6 = { nounwind }
attributes #7 = { 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 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"any pointer", !7, i64 0}
!11 = distinct !{!11, !12}
!12 = !{!"llvm.loop.mustprogress"}
!13 = distinct !{!13, !12}


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

@__const.main.strs = external hidden unnamed_addr constant [8 x ptr], align 16
@.str.8 = external hidden unnamed_addr constant [17 x i8], align 1
@.str.9 = external hidden unnamed_addr constant [22 x i8], align 1
@.str.10 = external hidden unnamed_addr constant [16 x i8], align 1
@.str.11 = external hidden unnamed_addr constant [21 x i8], align 1

; Function Attrs: mustprogress norecurse nounwind uwtable
define dso_local noundef i32 @main() local_unnamed_addr #0 {
  %1 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.8)
  %2 = load ptr, ptr @__const.main.strs, align 16, !tbaa !5
  %3 = tail call i64 @strlen(ptr noundef nonnull dereferenceable(1) %2) #4
  %4 = trunc i64 %3 to i32
  %5 = tail call noundef i32 @_ZN3algL11hash_stringEPKcj(ptr noundef %2, i32 noundef %4)
  %6 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.9, ptr noundef %2, i32 noundef %5)
  %7 = load ptr, ptr getelementptr inbounds (i8, ptr @__const.main.strs, i64 8), align 8, !tbaa !5
  %8 = tail call i64 @strlen(ptr noundef nonnull dereferenceable(1) %7) #4
  %9 = trunc i64 %8 to i32
  %10 = tail call noundef i32 @_ZN3algL11hash_stringEPKcj(ptr noundef %7, i32 noundef %9)
  %11 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.9, ptr noundef %7, i32 noundef %10)
  %12 = load ptr, ptr getelementptr inbounds (i8, ptr @__const.main.strs, i64 16), align 16, !tbaa !5
  %13 = tail call i64 @strlen(ptr noundef nonnull dereferenceable(1) %12) #4
  %14 = trunc i64 %13 to i32
  %15 = tail call noundef i32 @_ZN3algL11hash_stringEPKcj(ptr noundef %12, i32 noundef %14)
  %16 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.9, ptr noundef %12, i32 noundef %15)
  %17 = load ptr, ptr getelementptr inbounds (i8, ptr @__const.main.strs, i64 24), align 8, !tbaa !5
  %18 = tail call i64 @strlen(ptr noundef nonnull dereferenceable(1) %17) #4
  %19 = trunc i64 %18 to i32
  %20 = tail call noundef i32 @_ZN3algL11hash_stringEPKcj(ptr noundef %17, i32 noundef %19)
  %21 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.9, ptr noundef %17, i32 noundef %20)
  %22 = load ptr, ptr getelementptr inbounds (i8, ptr @__const.main.strs, i64 32), align 16, !tbaa !5
  %23 = tail call i64 @strlen(ptr noundef nonnull dereferenceable(1) %22) #4
  %24 = trunc i64 %23 to i32
  %25 = tail call noundef i32 @_ZN3algL11hash_stringEPKcj(ptr noundef %22, i32 noundef %24)
  %26 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.9, ptr noundef %22, i32 noundef %25)
  %27 = load ptr, ptr getelementptr inbounds (i8, ptr @__const.main.strs, i64 40), align 8, !tbaa !5
  %28 = tail call i64 @strlen(ptr noundef nonnull dereferenceable(1) %27) #4
  %29 = trunc i64 %28 to i32
  %30 = tail call noundef i32 @_ZN3algL11hash_stringEPKcj(ptr noundef %27, i32 noundef %29)
  %31 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.9, ptr noundef %27, i32 noundef %30)
  %32 = load ptr, ptr getelementptr inbounds (i8, ptr @__const.main.strs, i64 48), align 16, !tbaa !5
  %33 = tail call i64 @strlen(ptr noundef nonnull dereferenceable(1) %32) #4
  %34 = trunc i64 %33 to i32
  %35 = tail call noundef i32 @_ZN3algL11hash_stringEPKcj(ptr noundef %32, i32 noundef %34)
  %36 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.9, ptr noundef %32, i32 noundef %35)
  %37 = load ptr, ptr getelementptr inbounds (i8, ptr @__const.main.strs, i64 56), align 8, !tbaa !5
  %38 = tail call i64 @strlen(ptr noundef nonnull dereferenceable(1) %37) #4
  %39 = trunc i64 %38 to i32
  %40 = tail call noundef i32 @_ZN3algL11hash_stringEPKcj(ptr noundef %37, i32 noundef %39)
  %41 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.9, ptr noundef %37, i32 noundef %40)
  %42 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.10)
  %43 = tail call i64 @strlen(ptr noundef nonnull dereferenceable(1) %2) #4
  %44 = trunc i64 %43 to i32
  %45 = tail call noundef i32 @_ZN3algL10hash_fnv1aEPKcj(ptr noundef %2, i32 noundef %44)
  %46 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.11, ptr noundef %2, i32 noundef %45)
  %47 = tail call i64 @strlen(ptr noundef nonnull dereferenceable(1) %7) #4
  %48 = trunc i64 %47 to i32
  %49 = tail call noundef i32 @_ZN3algL10hash_fnv1aEPKcj(ptr noundef %7, i32 noundef %48)
  %50 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.11, ptr noundef %7, i32 noundef %49)
  %51 = tail call i64 @strlen(ptr noundef nonnull dereferenceable(1) %12) #4
  %52 = trunc i64 %51 to i32
  %53 = tail call noundef i32 @_ZN3algL10hash_fnv1aEPKcj(ptr noundef %12, i32 noundef %52)
  %54 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.11, ptr noundef %12, i32 noundef %53)
  %55 = tail call i64 @strlen(ptr noundef nonnull dereferenceable(1) %17) #4
  %56 = trunc i64 %55 to i32
  %57 = tail call noundef i32 @_ZN3algL10hash_fnv1aEPKcj(ptr noundef %17, i32 noundef %56)
  %58 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.11, ptr noundef %17, i32 noundef %57)
  %59 = tail call i64 @strlen(ptr noundef nonnull dereferenceable(1) %22) #4
  %60 = trunc i64 %59 to i32
  %61 = tail call noundef i32 @_ZN3algL10hash_fnv1aEPKcj(ptr noundef %22, i32 noundef %60)
  %62 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.11, ptr noundef %22, i32 noundef %61)
  %63 = tail call i64 @strlen(ptr noundef nonnull dereferenceable(1) %27) #4
  %64 = trunc i64 %63 to i32
  %65 = tail call noundef i32 @_ZN3algL10hash_fnv1aEPKcj(ptr noundef %27, i32 noundef %64)
  %66 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.11, ptr noundef %27, i32 noundef %65)
  %67 = tail call i64 @strlen(ptr noundef nonnull dereferenceable(1) %32) #4
  %68 = trunc i64 %67 to i32
  %69 = tail call noundef i32 @_ZN3algL10hash_fnv1aEPKcj(ptr noundef %32, i32 noundef %68)
  %70 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.11, ptr noundef %32, i32 noundef %69)
  %71 = tail call i64 @strlen(ptr noundef nonnull dereferenceable(1) %37) #4
  %72 = trunc i64 %71 to i32
  %73 = tail call noundef i32 @_ZN3algL10hash_fnv1aEPKcj(ptr noundef %37, i32 noundef %72)
  %74 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.11, ptr noundef %37, i32 noundef %73)
  ret i32 0
}

; Function Attrs: nofree nounwind
declare noundef i32 @printf(ptr nocapture noundef readonly, ...) local_unnamed_addr #1

; Function Attrs: mustprogress nounwind uwtable
declare hidden noundef i32 @_ZN3algL11hash_stringEPKcj(ptr noundef, i32 noundef) local_unnamed_addr #2

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

; Function Attrs: mustprogress nounwind uwtable
declare hidden noundef i32 @_ZN3algL10hash_fnv1aEPKcj(ptr noundef, i32 noundef) local_unnamed_addr #2

attributes #0 = { mustprogress norecurse 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 = { nofree 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 #2 = { mustprogress 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 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 #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++ TBAA"}


; Effective O3 passes: CorrelatedValuePropagationPass,EarlyCSEPass,GVNPass,GlobalOptPass,IndVarSimplifyPass,InferAlignmentPass,InferFunctionAttrsPass,InstCombinePass,LoopRotatePass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass,TailCallElimPass