; LLVM IR from caryll/otfcc :: lib/libcff (charstring-il)

; 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.cff_CharstringIL = type { i32, i32, ptr }
%struct.cff_CharstringInstruction = type { i32, i32, %union.anon }
%union.anon = type { double }

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

; Function Attrs: nounwind uwtable
define dso_local void @il_push_op(ptr noundef %0, i32 noundef %1) #0 {
  %3 = alloca ptr, align 8
  %4 = alloca i32, align 4
  store ptr %0, ptr %3, align 8, !tbaa !5
  store i32 %1, ptr %4, align 4, !tbaa !9
  %5 = load ptr, ptr %3, align 8, !tbaa !5
  call void @ensureThereIsSpace(ptr noundef %5)
  %6 = load ptr, ptr %3, align 8, !tbaa !5
  %7 = getelementptr inbounds %struct.cff_CharstringIL, ptr %6, i32 0, i32 2
  %8 = load ptr, ptr %7, align 8, !tbaa !11
  %9 = load ptr, ptr %3, align 8, !tbaa !5
  %10 = getelementptr inbounds %struct.cff_CharstringIL, ptr %9, i32 0, i32 0
  %11 = load i32, ptr %10, align 8, !tbaa !13
  %12 = zext i32 %11 to i64
  %13 = getelementptr inbounds %struct.cff_CharstringInstruction, ptr %8, i64 %12
  %14 = getelementptr inbounds %struct.cff_CharstringInstruction, ptr %13, i32 0, i32 0
  store i32 1, ptr %14, align 8, !tbaa !14
  %15 = load i32, ptr %4, align 4, !tbaa !9
  %16 = load ptr, ptr %3, align 8, !tbaa !5
  %17 = getelementptr inbounds %struct.cff_CharstringIL, ptr %16, i32 0, i32 2
  %18 = load ptr, ptr %17, align 8, !tbaa !11
  %19 = load ptr, ptr %3, align 8, !tbaa !5
  %20 = getelementptr inbounds %struct.cff_CharstringIL, ptr %19, i32 0, i32 0
  %21 = load i32, ptr %20, align 8, !tbaa !13
  %22 = zext i32 %21 to i64
  %23 = getelementptr inbounds %struct.cff_CharstringInstruction, ptr %18, i64 %22
  %24 = getelementptr inbounds %struct.cff_CharstringInstruction, ptr %23, i32 0, i32 2
  store i32 %15, ptr %24, align 8, !tbaa !16
  %25 = load i32, ptr %4, align 4, !tbaa !9
  %26 = call zeroext i8 @cff_getStandardArity(i32 noundef %25)
  %27 = zext i8 %26 to i32
  %28 = load ptr, ptr %3, align 8, !tbaa !5
  %29 = getelementptr inbounds %struct.cff_CharstringIL, ptr %28, i32 0, i32 2
  %30 = load ptr, ptr %29, align 8, !tbaa !11
  %31 = load ptr, ptr %3, align 8, !tbaa !5
  %32 = getelementptr inbounds %struct.cff_CharstringIL, ptr %31, i32 0, i32 0
  %33 = load i32, ptr %32, align 8, !tbaa !13
  %34 = zext i32 %33 to i64
  %35 = getelementptr inbounds %struct.cff_CharstringInstruction, ptr %30, i64 %34
  %36 = getelementptr inbounds %struct.cff_CharstringInstruction, ptr %35, i32 0, i32 1
  store i32 %27, ptr %36, align 4, !tbaa !17
  %37 = load ptr, ptr %3, align 8, !tbaa !5
  %38 = getelementptr inbounds %struct.cff_CharstringIL, ptr %37, i32 0, i32 0
  %39 = load i32, ptr %38, align 8, !tbaa !13
  %40 = add i32 %39, 1
  store i32 %40, ptr %38, align 8, !tbaa !13
  %41 = load ptr, ptr %3, align 8, !tbaa !5
  %42 = getelementptr inbounds %struct.cff_CharstringIL, ptr %41, i32 0, i32 1
  %43 = load i32, ptr %42, align 4, !tbaa !18
  %44 = add i32 %43, -1
  store i32 %44, ptr %42, align 4, !tbaa !18
  ret void
}

declare zeroext i8 @cff_getStandardArity(i32 noundef) #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 = { "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 = !{!"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 = !{!12, !6, i64 8}
!12 = !{!"", !10, i64 0, !10, i64 4, !6, i64 8}
!13 = !{!12, !10, i64 0}
!14 = !{!15, !10, i64 0}
!15 = !{!"", !10, i64 0, !10, i64 4, !7, i64 8}
!16 = !{!7, !7, i64 0}
!17 = !{!15, !10, i64 4}
!18 = !{!12, !10, 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.cff_CharstringInstruction = type { i32, i32, %union.anon }
%union.anon = type { double }

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

; Function Attrs: nounwind uwtable
define dso_local void @il_push_op(ptr noundef %0, i32 noundef %1) local_unnamed_addr #0 {
  tail call void @ensureThereIsSpace(ptr noundef %0)
  %3 = getelementptr inbounds i8, ptr %0, i64 8
  %4 = load ptr, ptr %3, align 8, !tbaa !5
  %5 = load i32, ptr %0, align 8, !tbaa !11
  %6 = zext i32 %5 to i64
  %7 = getelementptr inbounds %struct.cff_CharstringInstruction, ptr %4, i64 %6
  store i32 1, ptr %7, align 8, !tbaa !12
  %8 = getelementptr inbounds %struct.cff_CharstringInstruction, ptr %4, i64 %6, i32 2
  store i32 %1, ptr %8, align 8, !tbaa !14
  %9 = tail call zeroext i8 @cff_getStandardArity(i32 noundef %1) #2
  %10 = zext i8 %9 to i32
  %11 = load ptr, ptr %3, align 8, !tbaa !5
  %12 = load <2 x i32>, ptr %0, align 8, !tbaa !15
  %13 = extractelement <2 x i32> %12, i64 0
  %14 = zext i32 %13 to i64
  %15 = getelementptr inbounds %struct.cff_CharstringInstruction, ptr %11, i64 %14, i32 1
  store i32 %10, ptr %15, align 4, !tbaa !16
  %16 = add <2 x i32> %12, <i32 1, i32 -1>
  store <2 x i32> %16, ptr %0, align 8, !tbaa !15
  ret void
}

declare zeroext i8 @cff_getStandardArity(i32 noundef) local_unnamed_addr #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 = { "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 = { 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, !10, i64 8}
!6 = !{!"", !7, i64 0, !7, i64 4, !10, i64 8}
!7 = !{!"int", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"any pointer", !8, i64 0}
!11 = !{!6, !7, i64 0}
!12 = !{!13, !7, i64 0}
!13 = !{!"", !7, i64 0, !7, i64 4, !8, i64 8}
!14 = !{!8, !8, i64 0}
!15 = !{!7, !7, i64 0}
!16 = !{!13, !7, i64 4}


; Effective O3 passes: EarlyCSEPass,GlobalOptPass,InstCombinePass,SLPVectorizerPass,SROAPass,TailCallElimPass