unsigned short _FLASH_getId(unsigned short *id) {
  unsigned long addr = (0x0400000);
  unsigned short *psrc16 = (unsigned short *)id;
  volatile unsigned short *addr16 = (unsigned short *)addr;
  volatile unsigned short *pmfgid = (unsigned short *)addr;
  volatile unsigned short *pdevid1 = (unsigned short *)(addr + 0x1);
  volatile unsigned short *flash_ctl555 = (unsigned short *)(addr + 0x555);
  volatile unsigned short *flash_ctl2AA = (unsigned short *)(addr + 0x2AA);
  *addr16 = 0xFF;
  *addr16 = 0x90;
  *id++ = *pmfgid;
  *id++ = *pdevid1;
  *addr16 = 0xFF;
  return 0;
}


x86 assembly (clang, -O0):
<_FLASH_getId>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x8(%rbp)
movq   $0x400000,-0x10(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x18(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    -0x10(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x30(%rbp)
mov    -0x10(%rbp),%rax
add    $0x555,%rax
mov    %rax,-0x38(%rbp)
mov    -0x10(%rbp),%rax
add    $0x2aa,%rax
mov    %rax,-0x40(%rbp)
mov    -0x20(%rbp),%rax
movw   $0xff,(%rax)
mov    -0x20(%rbp),%rax
movw   $0x90,(%rax)
mov    -0x28(%rbp),%rax
mov    (%rax),%cx
mov    -0x8(%rbp),%rax
mov    %rax,%rdx
add    $0x2,%rdx
mov    %rdx,-0x8(%rbp)
mov    %cx,(%rax)
mov    -0x30(%rbp),%rax
mov    (%rax),%cx
mov    -0x8(%rbp),%rax
mov    %rax,%rdx
add    $0x2,%rdx
mov    %rdx,-0x8(%rbp)
mov    %cx,(%rax)
mov    -0x20(%rbp),%rax
movw   $0xff,(%rax)
xor    %eax,%eax
movzwl %ax,%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<_FLASH_getId>:
movw   $0xff,0x400000
movw   $0x90,0x400000
movzwl 0x400000,%eax
mov    %ax,(%rdi)
movzwl 0x400001,%eax
mov    %ax,0x2(%rdi)
movw   $0xff,0x400000
xor    %eax,%eax
ret

LLVM IR (-O0):
define zeroext i16 @_FLASH_getId(i16* %0) {
%2 = alloca i16*
%3 = alloca i64
%4 = alloca i16*
%5 = alloca i16*
%6 = alloca i16*
%7 = alloca i16*
%8 = alloca i16*
%9 = alloca i16*
store i16* %0, i16** %2
store i64 4194304, i64* %3
%10 = load i16*, i16** %2
store i16* %10, i16** %4
%11 = load i64, i64* %3
%12 = inttoptr i64 %11 to i16*
store i16* %12, i16** %5
%13 = load i64, i64* %3
%14 = inttoptr i64 %13 to i16*
store i16* %14, i16** %6
%15 = load i64, i64* %3
%16 = add i64 %15, 1
%17 = inttoptr i64 %16 to i16*
store i16* %17, i16** %7
%18 = load i64, i64* %3
%19 = add i64 %18, 1365
%20 = inttoptr i64 %19 to i16*
store i16* %20, i16** %8
%21 = load i64, i64* %3
%22 = add i64 %21, 682
%23 = inttoptr i64 %22 to i16*
store i16* %23, i16** %9
%24 = load i16*, i16** %5
store volatile i16 255, i16* %24
%25 = load i16*, i16** %5
store volatile i16 144, i16* %25
%26 = load i16*, i16** %6
%27 = load volatile i16, i16* %26
%28 = load i16*, i16** %2
%29 = getelementptr inbounds i16, i16* %28, i32 1
store i16* %29, i16** %2
store i16 %27, i16* %28
%30 = load i16*, i16** %7
%31 = load volatile i16, i16* %30
%32 = load i16*, i16** %2
%33 = getelementptr inbounds i16, i16* %32, i32 1
store i16* %33, i16** %2
store i16 %31, i16* %32
%34 = load i16*, i16** %5
store volatile i16 255, i16* %34
ret i16 0
}

LLVM IR (-O2):
define zeroext i16 @_FLASH_getId(i16* nocapture writeonly %0) {
store volatile i16 255, i16* inttoptr (i64 4194304 to i16*)
store volatile i16 144, i16* inttoptr (i64 4194304 to i16*)
%2 = load volatile i16, i16* inttoptr (i64 4194304 to i16*)
%3 = getelementptr inbounds i16, i16* %0, i64 1
store i16 %2, i16* %0
%4 = load volatile i16, i16* inttoptr (i64 4194305 to i16*)
store i16 %4, i16* %3
store volatile i16 255, i16* inttoptr (i64 4194304 to i16*)
ret i16 0
}