; LLVM IR from kkan2020/evacc :: firmware/main (qrcode)

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

%struct.BitBucket = type { i32, i16, ptr }
%struct.QRCode = type { i8, i8, i8, i8, i8, ptr }

@NUM_RAW_DATA_MODULES = external hidden constant [40 x i16], align 16
@NUM_ERROR_CORRECTION_CODEWORDS = external hidden constant [4 x [40 x i16]], align 16

; Function Attrs: nounwind uwtable
declare hidden zeroext i16 @bb_getGridSizeBytes(i8 noundef zeroext) #0

; Function Attrs: nounwind uwtable
define dso_local signext i8 @qrcode_initBytes(ptr noundef %0, ptr noundef %1, i8 noundef zeroext %2, i8 noundef zeroext %3, ptr noundef %4, i16 noundef zeroext %5) #0 {
  %7 = alloca i8, align 1
  %8 = alloca ptr, align 8
  %9 = alloca ptr, align 8
  %10 = alloca i8, align 1
  %11 = alloca i8, align 1
  %12 = alloca ptr, align 8
  %13 = alloca i16, align 2
  %14 = alloca i8, align 1
  %15 = alloca i8, align 1
  %16 = alloca i16, align 2
  %17 = alloca i16, align 2
  %18 = alloca %struct.BitBucket, align 8
  %19 = alloca ptr, align 8
  %20 = alloca i8, align 1
  %21 = alloca i32, align 4
  %22 = alloca i32, align 4
  %23 = alloca i8, align 1
  %24 = alloca %struct.BitBucket, align 8
  %25 = alloca %struct.BitBucket, align 8
  %26 = alloca ptr, align 8
  %27 = alloca i8, align 1
  %28 = alloca i32, align 4
  %29 = alloca i8, align 1
  %30 = alloca i32, align 4
  store ptr %0, ptr %8, align 8, !tbaa !5
  store ptr %1, ptr %9, align 8, !tbaa !5
  store i8 %2, ptr %10, align 1, !tbaa !9
  store i8 %3, ptr %11, align 1, !tbaa !9
  store ptr %4, ptr %12, align 8, !tbaa !5
  store i16 %5, ptr %13, align 2, !tbaa !10
  call void @llvm.lifetime.start.p0(i64 1, ptr %14) #2
  %31 = load i8, ptr %10, align 1, !tbaa !9
  %32 = zext i8 %31 to i32
  %33 = mul nsw i32 %32, 4
  %34 = add nsw i32 %33, 17
  %35 = trunc i32 %34 to i8
  store i8 %35, ptr %14, align 1, !tbaa !9
  %36 = load i8, ptr %10, align 1, !tbaa !9
  %37 = load ptr, ptr %8, align 8, !tbaa !5
  %38 = getelementptr inbounds %struct.QRCode, ptr %37, i32 0, i32 0
  store i8 %36, ptr %38, align 8, !tbaa !12
  %39 = load i8, ptr %14, align 1, !tbaa !9
  %40 = load ptr, ptr %8, align 8, !tbaa !5
  %41 = getelementptr inbounds %struct.QRCode, ptr %40, i32 0, i32 1
  store i8 %39, ptr %41, align 1, !tbaa !14
  %42 = load i8, ptr %11, align 1, !tbaa !9
  %43 = load ptr, ptr %8, align 8, !tbaa !5
  %44 = getelementptr inbounds %struct.QRCode, ptr %43, i32 0, i32 2
  store i8 %42, ptr %44, align 2, !tbaa !15
  %45 = load ptr, ptr %9, align 8, !tbaa !5
  %46 = load ptr, ptr %8, align 8, !tbaa !5
  %47 = getelementptr inbounds %struct.QRCode, ptr %46, i32 0, i32 5
  store ptr %45, ptr %47, align 8, !tbaa !16
  call void @llvm.lifetime.start.p0(i64 1, ptr %15) #2
  %48 = load i8, ptr %11, align 1, !tbaa !9
  %49 = zext i8 %48 to i32
  %50 = mul nsw i32 2, %49
  %51 = ashr i32 177, %50
  %52 = and i32 %51, 3
  %53 = trunc i32 %52 to i8
  store i8 %53, ptr %15, align 1, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 2, ptr %16) #2
  %54 = load i8, ptr %10, align 1, !tbaa !9
  %55 = zext i8 %54 to i32
  %56 = sub nsw i32 %55, 1
  %57 = sext i32 %56 to i64
  %58 = getelementptr inbounds [40 x i16], ptr @NUM_RAW_DATA_MODULES, i64 0, i64 %57
  %59 = load i16, ptr %58, align 2, !tbaa !10
  store i16 %59, ptr %16, align 2, !tbaa !10
  call void @llvm.lifetime.start.p0(i64 2, ptr %17) #2
  %60 = load i16, ptr %16, align 2, !tbaa !10
  %61 = zext i16 %60 to i32
  %62 = sdiv i32 %61, 8
  %63 = load i8, ptr %15, align 1, !tbaa !9
  %64 = zext i8 %63 to i64
  %65 = getelementptr inbounds [4 x [40 x i16]], ptr @NUM_ERROR_CORRECTION_CODEWORDS, i64 0, i64 %64
  %66 = load i8, ptr %10, align 1, !tbaa !9
  %67 = zext i8 %66 to i32
  %68 = sub nsw i32 %67, 1
  %69 = sext i32 %68 to i64
  %70 = getelementptr inbounds [40 x i16], ptr %65, i64 0, i64 %69
  %71 = load i16, ptr %70, align 2, !tbaa !10
  %72 = zext i16 %71 to i32
  %73 = sub nsw i32 %62, %72
  %74 = trunc i32 %73 to i16
  store i16 %74, ptr %17, align 2, !tbaa !10
  call void @llvm.lifetime.start.p0(i64 16, ptr %18) #2
  call void @llvm.lifetime.start.p0(i64 8, ptr %19) #2
  %75 = load i16, ptr %16, align 2, !tbaa !10
  %76 = zext i16 %75 to i32
  %77 = call zeroext i16 @bb_getBufferSizeBytes(i32 noundef %76)
  %78 = zext i16 %77 to i64
  %79 = alloca i8, i64 %78, align 16
  store ptr %79, ptr %19, align 8, !tbaa !5
  %80 = load ptr, ptr %19, align 8, !tbaa !5
  %81 = load i16, ptr %16, align 2, !tbaa !10
  %82 = zext i16 %81 to i32
  %83 = call zeroext i16 @bb_getBufferSizeBytes(i32 noundef %82)
  %84 = zext i16 %83 to i32
  call void @bb_initBuffer(ptr noundef %18, ptr noundef %80, i32 noundef %84)
  call void @llvm.lifetime.start.p0(i64 1, ptr %20) #2
  %85 = load ptr, ptr %12, align 8, !tbaa !5
  %86 = load i16, ptr %13, align 2, !tbaa !10
  %87 = load i8, ptr %10, align 1, !tbaa !9
  %88 = call signext i8 @encodeDataCodewords(ptr noundef %18, ptr noundef %85, i16 noundef zeroext %86, i8 noundef zeroext %87)
  store i8 %88, ptr %20, align 1, !tbaa !9
  %89 = load i8, ptr %20, align 1, !tbaa !9
  %90 = sext i8 %89 to i32
  %91 = icmp slt i32 %90, 0
  br i1 %91, label %92, label %93

92:                                               ; preds = %6
  store i8 -1, ptr %7, align 1
  store i32 1, ptr %21, align 4
  br label %172

93:                                               ; preds = %6
  %94 = load i8, ptr %20, align 1, !tbaa !9
  %95 = load ptr, ptr %8, align 8, !tbaa !5
  %96 = getelementptr inbounds %struct.QRCode, ptr %95, i32 0, i32 3
  store i8 %94, ptr %96, align 1, !tbaa !17
  call void @llvm.lifetime.start.p0(i64 4, ptr %22) #2
  %97 = load i16, ptr %17, align 2, !tbaa !10
  %98 = zext i16 %97 to i32
  %99 = mul nsw i32 %98, 8
  %100 = getelementptr inbounds %struct.BitBucket, ptr %18, i32 0, i32 0
  %101 = load i32, ptr %100, align 8, !tbaa !18
  %102 = sub i32 %99, %101
  store i32 %102, ptr %22, align 4, !tbaa !21
  %103 = load i32, ptr %22, align 4, !tbaa !21
  %104 = icmp ugt i32 %103, 4
  br i1 %104, label %105, label %106

105:                                              ; preds = %93
  store i32 4, ptr %22, align 4, !tbaa !21
  br label %106

106:                                              ; preds = %105, %93
  %107 = load i32, ptr %22, align 4, !tbaa !21
  %108 = trunc i32 %107 to i8
  call void @bb_appendBits(ptr noundef %18, i32 noundef 0, i8 noundef zeroext %108)
  %109 = getelementptr inbounds %struct.BitBucket, ptr %18, i32 0, i32 0
  %110 = load i32, ptr %109, align 8, !tbaa !18
  %111 = urem i32 %110, 8
  %112 = sub i32 8, %111
  %113 = urem i32 %112, 8
  %114 = trunc i32 %113 to i8
  call void @bb_appendBits(ptr noundef %18, i32 noundef 0, i8 noundef zeroext %114)
  call void @llvm.lifetime.start.p0(i64 1, ptr %23) #2
  store i8 -20, ptr %23, align 1, !tbaa !9
  br label %115

115:                                              ; preds = %126, %106
  %116 = getelementptr inbounds %struct.BitBucket, ptr %18, i32 0, i32 0
  %117 = load i32, ptr %116, align 8, !tbaa !18
  %118 = load i16, ptr %17, align 2, !tbaa !10
  %119 = zext i16 %118 to i32
  %120 = mul nsw i32 %119, 8
  %121 = icmp ult i32 %117, %120
  br i1 %121, label %123, label %122

122:                                              ; preds = %115
  store i32 2, ptr %21, align 4
  call void @llvm.lifetime.end.p0(i64 1, ptr %23) #2
  br label %131

123:                                              ; preds = %115
  %124 = load i8, ptr %23, align 1, !tbaa !9
  %125 = zext i8 %124 to i32
  call void @bb_appendBits(ptr noundef %18, i32 noundef %125, i8 noundef zeroext 8)
  br label %126

126:                                              ; preds = %123
  %127 = load i8, ptr %23, align 1, !tbaa !9
  %128 = zext i8 %127 to i32
  %129 = xor i32 %128, 253
  %130 = trunc i32 %129 to i8
  store i8 %130, ptr %23, align 1, !tbaa !9
  br label %115, !llvm.loop !22

131:                                              ; preds = %122
  call void @llvm.lifetime.start.p0(i64 16, ptr %24) #2
  %132 = load ptr, ptr %9, align 8, !tbaa !5
  %133 = load i8, ptr %14, align 1, !tbaa !9
  call void @bb_initGrid(ptr noundef %24, ptr noundef %132, i8 noundef zeroext %133)
  call void @llvm.lifetime.start.p0(i64 16, ptr %25) #2
  call void @llvm.lifetime.start.p0(i64 8, ptr %26) #2
  %134 = load i8, ptr %14, align 1, !tbaa !9
  %135 = call zeroext i16 @bb_getGridSizeBytes(i8 noundef zeroext %134)
  %136 = zext i16 %135 to i64
  %137 = alloca i8, i64 %136, align 16
  store ptr %137, ptr %26, align 8, !tbaa !5
  %138 = load ptr, ptr %26, align 8, !tbaa !5
  %139 = load i8, ptr %14, align 1, !tbaa !9
  call void @bb_initGrid(ptr noundef %25, ptr noundef %138, i8 noundef zeroext %139)
  %140 = load i8, ptr %10, align 1, !tbaa !9
  %141 = load i8, ptr %15, align 1, !tbaa !9
  call void @drawFunctionPatterns(ptr noundef %24, ptr noundef %25, i8 noundef zeroext %140, i8 noundef zeroext %141)
  %142 = load i8, ptr %10, align 1, !tbaa !9
  %143 = load i8, ptr %15, align 1, !tbaa !9
  call void @performErrorCorrection(i8 noundef zeroext %142, i8 noundef zeroext %143, ptr noundef %18)
  call void @drawCodewords(ptr noundef %24, ptr noundef %25, ptr noundef %18)
  call void @llvm.lifetime.start.p0(i64 1, ptr %27) #2
  store i8 0, ptr %27, align 1, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %28) #2
  store i32 2147483647, ptr %28, align 4, !tbaa !21
  call void @llvm.lifetime.start.p0(i64 1, ptr %29) #2
  store i8 0, ptr %29, align 1, !tbaa !9
  br label %144

144:                                              ; preds = %162, %131
  %145 = load i8, ptr %29, align 1, !tbaa !9
  %146 = zext i8 %145 to i32
  %147 = icmp slt i32 %146, 8
  br i1 %147, label %149, label %148

148:                                              ; preds = %144
  store i32 5, ptr %21, align 4
  call void @llvm.lifetime.end.p0(i64 1, ptr %29) #2
  br label %165

149:                                              ; preds = %144
  %150 = load i8, ptr %15, align 1, !tbaa !9
  %151 = load i8, ptr %29, align 1, !tbaa !9
  call void @drawFormatBits(ptr noundef %24, ptr noundef %25, i8 noundef zeroext %150, i8 noundef zeroext %151)
  %152 = load i8, ptr %29, align 1, !tbaa !9
  call void @applyMask(ptr noundef %24, ptr noundef %25, i8 noundef zeroext %152)
  call void @llvm.lifetime.start.p0(i64 4, ptr %30) #2
  %153 = call i32 @getPenaltyScore(ptr noundef %24)
  store i32 %153, ptr %30, align 4, !tbaa !21
  %154 = load i32, ptr %30, align 4, !tbaa !21
  %155 = load i32, ptr %28, align 4, !tbaa !21
  %156 = icmp slt i32 %154, %155
  br i1 %156, label %157, label %160

157:                                              ; preds = %149
  %158 = load i8, ptr %29, align 1, !tbaa !9
  store i8 %158, ptr %27, align 1, !tbaa !9
  %159 = load i32, ptr %30, align 4, !tbaa !21
  store i32 %159, ptr %28, align 4, !tbaa !21
  br label %160

160:                                              ; preds = %157, %149
  %161 = load i8, ptr %29, align 1, !tbaa !9
  call void @applyMask(ptr noundef %24, ptr noundef %25, i8 noundef zeroext %161)
  call void @llvm.lifetime.end.p0(i64 4, ptr %30) #2
  br label %162

162:                                              ; preds = %160
  %163 = load i8, ptr %29, align 1, !tbaa !9
  %164 = add i8 %163, 1
  store i8 %164, ptr %29, align 1, !tbaa !9
  br label %144, !llvm.loop !24

165:                                              ; preds = %148
  %166 = load i8, ptr %27, align 1, !tbaa !9
  %167 = load ptr, ptr %8, align 8, !tbaa !5
  %168 = getelementptr inbounds %struct.QRCode, ptr %167, i32 0, i32 4
  store i8 %166, ptr %168, align 4, !tbaa !25
  %169 = load i8, ptr %15, align 1, !tbaa !9
  %170 = load i8, ptr %27, align 1, !tbaa !9
  call void @drawFormatBits(ptr noundef %24, ptr noundef %25, i8 noundef zeroext %169, i8 noundef zeroext %170)
  %171 = load i8, ptr %27, align 1, !tbaa !9
  call void @applyMask(ptr noundef %24, ptr noundef %25, i8 noundef zeroext %171)
  store i8 0, ptr %7, align 1
  store i32 1, ptr %21, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %28) #2
  call void @llvm.lifetime.end.p0(i64 1, ptr %27) #2
  call void @llvm.lifetime.end.p0(i64 8, ptr %26) #2
  call void @llvm.lifetime.end.p0(i64 16, ptr %25) #2
  call void @llvm.lifetime.end.p0(i64 16, ptr %24) #2
  call void @llvm.lifetime.end.p0(i64 4, ptr %22) #2
  br label %172

172:                                              ; preds = %165, %92
  call void @llvm.lifetime.end.p0(i64 1, ptr %20) #2
  call void @llvm.lifetime.end.p0(i64 8, ptr %19) #2
  call void @llvm.lifetime.end.p0(i64 16, ptr %18) #2
  call void @llvm.lifetime.end.p0(i64 2, ptr %17) #2
  call void @llvm.lifetime.end.p0(i64 2, ptr %16) #2
  call void @llvm.lifetime.end.p0(i64 1, ptr %15) #2
  call void @llvm.lifetime.end.p0(i64 1, ptr %14) #2
  %173 = load i8, ptr %7, align 1
  ret i8 %173
}

; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture) #1

; Function Attrs: nounwind uwtable
declare hidden zeroext i16 @bb_getBufferSizeBytes(i32 noundef) #0

; Function Attrs: nounwind uwtable
declare hidden void @bb_initBuffer(ptr noundef, ptr noundef, i32 noundef) #0

; Function Attrs: nounwind uwtable
declare hidden signext i8 @encodeDataCodewords(ptr noundef, ptr noundef, i16 noundef zeroext, i8 noundef zeroext) #0

; Function Attrs: nounwind uwtable
declare hidden void @bb_appendBits(ptr noundef, i32 noundef, i8 noundef zeroext) #0

; 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
declare hidden void @bb_initGrid(ptr noundef, ptr noundef, i8 noundef zeroext) #0

; Function Attrs: nounwind uwtable
declare hidden void @drawFunctionPatterns(ptr noundef, ptr noundef, i8 noundef zeroext, i8 noundef zeroext) #0

; Function Attrs: nounwind uwtable
declare hidden void @performErrorCorrection(i8 noundef zeroext, i8 noundef zeroext, ptr noundef) #0

; Function Attrs: nounwind uwtable
declare hidden void @drawCodewords(ptr noundef, ptr noundef, ptr noundef) #0

; Function Attrs: nounwind uwtable
declare hidden void @drawFormatBits(ptr noundef, ptr noundef, i8 noundef zeroext, i8 noundef zeroext) #0

; Function Attrs: nounwind uwtable
declare hidden void @applyMask(ptr noundef, ptr noundef, i8 noundef zeroext) #0

; Function Attrs: nounwind uwtable
declare hidden i32 @getPenaltyScore(ptr noundef) #0

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 = !{!7, !7, i64 0}
!10 = !{!11, !11, i64 0}
!11 = !{!"short", !7, i64 0}
!12 = !{!13, !7, i64 0}
!13 = !{!"QRCode", !7, i64 0, !7, i64 1, !7, i64 2, !7, i64 3, !7, i64 4, !6, i64 8}
!14 = !{!13, !7, i64 1}
!15 = !{!13, !7, i64 2}
!16 = !{!13, !6, i64 8}
!17 = !{!13, !7, i64 3}
!18 = !{!19, !20, i64 0}
!19 = !{!"BitBucket", !20, i64 0, !11, i64 4, !6, i64 8}
!20 = !{!"int", !7, i64 0}
!21 = !{!20, !20, i64 0}
!22 = distinct !{!22, !23}
!23 = !{!"llvm.loop.mustprogress"}
!24 = distinct !{!24, !23}
!25 = !{!13, !7, i64 4}


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

%struct.BitBucket = type { i32, i16, ptr }

@NUM_RAW_DATA_MODULES = external hidden local_unnamed_addr constant [40 x i16], align 16
@NUM_ERROR_CORRECTION_CODEWORDS = external hidden local_unnamed_addr constant [4 x [40 x i16]], align 16

; Function Attrs: nounwind uwtable
declare hidden zeroext i16 @bb_getGridSizeBytes(i8 noundef zeroext) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
define dso_local signext range(i8 -1, 1) i8 @qrcode_initBytes(ptr nocapture noundef writeonly %0, ptr noundef %1, i8 noundef zeroext %2, i8 noundef zeroext %3, ptr noundef %4, i16 noundef zeroext %5) local_unnamed_addr #0 {
  %7 = alloca %struct.BitBucket, align 8
  %8 = alloca %struct.BitBucket, align 8
  %9 = alloca %struct.BitBucket, align 8
  %10 = zext i8 %2 to i64
  %11 = shl i8 %2, 2
  %12 = add i8 %11, 17
  store i8 %2, ptr %0, align 8, !tbaa !5
  %13 = getelementptr inbounds i8, ptr %0, i64 1
  store i8 %12, ptr %13, align 1, !tbaa !10
  %14 = getelementptr inbounds i8, ptr %0, i64 2
  store i8 %3, ptr %14, align 2, !tbaa !11
  %15 = getelementptr inbounds i8, ptr %0, i64 8
  store ptr %1, ptr %15, align 8, !tbaa !12
  %16 = zext i8 %3 to i32
  %17 = shl nuw nsw i32 %16, 1
  %18 = lshr i32 177, %17
  %19 = trunc nuw i32 %18 to i8
  %20 = and i8 %19, 3
  %21 = add nsw i64 %10, -1
  %22 = getelementptr inbounds [40 x i16], ptr @NUM_RAW_DATA_MODULES, i64 0, i64 %21
  %23 = load i16, ptr %22, align 2, !tbaa !13
  %24 = zext i16 %23 to i32
  %25 = zext nneg i8 %20 to i64
  %26 = getelementptr inbounds [4 x [40 x i16]], ptr @NUM_ERROR_CORRECTION_CODEWORDS, i64 0, i64 %25, i64 %21
  %27 = load i16, ptr %26, align 2, !tbaa !13
  call void @llvm.lifetime.start.p0(i64 16, ptr nonnull %7) #3
  %28 = tail call zeroext i16 @bb_getBufferSizeBytes(i32 noundef %24)
  %29 = zext i16 %28 to i64
  %30 = alloca i8, i64 %29, align 16
  %31 = tail call zeroext i16 @bb_getBufferSizeBytes(i32 noundef %24)
  %32 = zext i16 %31 to i32
  call void @bb_initBuffer(ptr noundef nonnull %7, ptr noundef nonnull %30, i32 noundef %32)
  %33 = call signext i8 @encodeDataCodewords(ptr noundef nonnull %7, ptr noundef %4, i16 noundef zeroext %5, i8 noundef zeroext %2)
  %34 = icmp slt i8 %33, 0
  br i1 %34, label %72, label %35

35:                                               ; preds = %6
  %36 = lshr i16 %23, 3
  %37 = sub i16 %36, %27
  %38 = getelementptr inbounds i8, ptr %0, i64 3
  store i8 %33, ptr %38, align 1, !tbaa !15
  %39 = zext i16 %37 to i32
  %40 = shl nuw nsw i32 %39, 3
  %41 = load i32, ptr %7, align 8, !tbaa !16
  %42 = sub i32 %40, %41
  %spec.store.select = call i32 @llvm.umin.i32(i32 %42, i32 4)
  %43 = trunc nuw nsw i32 %spec.store.select to i8
  call void @bb_appendBits(ptr noundef nonnull %7, i32 noundef 0, i8 noundef zeroext %43)
  %44 = load i32, ptr %7, align 8, !tbaa !16
  %45 = trunc i32 %44 to i8
  %46 = sub i8 0, %45
  %47 = and i8 %46, 7
  call void @bb_appendBits(ptr noundef nonnull %7, i32 noundef 0, i8 noundef zeroext %47)
  %48 = load i32, ptr %7, align 8, !tbaa !16
  %49 = icmp ult i32 %48, %40
  br i1 %49, label %.lr.ph, label %._crit_edge

._crit_edge:                                      ; preds = %.lr.ph, %35
  call void @llvm.lifetime.start.p0(i64 16, ptr nonnull %8) #3
  call void @bb_initGrid(ptr noundef nonnull %8, ptr noundef %1, i8 noundef zeroext %12)
  call void @llvm.lifetime.start.p0(i64 16, ptr nonnull %9) #3
  %50 = call zeroext i16 @bb_getGridSizeBytes(i8 noundef zeroext %12)
  %51 = zext i16 %50 to i64
  %52 = alloca i8, i64 %51, align 16
  call void @bb_initGrid(ptr noundef nonnull %9, ptr noundef nonnull %52, i8 noundef zeroext %12)
  call void @drawFunctionPatterns(ptr noundef nonnull %8, ptr noundef nonnull %9, i8 noundef zeroext %2, i8 noundef zeroext %20)
  call void @performErrorCorrection(i8 noundef zeroext %2, i8 noundef zeroext %20, ptr noundef nonnull %7)
  call void @drawCodewords(ptr noundef nonnull %8, ptr noundef nonnull %9, ptr noundef nonnull %7)
  call void @drawFormatBits(ptr noundef nonnull %8, ptr noundef nonnull %9, i8 noundef zeroext %20, i8 noundef zeroext 0)
  call void @applyMask(ptr noundef nonnull %8, ptr noundef nonnull %9, i8 noundef zeroext 0)
  %53 = call i32 @getPenaltyScore(ptr noundef nonnull %8)
  call void @applyMask(ptr noundef nonnull %8, ptr noundef nonnull %9, i8 noundef zeroext 0)
  call void @drawFormatBits(ptr noundef nonnull %8, ptr noundef nonnull %9, i8 noundef zeroext %20, i8 noundef zeroext 1)
  call void @applyMask(ptr noundef nonnull %8, ptr noundef nonnull %9, i8 noundef zeroext 1)
  %54 = call i32 @getPenaltyScore(ptr noundef nonnull %8)
  %55 = icmp slt i32 %54, %53
  %spec.select.1 = zext i1 %55 to i8
  %spec.select59.1 = call i32 @llvm.smin.i32(i32 %54, i32 %53)
  call void @applyMask(ptr noundef nonnull %8, ptr noundef nonnull %9, i8 noundef zeroext 1)
  call void @drawFormatBits(ptr noundef nonnull %8, ptr noundef nonnull %9, i8 noundef zeroext %20, i8 noundef zeroext 2)
  call void @applyMask(ptr noundef nonnull %8, ptr noundef nonnull %9, i8 noundef zeroext 2)
  %56 = call i32 @getPenaltyScore(ptr noundef nonnull %8)
  %57 = icmp slt i32 %56, %spec.select59.1
  %spec.select.2 = select i1 %57, i8 2, i8 %spec.select.1
  %spec.select59.2 = call i32 @llvm.smin.i32(i32 %56, i32 %spec.select59.1)
  call void @applyMask(ptr noundef nonnull %8, ptr noundef nonnull %9, i8 noundef zeroext 2)
  call void @drawFormatBits(ptr noundef nonnull %8, ptr noundef nonnull %9, i8 noundef zeroext %20, i8 noundef zeroext 3)
  call void @applyMask(ptr noundef nonnull %8, ptr noundef nonnull %9, i8 noundef zeroext 3)
  %58 = call i32 @getPenaltyScore(ptr noundef nonnull %8)
  %59 = icmp slt i32 %58, %spec.select59.2
  %spec.select.3 = select i1 %59, i8 3, i8 %spec.select.2
  %spec.select59.3 = call i32 @llvm.smin.i32(i32 %58, i32 %spec.select59.2)
  call void @applyMask(ptr noundef nonnull %8, ptr noundef nonnull %9, i8 noundef zeroext 3)
  call void @drawFormatBits(ptr noundef nonnull %8, ptr noundef nonnull %9, i8 noundef zeroext %20, i8 noundef zeroext 4)
  call void @applyMask(ptr noundef nonnull %8, ptr noundef nonnull %9, i8 noundef zeroext 4)
  %60 = call i32 @getPenaltyScore(ptr noundef nonnull %8)
  %61 = icmp slt i32 %60, %spec.select59.3
  %spec.select.4 = select i1 %61, i8 4, i8 %spec.select.3
  %spec.select59.4 = call i32 @llvm.smin.i32(i32 %60, i32 %spec.select59.3)
  call void @applyMask(ptr noundef nonnull %8, ptr noundef nonnull %9, i8 noundef zeroext 4)
  call void @drawFormatBits(ptr noundef nonnull %8, ptr noundef nonnull %9, i8 noundef zeroext %20, i8 noundef zeroext 5)
  call void @applyMask(ptr noundef nonnull %8, ptr noundef nonnull %9, i8 noundef zeroext 5)
  %62 = call i32 @getPenaltyScore(ptr noundef nonnull %8)
  %63 = icmp slt i32 %62, %spec.select59.4
  %spec.select.5 = select i1 %63, i8 5, i8 %spec.select.4
  %spec.select59.5 = call i32 @llvm.smin.i32(i32 %62, i32 %spec.select59.4)
  call void @applyMask(ptr noundef nonnull %8, ptr noundef nonnull %9, i8 noundef zeroext 5)
  call void @drawFormatBits(ptr noundef nonnull %8, ptr noundef nonnull %9, i8 noundef zeroext %20, i8 noundef zeroext 6)
  call void @applyMask(ptr noundef nonnull %8, ptr noundef nonnull %9, i8 noundef zeroext 6)
  %64 = call i32 @getPenaltyScore(ptr noundef nonnull %8)
  %65 = icmp slt i32 %64, %spec.select59.5
  %spec.select.6 = select i1 %65, i8 6, i8 %spec.select.5
  %spec.select59.6 = call i32 @llvm.smin.i32(i32 %64, i32 %spec.select59.5)
  call void @applyMask(ptr noundef nonnull %8, ptr noundef nonnull %9, i8 noundef zeroext 6)
  call void @drawFormatBits(ptr noundef nonnull %8, ptr noundef nonnull %9, i8 noundef zeroext %20, i8 noundef zeroext 7)
  call void @applyMask(ptr noundef nonnull %8, ptr noundef nonnull %9, i8 noundef zeroext 7)
  %66 = call i32 @getPenaltyScore(ptr noundef nonnull %8)
  %67 = icmp slt i32 %66, %spec.select59.6
  %spec.select.7 = select i1 %67, i8 7, i8 %spec.select.6
  call void @applyMask(ptr noundef nonnull %8, ptr noundef nonnull %9, i8 noundef zeroext 7)
  %68 = getelementptr inbounds i8, ptr %0, i64 4
  store i8 %spec.select.7, ptr %68, align 4, !tbaa !19
  call void @drawFormatBits(ptr noundef nonnull %8, ptr noundef nonnull %9, i8 noundef zeroext %20, i8 noundef zeroext %spec.select.7)
  call void @applyMask(ptr noundef nonnull %8, ptr noundef nonnull %9, i8 noundef zeroext %spec.select.7)
  call void @llvm.lifetime.end.p0(i64 16, ptr nonnull %9) #3
  call void @llvm.lifetime.end.p0(i64 16, ptr nonnull %8) #3
  br label %72

.lr.ph:                                           ; preds = %35, %.lr.ph
  %.05760 = phi i32 [ %69, %.lr.ph ], [ 236, %35 ]
  call void @bb_appendBits(ptr noundef nonnull %7, i32 noundef %.05760, i8 noundef zeroext 8)
  %69 = xor i32 %.05760, 253
  %70 = load i32, ptr %7, align 8, !tbaa !16
  %71 = icmp ult i32 %70, %40
  br i1 %71, label %.lr.ph, label %._crit_edge, !llvm.loop !20

72:                                               ; preds = %6, %._crit_edge
  %.0 = phi i8 [ 0, %._crit_edge ], [ -1, %6 ]
  call void @llvm.lifetime.end.p0(i64 16, ptr nonnull %7) #3
  ret i8 %.0
}

; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture) #1

; Function Attrs: nounwind uwtable
declare hidden zeroext i16 @bb_getBufferSizeBytes(i32 noundef) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
declare hidden void @bb_initBuffer(ptr noundef, ptr noundef, i32 noundef) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
declare hidden signext i8 @encodeDataCodewords(ptr noundef, ptr noundef, i16 noundef zeroext, i8 noundef zeroext) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
declare hidden void @bb_appendBits(ptr noundef, i32 noundef, i8 noundef zeroext) local_unnamed_addr #0

; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #1

; Function Attrs: nounwind uwtable
declare hidden void @bb_initGrid(ptr noundef, ptr noundef, i8 noundef zeroext) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
declare hidden void @drawFunctionPatterns(ptr noundef, ptr noundef, i8 noundef zeroext, i8 noundef zeroext) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
declare hidden void @performErrorCorrection(i8 noundef zeroext, i8 noundef zeroext, ptr noundef) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
declare hidden void @drawCodewords(ptr noundef, ptr noundef, ptr noundef) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
declare hidden void @drawFormatBits(ptr noundef, ptr noundef, i8 noundef zeroext, i8 noundef zeroext) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
declare hidden void @applyMask(ptr noundef, ptr noundef, i8 noundef zeroext) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
declare hidden i32 @getPenaltyScore(ptr noundef) local_unnamed_addr #0

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare i32 @llvm.umin.i32(i32, i32) #2

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare i32 @llvm.smin.i32(i32, i32) #2

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 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #3 = { 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, !7, i64 0}
!6 = !{!"QRCode", !7, i64 0, !7, i64 1, !7, i64 2, !7, i64 3, !7, i64 4, !9, i64 8}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!"any pointer", !7, i64 0}
!10 = !{!6, !7, i64 1}
!11 = !{!6, !7, i64 2}
!12 = !{!6, !9, i64 8}
!13 = !{!14, !14, i64 0}
!14 = !{!"short", !7, i64 0}
!15 = !{!6, !7, i64 3}
!16 = !{!17, !18, i64 0}
!17 = !{!"BitBucket", !18, i64 0, !14, i64 4, !9, i64 8}
!18 = !{!"int", !7, i64 0}
!19 = !{!6, !7, i64 4}
!20 = distinct !{!20, !21}
!21 = !{!"llvm.loop.mustprogress"}


; Effective O3 passes: EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,LCSSAPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass,TailCallElimPass