#define NULL ((void *)0)
typedef unsigned long size_t; // Customize by platform.
typedef long intptr_t;
typedef unsigned long uintptr_t;
typedef long scalar_t__; // Either arithmetic or pointer type.
/* By default, we understand bool (as a convenience). */
typedef int bool;
#define false 0
#define true 1

/* Forward declarations */

/* Type definitions */

/* Variables and functions */
int /*<<< orphan*/ adc_init();
int /*<<< orphan*/ delay_ms(int);
int /*<<< orphan*/ gpio_a_output(int);
int /*<<< orphan*/ gpio_a_set(int, int);
int /*<<< orphan*/ led_init(int);
int /*<<< orphan*/ led_off();
int my_strlen(char *);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ rcc_init();
int /*<<< orphan*/ serial_getl(char *);
int /*<<< orphan*/ serial_init();
int /*<<< orphan*/ serial_puts(char *);
int /*<<< orphan*/ systick_init_int(int);
void startup(void) {
  int t;
  unsigned long systick_next;
  int x;
  char buf[80];
  char *p;
  rcc_init();
  serial_init();
  printf(" -- Booting ------------------------------\n");
  adc_init();
  led_init(13);
  led_off();
  gpio_a_output(2);
  systick_init_int(72 * 1000 * 2000);
  x = 0;
  for (;;) {
    delay_ms(1000);
    if (x) {
      gpio_a_set(2, 1);
      x = 0;
    } else {
      gpio_a_set(2, 0);
      x = 1;
    }
  }
  serial_getl(buf);
  x = my_strlen(buf);
  for (;;) {
    printf("---\n");
    for (p = buf; *p; p++)
      printf(" %02x\n", *p);
    delay_ms(2000);
  }
  serial_puts("Main is spinning\n");
  for (;;)
    ;
}


x86 assembly (clang, -O0):
<startup>:
push   %rbp
mov    %rsp,%rbp
sub    $0x80,%rsp
mov    $0x0,%al
call   1060 <rcc_init@plt>
mov    $0x0,%al
call   10c0 <serial_init@plt>
lea    0xe40(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
mov    $0x0,%al
call   10a0 <adc_init@plt>
mov    $0xd,%edi
call   1080 <led_init@plt>
mov    $0x0,%al
call   1040 <led_off@plt>
mov    $0x2,%edi
call   1090 <gpio_a_output@plt>
mov    $0x8954400,%edi
call   1030 <systick_init_int@plt>
movl   $0x0,-0x14(%rbp)
mov    $0x3e8,%edi
call   10b0 <delay_ms@plt>
cmpl   $0x0,-0x14(%rbp)
je     1229 <startup+0x89>
mov    $0x2,%edi
mov    $0x1,%esi
call   1050 <gpio_a_set@plt>
movl   $0x0,-0x14(%rbp)
jmp    123c <startup+0x9c>
mov    $0x2,%edi
xor    %esi,%esi
call   1050 <gpio_a_set@plt>
movl   $0x1,-0x14(%rbp)
jmp    11fa <startup+0x5a>

x86 assembly (clang, -O2):
<startup>:
push   %rbx
xor    %ebx,%ebx
xor    %eax,%eax
call   1070 <rcc_init@plt>
xor    %eax,%eax
call   10c0 <serial_init@plt>
lea    0xe48(%rip),%rdi
call   1060 <puts@plt>
xor    %eax,%eax
call   10a0 <adc_init@plt>
mov    $0xd,%edi
call   1080 <led_init@plt>
xor    %eax,%eax
call   1040 <led_off@plt>
mov    $0x2,%edi
call   1090 <gpio_a_output@plt>
mov    $0x8954400,%edi
call   1030 <systick_init_int@plt>
nopl   0x0(%rax)
mov    $0x3e8,%edi
call   10b0 <delay_ms@plt>
xor    %esi,%esi
test   %ebx,%ebx
setne  %sil
xor    $0x1,%ebx
mov    $0x2,%edi
call   1050 <gpio_a_set@plt>
jmp    11f0 <startup+0x50>

LLVM IR (-O0):
@.str = [44 x i8] c" -- Booting ------------------------------\0A\00"
define void @startup() {
%1 = alloca i32
%2 = alloca i64
%3 = alloca i32
%4 = alloca [80 x i8]
%5 = alloca i8*
%6 = call i32 (...) @rcc_init()
%7 = call i32 (...) @serial_init()
%8 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str, i64 0, i64 0))
%9 = call i32 (...) @adc_init()
%10 = call i32 @led_init(i32 13)
%11 = call i32 (...) @led_off()
%12 = call i32 @gpio_a_output(i32 2)
%13 = call i32 @systick_init_int(i32 144000000)
store i32 0, i32* %3
br label %14
14: ; preds = %22, %0
%15 = call i32 @delay_ms(i32 1000)
%16 = load i32, i32* %3
%17 = icmp ne i32 %16, 0
br i1 %17, label %18, label %20
18: ; preds = %14
%19 = call i32 @gpio_a_set(i32 2, i32 1)
store i32 0, i32* %3
br label %22
20: ; preds = %14
%21 = call i32 @gpio_a_set(i32 2, i32 0)
store i32 1, i32* %3
br label %22
22: ; preds = %20, %18
br label %14
}

LLVM IR (-O2):
@str = [43 x i8] c" -- Booting ------------------------------\00"
define void @startup() {
%1 = tail call i32 (...) @rcc_init()
%2 = tail call i32 (...) @serial_init()
%3 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([43 x i8], [43 x i8]* @str, i64 0, i64 0))
%4 = tail call i32 (...) @adc_init()
%5 = tail call i32 @led_init(i32 13)
%6 = tail call i32 (...) @led_off()
%7 = tail call i32 @gpio_a_output(i32 2)
%8 = tail call i32 @systick_init_int(i32 144000000)
br label %9
9: ; preds = %9, %0
%10 = phi i32 [ 0, %0 ], [ %14, %9 ]
%11 = tail call i32 @delay_ms(i32 1000)
%12 = icmp ne i32 %10, 0
%13 = zext i1 %12 to i32
%14 = xor i32 %10, 1
%15 = tail call i32 @gpio_a_set(i32 2, i32 %13)
br label %9
}