; LLVM IR from cvra/robot-software :: lib/cmp (cmp)

; 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"

; Function Attrs: nounwind uwtable
declare dso_local zeroext i1 @cmp_write_nfix(ptr noundef, i8 noundef signext) #0

; Function Attrs: nounwind uwtable
declare dso_local zeroext i1 @cmp_write_s8(ptr noundef, i8 noundef signext) #0

; Function Attrs: nounwind uwtable
declare dso_local zeroext i1 @cmp_write_s16(ptr noundef, i16 noundef signext) #0

; Function Attrs: nounwind uwtable
declare dso_local zeroext i1 @cmp_write_s32(ptr noundef, i32 noundef) #0

; Function Attrs: nounwind uwtable
declare dso_local zeroext i1 @cmp_write_s64(ptr noundef, i64 noundef) #0

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

8:                                                ; preds = %2
  %9 = load ptr, ptr %4, align 8, !tbaa !5
  %10 = load i64, ptr %5, align 8, !tbaa !9
  %11 = call zeroext i1 @cmp_write_uint(ptr noundef %9, i64 noundef %10)
  store i1 %11, ptr %3, align 1
  br label %48

12:                                               ; preds = %2
  %13 = load i64, ptr %5, align 8, !tbaa !9
  %14 = icmp sge i64 %13, -32
  br i1 %14, label %15, label %20

15:                                               ; preds = %12
  %16 = load ptr, ptr %4, align 8, !tbaa !5
  %17 = load i64, ptr %5, align 8, !tbaa !9
  %18 = trunc i64 %17 to i8
  %19 = call zeroext i1 @cmp_write_nfix(ptr noundef %16, i8 noundef signext %18)
  store i1 %19, ptr %3, align 1
  br label %48

20:                                               ; preds = %12
  %21 = load i64, ptr %5, align 8, !tbaa !9
  %22 = icmp sge i64 %21, -128
  br i1 %22, label %23, label %28

23:                                               ; preds = %20
  %24 = load ptr, ptr %4, align 8, !tbaa !5
  %25 = load i64, ptr %5, align 8, !tbaa !9
  %26 = trunc i64 %25 to i8
  %27 = call zeroext i1 @cmp_write_s8(ptr noundef %24, i8 noundef signext %26)
  store i1 %27, ptr %3, align 1
  br label %48

28:                                               ; preds = %20
  %29 = load i64, ptr %5, align 8, !tbaa !9
  %30 = icmp sge i64 %29, -32768
  br i1 %30, label %31, label %36

31:                                               ; preds = %28
  %32 = load ptr, ptr %4, align 8, !tbaa !5
  %33 = load i64, ptr %5, align 8, !tbaa !9
  %34 = trunc i64 %33 to i16
  %35 = call zeroext i1 @cmp_write_s16(ptr noundef %32, i16 noundef signext %34)
  store i1 %35, ptr %3, align 1
  br label %48

36:                                               ; preds = %28
  %37 = load i64, ptr %5, align 8, !tbaa !9
  %38 = icmp sge i64 %37, -2147483648
  br i1 %38, label %39, label %44

39:                                               ; preds = %36
  %40 = load ptr, ptr %4, align 8, !tbaa !5
  %41 = load i64, ptr %5, align 8, !tbaa !9
  %42 = trunc i64 %41 to i32
  %43 = call zeroext i1 @cmp_write_s32(ptr noundef %40, i32 noundef %42)
  store i1 %43, ptr %3, align 1
  br label %48

44:                                               ; preds = %36
  %45 = load ptr, ptr %4, align 8, !tbaa !5
  %46 = load i64, ptr %5, align 8, !tbaa !9
  %47 = call zeroext i1 @cmp_write_s64(ptr noundef %45, i64 noundef %46)
  store i1 %47, ptr %3, align 1
  br label %48

48:                                               ; preds = %44, %39, %31, %23, %15, %8
  %49 = load i1, ptr %3, align 1
  ret i1 %49
}

; Function Attrs: nounwind uwtable
declare dso_local zeroext i1 @cmp_write_uint(ptr noundef, i64 noundef) #0

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" }

!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 = !{!"long", !7, 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"

; Function Attrs: nounwind uwtable
declare dso_local zeroext i1 @cmp_write_nfix(ptr noundef, i8 noundef signext) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
declare dso_local zeroext i1 @cmp_write_s8(ptr noundef, i8 noundef signext) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
declare dso_local zeroext i1 @cmp_write_s16(ptr noundef, i16 noundef signext) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
declare dso_local zeroext i1 @cmp_write_s32(ptr noundef, i32 noundef) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
declare dso_local zeroext i1 @cmp_write_s64(ptr noundef, i64 noundef) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
define dso_local zeroext i1 @cmp_write_sint(ptr noundef %0, i64 noundef %1) local_unnamed_addr #0 {
  %3 = icmp sgt i64 %1, -1
  br i1 %3, label %4, label %6

4:                                                ; preds = %2
  %5 = tail call zeroext i1 @cmp_write_uint(ptr noundef %0, i64 noundef %1)
  br label %28

6:                                                ; preds = %2
  %7 = icmp ugt i64 %1, -33
  br i1 %7, label %8, label %11

8:                                                ; preds = %6
  %9 = trunc nsw i64 %1 to i8
  %10 = tail call zeroext i1 @cmp_write_nfix(ptr noundef %0, i8 noundef signext %9)
  br label %28

11:                                               ; preds = %6
  %12 = icmp ugt i64 %1, -129
  br i1 %12, label %13, label %16

13:                                               ; preds = %11
  %14 = trunc nsw i64 %1 to i8
  %15 = tail call zeroext i1 @cmp_write_s8(ptr noundef %0, i8 noundef signext %14)
  br label %28

16:                                               ; preds = %11
  %17 = icmp ugt i64 %1, -32769
  br i1 %17, label %18, label %21

18:                                               ; preds = %16
  %19 = trunc nsw i64 %1 to i16
  %20 = tail call zeroext i1 @cmp_write_s16(ptr noundef %0, i16 noundef signext %19)
  br label %28

21:                                               ; preds = %16
  %22 = icmp ugt i64 %1, -2147483649
  br i1 %22, label %23, label %26

23:                                               ; preds = %21
  %24 = trunc nsw i64 %1 to i32
  %25 = tail call zeroext i1 @cmp_write_s32(ptr noundef %0, i32 noundef %24)
  br label %28

26:                                               ; preds = %21
  %27 = tail call zeroext i1 @cmp_write_s64(ptr noundef %0, i64 noundef %1)
  br label %28

28:                                               ; preds = %26, %23, %18, %13, %8, %4
  %.0 = phi i1 [ %5, %4 ], [ %10, %8 ], [ %15, %13 ], [ %20, %18 ], [ %25, %23 ], [ %27, %26 ]
  ret i1 %.0
}

; Function Attrs: nounwind uwtable
declare dso_local zeroext i1 @cmp_write_uint(ptr noundef, i64 noundef) local_unnamed_addr #0

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" }

!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)"}


; Effective O3 passes: CorrelatedValuePropagationPass,GlobalOptPass,IPSCCPPass,InstCombinePass,SROAPass,TailCallElimPass