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

; 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.fsdata_file = type { ptr, ptr, ptr, i32, i8 }
%struct.fs_file = type { ptr, i32, i32, ptr, i8 }

@file__index_html = external dso_local constant [1 x %struct.fsdata_file], align 16

; Function Attrs: nounwind uwtable
define dso_local signext i8 @fs_open(ptr noundef %0, ptr noundef %1) #0 {
  %3 = alloca i8, align 1
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = 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 8, ptr %6) #3
  %8 = load ptr, ptr %4, align 8, !tbaa !5
  %9 = icmp eq ptr %8, null
  br i1 %9, label %13, label %10

10:                                               ; preds = %2
  %11 = load ptr, ptr %5, align 8, !tbaa !5
  %12 = icmp eq ptr %11, null
  br i1 %12, label %13, label %14

13:                                               ; preds = %10, %2
  store i8 -16, ptr %3, align 1
  store i32 1, ptr %7, align 4
  br label %54

14:                                               ; preds = %10
  store ptr @file__index_html, ptr %6, align 8, !tbaa !5
  br label %15

15:                                               ; preds = %49, %14
  %16 = load ptr, ptr %6, align 8, !tbaa !5
  %17 = icmp ne ptr %16, null
  br i1 %17, label %18, label %53

18:                                               ; preds = %15
  %19 = load ptr, ptr %5, align 8, !tbaa !5
  %20 = load ptr, ptr %6, align 8, !tbaa !5
  %21 = getelementptr inbounds %struct.fsdata_file, ptr %20, i32 0, i32 1
  %22 = load ptr, ptr %21, align 8, !tbaa !9
  %23 = call i32 @strcmp(ptr noundef %19, ptr noundef %22) #4
  %24 = icmp ne i32 %23, 0
  br i1 %24, label %48, label %25

25:                                               ; preds = %18
  %26 = load ptr, ptr %6, align 8, !tbaa !5
  %27 = getelementptr inbounds %struct.fsdata_file, ptr %26, i32 0, i32 2
  %28 = load ptr, ptr %27, align 8, !tbaa !12
  %29 = load ptr, ptr %4, align 8, !tbaa !5
  %30 = getelementptr inbounds %struct.fs_file, ptr %29, i32 0, i32 0
  store ptr %28, ptr %30, align 8, !tbaa !13
  %31 = load ptr, ptr %6, align 8, !tbaa !5
  %32 = getelementptr inbounds %struct.fsdata_file, ptr %31, i32 0, i32 3
  %33 = load i32, ptr %32, align 8, !tbaa !15
  %34 = load ptr, ptr %4, align 8, !tbaa !5
  %35 = getelementptr inbounds %struct.fs_file, ptr %34, i32 0, i32 1
  store i32 %33, ptr %35, align 8, !tbaa !16
  %36 = load ptr, ptr %6, align 8, !tbaa !5
  %37 = getelementptr inbounds %struct.fsdata_file, ptr %36, i32 0, i32 3
  %38 = load i32, ptr %37, align 8, !tbaa !15
  %39 = load ptr, ptr %4, align 8, !tbaa !5
  %40 = getelementptr inbounds %struct.fs_file, ptr %39, i32 0, i32 2
  store i32 %38, ptr %40, align 4, !tbaa !17
  %41 = load ptr, ptr %4, align 8, !tbaa !5
  %42 = getelementptr inbounds %struct.fs_file, ptr %41, i32 0, i32 3
  store ptr null, ptr %42, align 8, !tbaa !18
  %43 = load ptr, ptr %6, align 8, !tbaa !5
  %44 = getelementptr inbounds %struct.fsdata_file, ptr %43, i32 0, i32 4
  %45 = load i8, ptr %44, align 4, !tbaa !19
  %46 = load ptr, ptr %4, align 8, !tbaa !5
  %47 = getelementptr inbounds %struct.fs_file, ptr %46, i32 0, i32 4
  store i8 %45, ptr %47, align 8, !tbaa !20
  store i8 0, ptr %3, align 1
  store i32 1, ptr %7, align 4
  br label %54

48:                                               ; preds = %18
  br label %49

49:                                               ; preds = %48
  %50 = load ptr, ptr %6, align 8, !tbaa !5
  %51 = getelementptr inbounds %struct.fsdata_file, ptr %50, i32 0, i32 0
  %52 = load ptr, ptr %51, align 8, !tbaa !21
  store ptr %52, ptr %6, align 8, !tbaa !5
  br label %15, !llvm.loop !22

53:                                               ; preds = %15
  store i8 -6, ptr %3, align 1
  store i32 1, ptr %7, align 4
  br label %54

54:                                               ; preds = %53, %25, %13
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #3
  %55 = load i8, ptr %3, align 1
  ret i8 %55
}

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

; Function Attrs: nounwind willreturn memory(read)
declare i32 @strcmp(ptr noundef, ptr noundef) #2

; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #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 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { nounwind willreturn memory(read) "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 }
attributes #4 = { nounwind willreturn memory(read) }

!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 = !{!"fsdata_file", !6, i64 0, !6, i64 8, !6, i64 16, !11, i64 24, !7, i64 28}
!11 = !{!"int", !7, i64 0}
!12 = !{!10, !6, i64 16}
!13 = !{!14, !6, i64 0}
!14 = !{!"fs_file", !6, i64 0, !11, i64 8, !11, i64 12, !6, i64 16, !7, i64 24}
!15 = !{!10, !11, i64 24}
!16 = !{!14, !11, i64 8}
!17 = !{!14, !11, i64 12}
!18 = !{!14, !6, i64 16}
!19 = !{!10, !7, i64 28}
!20 = !{!14, !7, i64 24}
!21 = !{!10, !6, i64 0}
!22 = distinct !{!22, !23}
!23 = !{!"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"

%struct.fsdata_file = type { ptr, ptr, ptr, i32, i8 }

@file__index_html = external dso_local local_unnamed_addr constant [1 x %struct.fsdata_file], align 16

; Function Attrs: nofree nounwind memory(read, argmem: readwrite, inaccessiblemem: none) uwtable
define dso_local signext range(i8 -16, 1) i8 @fs_open(ptr noundef writeonly %0, ptr noundef readonly %1) local_unnamed_addr #0 {
  %3 = icmp eq ptr %0, null
  %4 = icmp eq ptr %1, null
  %or.cond = or i1 %3, %4
  br i1 %or.cond, label %.loopexit, label %.preheader

.preheader:                                       ; preds = %2, %19
  %.021 = phi ptr [ %20, %19 ], [ @file__index_html, %2 ]
  %5 = getelementptr inbounds i8, ptr %.021, i64 8
  %6 = load ptr, ptr %5, align 8, !tbaa !5
  %7 = tail call i32 @strcmp(ptr noundef nonnull dereferenceable(1) %1, ptr noundef nonnull dereferenceable(1) %6) #2
  %.not19 = icmp eq i32 %7, 0
  br i1 %.not19, label %8, label %19

8:                                                ; preds = %.preheader
  %9 = getelementptr inbounds i8, ptr %.021, i64 16
  %10 = load ptr, ptr %9, align 8, !tbaa !11
  store ptr %10, ptr %0, align 8, !tbaa !12
  %11 = getelementptr inbounds i8, ptr %.021, i64 24
  %12 = load i32, ptr %11, align 8, !tbaa !14
  %13 = getelementptr inbounds i8, ptr %0, i64 8
  store i32 %12, ptr %13, align 8, !tbaa !15
  %14 = getelementptr inbounds i8, ptr %0, i64 12
  store i32 %12, ptr %14, align 4, !tbaa !16
  %15 = getelementptr inbounds i8, ptr %0, i64 16
  store ptr null, ptr %15, align 8, !tbaa !17
  %16 = getelementptr inbounds i8, ptr %.021, i64 28
  %17 = load i8, ptr %16, align 4, !tbaa !18
  %18 = getelementptr inbounds i8, ptr %0, i64 24
  store i8 %17, ptr %18, align 8, !tbaa !19
  br label %.loopexit

19:                                               ; preds = %.preheader
  %20 = load ptr, ptr %.021, align 8, !tbaa !20
  %.not = icmp eq ptr %20, null
  br i1 %.not, label %.loopexit, label %.preheader, !llvm.loop !21

.loopexit:                                        ; preds = %19, %2, %8
  %.016 = phi i8 [ 0, %8 ], [ -16, %2 ], [ -6, %19 ]
  ret i8 %.016
}

; Function Attrs: mustprogress nofree nounwind willreturn memory(argmem: read)
declare i32 @strcmp(ptr nocapture noundef, ptr nocapture noundef) local_unnamed_addr #1

attributes #0 = { nofree nounwind memory(read, argmem: readwrite, 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" }
attributes #1 = { mustprogress nofree nounwind willreturn memory(argmem: read) "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 willreturn memory(read) }

!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 = !{!"fsdata_file", !7, i64 0, !7, i64 8, !7, i64 16, !10, i64 24, !8, i64 28}
!7 = !{!"any pointer", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"int", !8, i64 0}
!11 = !{!6, !7, i64 16}
!12 = !{!13, !7, i64 0}
!13 = !{!"fs_file", !7, i64 0, !10, i64 8, !10, i64 12, !7, i64 16, !8, i64 24}
!14 = !{!6, !10, i64 24}
!15 = !{!13, !10, i64 8}
!16 = !{!13, !10, i64 12}
!17 = !{!13, !7, i64 16}
!18 = !{!6, !8, i64 28}
!19 = !{!13, !8, i64 24}
!20 = !{!6, !7, i64 0}
!21 = distinct !{!21, !22}
!22 = !{!"llvm.loop.mustprogress"}


; Effective O3 passes: EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,JumpThreadingPass,LCSSAPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass,TailCallElimPass