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

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

@eccTable = external hidden constant [41 x [4 x [2 x i32]]], align 16

; Function Attrs: nounwind uwtable
declare dso_local i32 @QRspec_getDataLength(i32 noundef, i32 noundef) #0

; Function Attrs: nounwind uwtable
declare dso_local i32 @QRspec_getECCLength(i32 noundef, i32 noundef) #0

; 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

; Function Attrs: nounwind uwtable
define dso_local void @QRspec_getEccSpec(i32 noundef %0, i32 noundef %1, ptr noundef %2) #0 {
  %4 = alloca i32, align 4
  %5 = alloca i32, align 4
  %6 = alloca ptr, align 8
  %7 = alloca i32, align 4
  %8 = alloca i32, align 4
  %9 = alloca i32, align 4
  %10 = alloca i32, align 4
  store i32 %0, ptr %4, align 4, !tbaa !5
  store i32 %1, ptr %5, align 4, !tbaa !5
  store ptr %2, ptr %6, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #2
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #2
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #2
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #2
  %11 = load i32, ptr %4, align 4, !tbaa !5
  %12 = sext i32 %11 to i64
  %13 = getelementptr inbounds [41 x [4 x [2 x i32]]], ptr @eccTable, i64 0, i64 %12
  %14 = load i32, ptr %5, align 4, !tbaa !5
  %15 = zext i32 %14 to i64
  %16 = getelementptr inbounds [4 x [2 x i32]], ptr %13, i64 0, i64 %15
  %17 = getelementptr inbounds [2 x i32], ptr %16, i64 0, i64 0
  %18 = load i32, ptr %17, align 8, !tbaa !5
  store i32 %18, ptr %7, align 4, !tbaa !5
  %19 = load i32, ptr %4, align 4, !tbaa !5
  %20 = sext i32 %19 to i64
  %21 = getelementptr inbounds [41 x [4 x [2 x i32]]], ptr @eccTable, i64 0, i64 %20
  %22 = load i32, ptr %5, align 4, !tbaa !5
  %23 = zext i32 %22 to i64
  %24 = getelementptr inbounds [4 x [2 x i32]], ptr %21, i64 0, i64 %23
  %25 = getelementptr inbounds [2 x i32], ptr %24, i64 0, i64 1
  %26 = load i32, ptr %25, align 4, !tbaa !5
  store i32 %26, ptr %8, align 4, !tbaa !5
  %27 = load i32, ptr %4, align 4, !tbaa !5
  %28 = load i32, ptr %5, align 4, !tbaa !5
  %29 = call i32 @QRspec_getDataLength(i32 noundef %27, i32 noundef %28)
  store i32 %29, ptr %9, align 4, !tbaa !5
  %30 = load i32, ptr %4, align 4, !tbaa !5
  %31 = load i32, ptr %5, align 4, !tbaa !5
  %32 = call i32 @QRspec_getECCLength(i32 noundef %30, i32 noundef %31)
  store i32 %32, ptr %10, align 4, !tbaa !5
  %33 = load i32, ptr %8, align 4, !tbaa !5
  %34 = icmp eq i32 %33, 0
  br i1 %34, label %35, label %53

35:                                               ; preds = %3
  %36 = load i32, ptr %7, align 4, !tbaa !5
  %37 = load ptr, ptr %6, align 8, !tbaa !9
  %38 = getelementptr inbounds i32, ptr %37, i64 0
  store i32 %36, ptr %38, align 4, !tbaa !5
  %39 = load i32, ptr %9, align 4, !tbaa !5
  %40 = load i32, ptr %7, align 4, !tbaa !5
  %41 = sdiv i32 %39, %40
  %42 = load ptr, ptr %6, align 8, !tbaa !9
  %43 = getelementptr inbounds i32, ptr %42, i64 1
  store i32 %41, ptr %43, align 4, !tbaa !5
  %44 = load i32, ptr %10, align 4, !tbaa !5
  %45 = load i32, ptr %7, align 4, !tbaa !5
  %46 = sdiv i32 %44, %45
  %47 = load ptr, ptr %6, align 8, !tbaa !9
  %48 = getelementptr inbounds i32, ptr %47, i64 2
  store i32 %46, ptr %48, align 4, !tbaa !5
  %49 = load ptr, ptr %6, align 8, !tbaa !9
  %50 = getelementptr inbounds i32, ptr %49, i64 4
  store i32 0, ptr %50, align 4, !tbaa !5
  %51 = load ptr, ptr %6, align 8, !tbaa !9
  %52 = getelementptr inbounds i32, ptr %51, i64 3
  store i32 0, ptr %52, align 4, !tbaa !5
  br label %80

53:                                               ; preds = %3
  %54 = load i32, ptr %7, align 4, !tbaa !5
  %55 = load ptr, ptr %6, align 8, !tbaa !9
  %56 = getelementptr inbounds i32, ptr %55, i64 0
  store i32 %54, ptr %56, align 4, !tbaa !5
  %57 = load i32, ptr %9, align 4, !tbaa !5
  %58 = load i32, ptr %7, align 4, !tbaa !5
  %59 = load i32, ptr %8, align 4, !tbaa !5
  %60 = add nsw i32 %58, %59
  %61 = sdiv i32 %57, %60
  %62 = load ptr, ptr %6, align 8, !tbaa !9
  %63 = getelementptr inbounds i32, ptr %62, i64 1
  store i32 %61, ptr %63, align 4, !tbaa !5
  %64 = load i32, ptr %10, align 4, !tbaa !5
  %65 = load i32, ptr %7, align 4, !tbaa !5
  %66 = load i32, ptr %8, align 4, !tbaa !5
  %67 = add nsw i32 %65, %66
  %68 = sdiv i32 %64, %67
  %69 = load ptr, ptr %6, align 8, !tbaa !9
  %70 = getelementptr inbounds i32, ptr %69, i64 2
  store i32 %68, ptr %70, align 4, !tbaa !5
  %71 = load i32, ptr %8, align 4, !tbaa !5
  %72 = load ptr, ptr %6, align 8, !tbaa !9
  %73 = getelementptr inbounds i32, ptr %72, i64 3
  store i32 %71, ptr %73, align 4, !tbaa !5
  %74 = load ptr, ptr %6, align 8, !tbaa !9
  %75 = getelementptr inbounds i32, ptr %74, i64 1
  %76 = load i32, ptr %75, align 4, !tbaa !5
  %77 = add nsw i32 %76, 1
  %78 = load ptr, ptr %6, align 8, !tbaa !9
  %79 = getelementptr inbounds i32, ptr %78, i64 4
  store i32 %77, ptr %79, align 4, !tbaa !5
  br label %80

80:                                               ; preds = %53, %35
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #2
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #2
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #2
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #2
  ret void
}

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

@eccTable = external hidden local_unnamed_addr constant [41 x [4 x [2 x i32]]], align 16

; Function Attrs: nounwind uwtable
declare dso_local i32 @QRspec_getDataLength(i32 noundef, i32 noundef) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
declare dso_local i32 @QRspec_getECCLength(i32 noundef, i32 noundef) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
define dso_local void @QRspec_getEccSpec(i32 noundef %0, i32 noundef %1, ptr nocapture noundef writeonly %2) local_unnamed_addr #0 {
  %4 = sext i32 %0 to i64
  %5 = zext i32 %1 to i64
  %6 = getelementptr inbounds [41 x [4 x [2 x i32]]], ptr @eccTable, i64 0, i64 %4, i64 %5
  %7 = load i32, ptr %6, align 8, !tbaa !5
  %8 = getelementptr inbounds i8, ptr %6, i64 4
  %9 = load i32, ptr %8, align 4, !tbaa !5
  %10 = tail call i32 @QRspec_getDataLength(i32 noundef %0, i32 noundef %1)
  %11 = tail call i32 @QRspec_getECCLength(i32 noundef %0, i32 noundef %1)
  %12 = icmp eq i32 %9, 0
  br i1 %12, label %13, label %15

13:                                               ; preds = %3
  %14 = sdiv i32 %10, %7
  br label %19

15:                                               ; preds = %3
  %16 = add nsw i32 %9, %7
  %17 = sdiv i32 %10, %16
  %18 = add nsw i32 %17, 1
  br label %19

19:                                               ; preds = %15, %13
  %.sink34 = phi i32 [ %14, %13 ], [ %17, %15 ]
  %.pn = phi i32 [ %7, %13 ], [ %16, %15 ]
  %.sink32 = phi i32 [ 0, %13 ], [ %18, %15 ]
  %.sink33 = sdiv i32 %11, %.pn
  store i32 %7, ptr %2, align 4
  %20 = getelementptr inbounds i8, ptr %2, i64 4
  store i32 %.sink34, ptr %20, align 4
  %21 = getelementptr inbounds i8, ptr %2, i64 8
  store i32 %.sink33, ptr %21, align 4
  %22 = getelementptr inbounds i8, ptr %2, i64 16
  store i32 %.sink32, ptr %22, align 4
  %23 = getelementptr inbounds i8, ptr %2, i64 12
  store i32 %9, ptr %23, align 4
  ret void
}

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

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


; Effective O3 passes: CorrelatedValuePropagationPass,EarlyCSEPass,GlobalOptPass,InferFunctionAttrsPass,InstCombinePass,MergedLoadStoreMotionPass,PostOrderFunctionAttrsPass,ReassociatePass,SROAPass,TailCallElimPass