; LLVM IR from johnb003/PlasmaSim :: src/font.ll (ZN4FontC2EPKci)

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

%class.Font = type { i32, i32 }

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN4FontC2EPKci(ptr noundef nonnull align 4 dereferenceable(8) %0, ptr noundef %1, i32 noundef %2) unnamed_addr #0 align 2 {
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca i32, align 4
  %7 = alloca i32, align 4
  %8 = alloca float, align 4
  %9 = alloca float, align 4
  %10 = alloca i32, align 4
  store ptr %0, ptr %4, align 8, !tbaa !5
  store ptr %1, ptr %5, align 8, !tbaa !5
  store i32 %2, ptr %6, align 4, !tbaa !9
  %11 = load ptr, ptr %4, align 8
  %12 = getelementptr inbounds %class.Font, ptr %11, i32 0, i32 1
  %13 = load i32, ptr %6, align 4, !tbaa !9
  store i32 %13, ptr %12, align 4, !tbaa !11
  %14 = load ptr, ptr %5, align 8, !tbaa !5
  %15 = call noundef i32 @_Z11LoadTexturePKcb(ptr noundef %14, i1 noundef zeroext false)
  %16 = getelementptr inbounds %class.Font, ptr %11, i32 0, i32 0
  store i32 %15, ptr %16, align 4, !tbaa !13
  %17 = getelementptr inbounds %class.Font, ptr %11, i32 0, i32 0
  %18 = load i32, ptr %17, align 4, !tbaa !13
  %19 = icmp ne i32 %18, 0
  br i1 %19, label %21, label %20

20:                                               ; preds = %3
  br label %70

21:                                               ; preds = %3
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #3
  %22 = call i32 @glGenLists(i32 noundef 257)
  store i32 %22, ptr %7, align 4, !tbaa !9
  call void @glNewList(i32 noundef 9, i32 noundef 4864)
  %23 = load i32, ptr %6, align 4, !tbaa !9
  %24 = sitofp i32 %23 to float
  %25 = fmul float 0x3FE3333340000000, %24
  %26 = fmul float %25, 4.000000e+00
  call void @glTranslatef(float noundef %26, float noundef 0.000000e+00, float noundef 0.000000e+00)
  call void @glEndList()
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #3
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #3
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #3
  store i32 0, ptr %10, align 4, !tbaa !9
  br label %27

27:                                               ; preds = %66, %21
  %28 = load i32, ptr %10, align 4, !tbaa !9
  %29 = icmp slt i32 %28, 256
  br i1 %29, label %31, label %30

30:                                               ; preds = %27
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #3
  br label %69

31:                                               ; preds = %27
  %32 = load i32, ptr %10, align 4, !tbaa !9
  %33 = srem i32 %32, 16
  %34 = sitofp i32 %33 to float
  %35 = fdiv float %34, 1.600000e+01
  store float %35, ptr %8, align 4, !tbaa !14
  %36 = load i32, ptr %10, align 4, !tbaa !9
  %37 = sdiv i32 %36, 16
  %38 = sitofp i32 %37 to float
  %39 = fdiv float %38, 1.600000e+01
  %40 = fadd float %39, 0x3F50624DE0000000
  store float %40, ptr %9, align 4, !tbaa !14
  %41 = load i32, ptr %10, align 4, !tbaa !9
  %42 = add nsw i32 32, %41
  call void @glNewList(i32 noundef %42, i32 noundef 4864)
  call void @glBegin(i32 noundef 7)
  %43 = load float, ptr %8, align 4, !tbaa !14
  %44 = load float, ptr %9, align 4, !tbaa !14
  call void @glTexCoord2f(float noundef %43, float noundef %44)
  call void @glVertex2d(double noundef 0.000000e+00, double noundef 0.000000e+00)
  %45 = load float, ptr %8, align 4, !tbaa !14
  %46 = load float, ptr %9, align 4, !tbaa !14
  %47 = fadd float %46, 6.250000e-02
  call void @glTexCoord2f(float noundef %45, float noundef %47)
  %48 = load i32, ptr %6, align 4, !tbaa !9
  %49 = sitofp i32 %48 to double
  call void @glVertex2d(double noundef 0.000000e+00, double noundef %49)
  %50 = load float, ptr %8, align 4, !tbaa !14
  %51 = fadd float %50, 6.250000e-02
  %52 = load float, ptr %9, align 4, !tbaa !14
  %53 = fadd float %52, 6.250000e-02
  call void @glTexCoord2f(float noundef %51, float noundef %53)
  %54 = load i32, ptr %6, align 4, !tbaa !9
  %55 = sitofp i32 %54 to double
  %56 = load i32, ptr %6, align 4, !tbaa !9
  %57 = sitofp i32 %56 to double
  call void @glVertex2d(double noundef %55, double noundef %57)
  %58 = load float, ptr %8, align 4, !tbaa !14
  %59 = fadd float %58, 6.250000e-02
  %60 = load float, ptr %9, align 4, !tbaa !14
  call void @glTexCoord2f(float noundef %59, float noundef %60)
  %61 = load i32, ptr %6, align 4, !tbaa !9
  %62 = sitofp i32 %61 to double
  call void @glVertex2d(double noundef %62, double noundef 0.000000e+00)
  call void @glEnd()
  %63 = load i32, ptr %6, align 4, !tbaa !9
  %64 = sitofp i32 %63 to float
  %65 = fmul float 0x3FE3333340000000, %64
  call void @glTranslatef(float noundef %65, float noundef 0.000000e+00, float noundef 0.000000e+00)
  call void @glEndList()
  br label %66

66:                                               ; preds = %31
  %67 = load i32, ptr %10, align 4, !tbaa !9
  %68 = add nsw i32 %67, 1
  store i32 %68, ptr %10, align 4, !tbaa !9
  br label %27, !llvm.loop !16

69:                                               ; preds = %30
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #3
  br label %70

70:                                               ; preds = %69, %20
  ret void
}

declare noundef i32 @_Z11LoadTexturePKcb(ptr noundef, i1 noundef zeroext) #1

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

declare i32 @glGenLists(i32 noundef) #1

declare void @glNewList(i32 noundef, i32 noundef) #1

declare void @glTranslatef(float noundef, float noundef, float noundef) #1

declare void @glEndList() #1

declare void @glBegin(i32 noundef) #1

declare void @glTexCoord2f(float noundef, float noundef) #1

declare void @glVertex2d(double noundef, double noundef) #1

declare void @glEnd() #1

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

attributes #0 = { mustprogress 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 = { "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 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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, !6, i64 0}
!6 = !{!"any pointer", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"int", !7, i64 0}
!11 = !{!12, !10, i64 4}
!12 = !{!"_ZTS4Font", !10, i64 0, !10, i64 4}
!13 = !{!12, !10, i64 0}
!14 = !{!15, !15, i64 0}
!15 = !{!"float", !7, i64 0}
!16 = distinct !{!16, !17}
!17 = !{!"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 uwtable
define dso_local void @_ZN4FontC2EPKci(ptr nocapture noundef nonnull writeonly align 4 dereferenceable(8) %0, ptr noundef %1, i32 noundef %2) unnamed_addr #0 align 2 {
  %4 = getelementptr inbounds i8, ptr %0, i64 4
  store i32 %2, ptr %4, align 4, !tbaa !5
  %5 = tail call noundef i32 @_Z11LoadTexturePKcb(ptr noundef %1, i1 noundef zeroext false)
  store i32 %5, ptr %0, align 4, !tbaa !10
  %.not = icmp eq i32 %5, 0
  br i1 %.not, label %.loopexit, label %6

6:                                                ; preds = %3
  %7 = tail call i32 @glGenLists(i32 noundef 257)
  tail call void @glNewList(i32 noundef 9, i32 noundef 4864)
  %8 = sitofp i32 %2 to float
  %9 = fmul float %8, 0x3FE3333340000000
  %10 = fmul float %9, 4.000000e+00
  tail call void @glTranslatef(float noundef %10, float noundef 0.000000e+00, float noundef 0.000000e+00)
  tail call void @glEndList()
  %11 = sitofp i32 %2 to double
  br label %12

12:                                               ; preds = %6, %12
  %.021 = phi i32 [ 0, %6 ], [ %23, %12 ]
  %13 = and i32 %.021, 15
  %14 = uitofp nneg i32 %13 to float
  %15 = fmul float %14, 6.250000e-02
  %16 = lshr i32 %.021, 4
  %17 = uitofp nneg i32 %16 to float
  %18 = fmul float %17, 6.250000e-02
  %19 = fadd float %18, 0x3F50624DE0000000
  %20 = add nuw nsw i32 %.021, 32
  tail call void @glNewList(i32 noundef %20, i32 noundef 4864)
  tail call void @glBegin(i32 noundef 7)
  tail call void @glTexCoord2f(float noundef %15, float noundef %19)
  tail call void @glVertex2d(double noundef 0.000000e+00, double noundef 0.000000e+00)
  %21 = fadd float %19, 6.250000e-02
  tail call void @glTexCoord2f(float noundef %15, float noundef %21)
  tail call void @glVertex2d(double noundef 0.000000e+00, double noundef %11)
  %22 = fadd float %15, 6.250000e-02
  tail call void @glTexCoord2f(float noundef %22, float noundef %21)
  tail call void @glVertex2d(double noundef %11, double noundef %11)
  tail call void @glTexCoord2f(float noundef %22, float noundef %19)
  tail call void @glVertex2d(double noundef %11, double noundef 0.000000e+00)
  tail call void @glEnd()
  tail call void @glTranslatef(float noundef %9, float noundef 0.000000e+00, float noundef 0.000000e+00)
  tail call void @glEndList()
  %23 = add nuw nsw i32 %.021, 1
  %exitcond.not = icmp eq i32 %23, 256
  br i1 %exitcond.not, label %.loopexit, label %12, !llvm.loop !11

.loopexit:                                        ; preds = %12, %3
  ret void
}

declare noundef i32 @_Z11LoadTexturePKcb(ptr noundef, i1 noundef zeroext) local_unnamed_addr #1

declare i32 @glGenLists(i32 noundef) local_unnamed_addr #1

declare void @glNewList(i32 noundef, i32 noundef) local_unnamed_addr #1

declare void @glTranslatef(float noundef, float noundef, float noundef) local_unnamed_addr #1

declare void @glEndList() local_unnamed_addr #1

declare void @glBegin(i32 noundef) local_unnamed_addr #1

declare void @glTexCoord2f(float noundef, float noundef) local_unnamed_addr #1

declare void @glVertex2d(double noundef, double noundef) local_unnamed_addr #1

declare void @glEnd() local_unnamed_addr #1

attributes #0 = { mustprogress 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 = { "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, !7, i64 4}
!6 = !{!"_ZTS4Font", !7, i64 0, !7, i64 4}
!7 = !{!"int", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C++ TBAA"}
!10 = !{!6, !7, i64 0}
!11 = distinct !{!11, !12}
!12 = !{!"llvm.loop.mustprogress"}


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