; LLVM IR from jingweizhanghuai/Morn :: src/util (morn_TAR)

; 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: nounwind uwtable
define dso_local i32 @OctToDec(ptr noundef %0) #0 {
  %2 = alloca ptr, align 8
  %3 = alloca i32, align 4
  %4 = alloca i32, align 4
  store ptr %0, ptr %2, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %3) #2
  store i32 0, ptr %3, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #2
  store i32 0, ptr %4, align 4, !tbaa !9
  br label %5

5:                                                ; preds = %20, %1
  %6 = load i32, ptr %4, align 4, !tbaa !9
  %7 = icmp slt i32 %6, 11
  br i1 %7, label %9, label %8

8:                                                ; preds = %5
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #2
  br label %23

9:                                                ; preds = %5
  %10 = load i32, ptr %3, align 4, !tbaa !9
  %11 = shl i32 %10, 3
  %12 = load ptr, ptr %2, align 8, !tbaa !5
  %13 = load i32, ptr %4, align 4, !tbaa !9
  %14 = sext i32 %13 to i64
  %15 = getelementptr inbounds i8, ptr %12, i64 %14
  %16 = load i8, ptr %15, align 1, !tbaa !11
  %17 = sext i8 %16 to i32
  %18 = sub nsw i32 %17, 48
  %19 = add nsw i32 %11, %18
  store i32 %19, ptr %3, align 4, !tbaa !9
  br label %20

20:                                               ; preds = %9
  %21 = load i32, ptr %4, align 4, !tbaa !9
  %22 = add nsw i32 %21, 1
  store i32 %22, ptr %4, align 4, !tbaa !9
  br label %5, !llvm.loop !12

23:                                               ; preds = %8
  %24 = load i32, ptr %3, align 4, !tbaa !9
  call void @llvm.lifetime.end.p0(i64 4, ptr %3) #2
  ret i32 %24
}

; 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

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 = { 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 = !{!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"

; Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn memory(argmem: read) uwtable
define dso_local i32 @OctToDec(ptr nocapture noundef readonly %0) local_unnamed_addr #0 {
  %2 = load i8, ptr %0, align 1, !tbaa !5
  %3 = sext i8 %2 to i32
  %4 = shl nsw i32 %3, 3
  %5 = getelementptr inbounds i8, ptr %0, i64 1
  %6 = load i8, ptr %5, align 1, !tbaa !5
  %7 = zext i8 %6 to i32
  %8 = add nsw i32 %4, 67108432
  %9 = add nsw i32 %8, %7
  %10 = shl nsw i32 %9, 3
  %11 = getelementptr inbounds i8, ptr %0, i64 2
  %12 = load i8, ptr %11, align 1, !tbaa !5
  %13 = zext i8 %12 to i32
  %14 = add i32 %10, 67108816
  %15 = add i32 %14, %13
  %16 = shl i32 %15, 3
  %17 = getelementptr inbounds i8, ptr %0, i64 3
  %18 = load i8, ptr %17, align 1, !tbaa !5
  %19 = sext i8 %18 to i32
  %20 = add i32 %16, 67108816
  %21 = add i32 %20, %19
  %22 = shl i32 %21, 3
  %23 = getelementptr inbounds i8, ptr %0, i64 4
  %24 = load i8, ptr %23, align 1, !tbaa !5
  %25 = sext i8 %24 to i32
  %26 = add i32 %22, 67108816
  %27 = add i32 %26, %25
  %28 = shl i32 %27, 3
  %29 = getelementptr inbounds i8, ptr %0, i64 5
  %30 = load i8, ptr %29, align 1, !tbaa !5
  %31 = sext i8 %30 to i32
  %32 = add i32 %28, 67108816
  %33 = add i32 %32, %31
  %34 = shl i32 %33, 3
  %35 = getelementptr inbounds i8, ptr %0, i64 6
  %36 = load i8, ptr %35, align 1, !tbaa !5
  %37 = sext i8 %36 to i32
  %38 = add i32 %34, 67108816
  %39 = add i32 %38, %37
  %40 = shl i32 %39, 3
  %41 = getelementptr inbounds i8, ptr %0, i64 7
  %42 = load i8, ptr %41, align 1, !tbaa !5
  %43 = sext i8 %42 to i32
  %44 = add i32 %40, 67108816
  %45 = add i32 %44, %43
  %46 = shl i32 %45, 3
  %47 = getelementptr inbounds i8, ptr %0, i64 8
  %48 = load i8, ptr %47, align 1, !tbaa !5
  %49 = sext i8 %48 to i32
  %50 = add i32 %46, 67108816
  %51 = add i32 %50, %49
  %52 = shl i32 %51, 3
  %53 = getelementptr inbounds i8, ptr %0, i64 9
  %54 = load i8, ptr %53, align 1, !tbaa !5
  %55 = sext i8 %54 to i32
  %56 = add i32 %52, 536870864
  %57 = add i32 %56, %55
  %58 = shl i32 %57, 3
  %59 = getelementptr inbounds i8, ptr %0, i64 10
  %60 = load i8, ptr %59, align 1, !tbaa !5
  %61 = sext i8 %60 to i32
  %62 = add i32 %58, -48
  %63 = add i32 %62, %61
  ret i32 %63
}

attributes #0 = { mustprogress nofree norecurse nosync nounwind willreturn memory(argmem: 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" }

!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: BDCEPass,GVNPass,GlobalOptPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,LCSSAPass,LoopRotatePass,PostOrderFunctionAttrsPass,ReassociatePass,SCCPPass,SROAPass,SimplifyCFGPass