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

; 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.ip4_addr = type { i32 }

@dns_servers = external hidden global [2 x %struct.ip4_addr], align 4

; Function Attrs: nounwind uwtable
define dso_local signext i8 @dns_gethostbyname_addrtype(ptr noundef %0, ptr noundef %1, ptr noundef %2, ptr noundef %3, i8 noundef zeroext %4) #0 {
  %6 = alloca i8, align 1
  %7 = alloca ptr, align 8
  %8 = alloca ptr, align 8
  %9 = alloca ptr, align 8
  %10 = alloca ptr, align 8
  %11 = alloca i8, align 1
  %12 = alloca i64, align 8
  %13 = alloca i32, align 4
  store ptr %0, ptr %7, align 8, !tbaa !5
  store ptr %1, ptr %8, align 8, !tbaa !5
  store ptr %2, ptr %9, align 8, !tbaa !5
  store ptr %3, ptr %10, align 8, !tbaa !5
  store i8 %4, ptr %11, align 1, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %12) #4
  %14 = load ptr, ptr %8, align 8, !tbaa !5
  %15 = icmp eq ptr %14, null
  br i1 %15, label %24, label %16

16:                                               ; preds = %5
  %17 = load ptr, ptr %7, align 8, !tbaa !5
  %18 = icmp ne ptr %17, null
  br i1 %18, label %19, label %24

19:                                               ; preds = %16
  %20 = load ptr, ptr %7, align 8, !tbaa !5
  %21 = getelementptr inbounds i8, ptr %20, i64 0
  %22 = load i8, ptr %21, align 1, !tbaa !9
  %23 = icmp ne i8 %22, 0
  br i1 %23, label %25, label %24

24:                                               ; preds = %19, %16, %5
  store i8 -16, ptr %6, align 1
  store i32 1, ptr %13, align 4
  br label %55

25:                                               ; preds = %19
  %26 = load ptr, ptr %7, align 8, !tbaa !5
  %27 = call i64 @strlen(ptr noundef %26) #5
  store i64 %27, ptr %12, align 8, !tbaa !10
  %28 = load i64, ptr %12, align 8, !tbaa !10
  %29 = icmp uge i64 %28, 256
  br i1 %29, label %30, label %31

30:                                               ; preds = %25
  store i8 -16, ptr %6, align 1
  store i32 1, ptr %13, align 4
  br label %55

31:                                               ; preds = %25
  %32 = load ptr, ptr %7, align 8, !tbaa !5
  %33 = load ptr, ptr %8, align 8, !tbaa !5
  %34 = call i32 @ip4addr_aton(ptr noundef %32, ptr noundef %33)
  %35 = icmp ne i32 %34, 0
  br i1 %35, label %36, label %37

36:                                               ; preds = %31
  store i8 0, ptr %6, align 1
  store i32 1, ptr %13, align 4
  br label %55

37:                                               ; preds = %31
  %38 = load ptr, ptr %7, align 8, !tbaa !5
  %39 = load ptr, ptr %8, align 8, !tbaa !5
  %40 = call signext i8 @dns_lookup(ptr noundef %38, ptr noundef %39)
  %41 = sext i8 %40 to i32
  %42 = icmp eq i32 %41, 0
  br i1 %42, label %43, label %44

43:                                               ; preds = %37
  store i8 0, ptr %6, align 1
  store i32 1, ptr %13, align 4
  br label %55

44:                                               ; preds = %37
  %45 = load i8, ptr %11, align 1, !tbaa !9
  %46 = load i32, ptr @dns_servers, align 4, !tbaa !12
  %47 = icmp eq i32 %46, 0
  br i1 %47, label %48, label %49

48:                                               ; preds = %44
  store i8 -6, ptr %6, align 1
  store i32 1, ptr %13, align 4
  br label %55

49:                                               ; preds = %44
  %50 = load ptr, ptr %7, align 8, !tbaa !5
  %51 = load i64, ptr %12, align 8, !tbaa !10
  %52 = load ptr, ptr %9, align 8, !tbaa !5
  %53 = load ptr, ptr %10, align 8, !tbaa !5
  %54 = call signext i8 @dns_enqueue(ptr noundef %50, i64 noundef %51, ptr noundef %52, ptr noundef %53)
  store i8 %54, ptr %6, align 1
  store i32 1, ptr %13, align 4
  br label %55

55:                                               ; preds = %49, %48, %43, %36, %30, %24
  call void @llvm.lifetime.end.p0(i64 8, ptr %12) #4
  %56 = load i8, ptr %6, align 1
  ret i8 %56
}

; 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 i64 @strlen(ptr noundef) #2

declare i32 @ip4addr_aton(ptr noundef, ptr noundef) #3

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

; Function Attrs: nounwind uwtable
declare hidden signext i8 @dns_enqueue(ptr noundef, i64 noundef, ptr noundef, 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 = { 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 = { "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 #4 = { nounwind }
attributes #5 = { 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 = !{!7, !7, i64 0}
!10 = !{!11, !11, i64 0}
!11 = !{!"long", !7, i64 0}
!12 = !{!13, !14, i64 0}
!13 = !{!"ip4_addr", !14, i64 0}
!14 = !{!"int", !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"

%struct.ip4_addr = type { i32 }

@dns_servers = external hidden local_unnamed_addr global [2 x %struct.ip4_addr], align 4

; Function Attrs: nounwind uwtable
define dso_local signext i8 @dns_gethostbyname_addrtype(ptr noundef %0, ptr noundef %1, ptr noundef %2, ptr noundef %3, i8 noundef zeroext %4) local_unnamed_addr #0 {
  %6 = icmp ne ptr %1, null
  %7 = icmp ne ptr %0, null
  %or.cond = and i1 %7, %6
  br i1 %or.cond, label %8, label %23

8:                                                ; preds = %5
  %9 = load i8, ptr %0, align 1, !tbaa !5
  %.not = icmp eq i8 %9, 0
  br i1 %.not, label %23, label %10

10:                                               ; preds = %8
  %11 = tail call i64 @strlen(ptr noundef nonnull dereferenceable(1) %0) #3
  %12 = icmp ugt i64 %11, 255
  br i1 %12, label %23, label %13

13:                                               ; preds = %10
  %14 = tail call i32 @ip4addr_aton(ptr noundef nonnull %0, ptr noundef nonnull %1) #4
  %.not18 = icmp eq i32 %14, 0
  br i1 %.not18, label %15, label %23

15:                                               ; preds = %13
  %16 = tail call signext i8 @dns_lookup(ptr noundef nonnull %0, ptr noundef nonnull %1)
  %17 = icmp eq i8 %16, 0
  br i1 %17, label %23, label %18

18:                                               ; preds = %15
  %19 = load i32, ptr @dns_servers, align 4, !tbaa !8
  %20 = icmp eq i32 %19, 0
  br i1 %20, label %23, label %21

21:                                               ; preds = %18
  %22 = tail call signext i8 @dns_enqueue(ptr noundef nonnull %0, i64 noundef %11, ptr noundef %2, ptr noundef %3)
  br label %23

23:                                               ; preds = %18, %15, %13, %10, %5, %8, %21
  %.0 = phi i8 [ %22, %21 ], [ -16, %8 ], [ -16, %5 ], [ -16, %10 ], [ 0, %13 ], [ 0, %15 ], [ -6, %18 ]
  ret i8 %.0
}

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

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

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

; Function Attrs: nounwind uwtable
declare hidden signext i8 @dns_enqueue(ptr noundef, i64 noundef, ptr noundef, ptr 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" }
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 = { "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 willreturn memory(read) }
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, !6, i64 0}
!6 = !{!"omnipotent char", !7, i64 0}
!7 = !{!"Simple C/C++ TBAA"}
!8 = !{!9, !10, i64 0}
!9 = !{!"ip4_addr", !10, i64 0}
!10 = !{!"int", !6, i64 0}


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