#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 */
typedef int uint32_t;

/* Variables and functions */
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ sleep_ms(int);
void usart1_init(void) {
  uint32_t reg;
  (*(volatile uint32_t *)((0x40021000UL) + 0x58)) |= (1 << 28);
  (*(volatile uint32_t *)((0x40021000UL) + 0x4C)) |= (1 << 6);
  while (((*(volatile uint32_t *)((0x40007000UL) + 0x04)) & (1 << 9)) == 0) {
    (*(volatile uint32_t *)((0x40007000UL) + 0x04)) |= (1 << 9);
    printf("Turning on VDDIO2\n");
    sleep_ms(1000);
  }
  (*(volatile uint32_t *)((0x40021000UL) + 0x4C)) |= (1 << 1);
  reg =
      (*((volatile uint32_t *)((0x48001800UL) + 0x00))) & ~(0x03 << ((10) * 2));
  (*((volatile uint32_t *)((0x48001800UL) + 0x00))) =
      reg | (0x02 << ((10) * 2));
  reg =
      (*((volatile uint32_t *)((0x48000400UL) + 0x00))) & ~(0x03 << ((6) * 2));
  (*((volatile uint32_t *)((0x48000400UL) + 0x00))) = reg | (0x02 << ((6) * 2));
  reg =
      (*((volatile uint32_t *)((0x48001800UL) + 0x0C))) & (0x03 << ((10) * 2));
  reg = (*((volatile uint32_t *)((0x48000400UL) + 0x0C))) & (0x03 << ((6) * 2));
  (*((volatile uint32_t *)((0x48000400UL) + 0x0C))) = reg | (0x01 << ((6) * 2));
  reg = (*((volatile uint32_t *)((0x48001800UL) + 0x24))) &
        ~(0xf << (((10) - 8) * 4));
  (*((volatile uint32_t *)((0x48001800UL) + 0x24))) =
      reg | (7 << (((10) - 8) * 4));
  reg =
      (*((volatile uint32_t *)((0x48000400UL) + 0x20))) & ~(0xf << (((6)) * 4));
  (*((volatile uint32_t *)((0x48000400UL) + 0x20))) = reg | (7 << (((6)) * 4));
  (*(volatile uint32_t *)((0x40021000UL) + 0x60)) |= (1 << 14);
}


x86 assembly (clang, -O0):
<usart1_init>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    $0x40021058,%eax
mov    (%rax),%ecx
or     $0x10000000,%ecx
mov    $0x40021058,%eax
mov    %ecx,(%rax)
mov    $0x4002104c,%eax
mov    (%rax),%ecx
or     $0x40,%ecx
mov    $0x4002104c,%eax
mov    %ecx,(%rax)
mov    $0x40007004,%eax
mov    (%rax),%eax
and    $0x200,%eax
cmp    $0x0,%eax
jne    1191 <usart1_init+0x71>
mov    $0x40007004,%eax
mov    (%rax),%ecx
or     $0x200,%ecx
mov    $0x40007004,%eax
mov    %ecx,(%rax)
lea    0xe83(%rip),%rdi
call   1030 <printf@plt>
mov    $0x3e8,%edi
call   1040 <sleep_ms@plt>
jmp    114d <usart1_init+0x2d>
mov    $0x4002104c,%eax
mov    (%rax),%ecx
or     $0x2,%ecx
mov    $0x4002104c,%eax
mov    %ecx,(%rax)
mov    $0x48001800,%eax
mov    (%rax),%eax
and    $0xffcfffff,%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%ecx
or     $0x200000,%ecx
mov    $0x48001800,%eax
mov    %ecx,(%rax)
mov    $0x48000400,%eax
mov    (%rax),%eax
and    $0xffffcfff,%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%ecx
or     $0x2000,%ecx
mov    $0x48000400,%eax
mov    %ecx,(%rax)
mov    $0x4800180c,%eax
mov    (%rax),%eax
and    $0x300000,%eax
mov    %eax,-0x4(%rbp)
mov    $0x4800040c,%eax
mov    (%rax),%eax
and    $0x3000,%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%ecx
or     $0x1000,%ecx
mov    $0x4800040c,%eax
mov    %ecx,(%rax)
mov    $0x48001824,%eax
mov    (%rax),%eax
and    $0xfffff0ff,%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%ecx
or     $0x700,%ecx
mov    $0x48001824,%eax
mov    %ecx,(%rax)
mov    $0x48000420,%eax
mov    (%rax),%eax
and    $0xf0ffffff,%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%ecx
or     $0x7000000,%ecx
mov    $0x48000420,%eax
mov    %ecx,(%rax)
mov    $0x40021060,%eax
mov    (%rax),%ecx
or     $0x4000,%ecx
mov    $0x40021060,%eax
mov    %ecx,(%rax)
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<usart1_init>:
push   %rbx
orl    $0x10000000,0x40021058
orl    $0x40,0x4002104c
40
testl  $0x200,0x40007004
jne    117a <usart1_init+0x5a>
lea    0xeb8(%rip),%rbx
nopl   0x0(%rax,%rax,1)
orl    $0x200,0x40007004
mov    %rbx,%rdi
call   1030 <puts@plt>
mov    $0x3e8,%edi
call   1040 <sleep_ms@plt>
testl  $0x200,0x40007004
je     1150 <usart1_init+0x30>
orl    $0x2,0x4002104c
02
mov    $0xffcfffff,%eax
and    0x48001800,%eax
or     $0x200000,%eax
mov    %eax,0x48001800
mov    $0xffffcfff,%eax
and    0x48000400,%eax
or     $0x2000,%eax
mov    %eax,0x48000400
mov    0x4800180c,%eax
mov    $0x2000,%eax
and    0x4800040c,%eax
or     $0x1000,%eax
mov    %eax,0x4800040c
mov    $0xfffff0ff,%eax
and    0x48001824,%eax
or     $0x700,%eax
mov    %eax,0x48001824
mov    $0xf0ffffff,%eax
and    0x48000420,%eax
or     $0x7000000,%eax
mov    %eax,0x48000420
orl    $0x4000,0x40021060
pop    %rbx
ret

LLVM IR (-O0):
@.str = [19 x i8] c"Turning on VDDIO2\0A\00"
define void @usart1_init() {
%1 = alloca i32
%2 = load volatile i32, i32* inttoptr (i64 1073877080 to i32*)
%3 = or i32 %2, 268435456
store volatile i32 %3, i32* inttoptr (i64 1073877080 to i32*)
%4 = load volatile i32, i32* inttoptr (i64 1073877068 to i32*)
%5 = or i32 %4, 64
store volatile i32 %5, i32* inttoptr (i64 1073877068 to i32*)
br label %6
6: ; preds = %10, %0
%7 = load volatile i32, i32* inttoptr (i64 1073770500 to i32*)
%8 = and i32 %7, 512
%9 = icmp eq i32 %8, 0
br i1 %9, label %10, label %15
10: ; preds = %6
%11 = load volatile i32, i32* inttoptr (i64 1073770500 to i32*)
%12 = or i32 %11, 512
store volatile i32 %12, i32* inttoptr (i64 1073770500 to i32*)
%13 = call i32 @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0))
%14 = call i32 @sleep_ms(i32 1000)
br label %6
15: ; preds = %6
%16 = load volatile i32, i32* inttoptr (i64 1073877068 to i32*)
%17 = or i32 %16, 2
store volatile i32 %17, i32* inttoptr (i64 1073877068 to i32*)
%18 = load volatile i32, i32* inttoptr (i64 1207965696 to i32*)
%19 = and i32 %18, -3145729
store i32 %19, i32* %1
%20 = load i32, i32* %1
%21 = or i32 %20, 2097152
store volatile i32 %21, i32* inttoptr (i64 1207965696 to i32*)
%22 = load volatile i32, i32* inttoptr (i64 1207960576 to i32*)
%23 = and i32 %22, -12289
store i32 %23, i32* %1
%24 = load i32, i32* %1
%25 = or i32 %24, 8192
store volatile i32 %25, i32* inttoptr (i64 1207960576 to i32*)
%26 = load volatile i32, i32* inttoptr (i64 1207965708 to i32*)
%27 = and i32 %26, 3145728
store i32 %27, i32* %1
%28 = load volatile i32, i32* inttoptr (i64 1207960588 to i32*)
%29 = and i32 %28, 12288
store i32 %29, i32* %1
%30 = load i32, i32* %1
%31 = or i32 %30, 4096
store volatile i32 %31, i32* inttoptr (i64 1207960588 to i32*)
%32 = load volatile i32, i32* inttoptr (i64 1207965732 to i32*)
%33 = and i32 %32, -3841
store i32 %33, i32* %1
%34 = load i32, i32* %1
%35 = or i32 %34, 1792
store volatile i32 %35, i32* inttoptr (i64 1207965732 to i32*)
%36 = load volatile i32, i32* inttoptr (i64 1207960608 to i32*)
%37 = and i32 %36, -251658241
store i32 %37, i32* %1
%38 = load i32, i32* %1
%39 = or i32 %38, 117440512
store volatile i32 %39, i32* inttoptr (i64 1207960608 to i32*)
%40 = load volatile i32, i32* inttoptr (i64 1073877088 to i32*)
%41 = or i32 %40, 16384
store volatile i32 %41, i32* inttoptr (i64 1073877088 to i32*)
ret void
}

LLVM IR (-O2):
@str = [18 x i8] c"Turning on VDDIO2\00"
define void @usart1_init() {
%1 = load volatile i32, i32* inttoptr (i64 1073877080 to i32*)
%2 = or i32 %1, 268435456
store volatile i32 %2, i32* inttoptr (i64 1073877080 to i32*)
%3 = load volatile i32, i32* inttoptr (i64 1073877068 to i32*)
%4 = or i32 %3, 64
store volatile i32 %4, i32* inttoptr (i64 1073877068 to i32*)
%5 = load volatile i32, i32* inttoptr (i64 1073770500 to i32*)
%6 = and i32 %5, 512
%7 = icmp eq i32 %6, 0
br i1 %7, label %8, label %16
8: ; preds = %0, %8
%9 = load volatile i32, i32* inttoptr (i64 1073770500 to i32*)
%10 = or i32 %9, 512
store volatile i32 %10, i32* inttoptr (i64 1073770500 to i32*)
%11 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @str, i64 0, i64 0))
%12 = tail call i32 @sleep_ms(i32 1000)
%13 = load volatile i32, i32* inttoptr (i64 1073770500 to i32*)
%14 = and i32 %13, 512
%15 = icmp eq i32 %14, 0
br i1 %15, label %8, label %16
16: ; preds = %8, %0
%17 = load volatile i32, i32* inttoptr (i64 1073877068 to i32*)
%18 = or i32 %17, 2
store volatile i32 %18, i32* inttoptr (i64 1073877068 to i32*)
%19 = load volatile i32, i32* inttoptr (i64 1207965696 to i32*)
%20 = and i32 %19, -3145729
%21 = or i32 %20, 2097152
store volatile i32 %21, i32* inttoptr (i64 1207965696 to i32*)
%22 = load volatile i32, i32* inttoptr (i64 1207960576 to i32*)
%23 = and i32 %22, -12289
%24 = or i32 %23, 8192
store volatile i32 %24, i32* inttoptr (i64 1207960576 to i32*)
%25 = load volatile i32, i32* inttoptr (i64 1207965708 to i32*)
%26 = load volatile i32, i32* inttoptr (i64 1207960588 to i32*)
%27 = and i32 %26, 8192
%28 = or i32 %27, 4096
store volatile i32 %28, i32* inttoptr (i64 1207960588 to i32*)
%29 = load volatile i32, i32* inttoptr (i64 1207965732 to i32*)
%30 = and i32 %29, -3841
%31 = or i32 %30, 1792
store volatile i32 %31, i32* inttoptr (i64 1207965732 to i32*)
%32 = load volatile i32, i32* inttoptr (i64 1207960608 to i32*)
%33 = and i32 %32, -251658241
%34 = or i32 %33, 117440512
store volatile i32 %34, i32* inttoptr (i64 1207960608 to i32*)
%35 = load volatile i32, i32* inttoptr (i64 1073877088 to i32*)
%36 = or i32 %35, 16384
store volatile i32 %36, i32* inttoptr (i64 1073877088 to i32*)
ret void
}