; LLVM IR from caryll/otfcc :: lib/table (vhea)

; 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.table_vhea = type { i32, i16, i16, i16, i16, i16, i16, i16, i16, i16, i16, i16, i16, i16, i16, i16, i16 }

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

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

; Function Attrs: nounwind uwtable
define dso_local ptr @otfcc_buildVhea(ptr noundef %0, ptr noundef %1) #1 {
  %3 = alloca ptr, align 8
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  store ptr %0, ptr %4, align 8, !tbaa !5
  store ptr %1, ptr %5, align 8, !tbaa !5
  %7 = load ptr, ptr %4, align 8, !tbaa !5
  %8 = icmp ne ptr %7, null
  br i1 %8, label %10, label %9

9:                                                ; preds = %2
  store ptr null, ptr %3, align 8
  br label %66

10:                                               ; preds = %2
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #3
  %11 = call ptr (...) @bufnew()
  store ptr %11, ptr %6, align 8, !tbaa !5
  %12 = load ptr, ptr %6, align 8, !tbaa !5
  %13 = load ptr, ptr %4, align 8, !tbaa !5
  %14 = getelementptr inbounds %struct.table_vhea, ptr %13, i32 0, i32 0
  %15 = load i32, ptr %14, align 4, !tbaa !9
  call void @bufwrite32b(ptr noundef %12, i32 noundef %15)
  %16 = load ptr, ptr %6, align 8, !tbaa !5
  %17 = load ptr, ptr %4, align 8, !tbaa !5
  %18 = getelementptr inbounds %struct.table_vhea, ptr %17, i32 0, i32 1
  %19 = load i16, ptr %18, align 4, !tbaa !13
  call void @bufwrite16b(ptr noundef %16, i16 noundef zeroext %19)
  %20 = load ptr, ptr %6, align 8, !tbaa !5
  %21 = load ptr, ptr %4, align 8, !tbaa !5
  %22 = getelementptr inbounds %struct.table_vhea, ptr %21, i32 0, i32 2
  %23 = load i16, ptr %22, align 2, !tbaa !14
  call void @bufwrite16b(ptr noundef %20, i16 noundef zeroext %23)
  %24 = load ptr, ptr %6, align 8, !tbaa !5
  %25 = load ptr, ptr %4, align 8, !tbaa !5
  %26 = getelementptr inbounds %struct.table_vhea, ptr %25, i32 0, i32 3
  %27 = load i16, ptr %26, align 4, !tbaa !15
  call void @bufwrite16b(ptr noundef %24, i16 noundef zeroext %27)
  %28 = load ptr, ptr %6, align 8, !tbaa !5
  %29 = load ptr, ptr %4, align 8, !tbaa !5
  %30 = getelementptr inbounds %struct.table_vhea, ptr %29, i32 0, i32 4
  %31 = load i16, ptr %30, align 2, !tbaa !16
  call void @bufwrite16b(ptr noundef %28, i16 noundef zeroext %31)
  %32 = load ptr, ptr %6, align 8, !tbaa !5
  %33 = load ptr, ptr %4, align 8, !tbaa !5
  %34 = getelementptr inbounds %struct.table_vhea, ptr %33, i32 0, i32 5
  %35 = load i16, ptr %34, align 4, !tbaa !17
  call void @bufwrite16b(ptr noundef %32, i16 noundef zeroext %35)
  %36 = load ptr, ptr %6, align 8, !tbaa !5
  %37 = load ptr, ptr %4, align 8, !tbaa !5
  %38 = getelementptr inbounds %struct.table_vhea, ptr %37, i32 0, i32 6
  %39 = load i16, ptr %38, align 2, !tbaa !18
  call void @bufwrite16b(ptr noundef %36, i16 noundef zeroext %39)
  %40 = load ptr, ptr %6, align 8, !tbaa !5
  %41 = load ptr, ptr %4, align 8, !tbaa !5
  %42 = getelementptr inbounds %struct.table_vhea, ptr %41, i32 0, i32 7
  %43 = load i16, ptr %42, align 4, !tbaa !19
  call void @bufwrite16b(ptr noundef %40, i16 noundef zeroext %43)
  %44 = load ptr, ptr %6, align 8, !tbaa !5
  %45 = load ptr, ptr %4, align 8, !tbaa !5
  %46 = getelementptr inbounds %struct.table_vhea, ptr %45, i32 0, i32 8
  %47 = load i16, ptr %46, align 2, !tbaa !20
  call void @bufwrite16b(ptr noundef %44, i16 noundef zeroext %47)
  %48 = load ptr, ptr %6, align 8, !tbaa !5
  %49 = load ptr, ptr %4, align 8, !tbaa !5
  %50 = getelementptr inbounds %struct.table_vhea, ptr %49, i32 0, i32 9
  %51 = load i16, ptr %50, align 4, !tbaa !21
  call void @bufwrite16b(ptr noundef %48, i16 noundef zeroext %51)
  %52 = load ptr, ptr %6, align 8, !tbaa !5
  %53 = load ptr, ptr %4, align 8, !tbaa !5
  %54 = getelementptr inbounds %struct.table_vhea, ptr %53, i32 0, i32 10
  %55 = load i16, ptr %54, align 2, !tbaa !22
  call void @bufwrite16b(ptr noundef %52, i16 noundef zeroext %55)
  %56 = load ptr, ptr %6, align 8, !tbaa !5
  call void @bufwrite16b(ptr noundef %56, i16 noundef zeroext 0)
  %57 = load ptr, ptr %6, align 8, !tbaa !5
  call void @bufwrite16b(ptr noundef %57, i16 noundef zeroext 0)
  %58 = load ptr, ptr %6, align 8, !tbaa !5
  call void @bufwrite16b(ptr noundef %58, i16 noundef zeroext 0)
  %59 = load ptr, ptr %6, align 8, !tbaa !5
  call void @bufwrite16b(ptr noundef %59, i16 noundef zeroext 0)
  %60 = load ptr, ptr %6, align 8, !tbaa !5
  call void @bufwrite16b(ptr noundef %60, i16 noundef zeroext 0)
  %61 = load ptr, ptr %6, align 8, !tbaa !5
  %62 = load ptr, ptr %4, align 8, !tbaa !5
  %63 = getelementptr inbounds %struct.table_vhea, ptr %62, i32 0, i32 16
  %64 = load i16, ptr %63, align 2, !tbaa !23
  call void @bufwrite16b(ptr noundef %61, i16 noundef zeroext %64)
  %65 = load ptr, ptr %6, align 8, !tbaa !5
  store ptr %65, ptr %3, align 8
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #3
  br label %66

66:                                               ; preds = %10, %9
  %67 = load ptr, ptr %3, align 8
  ret ptr %67
}

declare ptr @bufnew(...) #2

declare void @bufwrite32b(ptr noundef, i32 noundef) #2

declare void @bufwrite16b(ptr noundef, i16 noundef zeroext) #2

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { 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 #2 = { "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 }

!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, !11, i64 0}
!10 = !{!"", !11, i64 0, !12, i64 4, !12, i64 6, !12, i64 8, !12, i64 10, !12, i64 12, !12, i64 14, !12, i64 16, !12, i64 18, !12, i64 20, !12, i64 22, !12, i64 24, !12, i64 26, !12, i64 28, !12, i64 30, !12, i64 32, !12, i64 34}
!11 = !{!"int", !7, i64 0}
!12 = !{!"short", !7, i64 0}
!13 = !{!10, !12, i64 4}
!14 = !{!10, !12, i64 6}
!15 = !{!10, !12, i64 8}
!16 = !{!10, !12, i64 10}
!17 = !{!10, !12, i64 12}
!18 = !{!10, !12, i64 14}
!19 = !{!10, !12, i64 16}
!20 = !{!10, !12, i64 18}
!21 = !{!10, !12, i64 20}
!22 = !{!10, !12, i64 22}
!23 = !{!10, !12, i64 34}


; 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: nounwind uwtable
define dso_local noundef ptr @otfcc_buildVhea(ptr noundef readonly %0, ptr nocapture noundef readnone %1) local_unnamed_addr #0 {
  %.not = icmp eq ptr %0, null
  br i1 %.not, label %28, label %3

3:                                                ; preds = %2
  %4 = tail call ptr (...) @bufnew() #2
  %5 = load i32, ptr %0, align 4, !tbaa !5
  tail call void @bufwrite32b(ptr noundef %4, i32 noundef %5) #2
  %6 = getelementptr inbounds i8, ptr %0, i64 4
  %7 = load i16, ptr %6, align 4, !tbaa !11
  tail call void @bufwrite16b(ptr noundef %4, i16 noundef zeroext %7) #2
  %8 = getelementptr inbounds i8, ptr %0, i64 6
  %9 = load i16, ptr %8, align 2, !tbaa !12
  tail call void @bufwrite16b(ptr noundef %4, i16 noundef zeroext %9) #2
  %10 = getelementptr inbounds i8, ptr %0, i64 8
  %11 = load i16, ptr %10, align 4, !tbaa !13
  tail call void @bufwrite16b(ptr noundef %4, i16 noundef zeroext %11) #2
  %12 = getelementptr inbounds i8, ptr %0, i64 10
  %13 = load i16, ptr %12, align 2, !tbaa !14
  tail call void @bufwrite16b(ptr noundef %4, i16 noundef zeroext %13) #2
  %14 = getelementptr inbounds i8, ptr %0, i64 12
  %15 = load i16, ptr %14, align 4, !tbaa !15
  tail call void @bufwrite16b(ptr noundef %4, i16 noundef zeroext %15) #2
  %16 = getelementptr inbounds i8, ptr %0, i64 14
  %17 = load i16, ptr %16, align 2, !tbaa !16
  tail call void @bufwrite16b(ptr noundef %4, i16 noundef zeroext %17) #2
  %18 = getelementptr inbounds i8, ptr %0, i64 16
  %19 = load i16, ptr %18, align 4, !tbaa !17
  tail call void @bufwrite16b(ptr noundef %4, i16 noundef zeroext %19) #2
  %20 = getelementptr inbounds i8, ptr %0, i64 18
  %21 = load i16, ptr %20, align 2, !tbaa !18
  tail call void @bufwrite16b(ptr noundef %4, i16 noundef zeroext %21) #2
  %22 = getelementptr inbounds i8, ptr %0, i64 20
  %23 = load i16, ptr %22, align 4, !tbaa !19
  tail call void @bufwrite16b(ptr noundef %4, i16 noundef zeroext %23) #2
  %24 = getelementptr inbounds i8, ptr %0, i64 22
  %25 = load i16, ptr %24, align 2, !tbaa !20
  tail call void @bufwrite16b(ptr noundef %4, i16 noundef zeroext %25) #2
  tail call void @bufwrite16b(ptr noundef %4, i16 noundef zeroext 0) #2
  tail call void @bufwrite16b(ptr noundef %4, i16 noundef zeroext 0) #2
  tail call void @bufwrite16b(ptr noundef %4, i16 noundef zeroext 0) #2
  tail call void @bufwrite16b(ptr noundef %4, i16 noundef zeroext 0) #2
  tail call void @bufwrite16b(ptr noundef %4, i16 noundef zeroext 0) #2
  %26 = getelementptr inbounds i8, ptr %0, i64 34
  %27 = load i16, ptr %26, align 2, !tbaa !21
  tail call void @bufwrite16b(ptr noundef %4, i16 noundef zeroext %27) #2
  br label %28

28:                                               ; preds = %2, %3
  %.0 = phi ptr [ %4, %3 ], [ null, %2 ]
  ret ptr %.0
}

declare ptr @bufnew(...) local_unnamed_addr #1

declare void @bufwrite32b(ptr noundef, i32 noundef) local_unnamed_addr #1

declare void @bufwrite16b(ptr noundef, i16 noundef zeroext) 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, !7, i64 0}
!6 = !{!"", !7, i64 0, !10, i64 4, !10, i64 6, !10, i64 8, !10, i64 10, !10, i64 12, !10, i64 14, !10, i64 16, !10, i64 18, !10, i64 20, !10, i64 22, !10, i64 24, !10, i64 26, !10, i64 28, !10, i64 30, !10, i64 32, !10, i64 34}
!7 = !{!"int", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"short", !8, i64 0}
!11 = !{!6, !10, i64 4}
!12 = !{!6, !10, i64 6}
!13 = !{!6, !10, i64 8}
!14 = !{!6, !10, i64 10}
!15 = !{!6, !10, i64 12}
!16 = !{!6, !10, i64 14}
!17 = !{!6, !10, i64 16}
!18 = !{!6, !10, i64 18}
!19 = !{!6, !10, i64 20}
!20 = !{!6, !10, i64 22}
!21 = !{!6, !10, i64 34}


; Effective O3 passes: EarlyCSEPass,GlobalOptPass,InferFunctionAttrsPass,InstCombinePass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass,TailCallElimPass