; LLVM IR from whoiswelliton/Computer_Engineering_UTFPR-PB :: Embedded_Systems/TIVA Connected TM4C1294XL Projects/01 - lwIP_HTTPServer_on_TIVA (stricmp)

; 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: 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 i32 @lwip_stricmp(ptr noundef %0, ptr noundef %1) #1 {
  %3 = alloca i32, align 4
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca i8, align 1
  %7 = alloca i8, align 1
  %8 = alloca i8, align 1
  %9 = alloca i8, align 1
  %10 = alloca i32, align 4
  store ptr %0, ptr %4, align 8, !tbaa !5
  store ptr %1, ptr %5, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 1, ptr %6) #2
  call void @llvm.lifetime.start.p0(i64 1, ptr %7) #2
  br label %11

11:                                               ; preds = %56, %2
  %12 = load ptr, ptr %4, align 8, !tbaa !5
  %13 = getelementptr inbounds i8, ptr %12, i32 1
  store ptr %13, ptr %4, align 8, !tbaa !5
  %14 = load i8, ptr %12, align 1, !tbaa !9
  store i8 %14, ptr %6, align 1, !tbaa !9
  %15 = load ptr, ptr %5, align 8, !tbaa !5
  %16 = getelementptr inbounds i8, ptr %15, i32 1
  store ptr %16, ptr %5, align 8, !tbaa !5
  %17 = load i8, ptr %15, align 1, !tbaa !9
  store i8 %17, ptr %7, align 1, !tbaa !9
  %18 = load i8, ptr %6, align 1, !tbaa !9
  %19 = sext i8 %18 to i32
  %20 = load i8, ptr %7, align 1, !tbaa !9
  %21 = sext i8 %20 to i32
  %22 = icmp ne i32 %19, %21
  br i1 %22, label %23, label %55

23:                                               ; preds = %11
  call void @llvm.lifetime.start.p0(i64 1, ptr %8) #2
  %24 = load i8, ptr %6, align 1, !tbaa !9
  %25 = sext i8 %24 to i32
  %26 = or i32 %25, 32
  %27 = trunc i32 %26 to i8
  store i8 %27, ptr %8, align 1, !tbaa !9
  %28 = load i8, ptr %8, align 1, !tbaa !9
  %29 = sext i8 %28 to i32
  %30 = icmp sge i32 %29, 97
  br i1 %30, label %31, label %50

31:                                               ; preds = %23
  %32 = load i8, ptr %8, align 1, !tbaa !9
  %33 = sext i8 %32 to i32
  %34 = icmp sle i32 %33, 122
  br i1 %34, label %35, label %50

35:                                               ; preds = %31
  call void @llvm.lifetime.start.p0(i64 1, ptr %9) #2
  %36 = load i8, ptr %7, align 1, !tbaa !9
  %37 = sext i8 %36 to i32
  %38 = or i32 %37, 32
  %39 = trunc i32 %38 to i8
  store i8 %39, ptr %9, align 1, !tbaa !9
  %40 = load i8, ptr %8, align 1, !tbaa !9
  %41 = sext i8 %40 to i32
  %42 = load i8, ptr %9, align 1, !tbaa !9
  %43 = sext i8 %42 to i32
  %44 = icmp ne i32 %41, %43
  br i1 %44, label %45, label %46

45:                                               ; preds = %35
  store i32 1, ptr %3, align 4
  store i32 1, ptr %10, align 4
  br label %47

46:                                               ; preds = %35
  store i32 0, ptr %10, align 4
  br label %47

47:                                               ; preds = %46, %45
  call void @llvm.lifetime.end.p0(i64 1, ptr %9) #2
  %48 = load i32, ptr %10, align 4
  switch i32 %48, label %52 [
    i32 0, label %49
  ]

49:                                               ; preds = %47
  br label %51

50:                                               ; preds = %31, %23
  store i32 1, ptr %3, align 4
  store i32 1, ptr %10, align 4
  br label %52

51:                                               ; preds = %49
  store i32 0, ptr %10, align 4
  br label %52

52:                                               ; preds = %51, %50, %47
  call void @llvm.lifetime.end.p0(i64 1, ptr %8) #2
  %53 = load i32, ptr %10, align 4
  switch i32 %53, label %61 [
    i32 0, label %54
  ]

54:                                               ; preds = %52
  br label %55

55:                                               ; preds = %54, %11
  br label %56

56:                                               ; preds = %55
  %57 = load i8, ptr %6, align 1, !tbaa !9
  %58 = sext i8 %57 to i32
  %59 = icmp ne i32 %58, 0
  br i1 %59, label %11, label %60, !llvm.loop !10

60:                                               ; preds = %56
  store i32 0, ptr %3, align 4
  store i32 1, ptr %10, align 4
  br label %61

61:                                               ; preds = %60, %52
  call void @llvm.lifetime.end.p0(i64 1, ptr %7) #2
  call void @llvm.lifetime.end.p0(i64 1, ptr %6) #2
  %62 = load i32, ptr %3, align 4
  ret i32 %62
}

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 = { 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 = !{!7, !7, i64 0}
!10 = distinct !{!10, !11}
!11 = !{!"llvm.loop.mustprogress"}


; 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: nofree norecurse nosync nounwind memory(read, inaccessiblemem: none) uwtable
define dso_local noundef i32 @lwip_stricmp(ptr nocapture noundef readonly %0, ptr nocapture noundef readonly %1) local_unnamed_addr #0 {
  br label %3

3:                                                ; preds = %12, %2
  %.019 = phi ptr [ %1, %2 ], [ %6, %12 ]
  %.018 = phi ptr [ %0, %2 ], [ %4, %12 ]
  %4 = getelementptr inbounds i8, ptr %.018, i64 1
  %5 = load i8, ptr %.018, align 1, !tbaa !5
  %6 = getelementptr inbounds i8, ptr %.019, i64 1
  %7 = load i8, ptr %.019, align 1, !tbaa !5
  %.not = icmp eq i8 %5, %7
  br i1 %.not, label %12, label %8

8:                                                ; preds = %3
  %9 = or i8 %5, 32
  %10 = add i8 %9, -97
  %or.cond = icmp ult i8 %10, 26
  %11 = or i8 %7, 32
  %.not23 = icmp eq i8 %9, %11
  %narrow.not = and i1 %or.cond, %.not23
  br i1 %narrow.not, label %12, label %13

12:                                               ; preds = %3, %8
  %.not24 = icmp eq i8 %5, 0
  br i1 %.not24, label %13, label %3, !llvm.loop !8

13:                                               ; preds = %12, %8
  %.4 = phi i32 [ 1, %8 ], [ 0, %12 ]
  ret i32 %.4
}

attributes #0 = { nofree norecurse nosync nounwind memory(read, inaccessiblemem: none) 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 = !{!"omnipotent char", !7, i64 0}
!7 = !{!"Simple C/C++ TBAA"}
!8 = distinct !{!8, !9}
!9 = !{!"llvm.loop.mustprogress"}


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