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

; 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.netif = type { ptr, %struct.ip4_addr, %struct.ip4_addr, %struct.ip4_addr, ptr, ptr, ptr, ptr, ptr, [1 x ptr], i16, [6 x i8], i8, i8, [2 x i8], i8, i8 }
%struct.ip4_addr = type { i32 }
%struct.slipif_priv = type { ptr, ptr, ptr, i8, i16, i16 }

@.str = external hidden unnamed_addr constant [40 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [31 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [182 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [12 x i8], align 1

; Function Attrs: nounwind uwtable
define dso_local signext i8 @slipif_init(ptr noundef %0) #0 {
  %2 = alloca i8, align 1
  %3 = alloca ptr, align 8
  %4 = alloca ptr, align 8
  %5 = alloca i8, align 1
  %6 = alloca i32, align 4
  store ptr %0, ptr %3, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %4) #3
  call void @llvm.lifetime.start.p0(i64 1, ptr %5) #3
  br label %7

7:                                                ; preds = %1
  %8 = load ptr, ptr %3, align 8, !tbaa !5
  %9 = getelementptr inbounds %struct.netif, ptr %8, i32 0, i32 4
  %10 = load ptr, ptr %9, align 8, !tbaa !9
  %11 = icmp ne ptr %10, null
  br i1 %11, label %17, label %12

12:                                               ; preds = %7
  br label %13

13:                                               ; preds = %12
  %14 = call i32 (ptr, ...) @printf(ptr noundef @.str, ptr noundef @.str.1, i32 noundef 365, ptr noundef @.str.2)
  br label %15

15:                                               ; preds = %13
  br label %16

16:                                               ; preds = %15
  br label %17

17:                                               ; preds = %16, %7
  br label %18

18:                                               ; preds = %17
  br label %19

19:                                               ; preds = %18
  %20 = load ptr, ptr %3, align 8, !tbaa !5
  %21 = getelementptr inbounds %struct.netif, ptr %20, i32 0, i32 8
  %22 = load ptr, ptr %21, align 8, !tbaa !14
  %23 = ptrtoint ptr %22 to i64
  %24 = trunc i64 %23 to i8
  store i8 %24, ptr %5, align 1, !tbaa !15
  %25 = call ptr @mem_malloc(i16 noundef zeroext 32)
  store ptr %25, ptr %4, align 8, !tbaa !5
  %26 = load ptr, ptr %4, align 8, !tbaa !5
  %27 = icmp ne ptr %26, null
  br i1 %27, label %29, label %28

28:                                               ; preds = %19
  store i8 -1, ptr %2, align 1
  store i32 1, ptr %6, align 4
  br label %66

29:                                               ; preds = %19
  %30 = load ptr, ptr %3, align 8, !tbaa !5
  %31 = getelementptr inbounds %struct.netif, ptr %30, i32 0, i32 14
  %32 = getelementptr inbounds [2 x i8], ptr %31, i64 0, i64 0
  store i8 115, ptr %32, align 2, !tbaa !15
  %33 = load ptr, ptr %3, align 8, !tbaa !5
  %34 = getelementptr inbounds %struct.netif, ptr %33, i32 0, i32 14
  %35 = getelementptr inbounds [2 x i8], ptr %34, i64 0, i64 1
  store i8 108, ptr %35, align 1, !tbaa !15
  %36 = load ptr, ptr %3, align 8, !tbaa !5
  %37 = getelementptr inbounds %struct.netif, ptr %36, i32 0, i32 5
  store ptr @slipif_output_v4, ptr %37, align 8, !tbaa !16
  %38 = load ptr, ptr %3, align 8, !tbaa !5
  %39 = getelementptr inbounds %struct.netif, ptr %38, i32 0, i32 10
  store i16 1500, ptr %39, align 8, !tbaa !17
  %40 = load i8, ptr %5, align 1, !tbaa !15
  %41 = call ptr @sio_open(i8 noundef zeroext %40)
  %42 = load ptr, ptr %4, align 8, !tbaa !5
  %43 = getelementptr inbounds %struct.slipif_priv, ptr %42, i32 0, i32 0
  store ptr %41, ptr %43, align 8, !tbaa !18
  %44 = load ptr, ptr %4, align 8, !tbaa !5
  %45 = getelementptr inbounds %struct.slipif_priv, ptr %44, i32 0, i32 0
  %46 = load ptr, ptr %45, align 8, !tbaa !18
  %47 = icmp ne ptr %46, null
  br i1 %47, label %50, label %48

48:                                               ; preds = %29
  %49 = load ptr, ptr %4, align 8, !tbaa !5
  call void @mem_free(ptr noundef %49)
  store i8 -12, ptr %2, align 1
  store i32 1, ptr %6, align 4
  br label %66

50:                                               ; preds = %29
  %51 = load ptr, ptr %4, align 8, !tbaa !5
  %52 = getelementptr inbounds %struct.slipif_priv, ptr %51, i32 0, i32 1
  store ptr null, ptr %52, align 8, !tbaa !20
  %53 = load ptr, ptr %4, align 8, !tbaa !5
  %54 = getelementptr inbounds %struct.slipif_priv, ptr %53, i32 0, i32 2
  store ptr null, ptr %54, align 8, !tbaa !21
  %55 = load ptr, ptr %4, align 8, !tbaa !5
  %56 = getelementptr inbounds %struct.slipif_priv, ptr %55, i32 0, i32 3
  store i8 0, ptr %56, align 8, !tbaa !22
  %57 = load ptr, ptr %4, align 8, !tbaa !5
  %58 = getelementptr inbounds %struct.slipif_priv, ptr %57, i32 0, i32 4
  store i16 0, ptr %58, align 2, !tbaa !23
  %59 = load ptr, ptr %4, align 8, !tbaa !5
  %60 = getelementptr inbounds %struct.slipif_priv, ptr %59, i32 0, i32 5
  store i16 0, ptr %60, align 4, !tbaa !24
  %61 = load ptr, ptr %4, align 8, !tbaa !5
  %62 = load ptr, ptr %3, align 8, !tbaa !5
  %63 = getelementptr inbounds %struct.netif, ptr %62, i32 0, i32 8
  store ptr %61, ptr %63, align 8, !tbaa !14
  %64 = load ptr, ptr %3, align 8, !tbaa !5
  %65 = call ptr @sys_thread_new(ptr noundef @.str.3, ptr noundef @slipif_loop_thread, ptr noundef %64, i32 noundef 0, i32 noundef 1)
  store i8 0, ptr %2, align 1
  store i32 1, ptr %6, align 4
  br label %66

66:                                               ; preds = %50, %48, %28
  call void @llvm.lifetime.end.p0(i64 1, ptr %5) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %4) #3
  %67 = load i8, ptr %2, align 1
  ret i8 %67
}

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

declare i32 @printf(ptr noundef, ...) #2

declare ptr @mem_malloc(i16 noundef zeroext) #2

; Function Attrs: nounwind uwtable
declare hidden signext i8 @slipif_output_v4(ptr noundef, ptr noundef, ptr noundef) #0

declare ptr @sio_open(i8 noundef zeroext) #2

declare void @mem_free(ptr noundef) #2

declare ptr @sys_thread_new(ptr noundef, ptr noundef, ptr noundef, i32 noundef, i32 noundef) #2

; Function Attrs: nounwind uwtable
declare hidden void @slipif_loop_thread(ptr noundef) #0

; 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 = { "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, !6, i64 24}
!10 = !{!"netif", !6, i64 0, !11, i64 8, !11, i64 12, !11, i64 16, !6, i64 24, !6, i64 32, !6, i64 40, !6, i64 48, !6, i64 56, !7, i64 64, !13, i64 72, !7, i64 74, !7, i64 80, !7, i64 81, !7, i64 82, !7, i64 84, !7, i64 85}
!11 = !{!"ip4_addr", !12, i64 0}
!12 = !{!"int", !7, i64 0}
!13 = !{!"short", !7, i64 0}
!14 = !{!10, !6, i64 56}
!15 = !{!7, !7, i64 0}
!16 = !{!10, !6, i64 32}
!17 = !{!10, !13, i64 72}
!18 = !{!19, !6, i64 0}
!19 = !{!"slipif_priv", !6, i64 0, !6, i64 8, !6, i64 16, !7, i64 24, !13, i64 26, !13, i64 28}
!20 = !{!19, !6, i64 8}
!21 = !{!19, !6, i64 16}
!22 = !{!19, !7, i64 24}
!23 = !{!19, !13, i64 26}
!24 = !{!19, !13, i64 28}


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

@.str = external hidden unnamed_addr constant [40 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [31 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [182 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [12 x i8], align 1

; Function Attrs: nounwind uwtable
define dso_local signext range(i8 -12, 1) i8 @slipif_init(ptr noundef %0) local_unnamed_addr #0 {
  %2 = getelementptr inbounds i8, ptr %0, i64 24
  %3 = load ptr, ptr %2, align 8, !tbaa !5
  %.not = icmp eq ptr %3, null
  br i1 %.not, label %4, label %6

4:                                                ; preds = %1
  %5 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str, ptr noundef nonnull @.str.1, i32 noundef 365, ptr noundef nonnull @.str.2)
  br label %6

6:                                                ; preds = %4, %1
  %7 = getelementptr inbounds i8, ptr %0, i64 56
  %8 = load ptr, ptr %7, align 8, !tbaa !13
  %9 = tail call ptr @mem_malloc(i16 noundef zeroext 32) #4
  %.not20 = icmp eq ptr %9, null
  br i1 %.not20, label %24, label %10

10:                                               ; preds = %6
  %11 = ptrtoint ptr %8 to i64
  %12 = trunc i64 %11 to i8
  %13 = getelementptr inbounds i8, ptr %0, i64 82
  store i8 115, ptr %13, align 2, !tbaa !14
  %14 = getelementptr inbounds i8, ptr %0, i64 83
  store i8 108, ptr %14, align 1, !tbaa !14
  %15 = getelementptr inbounds i8, ptr %0, i64 32
  store ptr @slipif_output_v4, ptr %15, align 8, !tbaa !15
  %16 = getelementptr inbounds i8, ptr %0, i64 72
  store i16 1500, ptr %16, align 8, !tbaa !16
  %17 = tail call ptr @sio_open(i8 noundef zeroext %12) #4
  store ptr %17, ptr %9, align 8, !tbaa !17
  %.not21 = icmp eq ptr %17, null
  br i1 %.not21, label %18, label %19

18:                                               ; preds = %10
  tail call void @mem_free(ptr noundef nonnull %9) #4
  br label %24

19:                                               ; preds = %10
  %20 = getelementptr inbounds i8, ptr %9, i64 8
  %21 = getelementptr inbounds i8, ptr %9, i64 26
  store i16 0, ptr %21, align 2, !tbaa !19
  %22 = getelementptr inbounds i8, ptr %9, i64 28
  store i16 0, ptr %22, align 4, !tbaa !20
  tail call void @llvm.memset.p0.i64(ptr noundef nonnull align 8 dereferenceable(17) %20, i8 0, i64 17, i1 false)
  store ptr %9, ptr %7, align 8, !tbaa !13
  %23 = tail call ptr @sys_thread_new(ptr noundef nonnull @.str.3, ptr noundef nonnull @slipif_loop_thread, ptr noundef nonnull %0, i32 noundef 0, i32 noundef 1) #4
  br label %24

24:                                               ; preds = %6, %19, %18
  %.0 = phi i8 [ 0, %19 ], [ -12, %18 ], [ -1, %6 ]
  ret i8 %.0
}

; Function Attrs: nofree nounwind
declare noundef i32 @printf(ptr nocapture noundef readonly, ...) local_unnamed_addr #1

declare ptr @mem_malloc(i16 noundef zeroext) local_unnamed_addr #2

; Function Attrs: nounwind uwtable
declare hidden signext i8 @slipif_output_v4(ptr noundef, ptr noundef, ptr noundef) #0

declare ptr @sio_open(i8 noundef zeroext) local_unnamed_addr #2

declare void @mem_free(ptr noundef) local_unnamed_addr #2

declare ptr @sys_thread_new(ptr noundef, ptr noundef, ptr noundef, i32 noundef, i32 noundef) local_unnamed_addr #2

; Function Attrs: nounwind uwtable
declare hidden void @slipif_loop_thread(ptr noundef) #0

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #3

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 = { nofree nounwind "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 = { "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 = { nocallback nofree nounwind willreturn memory(argmem: write) }
attributes #4 = { 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 24}
!6 = !{!"netif", !7, i64 0, !10, i64 8, !10, i64 12, !10, i64 16, !7, i64 24, !7, i64 32, !7, i64 40, !7, i64 48, !7, i64 56, !8, i64 64, !12, i64 72, !8, i64 74, !8, i64 80, !8, i64 81, !8, i64 82, !8, i64 84, !8, i64 85}
!7 = !{!"any pointer", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"ip4_addr", !11, i64 0}
!11 = !{!"int", !8, i64 0}
!12 = !{!"short", !8, i64 0}
!13 = !{!6, !7, i64 56}
!14 = !{!8, !8, i64 0}
!15 = !{!6, !7, i64 32}
!16 = !{!6, !12, i64 72}
!17 = !{!18, !7, i64 0}
!18 = !{!"slipif_priv", !7, i64 0, !7, i64 8, !7, i64 16, !8, i64 24, !12, i64 26, !12, i64 28}
!19 = !{!18, !12, i64 26}
!20 = !{!18, !12, i64 28}


; Effective O3 passes: CorrelatedValuePropagationPass,EarlyCSEPass,GlobalOptPass,IPSCCPPass,InferFunctionAttrsPass,InstCombinePass,MemCpyOptPass,SROAPass,SimplifyCFGPass,TailCallElimPass