; LLVM IR from devicehive/esp8266-firmware :: firmware-src/sources (dhterminal_commandline)

; 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.DHCOMMAND = type { ptr, ptr, ptr }

@.str = external hidden unnamed_addr constant [64 x i8], align 1
@mCommands = external hidden constant [12 x %struct.DHCOMMAND], align 16
@.str.1 = external hidden unnamed_addr constant [4 x i8], align 1

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

2:                                                ; preds = %17, %0
  %3 = load i32, ptr %1, align 4, !tbaa !5
  %4 = sext i32 %3 to i64
  %5 = icmp ult i64 %4, 12
  br i1 %5, label %6, label %20

6:                                                ; preds = %2
  %7 = load i32, ptr %1, align 4, !tbaa !5
  %8 = sext i32 %7 to i64
  %9 = getelementptr inbounds [12 x %struct.DHCOMMAND], ptr @mCommands, i64 0, i64 %8
  %10 = getelementptr inbounds %struct.DHCOMMAND, ptr %9, i32 0, i32 0
  %11 = load ptr, ptr %10, align 8, !tbaa !9
  call void @dh_uart_send_str(ptr noundef %11)
  call void @dh_uart_send_str(ptr noundef @.str.1)
  %12 = load i32, ptr %1, align 4, !tbaa !5
  %13 = sext i32 %12 to i64
  %14 = getelementptr inbounds [12 x %struct.DHCOMMAND], ptr @mCommands, i64 0, i64 %13
  %15 = getelementptr inbounds %struct.DHCOMMAND, ptr %14, i32 0, i32 1
  %16 = load ptr, ptr %15, align 8, !tbaa !12
  call void @dh_uart_send_line(ptr noundef %16)
  br label %17

17:                                               ; preds = %6
  %18 = load i32, ptr %1, align 4, !tbaa !5
  %19 = add nsw i32 %18, 1
  store i32 %19, ptr %1, align 4, !tbaa !5
  br label %2, !llvm.loop !13

20:                                               ; preds = %2
  call void @llvm.lifetime.end.p0(i64 4, ptr %1) #3
  ret void
}

declare void @dh_uart_send_line(ptr noundef) #1

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

declare void @dh_uart_send_str(ptr noundef) #1

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

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 = { "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 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !11, i64 0}
!10 = !{!"", !11, i64 0, !11, i64 8, !11, i64 16}
!11 = !{!"any pointer", !7, i64 0}
!12 = !{!10, !11, i64 8}
!13 = distinct !{!13, !14}
!14 = !{!"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.DHCOMMAND = type { ptr, ptr, ptr }

@.str = external hidden unnamed_addr constant [64 x i8], align 1
@mCommands = external hidden local_unnamed_addr constant [12 x %struct.DHCOMMAND], align 16
@.str.1 = external hidden unnamed_addr constant [4 x i8], align 1

; Function Attrs: nounwind uwtable
define dso_local void @command_help() local_unnamed_addr #0 {
  tail call void @dh_uart_send_line(ptr noundef nonnull @.str) #2
  %1 = load ptr, ptr @mCommands, align 16, !tbaa !5
  tail call void @dh_uart_send_str(ptr noundef %1) #2
  tail call void @dh_uart_send_str(ptr noundef nonnull @.str.1) #2
  %2 = load ptr, ptr getelementptr inbounds (i8, ptr @mCommands, i64 8), align 8, !tbaa !10
  tail call void @dh_uart_send_line(ptr noundef %2) #2
  %3 = load ptr, ptr getelementptr inbounds (i8, ptr @mCommands, i64 24), align 8, !tbaa !5
  tail call void @dh_uart_send_str(ptr noundef %3) #2
  tail call void @dh_uart_send_str(ptr noundef nonnull @.str.1) #2
  %4 = load ptr, ptr getelementptr inbounds (i8, ptr @mCommands, i64 32), align 16, !tbaa !10
  tail call void @dh_uart_send_line(ptr noundef %4) #2
  %5 = load ptr, ptr getelementptr inbounds (i8, ptr @mCommands, i64 48), align 16, !tbaa !5
  tail call void @dh_uart_send_str(ptr noundef %5) #2
  tail call void @dh_uart_send_str(ptr noundef nonnull @.str.1) #2
  %6 = load ptr, ptr getelementptr inbounds (i8, ptr @mCommands, i64 56), align 8, !tbaa !10
  tail call void @dh_uart_send_line(ptr noundef %6) #2
  %7 = load ptr, ptr getelementptr inbounds (i8, ptr @mCommands, i64 72), align 8, !tbaa !5
  tail call void @dh_uart_send_str(ptr noundef %7) #2
  tail call void @dh_uart_send_str(ptr noundef nonnull @.str.1) #2
  %8 = load ptr, ptr getelementptr inbounds (i8, ptr @mCommands, i64 80), align 16, !tbaa !10
  tail call void @dh_uart_send_line(ptr noundef %8) #2
  %9 = load ptr, ptr getelementptr inbounds (i8, ptr @mCommands, i64 96), align 16, !tbaa !5
  tail call void @dh_uart_send_str(ptr noundef %9) #2
  tail call void @dh_uart_send_str(ptr noundef nonnull @.str.1) #2
  %10 = load ptr, ptr getelementptr inbounds (i8, ptr @mCommands, i64 104), align 8, !tbaa !10
  tail call void @dh_uart_send_line(ptr noundef %10) #2
  %11 = load ptr, ptr getelementptr inbounds (i8, ptr @mCommands, i64 120), align 8, !tbaa !5
  tail call void @dh_uart_send_str(ptr noundef %11) #2
  tail call void @dh_uart_send_str(ptr noundef nonnull @.str.1) #2
  %12 = load ptr, ptr getelementptr inbounds (i8, ptr @mCommands, i64 128), align 16, !tbaa !10
  tail call void @dh_uart_send_line(ptr noundef %12) #2
  %13 = load ptr, ptr getelementptr inbounds (i8, ptr @mCommands, i64 144), align 16, !tbaa !5
  tail call void @dh_uart_send_str(ptr noundef %13) #2
  tail call void @dh_uart_send_str(ptr noundef nonnull @.str.1) #2
  %14 = load ptr, ptr getelementptr inbounds (i8, ptr @mCommands, i64 152), align 8, !tbaa !10
  tail call void @dh_uart_send_line(ptr noundef %14) #2
  %15 = load ptr, ptr getelementptr inbounds (i8, ptr @mCommands, i64 168), align 8, !tbaa !5
  tail call void @dh_uart_send_str(ptr noundef %15) #2
  tail call void @dh_uart_send_str(ptr noundef nonnull @.str.1) #2
  %16 = load ptr, ptr getelementptr inbounds (i8, ptr @mCommands, i64 176), align 16, !tbaa !10
  tail call void @dh_uart_send_line(ptr noundef %16) #2
  %17 = load ptr, ptr getelementptr inbounds (i8, ptr @mCommands, i64 192), align 16, !tbaa !5
  tail call void @dh_uart_send_str(ptr noundef %17) #2
  tail call void @dh_uart_send_str(ptr noundef nonnull @.str.1) #2
  %18 = load ptr, ptr getelementptr inbounds (i8, ptr @mCommands, i64 200), align 8, !tbaa !10
  tail call void @dh_uart_send_line(ptr noundef %18) #2
  %19 = load ptr, ptr getelementptr inbounds (i8, ptr @mCommands, i64 216), align 8, !tbaa !5
  tail call void @dh_uart_send_str(ptr noundef %19) #2
  tail call void @dh_uart_send_str(ptr noundef nonnull @.str.1) #2
  %20 = load ptr, ptr getelementptr inbounds (i8, ptr @mCommands, i64 224), align 16, !tbaa !10
  tail call void @dh_uart_send_line(ptr noundef %20) #2
  %21 = load ptr, ptr getelementptr inbounds (i8, ptr @mCommands, i64 240), align 16, !tbaa !5
  tail call void @dh_uart_send_str(ptr noundef %21) #2
  tail call void @dh_uart_send_str(ptr noundef nonnull @.str.1) #2
  %22 = load ptr, ptr getelementptr inbounds (i8, ptr @mCommands, i64 248), align 8, !tbaa !10
  tail call void @dh_uart_send_line(ptr noundef %22) #2
  %23 = load ptr, ptr getelementptr inbounds (i8, ptr @mCommands, i64 264), align 8, !tbaa !5
  tail call void @dh_uart_send_str(ptr noundef %23) #2
  tail call void @dh_uart_send_str(ptr noundef nonnull @.str.1) #2
  %24 = load ptr, ptr getelementptr inbounds (i8, ptr @mCommands, i64 272), align 16, !tbaa !10
  tail call void @dh_uart_send_line(ptr noundef %24) #2
  ret void
}

declare void @dh_uart_send_line(ptr noundef) local_unnamed_addr #1

declare void @dh_uart_send_str(ptr noundef) local_unnamed_addr #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 = { "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, !7, i64 0}
!6 = !{!"", !7, i64 0, !7, i64 8, !7, i64 16}
!7 = !{!"any pointer", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!6, !7, i64 8}


; Effective O3 passes: EarlyCSEPass,GVNPass,GlobalOptPass,IndVarSimplifyPass,InferAlignmentPass,InferFunctionAttrsPass,InstCombinePass,LoopRotatePass,SROAPass,SimplifyCFGPass,TailCallElimPass