#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 */
void wram_1M_to_2M(unsigned char *m) {
  unsigned short *m1M_b0, *m1M_b1;
  unsigned int i, tmp, *m2M;
  m2M = (unsigned int *)m;
  m1M_b0 = (unsigned short *)(m + 0x20000);
  m1M_b1 = (unsigned short *)(m + 0x40000);
  for (i = 0x40000 / 4; i; i--) {
    tmp = *m1M_b0++ | (*m1M_b1++ << 16);
    *m2M++ = tmp;
  }
}


x86 assembly (clang, -O0):
<wram_1M_to_2M>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    -0x8(%rbp),%rax
add    $0x20000,%rax
mov    %rax,-0x10(%rbp)
mov    -0x8(%rbp),%rax
add    $0x40000,%rax
mov    %rax,-0x18(%rbp)
movl   $0x10000,-0x1c(%rbp)
cmpl   $0x0,-0x1c(%rbp)
je     118b <wram_1M_to_2M+0x8b>
mov    -0x10(%rbp),%rax
mov    %rax,%rcx
add    $0x2,%rcx
mov    %rcx,-0x10(%rbp)
movzwl (%rax),%eax
mov    -0x18(%rbp),%rcx
mov    %rcx,%rdx
add    $0x2,%rdx
mov    %rdx,-0x18(%rbp)
movzwl (%rcx),%ecx
shl    $0x10,%ecx
or     %ecx,%eax
mov    %eax,-0x20(%rbp)
mov    -0x20(%rbp),%ecx
mov    -0x28(%rbp),%rax
mov    %rax,%rdx
add    $0x4,%rdx
mov    %rdx,-0x28(%rbp)
mov    %ecx,(%rax)
mov    -0x1c(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x1c(%rbp)
jmp    1133 <wram_1M_to_2M+0x33>
pop    %rbp
ret

x86 assembly (clang, -O2):
<wram_1M_to_2M>:
mov    $0xffffffffffff0000,%rax
nopw   0x0(%rax,%rax,1)
movq   0x40000(%rdi,%rax,2),%xmm0
movq   0x40008(%rdi,%rax,2),%xmm1
movq   0x60000(%rdi,%rax,2),%xmm2
punpcklwd %xmm2,%xmm0
movq   0x60008(%rdi,%rax,2),%xmm2
punpcklwd %xmm2,%xmm1
movdqu %xmm0,0x40000(%rdi,%rax,4)
movdqu %xmm1,0x40010(%rdi,%rax,4)
add    $0x8,%rax
jne    1110 <wram_1M_to_2M+0x10>
ret

LLVM IR (-O0):
define void @wram_1M_to_2M(i8* %0) {
%2 = alloca i8*
%3 = alloca i16*
%4 = alloca i16*
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32*
store i8* %0, i8** %2
%8 = load i8*, i8** %2
%9 = bitcast i8* %8 to i32*
store i32* %9, i32** %7
%10 = load i8*, i8** %2
%11 = getelementptr inbounds i8, i8* %10, i64 131072
%12 = bitcast i8* %11 to i16*
store i16* %12, i16** %3
%13 = load i8*, i8** %2
%14 = getelementptr inbounds i8, i8* %13, i64 262144
%15 = bitcast i8* %14 to i16*
store i16* %15, i16** %4
store i32 65536, i32* %5
br label %16
16: ; preds = %33, %1
%17 = load i32, i32* %5
%18 = icmp ne i32 %17, 0
br i1 %18, label %19, label %36
19: ; preds = %16
%20 = load i16*, i16** %3
%21 = getelementptr inbounds i16, i16* %20, i32 1
store i16* %21, i16** %3
%22 = load i16, i16* %20
%23 = zext i16 %22 to i32
%24 = load i16*, i16** %4
%25 = getelementptr inbounds i16, i16* %24, i32 1
store i16* %25, i16** %4
%26 = load i16, i16* %24
%27 = zext i16 %26 to i32
%28 = shl i32 %27, 16
%29 = or i32 %23, %28
store i32 %29, i32* %6
%30 = load i32, i32* %6
%31 = load i32*, i32** %7
%32 = getelementptr inbounds i32, i32* %31, i32 1
store i32* %32, i32** %7
store i32 %30, i32* %31
br label %33
33: ; preds = %19
%34 = load i32, i32* %5
%35 = add i32 %34, -1
store i32 %35, i32* %5
br label %16
36: ; preds = %16
ret void
}

LLVM IR (-O2):
define void @wram_1M_to_2M(i8* nocapture %0) {
%2 = bitcast i8* %0 to i32*
%3 = getelementptr inbounds i8, i8* %0, i64 131072
%4 = bitcast i8* %3 to i16*
%5 = getelementptr inbounds i8, i8* %0, i64 262144
%6 = bitcast i8* %5 to i16*
br label %7
7: ; preds = %7, %1
%8 = phi i64 [ 0, %1 ], [ %33, %7 ]
%9 = getelementptr i32, i32* %2, i64 %8
%10 = getelementptr i16, i16* %4, i64 %8
%11 = getelementptr i16, i16* %6, i64 %8
%12 = bitcast i16* %10 to <4 x i16>*
%13 = load <4 x i16>, <4 x i16>* %12
%14 = getelementptr i16, i16* %10, i64 4
%15 = bitcast i16* %14 to <4 x i16>*
%16 = load <4 x i16>, <4 x i16>* %15
%17 = zext <4 x i16> %13 to <4 x i32>
%18 = zext <4 x i16> %16 to <4 x i32>
%19 = bitcast i16* %11 to <4 x i16>*
%20 = load <4 x i16>, <4 x i16>* %19
%21 = getelementptr i16, i16* %11, i64 4
%22 = bitcast i16* %21 to <4 x i16>*
%23 = load <4 x i16>, <4 x i16>* %22
%24 = zext <4 x i16> %20 to <4 x i32>
%25 = zext <4 x i16> %23 to <4 x i32>
%26 = shl nuw <4 x i32> %24, <i32 16, i32 16, i32 16, i32 16>
%27 = shl nuw <4 x i32> %25, <i32 16, i32 16, i32 16, i32 16>
%28 = or <4 x i32> %26, %17
%29 = or <4 x i32> %27, %18
%30 = bitcast i32* %9 to <4 x i32>*
store <4 x i32> %28, <4 x i32>* %30
%31 = getelementptr i32, i32* %9, i64 4
%32 = bitcast i32* %31 to <4 x i32>*
store <4 x i32> %29, <4 x i32>* %32
%33 = add nuw i64 %8, 8
%34 = icmp eq i64 %33, 65536
br i1 %34, label %35, label %7
35: ; preds = %7
ret void
}