; LLVM IR from mlcommons/tiny :: benchmark/interface/Drivers/BSP/Components/ft6x06 (ft6x06)

; 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.FT6X06_Object_t = type { %struct.FT6X06_IO_t, %struct.ft6x06_ctx_t, i8 }
%struct.FT6X06_IO_t = type { ptr, ptr, i16, ptr, ptr, ptr }
%struct.ft6x06_ctx_t = type { ptr, ptr, ptr }
%struct.FT6X06_Gesture_Init_t = type { i32, i32, i32, i32, i32, i32 }

; Function Attrs: nounwind uwtable
define dso_local i32 @FT6X06_GestureConfig(ptr noundef %0, ptr noundef %1) #0 {
  %3 = alloca ptr, align 8
  %4 = alloca ptr, align 8
  %5 = alloca i32, align 4
  store ptr %0, ptr %3, align 8, !tbaa !5
  store ptr %1, ptr %4, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #3
  %6 = load ptr, ptr %3, align 8, !tbaa !5
  %7 = getelementptr inbounds %struct.FT6X06_Object_t, ptr %6, i32 0, i32 1
  %8 = load ptr, ptr %4, align 8, !tbaa !5
  %9 = getelementptr inbounds %struct.FT6X06_Gesture_Init_t, ptr %8, i32 0, i32 0
  %10 = load i32, ptr %9, align 4, !tbaa !9
  %11 = trunc i32 %10 to i8
  %12 = call i32 @ft6x06_radian_value(ptr noundef %7, i8 noundef zeroext %11)
  store i32 %12, ptr %5, align 4, !tbaa !12
  %13 = load ptr, ptr %3, align 8, !tbaa !5
  %14 = getelementptr inbounds %struct.FT6X06_Object_t, ptr %13, i32 0, i32 1
  %15 = load ptr, ptr %4, align 8, !tbaa !5
  %16 = getelementptr inbounds %struct.FT6X06_Gesture_Init_t, ptr %15, i32 0, i32 1
  %17 = load i32, ptr %16, align 4, !tbaa !13
  %18 = trunc i32 %17 to i8
  %19 = call i32 @ft6x06_offset_left_right(ptr noundef %14, i8 noundef zeroext %18)
  %20 = load i32, ptr %5, align 4, !tbaa !12
  %21 = add nsw i32 %20, %19
  store i32 %21, ptr %5, align 4, !tbaa !12
  %22 = load ptr, ptr %3, align 8, !tbaa !5
  %23 = getelementptr inbounds %struct.FT6X06_Object_t, ptr %22, i32 0, i32 1
  %24 = load ptr, ptr %4, align 8, !tbaa !5
  %25 = getelementptr inbounds %struct.FT6X06_Gesture_Init_t, ptr %24, i32 0, i32 2
  %26 = load i32, ptr %25, align 4, !tbaa !14
  %27 = trunc i32 %26 to i8
  %28 = call i32 @ft6x06_offset_up_down(ptr noundef %23, i8 noundef zeroext %27)
  %29 = load i32, ptr %5, align 4, !tbaa !12
  %30 = add nsw i32 %29, %28
  store i32 %30, ptr %5, align 4, !tbaa !12
  %31 = load ptr, ptr %3, align 8, !tbaa !5
  %32 = getelementptr inbounds %struct.FT6X06_Object_t, ptr %31, i32 0, i32 1
  %33 = load ptr, ptr %4, align 8, !tbaa !5
  %34 = getelementptr inbounds %struct.FT6X06_Gesture_Init_t, ptr %33, i32 0, i32 3
  %35 = load i32, ptr %34, align 4, !tbaa !15
  %36 = trunc i32 %35 to i8
  %37 = call i32 @ft6x06_disatnce_left_right(ptr noundef %32, i8 noundef zeroext %36)
  %38 = load i32, ptr %5, align 4, !tbaa !12
  %39 = add nsw i32 %38, %37
  store i32 %39, ptr %5, align 4, !tbaa !12
  %40 = load ptr, ptr %3, align 8, !tbaa !5
  %41 = getelementptr inbounds %struct.FT6X06_Object_t, ptr %40, i32 0, i32 1
  %42 = load ptr, ptr %4, align 8, !tbaa !5
  %43 = getelementptr inbounds %struct.FT6X06_Gesture_Init_t, ptr %42, i32 0, i32 4
  %44 = load i32, ptr %43, align 4, !tbaa !16
  %45 = trunc i32 %44 to i8
  %46 = call i32 @ft6x06_distance_up_down(ptr noundef %41, i8 noundef zeroext %45)
  %47 = load i32, ptr %5, align 4, !tbaa !12
  %48 = add nsw i32 %47, %46
  store i32 %48, ptr %5, align 4, !tbaa !12
  %49 = load ptr, ptr %3, align 8, !tbaa !5
  %50 = getelementptr inbounds %struct.FT6X06_Object_t, ptr %49, i32 0, i32 1
  %51 = load ptr, ptr %4, align 8, !tbaa !5
  %52 = getelementptr inbounds %struct.FT6X06_Gesture_Init_t, ptr %51, i32 0, i32 5
  %53 = load i32, ptr %52, align 4, !tbaa !17
  %54 = trunc i32 %53 to i8
  %55 = call i32 @ft6x06_distance_zoom(ptr noundef %50, i8 noundef zeroext %54)
  %56 = load i32, ptr %5, align 4, !tbaa !12
  %57 = add nsw i32 %56, %55
  store i32 %57, ptr %5, align 4, !tbaa !12
  %58 = load i32, ptr %5, align 4, !tbaa !12
  %59 = icmp ne i32 %58, 0
  br i1 %59, label %60, label %61

60:                                               ; preds = %2
  store i32 -1, ptr %5, align 4, !tbaa !12
  br label %61

61:                                               ; preds = %60, %2
  %62 = load i32, ptr %5, align 4, !tbaa !12
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #3
  ret i32 %62
}

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

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

declare i32 @ft6x06_radian_value(ptr noundef, i8 noundef zeroext) #2

declare i32 @ft6x06_offset_left_right(ptr noundef, i8 noundef zeroext) #2

declare i32 @ft6x06_offset_up_down(ptr noundef, i8 noundef zeroext) #2

declare i32 @ft6x06_disatnce_left_right(ptr noundef, i8 noundef zeroext) #2

declare i32 @ft6x06_distance_up_down(ptr noundef, i8 noundef zeroext) #2

declare i32 @ft6x06_distance_zoom(ptr noundef, i8 noundef zeroext) #2

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 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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, !11, i64 4, !11, i64 8, !11, i64 12, !11, i64 16, !11, i64 20}
!11 = !{!"int", !7, i64 0}
!12 = !{!11, !11, i64 0}
!13 = !{!10, !11, i64 4}
!14 = !{!10, !11, i64 8}
!15 = !{!10, !11, i64 12}
!16 = !{!10, !11, i64 16}
!17 = !{!10, !11, i64 20}


; 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 i32 @FT6X06_GestureConfig(ptr noundef %0, ptr nocapture noundef readonly %1) local_unnamed_addr #0 {
  %3 = getelementptr inbounds i8, ptr %0, i64 48
  %4 = load i32, ptr %1, align 4, !tbaa !5
  %5 = trunc i32 %4 to i8
  %6 = tail call i32 @ft6x06_radian_value(ptr noundef nonnull %3, i8 noundef zeroext %5) #2
  %7 = getelementptr inbounds i8, ptr %1, i64 4
  %8 = load i32, ptr %7, align 4, !tbaa !10
  %9 = trunc i32 %8 to i8
  %10 = tail call i32 @ft6x06_offset_left_right(ptr noundef nonnull %3, i8 noundef zeroext %9) #2
  %11 = add nsw i32 %10, %6
  %12 = getelementptr inbounds i8, ptr %1, i64 8
  %13 = load i32, ptr %12, align 4, !tbaa !11
  %14 = trunc i32 %13 to i8
  %15 = tail call i32 @ft6x06_offset_up_down(ptr noundef nonnull %3, i8 noundef zeroext %14) #2
  %16 = add nsw i32 %11, %15
  %17 = getelementptr inbounds i8, ptr %1, i64 12
  %18 = load i32, ptr %17, align 4, !tbaa !12
  %19 = trunc i32 %18 to i8
  %20 = tail call i32 @ft6x06_disatnce_left_right(ptr noundef nonnull %3, i8 noundef zeroext %19) #2
  %21 = add nsw i32 %16, %20
  %22 = getelementptr inbounds i8, ptr %1, i64 16
  %23 = load i32, ptr %22, align 4, !tbaa !13
  %24 = trunc i32 %23 to i8
  %25 = tail call i32 @ft6x06_distance_up_down(ptr noundef nonnull %3, i8 noundef zeroext %24) #2
  %26 = add nsw i32 %21, %25
  %27 = getelementptr inbounds i8, ptr %1, i64 20
  %28 = load i32, ptr %27, align 4, !tbaa !14
  %29 = trunc i32 %28 to i8
  %30 = tail call i32 @ft6x06_distance_zoom(ptr noundef nonnull %3, i8 noundef zeroext %29) #2
  %31 = sub i32 0, %30
  %.not = icmp ne i32 %26, %31
  %spec.store.select = sext i1 %.not to i32
  ret i32 %spec.store.select
}

declare i32 @ft6x06_radian_value(ptr noundef, i8 noundef zeroext) local_unnamed_addr #1

declare i32 @ft6x06_offset_left_right(ptr noundef, i8 noundef zeroext) local_unnamed_addr #1

declare i32 @ft6x06_offset_up_down(ptr noundef, i8 noundef zeroext) local_unnamed_addr #1

declare i32 @ft6x06_disatnce_left_right(ptr noundef, i8 noundef zeroext) local_unnamed_addr #1

declare i32 @ft6x06_distance_up_down(ptr noundef, i8 noundef zeroext) local_unnamed_addr #1

declare i32 @ft6x06_distance_zoom(ptr noundef, i8 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, !7, i64 4, !7, i64 8, !7, i64 12, !7, i64 16, !7, i64 20}
!7 = !{!"int", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!6, !7, i64 4}
!11 = !{!6, !7, i64 8}
!12 = !{!6, !7, i64 12}
!13 = !{!6, !7, i64 16}
!14 = !{!6, !7, i64 20}


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