; LLVM IR from JonathanSalwan/Triton :: src/stubs (triton-stubs)

; 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 willreturn memory(read) uwtable
declare dso_local i32 @tolower(i32 noundef) #1

; Function Attrs: nounwind uwtable
define dso_local ptr @strcasestr(ptr noundef %0, ptr noundef %1) #2 {
  %3 = alloca ptr, align 8
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca ptr, align 8
  %8 = alloca i32, align 4
  store ptr %0, ptr %4, align 8, !tbaa !5
  store ptr %1, ptr %5, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #3
  %9 = load ptr, ptr %4, align 8, !tbaa !5
  store ptr %9, ptr %6, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #3
  %10 = load ptr, ptr %5, align 8, !tbaa !5
  store ptr %10, ptr %7, align 8, !tbaa !5
  br label %11

11:                                               ; preds = %50, %2
  %12 = load ptr, ptr %7, align 8, !tbaa !5
  %13 = load i8, ptr %12, align 1, !tbaa !9
  %14 = icmp ne i8 %13, 0
  br i1 %14, label %17, label %15

15:                                               ; preds = %11
  %16 = load ptr, ptr %4, align 8, !tbaa !5
  store ptr %16, ptr %3, align 8
  store i32 1, ptr %8, align 4
  br label %52

17:                                               ; preds = %11
  %18 = load ptr, ptr %7, align 8, !tbaa !5
  %19 = load i8, ptr %18, align 1, !tbaa !9
  %20 = sext i8 %19 to i32
  %21 = load ptr, ptr %6, align 8, !tbaa !5
  %22 = load i8, ptr %21, align 1, !tbaa !9
  %23 = sext i8 %22 to i32
  %24 = icmp eq i32 %20, %23
  br i1 %24, label %35, label %25

25:                                               ; preds = %17
  %26 = load ptr, ptr %7, align 8, !tbaa !5
  %27 = load i8, ptr %26, align 1, !tbaa !9
  %28 = zext i8 %27 to i32
  %29 = call i32 @tolower(i32 noundef %28) #4
  %30 = load ptr, ptr %6, align 8, !tbaa !5
  %31 = load i8, ptr %30, align 1, !tbaa !9
  %32 = zext i8 %31 to i32
  %33 = call i32 @tolower(i32 noundef %32) #4
  %34 = icmp eq i32 %29, %33
  br i1 %34, label %35, label %40

35:                                               ; preds = %25, %17
  %36 = load ptr, ptr %7, align 8, !tbaa !5
  %37 = getelementptr inbounds i8, ptr %36, i32 1
  store ptr %37, ptr %7, align 8, !tbaa !5
  %38 = load ptr, ptr %6, align 8, !tbaa !5
  %39 = getelementptr inbounds i8, ptr %38, i32 1
  store ptr %39, ptr %6, align 8, !tbaa !5
  br label %49

40:                                               ; preds = %25
  %41 = load ptr, ptr %5, align 8, !tbaa !5
  store ptr %41, ptr %7, align 8, !tbaa !5
  %42 = load ptr, ptr %6, align 8, !tbaa !5
  %43 = load i8, ptr %42, align 1, !tbaa !9
  %44 = icmp ne i8 %43, 0
  br i1 %44, label %46, label %45

45:                                               ; preds = %40
  store ptr null, ptr %3, align 8
  store i32 1, ptr %8, align 4
  br label %52

46:                                               ; preds = %40
  %47 = load ptr, ptr %4, align 8, !tbaa !5
  %48 = getelementptr inbounds i8, ptr %47, i32 1
  store ptr %48, ptr %4, align 8, !tbaa !5
  store ptr %48, ptr %6, align 8, !tbaa !5
  br label %49

49:                                               ; preds = %46, %35
  br label %50

50:                                               ; preds = %49
  br i1 true, label %11, label %51

51:                                               ; preds = %50
  store i32 0, ptr %8, align 4
  br label %52

52:                                               ; preds = %51, %45, %15
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #3
  %53 = load i32, ptr %8, align 4
  switch i32 %53, label %56 [
    i32 0, label %54
    i32 1, label %54
  ]

54:                                               ; preds = %52, %52
  %55 = load ptr, ptr %3, align 8
  ret ptr %55

56:                                               ; preds = %52
  unreachable
}

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

; Function Attrs: mustprogress nofree nounwind willreturn memory(read) uwtable
declare dso_local i32 @tolower(i32 noundef) local_unnamed_addr #0

; Function Attrs: nofree nounwind memory(read) uwtable
define dso_local ptr @strcasestr(ptr noundef readonly %0, ptr nocapture noundef readonly %1) local_unnamed_addr #1 {
  %3 = load i8, ptr %1, align 1, !tbaa !5
  %.not21 = icmp eq i8 %3, 0
  br i1 %.not21, label %._crit_edge, label %.lr.ph

.lr.ph:                                           ; preds = %2, %19
  %4 = phi i8 [ %20, %19 ], [ %3, %2 ]
  %.024 = phi ptr [ %.1, %19 ], [ %1, %2 ]
  %.01423 = phi ptr [ %.115, %19 ], [ %0, %2 ]
  %.01722 = phi ptr [ %.118, %19 ], [ %0, %2 ]
  %5 = load i8, ptr %.01423, align 1, !tbaa !5
  %6 = icmp eq i8 %4, %5
  br i1 %6, label %13, label %7

7:                                                ; preds = %.lr.ph
  %8 = zext i8 %4 to i32
  %9 = tail call i32 @tolower(i32 noundef %8) #2
  %10 = zext i8 %5 to i32
  %11 = tail call i32 @tolower(i32 noundef %10) #2
  %12 = icmp eq i32 %9, %11
  br i1 %12, label %13, label %16

13:                                               ; preds = %7, %.lr.ph
  %14 = getelementptr inbounds i8, ptr %.024, i64 1
  %15 = getelementptr inbounds i8, ptr %.01423, i64 1
  br label %19

16:                                               ; preds = %7
  %.not20 = icmp eq i8 %5, 0
  br i1 %.not20, label %._crit_edge, label %17

17:                                               ; preds = %16
  %18 = getelementptr inbounds i8, ptr %.01722, i64 1
  br label %19

19:                                               ; preds = %13, %17
  %.118 = phi ptr [ %.01722, %13 ], [ %18, %17 ]
  %.115 = phi ptr [ %15, %13 ], [ %18, %17 ]
  %.1 = phi ptr [ %14, %13 ], [ %1, %17 ]
  %20 = load i8, ptr %.1, align 1, !tbaa !5
  %.not = icmp eq i8 %20, 0
  br i1 %.not, label %._crit_edge, label %.lr.ph

._crit_edge:                                      ; preds = %19, %16, %2
  %.016 = phi ptr [ %0, %2 ], [ null, %16 ], [ %.118, %19 ]
  ret ptr %.016
}

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

!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"}


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