; 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 uwtable
define dso_local ptr @strstr(ptr noundef %0, ptr noundef %1) #1 {
  %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) #2
  %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) #2
  %10 = load ptr, ptr %5, align 8, !tbaa !5
  store ptr %10, ptr %7, align 8, !tbaa !5
  br label %11

11:                                               ; preds = %40, %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 %42

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 %25, label %30

25:                                               ; preds = %17
  %26 = load ptr, ptr %7, align 8, !tbaa !5
  %27 = getelementptr inbounds i8, ptr %26, i32 1
  store ptr %27, ptr %7, align 8, !tbaa !5
  %28 = load ptr, ptr %6, align 8, !tbaa !5
  %29 = getelementptr inbounds i8, ptr %28, i32 1
  store ptr %29, ptr %6, align 8, !tbaa !5
  br label %39

30:                                               ; preds = %17
  %31 = load ptr, ptr %5, align 8, !tbaa !5
  store ptr %31, ptr %7, align 8, !tbaa !5
  %32 = load ptr, ptr %6, align 8, !tbaa !5
  %33 = load i8, ptr %32, align 1, !tbaa !9
  %34 = icmp ne i8 %33, 0
  br i1 %34, label %36, label %35

35:                                               ; preds = %30
  store ptr null, ptr %3, align 8
  store i32 1, ptr %8, align 4
  br label %42

36:                                               ; preds = %30
  %37 = load ptr, ptr %4, align 8, !tbaa !5
  %38 = getelementptr inbounds i8, ptr %37, i32 1
  store ptr %38, ptr %4, align 8, !tbaa !5
  store ptr %38, ptr %6, align 8, !tbaa !5
  br label %39

39:                                               ; preds = %36, %25
  br label %40

40:                                               ; preds = %39
  br i1 true, label %11, label %41

41:                                               ; preds = %40
  store i32 0, ptr %8, align 4
  br label %42

42:                                               ; preds = %41, %35, %15
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #2
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #2
  %43 = load i32, ptr %8, align 4
  switch i32 %43, label %46 [
    i32 0, label %44
    i32 1, label %44
  ]

44:                                               ; preds = %42, %42
  %45 = load ptr, ptr %3, align 8
  ret ptr %45

46:                                               ; preds = %42
  unreachable
}

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { 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 #2 = { 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 = !{!"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: nofree norecurse nosync nounwind memory(read, inaccessiblemem: none) uwtable
define dso_local ptr @strstr(ptr noundef readonly %0, ptr nocapture noundef readonly %1) local_unnamed_addr #0 {
  %3 = load i8, ptr %1, align 1, !tbaa !5
  %.not19 = icmp eq i8 %3, 0
  br i1 %.not19, label %._crit_edge, label %.lr.ph

.lr.ph:                                           ; preds = %2, %13
  %4 = phi i8 [ %14, %13 ], [ %3, %2 ]
  %.022 = phi ptr [ %.1, %13 ], [ %1, %2 ]
  %.01221 = phi ptr [ %.113, %13 ], [ %0, %2 ]
  %.01520 = phi ptr [ %.116, %13 ], [ %0, %2 ]
  %5 = load i8, ptr %.01221, align 1, !tbaa !5
  %6 = icmp eq i8 %4, %5
  br i1 %6, label %7, label %10

7:                                                ; preds = %.lr.ph
  %8 = getelementptr inbounds i8, ptr %.022, i64 1
  %9 = getelementptr inbounds i8, ptr %.01221, i64 1
  br label %13

10:                                               ; preds = %.lr.ph
  %.not18 = icmp eq i8 %5, 0
  br i1 %.not18, label %._crit_edge, label %11

11:                                               ; preds = %10
  %12 = getelementptr inbounds i8, ptr %.01520, i64 1
  br label %13

13:                                               ; preds = %7, %11
  %.116 = phi ptr [ %.01520, %7 ], [ %12, %11 ]
  %.113 = phi ptr [ %9, %7 ], [ %12, %11 ]
  %.1 = phi ptr [ %8, %7 ], [ %1, %11 ]
  %14 = load i8, ptr %.1, align 1, !tbaa !5
  %.not = icmp eq i8 %14, 0
  br i1 %.not, label %._crit_edge, label %.lr.ph

._crit_edge:                                      ; preds = %13, %10, %2
  %.014 = phi ptr [ %0, %2 ], [ null, %10 ], [ %.116, %13 ]
  ret ptr %.014
}

attributes #0 = { nofree norecurse nosync nounwind memory(read, inaccessiblemem: none) 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" }

!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