; LLVM IR from nubot-nudt/simatch :: src/robot_code/world_model/rtdb/multicast.ll (Z14if_NameToIndexPcS_)

; 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.ifreq = type { %union.anon, %union.anon.0 }
%union.anon = type { [16 x i8] }
%union.anon.0 = type { %struct.ifmap }
%struct.ifmap = type { i64, i64, i16, i8, i8, i8 }
%struct.sockaddr = type { i16, [14 x i8] }

@.str = external hidden unnamed_addr constant [30 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [98 x i8], align 1
@__FUNCTION__._Z14if_NameToIndexPcS_ = external hidden unnamed_addr constant [15 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [29 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [13 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [42 x i8], align 1

; Function Attrs: mustprogress uwtable
define dso_local noundef i32 @_Z14if_NameToIndexPcS_(ptr noundef %0, ptr noundef %1) #0 {
  %3 = alloca i32, align 4
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca i32, align 4
  %7 = alloca %struct.ifreq, align 8
  %8 = alloca i32, align 4
  %9 = 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 4, ptr %6) #6
  call void @llvm.lifetime.start.p0(i64 40, ptr %7) #6
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #6
  call void @llvm.memset.p0.i64(ptr align 8 %7, i8 0, i64 40, i1 false)
  %10 = getelementptr inbounds %struct.ifreq, ptr %7, i32 0, i32 0
  %11 = getelementptr inbounds [16 x i8], ptr %10, i64 0, i64 0
  %12 = load ptr, ptr %4, align 8, !tbaa !5
  %13 = call ptr @strncpy(ptr noundef %11, ptr noundef %12, i64 noundef 15) #6
  %14 = call i32 @socket(i32 noundef 2, i32 noundef 2, i32 noundef 0) #6
  store i32 %14, ptr %6, align 4, !tbaa !9
  %15 = icmp eq i32 %14, -1
  br i1 %15, label %16, label %21

16:                                               ; preds = %2
  %17 = call ptr @__errno_location() #7
  %18 = load i32, ptr %17, align 4, !tbaa !9
  %19 = call ptr @strerror(i32 noundef %18) #6
  %20 = call i32 (ptr, ...) @printf(ptr noundef @.str, ptr noundef @.str.1, ptr noundef @__FUNCTION__._Z14if_NameToIndexPcS_, ptr noundef %19)
  store i32 -1, ptr %3, align 4
  store i32 1, ptr %9, align 4
  br label %79

21:                                               ; preds = %2
  %22 = load i32, ptr %6, align 4, !tbaa !9
  %23 = call i32 (i32, i64, ...) @ioctl(i32 noundef %22, i64 noundef 35123, ptr noundef %7) #6
  %24 = icmp eq i32 %23, -1
  br i1 %24, label %25, label %32

25:                                               ; preds = %21
  %26 = call ptr @__errno_location() #7
  %27 = load i32, ptr %26, align 4, !tbaa !9
  %28 = call ptr @strerror(i32 noundef %27) #6
  %29 = call i32 (ptr, ...) @printf(ptr noundef @.str.2, ptr noundef @.str.1, ptr noundef @__FUNCTION__._Z14if_NameToIndexPcS_, ptr noundef %28)
  %30 = load i32, ptr %6, align 4, !tbaa !9
  %31 = call i32 @close(i32 noundef %30)
  store i32 -1, ptr %3, align 4
  store i32 1, ptr %9, align 4
  br label %79

32:                                               ; preds = %21
  %33 = getelementptr inbounds %struct.ifreq, ptr %7, i32 0, i32 1
  %34 = load i32, ptr %33, align 8, !tbaa !11
  store i32 %34, ptr %8, align 4, !tbaa !9
  %35 = load i32, ptr %6, align 4, !tbaa !9
  %36 = call i32 (i32, i64, ...) @ioctl(i32 noundef %35, i64 noundef 35093, ptr noundef %7) #6
  %37 = icmp eq i32 %36, -1
  br i1 %37, label %38, label %45

38:                                               ; preds = %32
  %39 = call ptr @__errno_location() #7
  %40 = load i32, ptr %39, align 4, !tbaa !9
  %41 = call ptr @strerror(i32 noundef %40) #6
  %42 = call i32 (ptr, ...) @printf(ptr noundef @.str.2, ptr noundef @.str.1, ptr noundef @__FUNCTION__._Z14if_NameToIndexPcS_, ptr noundef %41)
  %43 = load i32, ptr %6, align 4, !tbaa !9
  %44 = call i32 @close(i32 noundef %43)
  store i32 -1, ptr %3, align 4
  store i32 1, ptr %9, align 4
  br label %79

45:                                               ; preds = %32
  %46 = load i32, ptr %6, align 4, !tbaa !9
  %47 = call i32 @close(i32 noundef %46)
  %48 = load ptr, ptr %5, align 8, !tbaa !5
  %49 = getelementptr inbounds %struct.ifreq, ptr %7, i32 0, i32 1
  %50 = getelementptr inbounds %struct.sockaddr, ptr %49, i32 0, i32 1
  %51 = getelementptr inbounds [14 x i8], ptr %50, i64 0, i64 0
  %52 = getelementptr inbounds i8, ptr %51, i64 2
  %53 = load i8, ptr %52, align 2, !tbaa !11
  %54 = zext i8 %53 to i32
  %55 = getelementptr inbounds %struct.ifreq, ptr %7, i32 0, i32 1
  %56 = getelementptr inbounds %struct.sockaddr, ptr %55, i32 0, i32 1
  %57 = getelementptr inbounds [14 x i8], ptr %56, i64 0, i64 0
  %58 = getelementptr inbounds i8, ptr %57, i64 3
  %59 = load i8, ptr %58, align 1, !tbaa !11
  %60 = zext i8 %59 to i32
  %61 = getelementptr inbounds %struct.ifreq, ptr %7, i32 0, i32 1
  %62 = getelementptr inbounds %struct.sockaddr, ptr %61, i32 0, i32 1
  %63 = getelementptr inbounds [14 x i8], ptr %62, i64 0, i64 0
  %64 = getelementptr inbounds i8, ptr %63, i64 4
  %65 = load i8, ptr %64, align 2, !tbaa !11
  %66 = zext i8 %65 to i32
  %67 = getelementptr inbounds %struct.ifreq, ptr %7, i32 0, i32 1
  %68 = getelementptr inbounds %struct.sockaddr, ptr %67, i32 0, i32 1
  %69 = getelementptr inbounds [14 x i8], ptr %68, i64 0, i64 0
  %70 = getelementptr inbounds i8, ptr %69, i64 5
  %71 = load i8, ptr %70, align 1, !tbaa !11
  %72 = zext i8 %71 to i32
  %73 = call i32 (ptr, ptr, ...) @sprintf(ptr noundef %48, ptr noundef @.str.3, i32 noundef %54, i32 noundef %60, i32 noundef %66, i32 noundef %72) #6
  %74 = getelementptr inbounds %struct.ifreq, ptr %7, i32 0, i32 0
  %75 = getelementptr inbounds [16 x i8], ptr %74, i64 0, i64 0
  %76 = load ptr, ptr %5, align 8, !tbaa !5
  %77 = call i32 (ptr, ...) @printf(ptr noundef @.str.4, ptr noundef %75, ptr noundef %76)
  %78 = load i32, ptr %8, align 4, !tbaa !9
  store i32 %78, ptr %3, align 4
  store i32 1, ptr %9, align 4
  br label %79

79:                                               ; preds = %45, %38, %25, %16
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #6
  call void @llvm.lifetime.end.p0(i64 40, ptr %7) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #6
  %80 = load i32, ptr %3, align 4
  ret i32 %80
}

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

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

; Function Attrs: nounwind
declare ptr @strncpy(ptr noundef, ptr noundef, i64 noundef) #3

; Function Attrs: nounwind
declare i32 @socket(i32 noundef, i32 noundef, i32 noundef) #3

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

; Function Attrs: nounwind
declare ptr @strerror(i32 noundef) #3

; Function Attrs: nounwind willreturn memory(none)
declare ptr @__errno_location() #5

; Function Attrs: nounwind
declare i32 @ioctl(i32 noundef, i64 noundef, ...) #3

declare i32 @close(i32 noundef) #4

; Function Attrs: nounwind
declare i32 @sprintf(ptr noundef, ptr noundef, ...) #3

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

attributes #0 = { mustprogress 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 = { nocallback nofree nounwind willreturn memory(argmem: write) }
attributes #3 = { 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 #4 = { "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 #5 = { nounwind willreturn memory(none) "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 #6 = { nounwind }
attributes #7 = { nounwind willreturn memory(none) }

!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++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"int", !7, i64 0}
!11 = !{!7, !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.ifreq = type { %union.anon, %union.anon.0 }
%union.anon = type { [16 x i8] }
%union.anon.0 = type { %struct.ifmap }
%struct.ifmap = type { i64, i64, i16, i8, i8, i8 }

@.str = external hidden unnamed_addr constant [30 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [98 x i8], align 1
@__FUNCTION__._Z14if_NameToIndexPcS_ = external hidden unnamed_addr constant [15 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [29 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [13 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [42 x i8], align 1

; Function Attrs: mustprogress uwtable
define dso_local noundef i32 @_Z14if_NameToIndexPcS_(ptr nocapture noundef readonly %0, ptr noundef %1) local_unnamed_addr #0 {
  %3 = alloca %struct.ifreq, align 8
  call void @llvm.lifetime.start.p0(i64 40, ptr nonnull %3) #8
  %4 = getelementptr inbounds i8, ptr %3, i64 8
  call void @llvm.memset.p0.i64(ptr noundef nonnull align 8 dereferenceable(40) %4, i8 0, i64 32, i1 false)
  %5 = call ptr @strncpy(ptr noundef nonnull dereferenceable(1) %3, ptr noundef nonnull dereferenceable(1) %0, i64 noundef 15) #8
  %6 = call i32 @socket(i32 noundef 2, i32 noundef 2, i32 noundef 0) #8
  %7 = icmp eq i32 %6, -1
  br i1 %7, label %8, label %13

8:                                                ; preds = %2
  %9 = tail call ptr @__errno_location() #9
  %10 = load i32, ptr %9, align 4, !tbaa !5
  %11 = call ptr @strerror(i32 noundef %10) #8
  %12 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str, ptr noundef nonnull @.str.1, ptr noundef nonnull @__FUNCTION__._Z14if_NameToIndexPcS_, ptr noundef %11)
  br label %49

13:                                               ; preds = %2
  %14 = call i32 (i32, i64, ...) @ioctl(i32 noundef %6, i64 noundef 35123, ptr noundef nonnull %3) #8
  %15 = icmp eq i32 %14, -1
  br i1 %15, label %16, label %22

16:                                               ; preds = %13
  %17 = tail call ptr @__errno_location() #9
  %18 = load i32, ptr %17, align 4, !tbaa !5
  %19 = call ptr @strerror(i32 noundef %18) #8
  %20 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.2, ptr noundef nonnull @.str.1, ptr noundef nonnull @__FUNCTION__._Z14if_NameToIndexPcS_, ptr noundef %19)
  %21 = call i32 @close(i32 noundef %6)
  br label %49

22:                                               ; preds = %13
  %23 = getelementptr inbounds i8, ptr %3, i64 16
  %24 = load i32, ptr %23, align 8, !tbaa !9
  %25 = call i32 (i32, i64, ...) @ioctl(i32 noundef %6, i64 noundef 35093, ptr noundef nonnull %3) #8
  %26 = icmp eq i32 %25, -1
  br i1 %26, label %27, label %33

27:                                               ; preds = %22
  %28 = tail call ptr @__errno_location() #9
  %29 = load i32, ptr %28, align 4, !tbaa !5
  %30 = call ptr @strerror(i32 noundef %29) #8
  %31 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.2, ptr noundef nonnull @.str.1, ptr noundef nonnull @__FUNCTION__._Z14if_NameToIndexPcS_, ptr noundef %30)
  %32 = call i32 @close(i32 noundef %6)
  br label %49

33:                                               ; preds = %22
  %34 = call i32 @close(i32 noundef %6)
  %35 = getelementptr inbounds i8, ptr %3, i64 20
  %36 = load i8, ptr %35, align 4, !tbaa !9
  %37 = zext i8 %36 to i32
  %38 = getelementptr inbounds i8, ptr %3, i64 21
  %39 = load i8, ptr %38, align 1, !tbaa !9
  %40 = zext i8 %39 to i32
  %41 = getelementptr inbounds i8, ptr %3, i64 22
  %42 = load i8, ptr %41, align 2, !tbaa !9
  %43 = zext i8 %42 to i32
  %44 = getelementptr inbounds i8, ptr %3, i64 23
  %45 = load i8, ptr %44, align 1, !tbaa !9
  %46 = zext i8 %45 to i32
  %47 = call i32 (ptr, ptr, ...) @sprintf(ptr noundef nonnull dereferenceable(1) %1, ptr noundef nonnull dereferenceable(1) @.str.3, i32 noundef %37, i32 noundef %40, i32 noundef %43, i32 noundef %46) #8
  %48 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.4, ptr noundef nonnull %3, ptr noundef %1)
  br label %49

49:                                               ; preds = %33, %27, %16, %8
  %.0 = phi i32 [ -1, %8 ], [ -1, %16 ], [ -1, %27 ], [ %24, %33 ]
  call void @llvm.lifetime.end.p0(i64 40, ptr nonnull %3) #8
  ret i32 %.0
}

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

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

; Function Attrs: mustprogress nofree nounwind willreturn memory(argmem: readwrite)
declare ptr @strncpy(ptr noalias noundef returned writeonly, ptr noalias nocapture noundef readonly, i64 noundef) local_unnamed_addr #3

; Function Attrs: nounwind
declare i32 @socket(i32 noundef, i32 noundef, i32 noundef) local_unnamed_addr #4

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

; Function Attrs: nounwind
declare ptr @strerror(i32 noundef) local_unnamed_addr #4

; Function Attrs: mustprogress nofree nosync nounwind willreturn memory(none)
declare ptr @__errno_location() local_unnamed_addr #6

; Function Attrs: nounwind
declare i32 @ioctl(i32 noundef, i64 noundef, ...) local_unnamed_addr #4

declare i32 @close(i32 noundef) local_unnamed_addr #7

; Function Attrs: nofree nounwind
declare noundef i32 @sprintf(ptr noalias nocapture noundef writeonly, ptr nocapture noundef readonly, ...) local_unnamed_addr #5

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

attributes #0 = { mustprogress 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 nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { mustprogress nocallback nofree nounwind willreturn memory(argmem: write) }
attributes #3 = { mustprogress nofree nounwind willreturn memory(argmem: readwrite) "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 "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 #5 = { 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 #6 = { mustprogress nofree nosync nounwind willreturn memory(none) "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 #7 = { "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 #8 = { nounwind }
attributes #9 = { nounwind willreturn memory(none) }

!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 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{!7, !7, i64 0}


; Effective O3 passes: DSEPass,EarlyCSEPass,GlobalOptPass,InferAlignmentPass,InferFunctionAttrsPass,InstCombinePass,PostOrderFunctionAttrsPass,SROAPass,TailCallElimPass