; LLVM IR from ConcealNetwork/conceal-desktop :: libqrencode/tests (rsecc_decoder)

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

@alpha = external hidden global [256 x i8], align 16
@aindex = external hidden global [256 x i8], align 16

; Function Attrs: nounwind uwtable
define dso_local void @RSECC_decoder_init() #0 {
  %1 = alloca i32, align 4
  %2 = alloca i32, align 4
  call void @llvm.lifetime.start.p0(i64 4, ptr %1) #2
  call void @llvm.lifetime.start.p0(i64 4, ptr %2) #2
  store i8 0, ptr getelementptr inbounds ([256 x i8], ptr @alpha, i64 0, i64 255), align 1, !tbaa !5
  store i8 -1, ptr @aindex, align 16, !tbaa !5
  store i32 1, ptr %2, align 4, !tbaa !8
  store i32 0, ptr %1, align 4, !tbaa !8
  br label %3

3:                                                ; preds = %28, %0
  %4 = load i32, ptr %1, align 4, !tbaa !8
  %5 = icmp slt i32 %4, 255
  br i1 %5, label %6, label %31

6:                                                ; preds = %3
  %7 = load i32, ptr %2, align 4, !tbaa !8
  %8 = trunc i32 %7 to i8
  %9 = load i32, ptr %1, align 4, !tbaa !8
  %10 = sext i32 %9 to i64
  %11 = getelementptr inbounds [256 x i8], ptr @alpha, i64 0, i64 %10
  store i8 %8, ptr %11, align 1, !tbaa !5
  %12 = load i32, ptr %1, align 4, !tbaa !8
  %13 = trunc i32 %12 to i8
  %14 = load i32, ptr %2, align 4, !tbaa !8
  %15 = sext i32 %14 to i64
  %16 = getelementptr inbounds [256 x i8], ptr @aindex, i64 0, i64 %15
  store i8 %13, ptr %16, align 1, !tbaa !5
  %17 = load i32, ptr %2, align 4, !tbaa !8
  %18 = shl i32 %17, 1
  store i32 %18, ptr %2, align 4, !tbaa !8
  %19 = load i32, ptr %2, align 4, !tbaa !8
  %20 = and i32 %19, 256
  %21 = icmp ne i32 %20, 0
  br i1 %21, label %22, label %25

22:                                               ; preds = %6
  %23 = load i32, ptr %2, align 4, !tbaa !8
  %24 = xor i32 %23, 285
  store i32 %24, ptr %2, align 4, !tbaa !8
  br label %25

25:                                               ; preds = %22, %6
  %26 = load i32, ptr %2, align 4, !tbaa !8
  %27 = and i32 %26, 255
  store i32 %27, ptr %2, align 4, !tbaa !8
  br label %28

28:                                               ; preds = %25
  %29 = load i32, ptr %1, align 4, !tbaa !8
  %30 = add nsw i32 %29, 1
  store i32 %30, ptr %1, align 4, !tbaa !8
  br label %3, !llvm.loop !10

31:                                               ; preds = %3
  call void @llvm.lifetime.end.p0(i64 4, ptr %2) #2
  call void @llvm.lifetime.end.p0(i64 4, ptr %1) #2
  ret void
}

; 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 = !{!"omnipotent char", !7, i64 0}
!7 = !{!"Simple C/C++ TBAA"}
!8 = !{!9, !9, i64 0}
!9 = !{!"int", !6, i64 0}
!10 = distinct !{!10, !11}
!11 = !{!"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"

@alpha = external hidden local_unnamed_addr global [256 x i8], align 16
@aindex = external hidden local_unnamed_addr global [256 x i8], align 16

; Function Attrs: nofree norecurse nosync nounwind memory(write, argmem: none, inaccessiblemem: none) uwtable
define dso_local void @RSECC_decoder_init() local_unnamed_addr #0 {
  store i8 0, ptr getelementptr inbounds (i8, ptr @alpha, i64 255), align 1, !tbaa !5
  store i8 -1, ptr @aindex, align 16, !tbaa !5
  br label %1

1:                                                ; preds = %7, %0
  %indvars.iv = phi i64 [ 0, %0 ], [ %indvars.iv.next.1, %7 ]
  %.012 = phi i32 [ 1, %0 ], [ %18, %7 ]
  %2 = trunc nuw i32 %.012 to i8
  %3 = getelementptr inbounds [256 x i8], ptr @alpha, i64 0, i64 %indvars.iv
  store i8 %2, ptr %3, align 2, !tbaa !5
  %4 = trunc i64 %indvars.iv to i8
  %5 = zext nneg i32 %.012 to i64
  %6 = getelementptr inbounds [256 x i8], ptr @aindex, i64 0, i64 %5
  store i8 %4, ptr %6, align 1, !tbaa !5
  %exitcond.not = icmp eq i64 %indvars.iv, 254
  br i1 %exitcond.not, label %19, label %7, !llvm.loop !8

7:                                                ; preds = %1
  %indvars.iv.next = or disjoint i64 %indvars.iv, 1
  %.not = icmp ult i32 %.012, 128
  %8 = shl nuw nsw i32 %.012, 1
  %9 = xor i32 %8, 29
  %spec.select = select i1 %.not, i32 %8, i32 %9
  %10 = and i32 %spec.select, 255
  %11 = trunc i32 %spec.select to i8
  %12 = getelementptr inbounds [256 x i8], ptr @alpha, i64 0, i64 %indvars.iv.next
  store i8 %11, ptr %12, align 1, !tbaa !5
  %13 = trunc i64 %indvars.iv.next to i8
  %14 = zext nneg i32 %10 to i64
  %15 = getelementptr inbounds [256 x i8], ptr @aindex, i64 0, i64 %14
  store i8 %13, ptr %15, align 1, !tbaa !5
  %16 = shl nuw nsw i32 %10, 1
  %.not.1 = icmp ult i32 %10, 128
  %17 = xor i32 %16, 29
  %spec.select.1 = select i1 %.not.1, i32 %16, i32 %17
  %18 = and i32 %spec.select.1, 255
  %indvars.iv.next.1 = add nuw nsw i64 %indvars.iv, 2
  br label %1

19:                                               ; preds = %1
  ret void
}

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: GlobalOptPass,IndVarSimplifyPass,InferAlignmentPass,InferFunctionAttrsPass,InstCombinePass,LoopRotatePass,LoopUnrollPass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass