; LLVM IR from cpq/bare-metal-programming-guide :: steps/step-7-webserver/nucleo-f429zi (main)

; 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.mip_driver_stm32 = type { i32 }
%struct.mip_driver = type { ptr, ptr, ptr, ptr, ptr }
%struct.mg_mgr = type { ptr, %struct.mg_dns, %struct.mg_dns, i32, i8, i64, i64, ptr, i16, ptr, ptr, i32, ptr, i64 }
%struct.mg_dns = type { ptr, ptr }
%struct.mip_if = type { [6 x i8], i32, i32, i32, %struct.mg_str, %struct.mg_str, i8, ptr, ptr, ptr, i64, i64, i64, [62 x i8], i16, i16, i8, %struct.queue }
%struct.mg_str = type { ptr, i64 }
%struct.queue = type { ptr, i64, i64, i64 }
%struct.RCC_TypeDef = type { i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, [2 x i32], i32, i32, i32, i32, i32, i32, [2 x i32], i32, i32, i32, i32, i32, i32, [2 x i32], i32, i32, [2 x i32], i32, i32, i32, i32 }
%struct.SYSCFG_TypeDef = type { i32, i32, [4 x i32], [2 x i32], i32 }

@s_ticks = external hidden global i32, align 4
@__const.main.pins = external hidden unnamed_addr constant [9 x i16], align 16
@__const.main.driver_data = external hidden unnamed_addr constant %struct.mip_driver_stm32, align 4
@mip_driver_stm32 = external global %struct.mip_driver, align 8
@.str = external hidden unnamed_addr constant [15 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [110 x i8], align 1
@__func__.main = external hidden unnamed_addr constant [5 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [30 x i8], align 1
@main.on = external hidden global i8, align 1
@.str.3 = external hidden unnamed_addr constant [21 x i8], align 1

; Function Attrs: nounwind uwtable
define dso_local i32 @main() #0 {
  %1 = alloca i32, align 4
  %2 = alloca i16, align 2
  %3 = alloca i32, align 4
  %4 = alloca i32, align 4
  %5 = alloca [9 x i16], align 16
  %6 = alloca i64, align 8
  %7 = alloca %struct.mg_mgr, align 8
  %8 = alloca %struct.mip_driver_stm32, align 4
  %9 = alloca %struct.mip_if, align 8
  store i32 0, ptr %1, align 4
  call void @llvm.lifetime.start.p0(i64 2, ptr %2) #6
  store i16 263, ptr %2, align 2, !tbaa !5
  call void @clock_init()
  call void @systick_init(i32 noundef 180000)
  %10 = load i16, ptr %2, align 2, !tbaa !5
  call void @gpio_set_mode(i16 noundef zeroext %10, i8 noundef zeroext 1)
  call void @uart_init(ptr noundef inttoptr (i64 1073760256 to ptr), i64 noundef 115200)
  call void @llvm.lifetime.start.p0(i64 4, ptr %3) #6
  store i32 0, ptr %3, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #6
  store i32 500, ptr %4, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 18, ptr %5) #6
  call void @llvm.memcpy.p0.p0.i64(ptr align 16 %5, ptr align 16 @__const.main.pins, i64 18, i1 false)
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #6
  store i64 0, ptr %6, align 8, !tbaa !11
  br label %11

11:                                               ; preds = %19, %0
  %12 = load i64, ptr %6, align 8, !tbaa !11
  %13 = icmp ult i64 %12, 9
  br i1 %13, label %15, label %14

14:                                               ; preds = %11
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #6
  br label %22

15:                                               ; preds = %11
  %16 = load i64, ptr %6, align 8, !tbaa !11
  %17 = getelementptr inbounds [9 x i16], ptr %5, i64 0, i64 %16
  %18 = load i16, ptr %17, align 2, !tbaa !5
  call void @gpio_init(i16 noundef zeroext %18, i8 noundef zeroext 2, i8 noundef zeroext 0, i8 noundef zeroext 3, i8 noundef zeroext 0, i8 noundef zeroext 11)
  br label %19

19:                                               ; preds = %15
  %20 = load i64, ptr %6, align 8, !tbaa !11
  %21 = add i64 %20, 1
  store i64 %21, ptr %6, align 8, !tbaa !11
  br label %11, !llvm.loop !13

22:                                               ; preds = %14
  call void @__NVIC_EnableIRQ(i32 noundef 61)
  %23 = load volatile i32, ptr getelementptr inbounds (%struct.RCC_TypeDef, ptr inttoptr (i64 1073887232 to ptr), i32 0, i32 16), align 4, !tbaa !15
  %24 = zext i32 %23 to i64
  %25 = or i64 %24, 16384
  %26 = trunc i64 %25 to i32
  store volatile i32 %26, ptr getelementptr inbounds (%struct.RCC_TypeDef, ptr inttoptr (i64 1073887232 to ptr), i32 0, i32 16), align 4, !tbaa !15
  %27 = load volatile i32, ptr getelementptr inbounds (%struct.SYSCFG_TypeDef, ptr inttoptr (i64 1073821696 to ptr), i32 0, i32 1), align 4, !tbaa !17
  %28 = zext i32 %27 to i64
  %29 = or i64 %28, 8388608
  %30 = trunc i64 %29 to i32
  store volatile i32 %30, ptr getelementptr inbounds (%struct.SYSCFG_TypeDef, ptr inttoptr (i64 1073821696 to ptr), i32 0, i32 1), align 4, !tbaa !17
  %31 = load volatile i32, ptr getelementptr inbounds (%struct.RCC_TypeDef, ptr inttoptr (i64 1073887232 to ptr), i32 0, i32 11), align 4, !tbaa !19
  %32 = zext i32 %31 to i64
  %33 = or i64 %32, 234881024
  %34 = trunc i64 %33 to i32
  store volatile i32 %34, ptr getelementptr inbounds (%struct.RCC_TypeDef, ptr inttoptr (i64 1073887232 to ptr), i32 0, i32 11), align 4, !tbaa !19
  %35 = load volatile i32, ptr getelementptr inbounds (%struct.RCC_TypeDef, ptr inttoptr (i64 1073887232 to ptr), i32 0, i32 4), align 4, !tbaa !20
  %36 = zext i32 %35 to i64
  %37 = or i64 %36, 33554432
  %38 = trunc i64 %37 to i32
  store volatile i32 %38, ptr getelementptr inbounds (%struct.RCC_TypeDef, ptr inttoptr (i64 1073887232 to ptr), i32 0, i32 4), align 4, !tbaa !20
  %39 = load volatile i32, ptr getelementptr inbounds (%struct.RCC_TypeDef, ptr inttoptr (i64 1073887232 to ptr), i32 0, i32 4), align 4, !tbaa !20
  %40 = zext i32 %39 to i64
  %41 = and i64 %40, -33554433
  %42 = trunc i64 %41 to i32
  store volatile i32 %42, ptr getelementptr inbounds (%struct.RCC_TypeDef, ptr inttoptr (i64 1073887232 to ptr), i32 0, i32 4), align 4, !tbaa !20
  call void @llvm.lifetime.start.p0(i64 120, ptr %7) #6
  call void @mg_mgr_init(ptr noundef %7)
  call void @mg_log_set(i32 noundef 3)
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #6
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %8, ptr align 4 @__const.main.driver_data, i64 4, i1 false)
  call void @llvm.lifetime.start.p0(i64 216, ptr %9) #6
  call void @llvm.memset.p0.i64(ptr align 8 %9, i8 0, i64 216, i1 false)
  %43 = getelementptr inbounds %struct.mip_if, ptr %9, i32 0, i32 0
  store i8 2, ptr %43, align 1, !tbaa !21
  %44 = getelementptr inbounds i8, ptr %43, i64 1
  %45 = getelementptr inbounds i8, ptr %43, i64 2
  store i8 1, ptr %45, align 1, !tbaa !21
  %46 = getelementptr inbounds i8, ptr %43, i64 3
  store i8 2, ptr %46, align 1, !tbaa !21
  %47 = getelementptr inbounds i8, ptr %43, i64 4
  store i8 3, ptr %47, align 1, !tbaa !21
  %48 = getelementptr inbounds i8, ptr %43, i64 5
  store i8 5, ptr %48, align 1, !tbaa !21
  %49 = getelementptr inbounds %struct.mip_if, ptr %9, i32 0, i32 1
  %50 = getelementptr inbounds %struct.mip_if, ptr %9, i32 0, i32 2
  %51 = getelementptr inbounds %struct.mip_if, ptr %9, i32 0, i32 3
  %52 = getelementptr inbounds %struct.mip_if, ptr %9, i32 0, i32 4
  %53 = getelementptr inbounds %struct.mip_if, ptr %9, i32 0, i32 5
  %54 = getelementptr inbounds %struct.mip_if, ptr %9, i32 0, i32 6
  store i8 1, ptr %54, align 8, !tbaa !22
  %55 = getelementptr inbounds %struct.mip_if, ptr %9, i32 0, i32 7
  store ptr @mip_driver_stm32, ptr %55, align 8, !tbaa !28
  %56 = getelementptr inbounds %struct.mip_if, ptr %9, i32 0, i32 8
  store ptr %8, ptr %56, align 8, !tbaa !29
  %57 = getelementptr inbounds %struct.mip_if, ptr %9, i32 0, i32 9
  %58 = getelementptr inbounds %struct.mip_if, ptr %9, i32 0, i32 10
  %59 = getelementptr inbounds %struct.mip_if, ptr %9, i32 0, i32 11
  %60 = getelementptr inbounds %struct.mip_if, ptr %9, i32 0, i32 12
  %61 = getelementptr inbounds %struct.mip_if, ptr %9, i32 0, i32 13
  %62 = getelementptr inbounds %struct.mip_if, ptr %9, i32 0, i32 14
  %63 = getelementptr inbounds %struct.mip_if, ptr %9, i32 0, i32 15
  %64 = getelementptr inbounds %struct.mip_if, ptr %9, i32 0, i32 16
  %65 = getelementptr inbounds %struct.mip_if, ptr %9, i32 0, i32 17
  call void @mip_init(ptr noundef %7, ptr noundef %9)
  %66 = call ptr @mg_http_listen(ptr noundef %7, ptr noundef @.str, ptr noundef @device_dashboard_fn, ptr noundef %7)
  br label %67

67:                                               ; preds = %22
  %68 = call zeroext i1 @mg_log_prefix(i32 noundef 2, ptr noundef @.str.1, i32 noundef 51, ptr noundef @__func__.main)
  br i1 %68, label %69, label %70

69:                                               ; preds = %67
  call void (ptr, ...) @mg_log(ptr noundef @.str.2)
  br label %70

70:                                               ; preds = %69, %67
  br label %71

71:                                               ; preds = %70
  br label %72

72:                                               ; preds = %71
  br label %73

73:                                               ; preds = %90, %72
  %74 = load i32, ptr %4, align 4, !tbaa !9
  %75 = load volatile i32, ptr @s_ticks, align 4, !tbaa !9
  %76 = call zeroext i1 @timer_expired(ptr noundef %3, i32 noundef %74, i32 noundef %75)
  br i1 %76, label %77, label %90

77:                                               ; preds = %73
  %78 = load i16, ptr %2, align 2, !tbaa !5
  %79 = load i8, ptr @main.on, align 1, !tbaa !30, !range !31, !noundef !32
  %80 = trunc i8 %79 to i1
  call void @gpio_write(i16 noundef zeroext %78, i1 noundef zeroext %80)
  %81 = load i8, ptr @main.on, align 1, !tbaa !30, !range !31, !noundef !32
  %82 = trunc i8 %81 to i1
  %83 = xor i1 %82, true
  %84 = zext i1 %83 to i8
  store i8 %84, ptr @main.on, align 1, !tbaa !30
  %85 = load i8, ptr @main.on, align 1, !tbaa !30, !range !31, !noundef !32
  %86 = trunc i8 %85 to i1
  %87 = zext i1 %86 to i32
  %88 = load volatile i32, ptr @s_ticks, align 4, !tbaa !9
  %89 = call i32 (ptr, ...) @printf(ptr noundef @.str.3, i32 noundef %87, i32 noundef %88)
  br label %90

90:                                               ; preds = %77, %73
  call void @mg_mgr_poll(ptr noundef %7, i32 noundef 0)
  br label %73
}

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

; Function Attrs: inlinehint nounwind uwtable
declare hidden void @clock_init() #2

; Function Attrs: inlinehint nounwind uwtable
declare hidden void @systick_init(i32 noundef) #2

; Function Attrs: inlinehint nounwind uwtable
declare hidden void @gpio_set_mode(i16 noundef zeroext, i8 noundef zeroext) #2

; Function Attrs: inlinehint nounwind uwtable
declare hidden void @uart_init(ptr noundef, i64 noundef) #2

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: readwrite)
declare void @llvm.memcpy.p0.p0.i64(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i64, i1 immarg) #3

; Function Attrs: inlinehint nounwind uwtable
declare hidden void @gpio_init(i16 noundef zeroext, i8 noundef zeroext, i8 noundef zeroext, i8 noundef zeroext, i8 noundef zeroext, i8 noundef zeroext) #2

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

; Function Attrs: inlinehint nounwind uwtable
declare hidden void @__NVIC_EnableIRQ(i32 noundef) #2

declare void @mg_mgr_init(ptr noundef) #4

declare void @mg_log_set(i32 noundef) #4

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

declare void @mip_init(ptr noundef, ptr noundef) #4

declare ptr @mg_http_listen(ptr noundef, ptr noundef, ptr noundef, ptr noundef) #4

declare void @device_dashboard_fn(ptr noundef, i32 noundef, ptr noundef, ptr noundef) #4

declare zeroext i1 @mg_log_prefix(i32 noundef, ptr noundef, i32 noundef, ptr noundef) #4

declare void @mg_log(ptr noundef, ...) #4

; Function Attrs: inlinehint nounwind uwtable
declare hidden zeroext i1 @timer_expired(ptr noundef, i32 noundef, i32 noundef) #2

; Function Attrs: inlinehint nounwind uwtable
declare hidden void @gpio_write(i16 noundef zeroext, i1 noundef zeroext) #2

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

declare void @mg_mgr_poll(ptr noundef, i32 noundef) #4

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 = { inlinehint 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 #3 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
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 = { nocallback nofree nounwind willreturn memory(argmem: write) }
attributes #6 = { 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 = !{!"short", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"int", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"long", !7, i64 0}
!13 = distinct !{!13, !14}
!14 = !{!"llvm.loop.mustprogress"}
!15 = !{!16, !10, i64 68}
!16 = !{!"", !10, i64 0, !10, i64 4, !10, i64 8, !10, i64 12, !10, i64 16, !10, i64 20, !10, i64 24, !10, i64 28, !10, i64 32, !10, i64 36, !7, i64 40, !10, i64 48, !10, i64 52, !10, i64 56, !10, i64 60, !10, i64 64, !10, i64 68, !7, i64 72, !10, i64 80, !10, i64 84, !10, i64 88, !10, i64 92, !10, i64 96, !10, i64 100, !7, i64 104, !10, i64 112, !10, i64 116, !7, i64 120, !10, i64 128, !10, i64 132, !10, i64 136, !10, i64 140}
!17 = !{!18, !10, i64 4}
!18 = !{!"", !10, i64 0, !10, i64 4, !7, i64 8, !7, i64 24, !10, i64 32}
!19 = !{!16, !10, i64 48}
!20 = !{!16, !10, i64 16}
!21 = !{!7, !7, i64 0}
!22 = !{!23, !26, i64 56}
!23 = !{!"mip_if", !7, i64 0, !10, i64 8, !10, i64 12, !10, i64 16, !24, i64 24, !24, i64 40, !26, i64 56, !25, i64 64, !25, i64 72, !25, i64 80, !12, i64 88, !12, i64 96, !12, i64 104, !7, i64 112, !6, i64 174, !6, i64 176, !7, i64 178, !27, i64 184}
!24 = !{!"mg_str", !25, i64 0, !12, i64 8}
!25 = !{!"any pointer", !7, i64 0}
!26 = !{!"_Bool", !7, i64 0}
!27 = !{!"queue", !25, i64 0, !12, i64 8, !12, i64 16, !12, i64 24}
!28 = !{!23, !25, i64 64}
!29 = !{!23, !25, i64 72}
!30 = !{!26, !26, i64 0}
!31 = !{i8 0, i8 2}
!32 = !{}


; 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.mip_driver_stm32 = type { i32 }
%struct.mip_driver = type { ptr, ptr, ptr, ptr, ptr }
%struct.mg_mgr = type { ptr, %struct.mg_dns, %struct.mg_dns, i32, i8, i64, i64, ptr, i16, ptr, ptr, i32, ptr, i64 }
%struct.mg_dns = type { ptr, ptr }
%struct.mip_if = type { [6 x i8], i32, i32, i32, %struct.mg_str, %struct.mg_str, i8, ptr, ptr, ptr, i64, i64, i64, [62 x i8], i16, i16, i8, %struct.queue }
%struct.mg_str = type { ptr, i64 }
%struct.queue = type { ptr, i64, i64, i64 }

@s_ticks = external hidden global i32, align 4
@__const.main.pins = external hidden unnamed_addr constant [9 x i16], align 16
@__const.main.driver_data = external hidden unnamed_addr constant %struct.mip_driver_stm32, align 4
@mip_driver_stm32 = external global %struct.mip_driver, align 8
@.str = external hidden unnamed_addr constant [15 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [110 x i8], align 1
@__func__.main = external hidden unnamed_addr constant [5 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [30 x i8], align 1
@main.on = external hidden local_unnamed_addr global i8, align 1
@.str.3 = external hidden unnamed_addr constant [21 x i8], align 1

; Function Attrs: noreturn nounwind uwtable
define dso_local noundef i32 @main() local_unnamed_addr #0 {
  %1 = alloca i32, align 4
  %2 = alloca %struct.mg_mgr, align 8
  %3 = alloca %struct.mip_driver_stm32, align 4
  %4 = alloca %struct.mip_if, align 8
  tail call void @clock_init()
  tail call void @systick_init(i32 noundef 180000)
  tail call void @gpio_set_mode(i16 noundef zeroext 263, i8 noundef zeroext 1)
  tail call void @uart_init(ptr noundef nonnull inttoptr (i64 1073760256 to ptr), i64 noundef 115200)
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %1) #6
  store i32 0, ptr %1, align 4, !tbaa !5
  %5 = load i16, ptr @__const.main.pins, align 16, !tbaa !9
  tail call void @gpio_init(i16 noundef zeroext %5, i8 noundef zeroext 2, i8 noundef zeroext 0, i8 noundef zeroext 3, i8 noundef zeroext 0, i8 noundef zeroext 11)
  %6 = load i16, ptr getelementptr inbounds (i8, ptr @__const.main.pins, i64 2), align 2, !tbaa !9
  tail call void @gpio_init(i16 noundef zeroext %6, i8 noundef zeroext 2, i8 noundef zeroext 0, i8 noundef zeroext 3, i8 noundef zeroext 0, i8 noundef zeroext 11)
  %7 = load i16, ptr getelementptr inbounds (i8, ptr @__const.main.pins, i64 4), align 4, !tbaa !9
  tail call void @gpio_init(i16 noundef zeroext %7, i8 noundef zeroext 2, i8 noundef zeroext 0, i8 noundef zeroext 3, i8 noundef zeroext 0, i8 noundef zeroext 11)
  %8 = load i16, ptr getelementptr inbounds (i8, ptr @__const.main.pins, i64 6), align 2, !tbaa !9
  tail call void @gpio_init(i16 noundef zeroext %8, i8 noundef zeroext 2, i8 noundef zeroext 0, i8 noundef zeroext 3, i8 noundef zeroext 0, i8 noundef zeroext 11)
  %9 = load i16, ptr getelementptr inbounds (i8, ptr @__const.main.pins, i64 8), align 8, !tbaa !9
  tail call void @gpio_init(i16 noundef zeroext %9, i8 noundef zeroext 2, i8 noundef zeroext 0, i8 noundef zeroext 3, i8 noundef zeroext 0, i8 noundef zeroext 11)
  %10 = load i16, ptr getelementptr inbounds (i8, ptr @__const.main.pins, i64 10), align 2, !tbaa !9
  tail call void @gpio_init(i16 noundef zeroext %10, i8 noundef zeroext 2, i8 noundef zeroext 0, i8 noundef zeroext 3, i8 noundef zeroext 0, i8 noundef zeroext 11)
  %11 = load i16, ptr getelementptr inbounds (i8, ptr @__const.main.pins, i64 12), align 4, !tbaa !9
  tail call void @gpio_init(i16 noundef zeroext %11, i8 noundef zeroext 2, i8 noundef zeroext 0, i8 noundef zeroext 3, i8 noundef zeroext 0, i8 noundef zeroext 11)
  %12 = load i16, ptr getelementptr inbounds (i8, ptr @__const.main.pins, i64 14), align 2, !tbaa !9
  tail call void @gpio_init(i16 noundef zeroext %12, i8 noundef zeroext 2, i8 noundef zeroext 0, i8 noundef zeroext 3, i8 noundef zeroext 0, i8 noundef zeroext 11)
  %13 = load i16, ptr getelementptr inbounds (i8, ptr @__const.main.pins, i64 16), align 16, !tbaa !9
  tail call void @gpio_init(i16 noundef zeroext %13, i8 noundef zeroext 2, i8 noundef zeroext 0, i8 noundef zeroext 3, i8 noundef zeroext 0, i8 noundef zeroext 11)
  tail call void @__NVIC_EnableIRQ(i32 noundef 61)
  %14 = load volatile i32, ptr inttoptr (i64 1073887300 to ptr), align 4, !tbaa !11
  %15 = or i32 %14, 16384
  store volatile i32 %15, ptr inttoptr (i64 1073887300 to ptr), align 4, !tbaa !11
  %16 = load volatile i32, ptr inttoptr (i64 1073821700 to ptr), align 4, !tbaa !13
  %17 = or i32 %16, 8388608
  store volatile i32 %17, ptr inttoptr (i64 1073821700 to ptr), align 4, !tbaa !13
  %18 = load volatile i32, ptr inttoptr (i64 1073887280 to ptr), align 16, !tbaa !15
  %19 = or i32 %18, 234881024
  store volatile i32 %19, ptr inttoptr (i64 1073887280 to ptr), align 16, !tbaa !15
  %20 = load volatile i32, ptr inttoptr (i64 1073887248 to ptr), align 16, !tbaa !16
  %21 = or i32 %20, 33554432
  store volatile i32 %21, ptr inttoptr (i64 1073887248 to ptr), align 16, !tbaa !16
  %22 = load volatile i32, ptr inttoptr (i64 1073887248 to ptr), align 16, !tbaa !16
  %23 = and i32 %22, -33554433
  store volatile i32 %23, ptr inttoptr (i64 1073887248 to ptr), align 16, !tbaa !16
  call void @llvm.lifetime.start.p0(i64 120, ptr nonnull %2) #6
  call void @mg_mgr_init(ptr noundef nonnull %2) #6
  call void @mg_log_set(i32 noundef 3) #6
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %3) #6
  %24 = load i32, ptr @__const.main.driver_data, align 4
  store i32 %24, ptr %3, align 4
  call void @llvm.lifetime.start.p0(i64 216, ptr nonnull %4) #6
  call void @llvm.memset.p0.i64(ptr noundef nonnull align 8 dereferenceable(216) %4, i8 0, i64 216, i1 false)
  store i8 2, ptr %4, align 8, !tbaa !17
  %25 = getelementptr inbounds i8, ptr %4, i64 2
  store <4 x i8> <i8 1, i8 2, i8 3, i8 5>, ptr %25, align 2, !tbaa !17
  %26 = getelementptr inbounds i8, ptr %4, i64 56
  store i8 1, ptr %26, align 8, !tbaa !18
  %27 = getelementptr inbounds i8, ptr %4, i64 64
  store ptr @mip_driver_stm32, ptr %27, align 8, !tbaa !25
  %28 = getelementptr inbounds i8, ptr %4, i64 72
  store ptr %3, ptr %28, align 8, !tbaa !26
  call void @mip_init(ptr noundef nonnull %2, ptr noundef nonnull %4) #6
  %29 = call ptr @mg_http_listen(ptr noundef nonnull %2, ptr noundef nonnull @.str, ptr noundef nonnull @device_dashboard_fn, ptr noundef nonnull %2) #6
  %30 = call zeroext i1 @mg_log_prefix(i32 noundef 2, ptr noundef nonnull @.str.1, i32 noundef 51, ptr noundef nonnull @__func__.main) #6
  br i1 %30, label %31, label %.preheader

31:                                               ; preds = %0
  call void (ptr, ...) @mg_log(ptr noundef nonnull @.str.2) #6
  br label %.preheader

.preheader:                                       ; preds = %31, %0
  br label %32

32:                                               ; preds = %.preheader, %45
  %33 = load volatile i32, ptr @s_ticks, align 4, !tbaa !5
  %34 = call zeroext i1 @timer_expired(ptr noundef nonnull %1, i32 noundef 500, i32 noundef %33)
  br i1 %34, label %35, label %45

35:                                               ; preds = %32
  %36 = load i8, ptr @main.on, align 1, !tbaa !27, !range !28, !noundef !29
  %37 = trunc nuw i8 %36 to i1
  call void @gpio_write(i16 noundef zeroext 263, i1 noundef zeroext %37)
  %38 = load i8, ptr @main.on, align 1, !tbaa !27, !range !28, !noundef !29
  %39 = trunc nuw i8 %38 to i1
  %40 = xor i1 %39, true
  %41 = zext i1 %40 to i8
  store i8 %41, ptr @main.on, align 1, !tbaa !27
  %42 = zext i1 %40 to i32
  %43 = load volatile i32, ptr @s_ticks, align 4, !tbaa !5
  %44 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.3, i32 noundef %42, i32 noundef %43)
  br label %45

45:                                               ; preds = %35, %32
  call void @mg_mgr_poll(ptr noundef nonnull %2, i32 noundef 0) #6
  br label %32
}

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

; Function Attrs: inlinehint nounwind uwtable
declare hidden void @clock_init() local_unnamed_addr #2

; Function Attrs: inlinehint nounwind uwtable
declare hidden void @systick_init(i32 noundef) local_unnamed_addr #2

; Function Attrs: inlinehint nounwind uwtable
declare hidden void @gpio_set_mode(i16 noundef zeroext, i8 noundef zeroext) local_unnamed_addr #2

; Function Attrs: inlinehint nounwind uwtable
declare hidden void @uart_init(ptr noundef, i64 noundef) local_unnamed_addr #2

; Function Attrs: inlinehint nounwind uwtable
declare hidden void @gpio_init(i16 noundef zeroext, i8 noundef zeroext, i8 noundef zeroext, i8 noundef zeroext, i8 noundef zeroext, i8 noundef zeroext) local_unnamed_addr #2

; Function Attrs: inlinehint nounwind uwtable
declare hidden void @__NVIC_EnableIRQ(i32 noundef) local_unnamed_addr #2

declare void @mg_mgr_init(ptr noundef) local_unnamed_addr #3

declare void @mg_log_set(i32 noundef) local_unnamed_addr #3

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

declare void @mip_init(ptr noundef, ptr noundef) local_unnamed_addr #3

declare ptr @mg_http_listen(ptr noundef, ptr noundef, ptr noundef, ptr noundef) local_unnamed_addr #3

declare void @device_dashboard_fn(ptr noundef, i32 noundef, ptr noundef, ptr noundef) #3

declare zeroext i1 @mg_log_prefix(i32 noundef, ptr noundef, i32 noundef, ptr noundef) local_unnamed_addr #3

declare void @mg_log(ptr noundef, ...) local_unnamed_addr #3

; Function Attrs: inlinehint nounwind uwtable
declare hidden zeroext i1 @timer_expired(ptr noundef, i32 noundef, i32 noundef) local_unnamed_addr #2

; Function Attrs: inlinehint nounwind uwtable
declare hidden void @gpio_write(i16 noundef zeroext, i1 noundef zeroext) local_unnamed_addr #2

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

declare void @mg_mgr_poll(ptr noundef, i32 noundef) local_unnamed_addr #3

attributes #0 = { noreturn 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 nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { inlinehint 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 #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 = { mustprogress nocallback nofree nounwind willreturn memory(argmem: write) }
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 = { 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, !10, i64 0}
!10 = !{!"short", !7, i64 0}
!11 = !{!12, !6, i64 68}
!12 = !{!"", !6, i64 0, !6, i64 4, !6, i64 8, !6, i64 12, !6, i64 16, !6, i64 20, !6, i64 24, !6, i64 28, !6, i64 32, !6, i64 36, !7, i64 40, !6, i64 48, !6, i64 52, !6, i64 56, !6, i64 60, !6, i64 64, !6, i64 68, !7, i64 72, !6, i64 80, !6, i64 84, !6, i64 88, !6, i64 92, !6, i64 96, !6, i64 100, !7, i64 104, !6, i64 112, !6, i64 116, !7, i64 120, !6, i64 128, !6, i64 132, !6, i64 136, !6, i64 140}
!13 = !{!14, !6, i64 4}
!14 = !{!"", !6, i64 0, !6, i64 4, !7, i64 8, !7, i64 24, !6, i64 32}
!15 = !{!12, !6, i64 48}
!16 = !{!12, !6, i64 16}
!17 = !{!7, !7, i64 0}
!18 = !{!19, !23, i64 56}
!19 = !{!"mip_if", !7, i64 0, !6, i64 8, !6, i64 12, !6, i64 16, !20, i64 24, !20, i64 40, !23, i64 56, !21, i64 64, !21, i64 72, !21, i64 80, !22, i64 88, !22, i64 96, !22, i64 104, !7, i64 112, !10, i64 174, !10, i64 176, !7, i64 178, !24, i64 184}
!20 = !{!"mg_str", !21, i64 0, !22, i64 8}
!21 = !{!"any pointer", !7, i64 0}
!22 = !{!"long", !7, i64 0}
!23 = !{!"_Bool", !7, i64 0}
!24 = !{!"queue", !21, i64 0, !22, i64 8, !22, i64 16, !22, i64 24}
!25 = !{!19, !21, i64 64}
!26 = !{!19, !21, i64 72}
!27 = !{!23, !23, i64 0}
!28 = !{i8 0, i8 2}
!29 = !{}


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