; LLVM IR from caryll/otfcc :: lib/table_ (TSI)

; 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.tsi_BuildTarget = type { ptr, ptr }

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

8:                                                ; preds = %2
  %9 = getelementptr inbounds %struct.tsi_BuildTarget, ptr %3, i32 0, i32 1
  store ptr null, ptr %9, align 8, !tbaa !9
  %10 = getelementptr inbounds %struct.tsi_BuildTarget, ptr %3, i32 0, i32 0
  store ptr null, ptr %10, align 8, !tbaa !11
  br label %27

11:                                               ; preds = %2
  %12 = call ptr (...) @bufnew()
  %13 = getelementptr inbounds %struct.tsi_BuildTarget, ptr %3, i32 0, i32 1
  store ptr %12, ptr %13, align 8, !tbaa !9
  %14 = call ptr (...) @bufnew()
  %15 = getelementptr inbounds %struct.tsi_BuildTarget, ptr %3, i32 0, i32 0
  store ptr %14, ptr %15, align 8, !tbaa !11
  %16 = load ptr, ptr %4, align 8, !tbaa !5
  call void @pushTSIEntries(ptr noundef %3, ptr noundef %16, i32 noundef 0, i16 noundef zeroext 0)
  %17 = getelementptr inbounds %struct.tsi_BuildTarget, ptr %3, i32 0, i32 0
  %18 = load ptr, ptr %17, align 8, !tbaa !11
  call void @bufwrite16b(ptr noundef %18, i16 noundef zeroext -2)
  %19 = getelementptr inbounds %struct.tsi_BuildTarget, ptr %3, i32 0, i32 0
  %20 = load ptr, ptr %19, align 8, !tbaa !11
  call void @bufwrite16b(ptr noundef %20, i16 noundef zeroext 0)
  %21 = getelementptr inbounds %struct.tsi_BuildTarget, ptr %3, i32 0, i32 0
  %22 = load ptr, ptr %21, align 8, !tbaa !11
  call void @bufwrite32b(ptr noundef %22, i32 noundef -1409540300)
  %23 = load ptr, ptr %4, align 8, !tbaa !5
  call void @pushTSIEntries(ptr noundef %3, ptr noundef %23, i32 noundef 2, i16 noundef zeroext 1)
  %24 = load ptr, ptr %4, align 8, !tbaa !5
  call void @pushTSIEntries(ptr noundef %3, ptr noundef %24, i32 noundef 3, i16 noundef zeroext 1)
  %25 = load ptr, ptr %4, align 8, !tbaa !5
  call void @pushTSIEntries(ptr noundef %3, ptr noundef %25, i32 noundef 4, i16 noundef zeroext 1)
  %26 = load ptr, ptr %4, align 8, !tbaa !5
  call void @pushTSIEntries(ptr noundef %3, ptr noundef %26, i32 noundef 1, i16 noundef zeroext 1)
  br label %27

27:                                               ; preds = %11, %8
  %28 = load { ptr, ptr }, ptr %3, align 8
  ret { ptr, ptr } %28
}

declare ptr @bufnew(...) #1

; Function Attrs: nounwind uwtable
declare hidden void @pushTSIEntries(ptr noundef, ptr noundef, i32 noundef, i16 noundef zeroext) #0

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

declare void @bufwrite32b(ptr noundef, 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, !6, i64 8}
!10 = !{!"", !6, i64 0, !6, i64 8}
!11 = !{!10, !6, i64 0}


; 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.tsi_BuildTarget = type { ptr, ptr }

; Function Attrs: nounwind uwtable
define dso_local { ptr, ptr } @otfcc_buildTSI(ptr noundef %0, ptr nocapture noundef readnone %1) local_unnamed_addr #0 {
  %3 = alloca %struct.tsi_BuildTarget, align 8
  %.not = icmp eq ptr %0, null
  br i1 %.not, label %11, label %4

4:                                                ; preds = %2
  %5 = tail call ptr (...) @bufnew() #2
  %6 = getelementptr inbounds i8, ptr %3, i64 8
  store ptr %5, ptr %6, align 8, !tbaa !5
  %7 = tail call ptr (...) @bufnew() #2
  store ptr %7, ptr %3, align 8, !tbaa !10
  call void @pushTSIEntries(ptr noundef nonnull %3, ptr noundef nonnull %0, i32 noundef 0, i16 noundef zeroext 0)
  %8 = load ptr, ptr %3, align 8, !tbaa !10
  call void @bufwrite16b(ptr noundef %8, i16 noundef zeroext -2) #2
  %9 = load ptr, ptr %3, align 8, !tbaa !10
  call void @bufwrite16b(ptr noundef %9, i16 noundef zeroext 0) #2
  %10 = load ptr, ptr %3, align 8, !tbaa !10
  call void @bufwrite32b(ptr noundef %10, i32 noundef -1409540300) #2
  call void @pushTSIEntries(ptr noundef nonnull %3, ptr noundef nonnull %0, i32 noundef 2, i16 noundef zeroext 1)
  call void @pushTSIEntries(ptr noundef nonnull %3, ptr noundef nonnull %0, i32 noundef 3, i16 noundef zeroext 1)
  call void @pushTSIEntries(ptr noundef nonnull %3, ptr noundef nonnull %0, i32 noundef 4, i16 noundef zeroext 1)
  call void @pushTSIEntries(ptr noundef nonnull %3, ptr noundef nonnull %0, i32 noundef 1, i16 noundef zeroext 1)
  %.fca.0.load.pre = load ptr, ptr %3, align 8
  %.fca.1.load.pre = load ptr, ptr %6, align 8
  br label %11

11:                                               ; preds = %2, %4
  %.fca.1.load = phi ptr [ %.fca.1.load.pre, %4 ], [ null, %2 ]
  %.fca.0.load = phi ptr [ %.fca.0.load.pre, %4 ], [ null, %2 ]
  %.fca.0.insert = insertvalue { ptr, ptr } poison, ptr %.fca.0.load, 0
  %.fca.1.insert = insertvalue { ptr, ptr } %.fca.0.insert, ptr %.fca.1.load, 1
  ret { ptr, ptr } %.fca.1.insert
}

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

; Function Attrs: nounwind uwtable
declare hidden void @pushTSIEntries(ptr noundef, ptr noundef, i32 noundef, i16 noundef zeroext) local_unnamed_addr #0

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

declare void @bufwrite32b(ptr noundef, 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, !7, i64 8}
!6 = !{!"", !7, i64 0, !7, i64 8}
!7 = !{!"any pointer", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!6, !7, i64 0}


; Effective O3 passes: BDCEPass,DSEPass,EarlyCSEPass,GVNPass,GlobalOptPass,InstCombinePass,MemCpyOptPass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass,TailCallElimPass