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

; 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_maxp = type { i32, 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_buildMaxp(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 %79

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_maxp, 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_maxp, 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 %4, align 8, !tbaa !5
  %21 = getelementptr inbounds %struct.table_maxp, ptr %20, i32 0, i32 0
  %22 = load i32, ptr %21, align 4, !tbaa !9
  %23 = icmp sgt i32 %22, 20480
  br i1 %23, label %24, label %77

24:                                               ; preds = %10
  %25 = load ptr, ptr %6, align 8, !tbaa !5
  %26 = load ptr, ptr %4, align 8, !tbaa !5
  %27 = getelementptr inbounds %struct.table_maxp, ptr %26, i32 0, i32 2
  %28 = load i16, ptr %27, align 2, !tbaa !14
  call void @bufwrite16b(ptr noundef %25, i16 noundef zeroext %28)
  %29 = load ptr, ptr %6, align 8, !tbaa !5
  %30 = load ptr, ptr %4, align 8, !tbaa !5
  %31 = getelementptr inbounds %struct.table_maxp, ptr %30, i32 0, i32 3
  %32 = load i16, ptr %31, align 4, !tbaa !15
  call void @bufwrite16b(ptr noundef %29, i16 noundef zeroext %32)
  %33 = load ptr, ptr %6, align 8, !tbaa !5
  %34 = load ptr, ptr %4, align 8, !tbaa !5
  %35 = getelementptr inbounds %struct.table_maxp, ptr %34, i32 0, i32 4
  %36 = load i16, ptr %35, align 2, !tbaa !16
  call void @bufwrite16b(ptr noundef %33, i16 noundef zeroext %36)
  %37 = load ptr, ptr %6, align 8, !tbaa !5
  %38 = load ptr, ptr %4, align 8, !tbaa !5
  %39 = getelementptr inbounds %struct.table_maxp, ptr %38, i32 0, i32 5
  %40 = load i16, ptr %39, align 4, !tbaa !17
  call void @bufwrite16b(ptr noundef %37, i16 noundef zeroext %40)
  %41 = load ptr, ptr %6, align 8, !tbaa !5
  %42 = load ptr, ptr %4, align 8, !tbaa !5
  %43 = getelementptr inbounds %struct.table_maxp, ptr %42, i32 0, i32 6
  %44 = load i16, ptr %43, align 2, !tbaa !18
  call void @bufwrite16b(ptr noundef %41, i16 noundef zeroext %44)
  %45 = load ptr, ptr %6, align 8, !tbaa !5
  %46 = load ptr, ptr %4, align 8, !tbaa !5
  %47 = getelementptr inbounds %struct.table_maxp, ptr %46, i32 0, i32 7
  %48 = load i16, ptr %47, align 4, !tbaa !19
  call void @bufwrite16b(ptr noundef %45, i16 noundef zeroext %48)
  %49 = load ptr, ptr %6, align 8, !tbaa !5
  %50 = load ptr, ptr %4, align 8, !tbaa !5
  %51 = getelementptr inbounds %struct.table_maxp, ptr %50, i32 0, i32 8
  %52 = load i16, ptr %51, align 2, !tbaa !20
  call void @bufwrite16b(ptr noundef %49, i16 noundef zeroext %52)
  %53 = load ptr, ptr %6, align 8, !tbaa !5
  %54 = load ptr, ptr %4, align 8, !tbaa !5
  %55 = getelementptr inbounds %struct.table_maxp, ptr %54, i32 0, i32 9
  %56 = load i16, ptr %55, align 4, !tbaa !21
  call void @bufwrite16b(ptr noundef %53, i16 noundef zeroext %56)
  %57 = load ptr, ptr %6, align 8, !tbaa !5
  %58 = load ptr, ptr %4, align 8, !tbaa !5
  %59 = getelementptr inbounds %struct.table_maxp, ptr %58, i32 0, i32 10
  %60 = load i16, ptr %59, align 2, !tbaa !22
  call void @bufwrite16b(ptr noundef %57, i16 noundef zeroext %60)
  %61 = load ptr, ptr %6, align 8, !tbaa !5
  %62 = load ptr, ptr %4, align 8, !tbaa !5
  %63 = getelementptr inbounds %struct.table_maxp, ptr %62, i32 0, i32 11
  %64 = load i16, ptr %63, align 4, !tbaa !23
  call void @bufwrite16b(ptr noundef %61, i16 noundef zeroext %64)
  %65 = load ptr, ptr %6, align 8, !tbaa !5
  %66 = load ptr, ptr %4, align 8, !tbaa !5
  %67 = getelementptr inbounds %struct.table_maxp, ptr %66, i32 0, i32 12
  %68 = load i16, ptr %67, align 2, !tbaa !24
  call void @bufwrite16b(ptr noundef %65, i16 noundef zeroext %68)
  %69 = load ptr, ptr %6, align 8, !tbaa !5
  %70 = load ptr, ptr %4, align 8, !tbaa !5
  %71 = getelementptr inbounds %struct.table_maxp, ptr %70, i32 0, i32 13
  %72 = load i16, ptr %71, align 4, !tbaa !25
  call void @bufwrite16b(ptr noundef %69, i16 noundef zeroext %72)
  %73 = load ptr, ptr %6, align 8, !tbaa !5
  %74 = load ptr, ptr %4, align 8, !tbaa !5
  %75 = getelementptr inbounds %struct.table_maxp, ptr %74, i32 0, i32 14
  %76 = load i16, ptr %75, align 2, !tbaa !26
  call void @bufwrite16b(ptr noundef %73, i16 noundef zeroext %76)
  br label %77

77:                                               ; preds = %24, %10
  %78 = load ptr, ptr %6, align 8, !tbaa !5
  store ptr %78, ptr %3, align 8
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #3
  br label %79

79:                                               ; preds = %77, %9
  %80 = load ptr, ptr %3, align 8
  ret ptr %80
}

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}
!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 24}
!24 = !{!10, !12, i64 26}
!25 = !{!10, !12, i64 28}
!26 = !{!10, !12, i64 30}


; 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_buildMaxp(ptr noundef readonly %0, ptr nocapture noundef readnone %1) local_unnamed_addr #0 {
  %.not = icmp eq ptr %0, null
  br i1 %.not, label %37, 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 = load i32, ptr %0, align 4, !tbaa !5
  %9 = icmp sgt i32 %8, 20480
  br i1 %9, label %10, label %37

10:                                               ; preds = %3
  %11 = getelementptr inbounds i8, ptr %0, i64 6
  %12 = load i16, ptr %11, align 2, !tbaa !12
  tail call void @bufwrite16b(ptr noundef %4, i16 noundef zeroext %12) #2
  %13 = getelementptr inbounds i8, ptr %0, i64 8
  %14 = load i16, ptr %13, align 4, !tbaa !13
  tail call void @bufwrite16b(ptr noundef %4, i16 noundef zeroext %14) #2
  %15 = getelementptr inbounds i8, ptr %0, i64 10
  %16 = load i16, ptr %15, align 2, !tbaa !14
  tail call void @bufwrite16b(ptr noundef %4, i16 noundef zeroext %16) #2
  %17 = getelementptr inbounds i8, ptr %0, i64 12
  %18 = load i16, ptr %17, align 4, !tbaa !15
  tail call void @bufwrite16b(ptr noundef %4, i16 noundef zeroext %18) #2
  %19 = getelementptr inbounds i8, ptr %0, i64 14
  %20 = load i16, ptr %19, align 2, !tbaa !16
  tail call void @bufwrite16b(ptr noundef %4, i16 noundef zeroext %20) #2
  %21 = getelementptr inbounds i8, ptr %0, i64 16
  %22 = load i16, ptr %21, align 4, !tbaa !17
  tail call void @bufwrite16b(ptr noundef %4, i16 noundef zeroext %22) #2
  %23 = getelementptr inbounds i8, ptr %0, i64 18
  %24 = load i16, ptr %23, align 2, !tbaa !18
  tail call void @bufwrite16b(ptr noundef %4, i16 noundef zeroext %24) #2
  %25 = getelementptr inbounds i8, ptr %0, i64 20
  %26 = load i16, ptr %25, align 4, !tbaa !19
  tail call void @bufwrite16b(ptr noundef %4, i16 noundef zeroext %26) #2
  %27 = getelementptr inbounds i8, ptr %0, i64 22
  %28 = load i16, ptr %27, align 2, !tbaa !20
  tail call void @bufwrite16b(ptr noundef %4, i16 noundef zeroext %28) #2
  %29 = getelementptr inbounds i8, ptr %0, i64 24
  %30 = load i16, ptr %29, align 4, !tbaa !21
  tail call void @bufwrite16b(ptr noundef %4, i16 noundef zeroext %30) #2
  %31 = getelementptr inbounds i8, ptr %0, i64 26
  %32 = load i16, ptr %31, align 2, !tbaa !22
  tail call void @bufwrite16b(ptr noundef %4, i16 noundef zeroext %32) #2
  %33 = getelementptr inbounds i8, ptr %0, i64 28
  %34 = load i16, ptr %33, align 4, !tbaa !23
  tail call void @bufwrite16b(ptr noundef %4, i16 noundef zeroext %34) #2
  %35 = getelementptr inbounds i8, ptr %0, i64 30
  %36 = load i16, ptr %35, align 2, !tbaa !24
  tail call void @bufwrite16b(ptr noundef %4, i16 noundef zeroext %36) #2
  br label %37

37:                                               ; preds = %3, %10, %2
  %.0 = phi ptr [ null, %2 ], [ %4, %10 ], [ %4, %3 ]
  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}
!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 24}
!22 = !{!6, !10, i64 26}
!23 = !{!6, !10, i64 28}
!24 = !{!6, !10, i64 30}


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