; LLVM IR from AlgoGenesis/C :: String Algorithms/Anagram Check (anagram_check)

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

@.str = external hidden unnamed_addr constant [25 x i8], align 1
@stdin = external global ptr, align 8
@.str.1 = external hidden unnamed_addr constant [2 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [26 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [27 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [31 x i8], align 1

; Function Attrs: nounwind uwtable
declare dso_local zeroext i1 @areAnagrams(ptr noundef, ptr noundef) #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 nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #1

; Function Attrs: nounwind uwtable
define dso_local i32 @main() #0 {
  %1 = alloca i32, align 4
  %2 = alloca [100 x i8], align 16
  %3 = alloca [100 x i8], align 16
  %4 = alloca [100 x i8], align 16
  %5 = alloca [100 x i8], align 16
  %6 = alloca i32, align 4
  %7 = alloca i32, align 4
  %8 = alloca i32, align 4
  %9 = alloca i32, align 4
  %10 = alloca i32, align 4
  store i32 0, ptr %1, align 4
  call void @llvm.lifetime.start.p0(i64 100, ptr %2) #5
  call void @llvm.lifetime.start.p0(i64 100, ptr %3) #5
  call void @llvm.lifetime.start.p0(i64 100, ptr %4) #5
  call void @llvm.lifetime.start.p0(i64 100, ptr %5) #5
  %11 = call i32 (ptr, ...) @printf(ptr noundef @.str)
  %12 = getelementptr inbounds [100 x i8], ptr %2, i64 0, i64 0
  %13 = load ptr, ptr @stdin, align 8, !tbaa !5
  %14 = call ptr @fgets(ptr noundef %12, i32 noundef 100, ptr noundef %13)
  %15 = getelementptr inbounds [100 x i8], ptr %2, i64 0, i64 0
  %16 = call i64 @strcspn(ptr noundef %15, ptr noundef @.str.1) #6
  %17 = getelementptr inbounds [100 x i8], ptr %2, i64 0, i64 %16
  store i8 0, ptr %17, align 1, !tbaa !9
  %18 = call i32 (ptr, ...) @printf(ptr noundef @.str.2)
  %19 = getelementptr inbounds [100 x i8], ptr %3, i64 0, i64 0
  %20 = load ptr, ptr @stdin, align 8, !tbaa !5
  %21 = call ptr @fgets(ptr noundef %19, i32 noundef 100, ptr noundef %20)
  %22 = getelementptr inbounds [100 x i8], ptr %3, i64 0, i64 0
  %23 = call i64 @strcspn(ptr noundef %22, ptr noundef @.str.1) #6
  %24 = getelementptr inbounds [100 x i8], ptr %3, i64 0, i64 %23
  store i8 0, ptr %24, align 1, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #5
  store i32 0, ptr %6, align 4, !tbaa !10
  br label %25

25:                                               ; preds = %48, %0
  %26 = load i32, ptr %6, align 4, !tbaa !10
  %27 = sext i32 %26 to i64
  %28 = getelementptr inbounds [100 x i8], ptr %2, i64 0, i64 %27
  %29 = load i8, ptr %28, align 1, !tbaa !9
  %30 = icmp ne i8 %29, 0
  br i1 %30, label %31, label %51

31:                                               ; preds = %25
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #5
  %32 = call ptr @__ctype_tolower_loc() #7
  %33 = load ptr, ptr %32, align 8, !tbaa !5
  %34 = load i32, ptr %6, align 4, !tbaa !10
  %35 = sext i32 %34 to i64
  %36 = getelementptr inbounds [100 x i8], ptr %2, i64 0, i64 %35
  %37 = load i8, ptr %36, align 1, !tbaa !9
  %38 = sext i8 %37 to i32
  %39 = sext i32 %38 to i64
  %40 = getelementptr inbounds i32, ptr %33, i64 %39
  %41 = load i32, ptr %40, align 4, !tbaa !10
  store i32 %41, ptr %7, align 4, !tbaa !10
  %42 = load i32, ptr %7, align 4, !tbaa !10
  store i32 %42, ptr %8, align 4, !tbaa !10
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #5
  %43 = load i32, ptr %8, align 4, !tbaa !10
  %44 = trunc i32 %43 to i8
  %45 = load i32, ptr %6, align 4, !tbaa !10
  %46 = sext i32 %45 to i64
  %47 = getelementptr inbounds [100 x i8], ptr %4, i64 0, i64 %46
  store i8 %44, ptr %47, align 1, !tbaa !9
  br label %48

48:                                               ; preds = %31
  %49 = load i32, ptr %6, align 4, !tbaa !10
  %50 = add nsw i32 %49, 1
  store i32 %50, ptr %6, align 4, !tbaa !10
  br label %25, !llvm.loop !12

51:                                               ; preds = %25
  %52 = load i32, ptr %6, align 4, !tbaa !10
  %53 = sext i32 %52 to i64
  %54 = getelementptr inbounds [100 x i8], ptr %4, i64 0, i64 %53
  store i8 0, ptr %54, align 1, !tbaa !9
  store i32 0, ptr %6, align 4, !tbaa !10
  br label %55

55:                                               ; preds = %78, %51
  %56 = load i32, ptr %6, align 4, !tbaa !10
  %57 = sext i32 %56 to i64
  %58 = getelementptr inbounds [100 x i8], ptr %3, i64 0, i64 %57
  %59 = load i8, ptr %58, align 1, !tbaa !9
  %60 = icmp ne i8 %59, 0
  br i1 %60, label %61, label %81

61:                                               ; preds = %55
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #5
  %62 = call ptr @__ctype_tolower_loc() #7
  %63 = load ptr, ptr %62, align 8, !tbaa !5
  %64 = load i32, ptr %6, align 4, !tbaa !10
  %65 = sext i32 %64 to i64
  %66 = getelementptr inbounds [100 x i8], ptr %3, i64 0, i64 %65
  %67 = load i8, ptr %66, align 1, !tbaa !9
  %68 = sext i8 %67 to i32
  %69 = sext i32 %68 to i64
  %70 = getelementptr inbounds i32, ptr %63, i64 %69
  %71 = load i32, ptr %70, align 4, !tbaa !10
  store i32 %71, ptr %9, align 4, !tbaa !10
  %72 = load i32, ptr %9, align 4, !tbaa !10
  store i32 %72, ptr %10, align 4, !tbaa !10
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #5
  %73 = load i32, ptr %10, align 4, !tbaa !10
  %74 = trunc i32 %73 to i8
  %75 = load i32, ptr %6, align 4, !tbaa !10
  %76 = sext i32 %75 to i64
  %77 = getelementptr inbounds [100 x i8], ptr %5, i64 0, i64 %76
  store i8 %74, ptr %77, align 1, !tbaa !9
  br label %78

78:                                               ; preds = %61
  %79 = load i32, ptr %6, align 4, !tbaa !10
  %80 = add nsw i32 %79, 1
  store i32 %80, ptr %6, align 4, !tbaa !10
  br label %55, !llvm.loop !14

81:                                               ; preds = %55
  %82 = load i32, ptr %6, align 4, !tbaa !10
  %83 = sext i32 %82 to i64
  %84 = getelementptr inbounds [100 x i8], ptr %5, i64 0, i64 %83
  store i8 0, ptr %84, align 1, !tbaa !9
  %85 = getelementptr inbounds [100 x i8], ptr %4, i64 0, i64 0
  %86 = getelementptr inbounds [100 x i8], ptr %5, i64 0, i64 0
  %87 = call zeroext i1 @areAnagrams(ptr noundef %85, ptr noundef %86)
  br i1 %87, label %88, label %90

88:                                               ; preds = %81
  %89 = call i32 (ptr, ...) @printf(ptr noundef @.str.3)
  br label %92

90:                                               ; preds = %81
  %91 = call i32 (ptr, ...) @printf(ptr noundef @.str.4)
  br label %92

92:                                               ; preds = %90, %88
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #5
  call void @llvm.lifetime.end.p0(i64 100, ptr %5) #5
  call void @llvm.lifetime.end.p0(i64 100, ptr %4) #5
  call void @llvm.lifetime.end.p0(i64 100, ptr %3) #5
  call void @llvm.lifetime.end.p0(i64 100, ptr %2) #5
  ret i32 0
}

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

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

; Function Attrs: nounwind willreturn memory(read)
declare i64 @strcspn(ptr noundef, ptr noundef) #3

; Function Attrs: nounwind willreturn memory(none)
declare ptr @__ctype_tolower_loc() #4

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 = { "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) "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(none) "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 }
attributes #6 = { nounwind willreturn memory(read) }
attributes #7 = { nounwind willreturn memory(none) }

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

@.str = external hidden unnamed_addr constant [25 x i8], align 1
@stdin = external local_unnamed_addr global ptr, align 8
@.str.1 = external hidden unnamed_addr constant [2 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [26 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [27 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [31 x i8], align 1

; Function Attrs: nounwind uwtable
declare dso_local zeroext i1 @areAnagrams(ptr noundef, ptr noundef) local_unnamed_addr #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 nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #1

; Function Attrs: nounwind uwtable
define dso_local noundef i32 @main() local_unnamed_addr #0 {
  %1 = alloca [100 x i8], align 16
  %2 = alloca [100 x i8], align 16
  %3 = alloca [100 x i8], align 16
  %4 = alloca [100 x i8], align 16
  call void @llvm.lifetime.start.p0(i64 100, ptr nonnull %1) #5
  call void @llvm.lifetime.start.p0(i64 100, ptr nonnull %2) #5
  call void @llvm.lifetime.start.p0(i64 100, ptr nonnull %3) #5
  call void @llvm.lifetime.start.p0(i64 100, ptr nonnull %4) #5
  %5 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str)
  %6 = load ptr, ptr @stdin, align 8, !tbaa !5
  %7 = call ptr @fgets(ptr noundef nonnull %1, i32 noundef 100, ptr noundef %6)
  %8 = call i64 @strcspn(ptr noundef nonnull %1, ptr noundef nonnull @.str.1) #6
  %9 = getelementptr inbounds [100 x i8], ptr %1, i64 0, i64 %8
  store i8 0, ptr %9, align 1, !tbaa !9
  %10 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.2)
  %11 = load ptr, ptr @stdin, align 8, !tbaa !5
  %12 = call ptr @fgets(ptr noundef nonnull %2, i32 noundef 100, ptr noundef %11)
  %13 = call i64 @strcspn(ptr noundef nonnull %2, ptr noundef nonnull @.str.1) #6
  %14 = getelementptr inbounds [100 x i8], ptr %2, i64 0, i64 %13
  store i8 0, ptr %14, align 1, !tbaa !9
  %15 = load i8, ptr %1, align 16, !tbaa !9
  %.not18 = icmp eq i8 %15, 0
  br i1 %.not18, label %._crit_edge, label %.lr.ph

.lr.ph:                                           ; preds = %0
  %16 = tail call ptr @__ctype_tolower_loc() #7
  %.pre = load ptr, ptr %16, align 8, !tbaa !5
  br label %17

17:                                               ; preds = %.lr.ph, %17
  %indvars.iv = phi i64 [ 0, %.lr.ph ], [ %indvars.iv.next, %17 ]
  %18 = phi i8 [ %15, %.lr.ph ], [ %25, %17 ]
  %19 = sext i8 %18 to i64
  %20 = getelementptr inbounds i32, ptr %.pre, i64 %19
  %21 = load i32, ptr %20, align 4, !tbaa !10
  %22 = trunc i32 %21 to i8
  %23 = getelementptr inbounds [100 x i8], ptr %3, i64 0, i64 %indvars.iv
  store i8 %22, ptr %23, align 1, !tbaa !9
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %24 = getelementptr inbounds [100 x i8], ptr %1, i64 0, i64 %indvars.iv.next
  %25 = load i8, ptr %24, align 1, !tbaa !9
  %.not = icmp eq i8 %25, 0
  br i1 %.not, label %._crit_edge, label %17, !llvm.loop !12

._crit_edge:                                      ; preds = %17, %0
  %.lcssa17 = phi i64 [ 0, %0 ], [ %indvars.iv.next, %17 ]
  %26 = getelementptr inbounds [100 x i8], ptr %3, i64 0, i64 %.lcssa17
  store i8 0, ptr %26, align 1, !tbaa !9
  %27 = load i8, ptr %2, align 16, !tbaa !9
  %.not1620 = icmp eq i8 %27, 0
  br i1 %.not1620, label %._crit_edge24, label %.lr.ph23

.lr.ph23:                                         ; preds = %._crit_edge
  %28 = tail call ptr @__ctype_tolower_loc() #7
  %.pre30 = load ptr, ptr %28, align 8, !tbaa !5
  br label %29

29:                                               ; preds = %.lr.ph23, %29
  %indvars.iv28 = phi i64 [ 0, %.lr.ph23 ], [ %indvars.iv.next29, %29 ]
  %30 = phi i8 [ %27, %.lr.ph23 ], [ %37, %29 ]
  %31 = sext i8 %30 to i64
  %32 = getelementptr inbounds i32, ptr %.pre30, i64 %31
  %33 = load i32, ptr %32, align 4, !tbaa !10
  %34 = trunc i32 %33 to i8
  %35 = getelementptr inbounds [100 x i8], ptr %4, i64 0, i64 %indvars.iv28
  store i8 %34, ptr %35, align 1, !tbaa !9
  %indvars.iv.next29 = add nuw nsw i64 %indvars.iv28, 1
  %36 = getelementptr inbounds [100 x i8], ptr %2, i64 0, i64 %indvars.iv.next29
  %37 = load i8, ptr %36, align 1, !tbaa !9
  %.not16 = icmp eq i8 %37, 0
  br i1 %.not16, label %._crit_edge24, label %29, !llvm.loop !14

._crit_edge24:                                    ; preds = %29, %._crit_edge
  %.lcssa = phi i64 [ 0, %._crit_edge ], [ %indvars.iv.next29, %29 ]
  %38 = getelementptr inbounds [100 x i8], ptr %4, i64 0, i64 %.lcssa
  store i8 0, ptr %38, align 1, !tbaa !9
  %39 = call zeroext i1 @areAnagrams(ptr noundef nonnull %3, ptr noundef nonnull %4)
  %.str.3..str.4 = select i1 %39, ptr @.str.3, ptr @.str.4
  %40 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) %.str.3..str.4)
  call void @llvm.lifetime.end.p0(i64 100, ptr nonnull %4) #5
  call void @llvm.lifetime.end.p0(i64 100, ptr nonnull %3) #5
  call void @llvm.lifetime.end.p0(i64 100, ptr nonnull %2) #5
  call void @llvm.lifetime.end.p0(i64 100, ptr nonnull %1) #5
  ret i32 0
}

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

; Function Attrs: nofree nounwind
declare noundef ptr @fgets(ptr noundef, i32 noundef, ptr nocapture noundef) local_unnamed_addr #2

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

; Function Attrs: mustprogress nofree nosync nounwind willreturn memory(none)
declare ptr @__ctype_tolower_loc() local_unnamed_addr #4

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 = { 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 #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 = { mustprogress nofree nosync nounwind willreturn memory(none) "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 }
attributes #6 = { nounwind willreturn memory(read) }
attributes #7 = { nounwind willreturn memory(none) }

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


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