#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 rand();
void MakeWhiteNoise(int n_xres, int n_yres, unsigned char *pNoise) {
  int i, j;
  for (j = 0; j < n_yres; j++)
    for (i = 0; i < n_xres; i++) {
      int r = rand();
      r = ((r & 0xff) + ((r & 0xff00) >> 8)) & 0xff;
      pNoise[j * n_xres + i] = (unsigned char)r;
    }
}


x86 assembly (clang, -O0):
<MakeWhiteNoise>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %rdx,-0x10(%rbp)
movl   $0x0,-0x18(%rbp)
mov    -0x18(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    11aa <MakeWhiteNoise+0x9a>
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x4(%rbp),%eax
jge    1197 <MakeWhiteNoise+0x87>
mov    $0x0,%al
call   1030 <rand@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
and    $0xff,%eax
mov    -0x1c(%rbp),%ecx
and    $0xff00,%ecx
sar    $0x8,%ecx
add    %ecx,%eax
and    $0xff,%eax
mov    %eax,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
mov    %al,%dl
mov    -0x10(%rbp),%rax
mov    -0x18(%rbp),%ecx
imul   -0x4(%rbp),%ecx
add    -0x14(%rbp),%ecx
movslq %ecx,%rcx
mov    %dl,(%rax,%rcx,1)
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    113c <MakeWhiteNoise+0x2c>
jmp    119c <MakeWhiteNoise+0x8c>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    1129 <MakeWhiteNoise+0x19>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<MakeWhiteNoise>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %edi,0x4(%rsp)
test   %esi,%esi
jle    117d <MakeWhiteNoise+0x6d>
mov    %rdx,%rbx
movslq 0x4(%rsp),%r12
mov    %esi,%r15d
mov    %r12d,%ebp
xor    %r13d,%r13d
jmp    114c <MakeWhiteNoise+0x3c>
cs nopw 0x0(%rax,%rax,1)
add    $0x1,%r13
add    %r12,%rbx
cmp    %r15,%r13
je     117d <MakeWhiteNoise+0x6d>
cmpl   $0x0,0x4(%rsp)
jle    1140 <MakeWhiteNoise+0x30>
xor    %r14d,%r14d
cs nopw 0x0(%rax,%rax,1)
xor    %eax,%eax
call   1030 <rand@plt>
mov    %eax,%ecx
shr    $0x8,%ecx
add    %eax,%ecx
mov    %cl,(%rbx,%r14,1)
add    $0x1,%r14
cmp    %r14,%rbp
jne    1160 <MakeWhiteNoise+0x50>
jmp    1140 <MakeWhiteNoise+0x30>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define void @MakeWhiteNoise(i32 %0, i32 %1, i8* %2) {
%4 = alloca i32
%5 = alloca i32
%6 = alloca i8*
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
store i32 %0, i32* %4
store i32 %1, i32* %5
store i8* %2, i8** %6
store i32 0, i32* %8
br label %10
10: ; preds = %42, %3
%11 = load i32, i32* %8
%12 = load i32, i32* %5
%13 = icmp slt i32 %11, %12
br i1 %13, label %14, label %45
14: ; preds = %10
store i32 0, i32* %7
br label %15
15: ; preds = %38, %14
%16 = load i32, i32* %7
%17 = load i32, i32* %4
%18 = icmp slt i32 %16, %17
br i1 %18, label %19, label %41
19: ; preds = %15
%20 = call i32 (...) @rand()
store i32 %20, i32* %9
%21 = load i32, i32* %9
%22 = and i32 %21, 255
%23 = load i32, i32* %9
%24 = and i32 %23, 65280
%25 = ashr i32 %24, 8
%26 = add nsw i32 %22, %25
%27 = and i32 %26, 255
store i32 %27, i32* %9
%28 = load i32, i32* %9
%29 = trunc i32 %28 to i8
%30 = load i8*, i8** %6
%31 = load i32, i32* %8
%32 = load i32, i32* %4
%33 = mul nsw i32 %31, %32
%34 = load i32, i32* %7
%35 = add nsw i32 %33, %34
%36 = sext i32 %35 to i64
%37 = getelementptr inbounds i8, i8* %30, i64 %36
store i8 %29, i8* %37
br label %38
38: ; preds = %19
%39 = load i32, i32* %7
%40 = add nsw i32 %39, 1
store i32 %40, i32* %7
br label %15
41: ; preds = %15
br label %42
42: ; preds = %41
%43 = load i32, i32* %8
%44 = add nsw i32 %43, 1
store i32 %44, i32* %8
br label %10
45: ; preds = %10
ret void
}

LLVM IR (-O2):
define void @MakeWhiteNoise(i32 %0, i32 %1, i8* nocapture writeonly %2) {
%4 = icmp sgt i32 %1, 0
br i1 %4, label %5, label %27
5: ; preds = %3
%6 = icmp sgt i32 %0, 0
%7 = sext i32 %0 to i64
%8 = zext i32 %1 to i64
%9 = zext i32 %0 to i64
br label %10
10: ; preds = %5, %24
%11 = phi i64 [ 0, %5 ], [ %25, %24 ]
br i1 %6, label %12, label %24
12: ; preds = %10
%13 = mul nsw i64 %11, %7
br label %14
14: ; preds = %12, %14
%15 = phi i64 [ 0, %12 ], [ %22, %14 ]
%16 = tail call i32 (...) @rand()
%17 = lshr i32 %16, 8
%18 = add i32 %17, %16
%19 = trunc i32 %18 to i8
%20 = add nsw i64 %15, %13
%21 = getelementptr inbounds i8, i8* %2, i64 %20
store i8 %19, i8* %21
%22 = add nuw nsw i64 %15, 1
%23 = icmp eq i64 %22, %9
br i1 %23, label %24, label %14
24: ; preds = %14, %10
%25 = add nuw nsw i64 %11, 1
%26 = icmp eq i64 %25, %8
br i1 %26, label %27, label %10
27: ; preds = %24, %3
ret void
}