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

@l64a.result = external hidden global [7 x i8], align 1
@.str = external hidden unnamed_addr constant [1 x i8], align 1
@conv_table = external hidden constant [64 x i8], align 16

; 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 @l64a(i64 noundef %0) #1 {
  %2 = alloca ptr, align 8
  %3 = alloca i64, align 8
  %4 = alloca i64, align 8
  %5 = alloca i32, align 4
  %6 = alloca i32, align 4
  store i64 %0, ptr %3, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %4) #2
  %7 = load i64, ptr %3, align 8, !tbaa !5
  store i64 %7, ptr %4, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #2
  %8 = load i64, ptr %4, align 8, !tbaa !5
  %9 = and i64 %8, 4294967295
  store i64 %9, ptr %4, align 8, !tbaa !5
  %10 = load i64, ptr %4, align 8, !tbaa !5
  %11 = icmp eq i64 %10, 0
  br i1 %11, label %12, label %13

12:                                               ; preds = %1
  store ptr @.str, ptr %2, align 8
  store i32 1, ptr %6, align 4
  br label %34

13:                                               ; preds = %1
  store i32 0, ptr %5, align 4, !tbaa !9
  br label %14

14:                                               ; preds = %27, %13
  %15 = load i64, ptr %4, align 8, !tbaa !5
  %16 = icmp ugt i64 %15, 0
  br i1 %16, label %17, label %30

17:                                               ; preds = %14
  %18 = load i64, ptr %4, align 8, !tbaa !5
  %19 = and i64 %18, 63
  %20 = getelementptr inbounds [64 x i8], ptr @conv_table, i64 0, i64 %19
  %21 = load i8, ptr %20, align 1, !tbaa !11
  %22 = load i32, ptr %5, align 4, !tbaa !9
  %23 = sext i32 %22 to i64
  %24 = getelementptr inbounds [7 x i8], ptr @l64a.result, i64 0, i64 %23
  store i8 %21, ptr %24, align 1, !tbaa !11
  %25 = load i64, ptr %4, align 8, !tbaa !5
  %26 = lshr i64 %25, 6
  store i64 %26, ptr %4, align 8, !tbaa !5
  br label %27

27:                                               ; preds = %17
  %28 = load i32, ptr %5, align 4, !tbaa !9
  %29 = add nsw i32 %28, 1
  store i32 %29, ptr %5, align 4, !tbaa !9
  br label %14, !llvm.loop !12

30:                                               ; preds = %14
  %31 = load i32, ptr %5, align 4, !tbaa !9
  %32 = sext i32 %31 to i64
  %33 = getelementptr inbounds [7 x i8], ptr @l64a.result, i64 0, i64 %32
  store i8 0, ptr %33, align 1, !tbaa !11
  store ptr @l64a.result, ptr %2, align 8
  store i32 1, ptr %6, align 4
  br label %34

34:                                               ; preds = %30, %12
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #2
  call void @llvm.lifetime.end.p0(i64 8, ptr %4) #2
  %35 = load ptr, ptr %2, align 8
  ret ptr %35
}

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 = !{!"long", !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 = !{!7, !7, i64 0}
!12 = distinct !{!12, !13}
!13 = !{!"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"

@l64a.result = external hidden global [7 x i8], align 1
@.str = external hidden unnamed_addr constant [1 x i8], align 1
@conv_table = external hidden local_unnamed_addr constant [64 x i8], align 16

; Function Attrs: nofree norecurse nosync nounwind memory(write, argmem: none, inaccessiblemem: none) uwtable
define dso_local noundef nonnull ptr @l64a(i64 noundef %0) local_unnamed_addr #0 {
  %2 = and i64 %0, 4294967295
  %3 = icmp eq i64 %2, 0
  br i1 %3, label %12, label %.preheader

.preheader:                                       ; preds = %1, %.preheader
  %indvars.iv = phi i64 [ %indvars.iv.next, %.preheader ], [ 0, %1 ]
  %.0912 = phi i64 [ %8, %.preheader ], [ %2, %1 ]
  %4 = and i64 %.0912, 63
  %5 = getelementptr inbounds [64 x i8], ptr @conv_table, i64 0, i64 %4
  %6 = load i8, ptr %5, align 1, !tbaa !5
  %7 = getelementptr inbounds [7 x i8], ptr @l64a.result, i64 0, i64 %indvars.iv
  store i8 %6, ptr %7, align 1, !tbaa !5
  %8 = lshr i64 %.0912, 6
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %.not = icmp ult i64 %.0912, 64
  br i1 %.not, label %9, label %.preheader, !llvm.loop !8

9:                                                ; preds = %.preheader
  %10 = and i64 %indvars.iv.next, 4294967295
  %11 = getelementptr inbounds [7 x i8], ptr @l64a.result, i64 0, i64 %10
  store i8 0, ptr %11, align 1, !tbaa !5
  br label %12

12:                                               ; preds = %1, %9
  %.010 = phi ptr [ @l64a.result, %9 ], [ @.str, %1 ]
  ret ptr %.010
}

attributes #0 = { nofree norecurse nosync nounwind memory(write, argmem: none, 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"}
!8 = distinct !{!8, !9}
!9 = !{!"llvm.loop.mustprogress"}


; Effective O3 passes: GVNPass,GlobalOptPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,LCSSAPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass