; LLVM IR from EyalAr/lwip :: src/lib/gif (gif_font)

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

@.str = external hidden unnamed_addr constant [3 x i8], align 1

; Function Attrs: nounwind uwtable
declare dso_local void @GifDrawText8x8(ptr noundef, i32 noundef, i32 noundef, ptr 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
declare dso_local void @GifDrawBox(ptr noundef, i32 noundef, i32 noundef, i32 noundef, i32 noundef, i32 noundef) #0

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

; Function Attrs: nounwind uwtable
define dso_local void @GifDrawBoxedText8x8(ptr noundef %0, i32 noundef %1, i32 noundef %2, ptr noundef %3, i32 noundef %4, i32 noundef %5, i32 noundef %6) #0 {
  %8 = alloca ptr, align 8
  %9 = alloca i32, align 4
  %10 = alloca i32, align 4
  %11 = alloca ptr, align 8
  %12 = alloca i32, align 4
  %13 = alloca i32, align 4
  %14 = alloca i32, align 4
  %15 = alloca i32, align 4
  %16 = alloca i32, align 4
  %17 = alloca i32, align 4
  %18 = alloca i32, align 4
  %19 = alloca ptr, align 8
  %20 = alloca i32, align 4
  store ptr %0, ptr %8, align 8, !tbaa !5
  store i32 %1, ptr %9, align 4, !tbaa !9
  store i32 %2, ptr %10, align 4, !tbaa !9
  store ptr %3, ptr %11, align 8, !tbaa !5
  store i32 %4, ptr %12, align 4, !tbaa !9
  store i32 %5, ptr %13, align 4, !tbaa !9
  store i32 %6, ptr %14, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %15) #4
  call void @llvm.lifetime.start.p0(i64 4, ptr %16) #4
  store i32 0, ptr %16, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %17) #4
  store i32 0, ptr %17, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %18) #4
  store i32 0, ptr %18, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %19) #4
  %21 = load ptr, ptr %11, align 8, !tbaa !5
  store ptr %21, ptr %19, align 8, !tbaa !5
  br label %22

22:                                               ; preds = %50, %7
  %23 = load ptr, ptr %19, align 8, !tbaa !5
  %24 = load i8, ptr %23, align 1, !tbaa !11
  %25 = icmp ne i8 %24, 0
  br i1 %25, label %26, label %53

26:                                               ; preds = %22
  %27 = load ptr, ptr %19, align 8, !tbaa !5
  %28 = load i8, ptr %27, align 1, !tbaa !11
  %29 = sext i8 %28 to i32
  %30 = icmp eq i32 %29, 13
  br i1 %30, label %31, label %40

31:                                               ; preds = %26
  %32 = load i32, ptr %16, align 4, !tbaa !9
  %33 = load i32, ptr %18, align 4, !tbaa !9
  %34 = icmp sgt i32 %32, %33
  br i1 %34, label %35, label %37

35:                                               ; preds = %31
  %36 = load i32, ptr %16, align 4, !tbaa !9
  store i32 %36, ptr %18, align 4, !tbaa !9
  br label %37

37:                                               ; preds = %35, %31
  store i32 0, ptr %16, align 4, !tbaa !9
  %38 = load i32, ptr %17, align 4, !tbaa !9
  %39 = add nsw i32 %38, 1
  store i32 %39, ptr %17, align 4, !tbaa !9
  br label %49

40:                                               ; preds = %26
  %41 = load ptr, ptr %19, align 8, !tbaa !5
  %42 = load i8, ptr %41, align 1, !tbaa !11
  %43 = sext i8 %42 to i32
  %44 = icmp ne i32 %43, 9
  br i1 %44, label %45, label %48

45:                                               ; preds = %40
  %46 = load i32, ptr %16, align 4, !tbaa !9
  %47 = add nsw i32 %46, 1
  store i32 %47, ptr %16, align 4, !tbaa !9
  br label %48

48:                                               ; preds = %45, %40
  br label %49

49:                                               ; preds = %48, %37
  br label %50

50:                                               ; preds = %49
  %51 = load ptr, ptr %19, align 8, !tbaa !5
  %52 = getelementptr inbounds i8, ptr %51, i32 1
  store ptr %52, ptr %19, align 8, !tbaa !5
  br label %22, !llvm.loop !12

53:                                               ; preds = %22
  %54 = load i32, ptr %17, align 4, !tbaa !9
  %55 = add nsw i32 %54, 1
  store i32 %55, ptr %17, align 4, !tbaa !9
  %56 = load i32, ptr %16, align 4, !tbaa !9
  %57 = load i32, ptr %18, align 4, !tbaa !9
  %58 = icmp sgt i32 %56, %57
  br i1 %58, label %59, label %61

59:                                               ; preds = %53
  %60 = load i32, ptr %16, align 4, !tbaa !9
  store i32 %60, ptr %18, align 4, !tbaa !9
  br label %61

61:                                               ; preds = %59, %53
  %62 = load ptr, ptr %8, align 8, !tbaa !5
  %63 = load i32, ptr %9, align 4, !tbaa !9
  %64 = add nsw i32 %63, 1
  %65 = load i32, ptr %10, align 4, !tbaa !9
  %66 = add nsw i32 %65, 1
  %67 = load i32, ptr %12, align 4, !tbaa !9
  %68 = load i32, ptr %18, align 4, !tbaa !9
  %69 = mul nsw i32 %68, 8
  %70 = add nsw i32 %67, %69
  %71 = load i32, ptr %12, align 4, !tbaa !9
  %72 = add nsw i32 %70, %71
  %73 = sub nsw i32 %72, 1
  %74 = load i32, ptr %12, align 4, !tbaa !9
  %75 = load i32, ptr %17, align 4, !tbaa !9
  %76 = mul nsw i32 %75, 8
  %77 = add nsw i32 %74, %76
  %78 = load i32, ptr %12, align 4, !tbaa !9
  %79 = add nsw i32 %77, %78
  %80 = sub nsw i32 %79, 1
  %81 = load i32, ptr %13, align 4, !tbaa !9
  call void @GifDrawRectangle(ptr noundef %62, i32 noundef %64, i32 noundef %66, i32 noundef %73, i32 noundef %80, i32 noundef %81)
  store i32 0, ptr %15, align 4, !tbaa !9
  %82 = load ptr, ptr %11, align 8, !tbaa !5
  %83 = call ptr @strtok(ptr noundef %82, ptr noundef @.str) #4
  store ptr %83, ptr %19, align 8, !tbaa !5
  br label %84

84:                                               ; preds = %117, %61
  call void @llvm.lifetime.start.p0(i64 4, ptr %20) #4
  store i32 0, ptr %20, align 4, !tbaa !9
  %85 = load ptr, ptr %19, align 8, !tbaa !5
  %86 = getelementptr inbounds i8, ptr %85, i64 0
  %87 = load i8, ptr %86, align 1, !tbaa !11
  %88 = sext i8 %87 to i32
  %89 = icmp eq i32 %88, 9
  br i1 %89, label %90, label %99

90:                                               ; preds = %84
  %91 = load i32, ptr %18, align 4, !tbaa !9
  %92 = sext i32 %91 to i64
  %93 = load ptr, ptr %19, align 8, !tbaa !5
  %94 = getelementptr inbounds i8, ptr %93, i32 1
  store ptr %94, ptr %19, align 8, !tbaa !5
  %95 = call i64 @strlen(ptr noundef %94) #5
  %96 = sub i64 %92, %95
  %97 = udiv i64 %96, 2
  %98 = trunc i64 %97 to i32
  store i32 %98, ptr %20, align 4, !tbaa !9
  br label %99

99:                                               ; preds = %90, %84
  %100 = load ptr, ptr %8, align 8, !tbaa !5
  %101 = load i32, ptr %9, align 4, !tbaa !9
  %102 = load i32, ptr %12, align 4, !tbaa !9
  %103 = add nsw i32 %101, %102
  %104 = load i32, ptr %20, align 4, !tbaa !9
  %105 = mul nsw i32 %104, 8
  %106 = add nsw i32 %103, %105
  %107 = load i32, ptr %10, align 4, !tbaa !9
  %108 = load i32, ptr %12, align 4, !tbaa !9
  %109 = add nsw i32 %107, %108
  %110 = load i32, ptr %15, align 4, !tbaa !9
  %111 = add nsw i32 %110, 1
  store i32 %111, ptr %15, align 4, !tbaa !9
  %112 = mul nsw i32 8, %110
  %113 = add nsw i32 %109, %112
  %114 = load ptr, ptr %19, align 8, !tbaa !5
  %115 = load i32, ptr %14, align 4, !tbaa !9
  call void @GifDrawText8x8(ptr noundef %100, i32 noundef %106, i32 noundef %113, ptr noundef %114, i32 noundef %115)
  %116 = call ptr @strtok(ptr noundef null, ptr noundef @.str) #4
  store ptr %116, ptr %19, align 8, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 4, ptr %20) #4
  br label %117

117:                                              ; preds = %99
  %118 = load ptr, ptr %19, align 8, !tbaa !5
  %119 = icmp ne ptr %118, null
  br i1 %119, label %84, label %120, !llvm.loop !14

120:                                              ; preds = %117
  %121 = load ptr, ptr %8, align 8, !tbaa !5
  %122 = load i32, ptr %9, align 4, !tbaa !9
  %123 = load i32, ptr %10, align 4, !tbaa !9
  %124 = load i32, ptr %12, align 4, !tbaa !9
  %125 = load i32, ptr %18, align 4, !tbaa !9
  %126 = mul nsw i32 %125, 8
  %127 = add nsw i32 %124, %126
  %128 = load i32, ptr %12, align 4, !tbaa !9
  %129 = add nsw i32 %127, %128
  %130 = load i32, ptr %12, align 4, !tbaa !9
  %131 = load i32, ptr %17, align 4, !tbaa !9
  %132 = mul nsw i32 %131, 8
  %133 = add nsw i32 %130, %132
  %134 = load i32, ptr %12, align 4, !tbaa !9
  %135 = add nsw i32 %133, %134
  %136 = load i32, ptr %14, align 4, !tbaa !9
  call void @GifDrawBox(ptr noundef %121, i32 noundef %122, i32 noundef %123, i32 noundef %129, i32 noundef %135, i32 noundef %136)
  call void @llvm.lifetime.end.p0(i64 8, ptr %19) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %18) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %17) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %16) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %15) #4
  ret void
}

; Function Attrs: nounwind
declare ptr @strtok(ptr noundef, ptr noundef) #2

; Function Attrs: nounwind willreturn memory(read)
declare i64 @strlen(ptr noundef) #3

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 "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 #3 = { nounwind willreturn memory(read) "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 #4 = { nounwind }
attributes #5 = { nounwind willreturn memory(read) }

!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"}
!14 = distinct !{!14, !13}


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

@.str = external hidden unnamed_addr constant [3 x i8], align 1

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

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

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

; Function Attrs: nounwind uwtable
define dso_local void @GifDrawBoxedText8x8(ptr noundef %0, i32 noundef %1, i32 noundef %2, ptr noundef %3, i32 noundef %4, i32 noundef %5, i32 noundef %6) local_unnamed_addr #0 {
  br label %8

8:                                                ; preds = %14, %7
  %.053 = phi i32 [ 0, %7 ], [ %.154, %14 ]
  %.051 = phi i32 [ 0, %7 ], [ %.152, %14 ]
  %.048 = phi i32 [ 0, %7 ], [ %.250, %14 ]
  %.047 = phi ptr [ %3, %7 ], [ %15, %14 ]
  %9 = load i8, ptr %.047, align 1, !tbaa !5
  switch i8 %9, label %12 [
    i8 0, label %16
    i8 13, label %10
    i8 9, label %14
  ]

10:                                               ; preds = %8
  %spec.select = tail call i32 @llvm.smax.i32(i32 %.053, i32 %.048)
  %11 = add nsw i32 %.051, 1
  br label %14

12:                                               ; preds = %8
  %13 = add nsw i32 %.053, 1
  br label %14

14:                                               ; preds = %8, %10, %12
  %.154 = phi i32 [ 0, %10 ], [ %13, %12 ], [ %.053, %8 ]
  %.152 = phi i32 [ %11, %10 ], [ %.051, %12 ], [ %.051, %8 ]
  %.250 = phi i32 [ %spec.select, %10 ], [ %.048, %12 ], [ %.048, %8 ]
  %15 = getelementptr inbounds i8, ptr %.047, i64 1
  br label %8, !llvm.loop !8

16:                                               ; preds = %8
  %spec.select62 = tail call i32 @llvm.smax.i32(i32 %.053, i32 %.048)
  %17 = add nsw i32 %1, 1
  %18 = add nsw i32 %2, 1
  %19 = shl nsw i32 %spec.select62, 3
  %reass.add = shl i32 %4, 1
  %20 = add i32 %19, %reass.add
  %21 = add nsw i32 %20, -1
  %22 = shl i32 %.051, 3
  %23 = add i32 %reass.add, 8
  %24 = add i32 %23, %22
  %25 = add nsw i32 %24, -1
  tail call void @GifDrawRectangle(ptr noundef %0, i32 noundef %17, i32 noundef %18, i32 noundef %21, i32 noundef %25, i32 noundef %5)
  %26 = tail call ptr @strtok(ptr noundef %3, ptr noundef nonnull @.str) #4
  %27 = add nsw i32 %4, %1
  %28 = add nsw i32 %4, %2
  %29 = zext nneg i32 %spec.select62 to i64
  br label %30

30:                                               ; preds = %39, %16
  %.055 = phi i32 [ 0, %16 ], [ %42, %39 ]
  %.1 = phi ptr [ %26, %16 ], [ %45, %39 ]
  %31 = load i8, ptr %.1, align 1, !tbaa !5
  %32 = icmp eq i8 %31, 9
  br i1 %32, label %33, label %39

33:                                               ; preds = %30
  %34 = getelementptr inbounds i8, ptr %.1, i64 1
  %35 = tail call i64 @strlen(ptr noundef nonnull dereferenceable(1) %34) #5
  %36 = sub i64 %29, %35
  %37 = lshr i64 %36, 1
  %38 = trunc i64 %37 to i32
  br label %39

39:                                               ; preds = %33, %30
  %.2 = phi ptr [ %34, %33 ], [ %.1, %30 ]
  %.0 = phi i32 [ %38, %33 ], [ 0, %30 ]
  %40 = shl nsw i32 %.0, 3
  %41 = add nsw i32 %27, %40
  %42 = add nuw nsw i32 %.055, 1
  %43 = shl nsw i32 %.055, 3
  %44 = add nsw i32 %28, %43
  tail call void @GifDrawText8x8(ptr noundef %0, i32 noundef %41, i32 noundef %44, ptr noundef nonnull %.2, i32 noundef %6)
  %45 = tail call ptr @strtok(ptr noundef null, ptr noundef nonnull @.str) #4
  %.not60 = icmp eq ptr %45, null
  br i1 %.not60, label %46, label %30, !llvm.loop !10

46:                                               ; preds = %39
  tail call void @GifDrawBox(ptr noundef %0, i32 noundef %1, i32 noundef %2, i32 noundef %20, i32 noundef %24, i32 noundef %6)
  ret void
}

; Function Attrs: mustprogress nofree nounwind willreturn
declare ptr @strtok(ptr noundef, ptr nocapture noundef readonly) local_unnamed_addr #1

; Function Attrs: mustprogress nofree nounwind willreturn memory(argmem: read)
declare i64 @strlen(ptr nocapture noundef) local_unnamed_addr #2

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

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 nofree nounwind willreturn "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 = { mustprogress nofree nounwind willreturn memory(argmem: read) "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 #3 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #4 = { nounwind }
attributes #5 = { nounwind willreturn memory(read) }

!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"}
!10 = distinct !{!10, !9}


; Effective O3 passes: EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,LCSSAPass,LICMPass,LoopUnrollPass,ReassociatePass,SROAPass,SimplifyCFGPass,TailCallElimPass