#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*/ error_diffuse(unsigned char *, int, int, int, int, int);
void diffuse_fs(unsigned char *data, int width, int height, int x, int y,
                int depth, int offset) {
  int n;
  int pos;
  pos = y * width + x;
  if (x > 1 && x < width - 1 && y < height - 1) {
    error_diffuse(data, pos + width * 0 + 1, depth, offset, 7, 16);
    error_diffuse(data, pos + width * 1 - 1, depth, offset, 3, 16);
    error_diffuse(data, pos + width * 1 + 0, depth, offset, 5, 16);
    error_diffuse(data, pos + width * 1 + 1, depth, offset, 1, 16);
  }
}


x86 assembly (clang, -O0):
<diffuse_fs>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    0x10(%rbp),%eax
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
mov    %ecx,-0x14(%rbp)
mov    %r8d,-0x18(%rbp)
mov    %r9d,-0x1c(%rbp)
mov    -0x18(%rbp),%eax
imul   -0xc(%rbp),%eax
add    -0x14(%rbp),%eax
mov    %eax,-0x24(%rbp)
cmpl   $0x1,-0x14(%rbp)
jle    120b <diffuse_fs+0xfb>
mov    -0x14(%rbp),%eax
mov    -0xc(%rbp),%ecx
sub    $0x1,%ecx
cmp    %ecx,%eax
jge    120b <diffuse_fs+0xfb>
mov    -0x18(%rbp),%eax
mov    -0x10(%rbp),%ecx
sub    $0x1,%ecx
cmp    %ecx,%eax
jge    120b <diffuse_fs+0xfb>
mov    -0x8(%rbp),%rdi
mov    -0x24(%rbp),%esi
imul   $0x0,-0xc(%rbp),%eax
add    %eax,%esi
add    $0x1,%esi
mov    -0x1c(%rbp),%edx
mov    0x10(%rbp),%ecx
mov    $0x7,%r8d
mov    $0x10,%r9d
call   1030 <error_diffuse@plt>
mov    -0x8(%rbp),%rdi
mov    -0x24(%rbp),%esi
mov    -0xc(%rbp),%eax
shl    $0x0,%eax
add    %eax,%esi
sub    $0x1,%esi
mov    -0x1c(%rbp),%edx
mov    0x10(%rbp),%ecx
mov    $0x3,%r8d
mov    $0x10,%r9d
call   1030 <error_diffuse@plt>
mov    -0x8(%rbp),%rdi
mov    -0x24(%rbp),%esi
mov    -0xc(%rbp),%eax
shl    $0x0,%eax
add    %eax,%esi
add    $0x0,%esi
mov    -0x1c(%rbp),%edx
mov    0x10(%rbp),%ecx
mov    $0x5,%r8d
mov    $0x10,%r9d
call   1030 <error_diffuse@plt>
mov    -0x8(%rbp),%rdi
mov    -0x24(%rbp),%esi
mov    -0xc(%rbp),%eax
shl    $0x0,%eax
add    %eax,%esi
add    $0x1,%esi
mov    -0x1c(%rbp),%edx
mov    0x10(%rbp),%ecx
mov    $0x1,%r8d
mov    $0x10,%r9d
call   1030 <error_diffuse@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<diffuse_fs>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
cmp    $0x2,%ecx
jl     11d9 <diffuse_fs+0xc9>
mov    %esi,%ebp
lea    -0x1(%rbp),%eax
cmp    %ecx,%eax
jle    11d9 <diffuse_fs+0xc9>
mov    %r8d,%ebx
add    $0xffffffff,%edx
cmp    %r8d,%edx
jle    11d9 <diffuse_fs+0xc9>
mov    %r9d,%r14d
mov    %rdi,%r15
mov    0x40(%rsp),%r12d
imul   %ebp,%ebx
add    %ecx,%ebx
lea    0x1(%rbx),%esi
mov    %r9d,%edx
mov    %r12d,%ecx
mov    $0x7,%r8d
mov    $0x10,%r9d
call   1030 <error_diffuse@plt>
lea    (%rbx,%rbp,1),%r13d
lea    (%rbx,%rbp,1),%esi
add    $0xffffffff,%esi
mov    %r15,%rdi
mov    %r14d,%edx
mov    %r12d,%ecx
mov    $0x3,%r8d
mov    $0x10,%r9d
call   1030 <error_diffuse@plt>
mov    %r15,%rdi
mov    %r13d,%esi
mov    %r14d,%edx
mov    %r12d,%ecx
mov    $0x5,%r8d
mov    $0x10,%r9d
call   1030 <error_diffuse@plt>
lea    (%rbx,%rbp,1),%esi
add    $0x1,%esi
mov    %r15,%rdi
mov    %r14d,%edx
mov    %r12d,%ecx
mov    $0x1,%r8d
mov    $0x10,%r9d
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <error_diffuse@plt>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define void @diffuse_fs(i8* %0, i32 %1, i32 %2, i32 %3, i32 %4, i32 %5, i32 %6) {
%8 = alloca i8*
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32
%13 = alloca i32
%14 = alloca i32
%15 = alloca i32
%16 = alloca i32
store i8* %0, i8** %8
store i32 %1, i32* %9
store i32 %2, i32* %10
store i32 %3, i32* %11
store i32 %4, i32* %12
store i32 %5, i32* %13
store i32 %6, i32* %14
%17 = load i32, i32* %12
%18 = load i32, i32* %9
%19 = mul nsw i32 %17, %18
%20 = load i32, i32* %11
%21 = add nsw i32 %19, %20
store i32 %21, i32* %16
%22 = load i32, i32* %11
%23 = icmp sgt i32 %22, 1
br i1 %23, label %24, label %71
24: ; preds = %7
%25 = load i32, i32* %11
%26 = load i32, i32* %9
%27 = sub nsw i32 %26, 1
%28 = icmp slt i32 %25, %27
br i1 %28, label %29, label %71
29: ; preds = %24
%30 = load i32, i32* %12
%31 = load i32, i32* %10
%32 = sub nsw i32 %31, 1
%33 = icmp slt i32 %30, %32
br i1 %33, label %34, label %71
34: ; preds = %29
%35 = load i8*, i8** %8
%36 = load i32, i32* %16
%37 = load i32, i32* %9
%38 = mul nsw i32 %37, 0
%39 = add nsw i32 %36, %38
%40 = add nsw i32 %39, 1
%41 = load i32, i32* %13
%42 = load i32, i32* %14
%43 = call i32 @error_diffuse(i8* %35, i32 %40, i32 %41, i32 %42, i32 7, i32 16)
%44 = load i8*, i8** %8
%45 = load i32, i32* %16
%46 = load i32, i32* %9
%47 = mul nsw i32 %46, 1
%48 = add nsw i32 %45, %47
%49 = sub nsw i32 %48, 1
%50 = load i32, i32* %13
%51 = load i32, i32* %14
%52 = call i32 @error_diffuse(i8* %44, i32 %49, i32 %50, i32 %51, i32 3, i32 16)
%53 = load i8*, i8** %8
%54 = load i32, i32* %16
%55 = load i32, i32* %9
%56 = mul nsw i32 %55, 1
%57 = add nsw i32 %54, %56
%58 = add nsw i32 %57, 0
%59 = load i32, i32* %13
%60 = load i32, i32* %14
%61 = call i32 @error_diffuse(i8* %53, i32 %58, i32 %59, i32 %60, i32 5, i32 16)
%62 = load i8*, i8** %8
%63 = load i32, i32* %16
%64 = load i32, i32* %9
%65 = mul nsw i32 %64, 1
%66 = add nsw i32 %63, %65
%67 = add nsw i32 %66, 1
%68 = load i32, i32* %13
%69 = load i32, i32* %14
%70 = call i32 @error_diffuse(i8* %62, i32 %67, i32 %68, i32 %69, i32 1, i32 16)
br label %71
71: ; preds = %34, %29, %24, %7
ret void
}

LLVM IR (-O2):
define void @diffuse_fs(i8* %0, i32 %1, i32 %2, i32 %3, i32 %4, i32 %5, i32 %6) {
%8 = mul nsw i32 %4, %1
%9 = add nsw i32 %8, %3
%10 = icmp sgt i32 %3, 1
%11 = add nsw i32 %1, -1
%12 = icmp sgt i32 %11, %3
%13 = select i1 %10, i1 %12, i1 false
%14 = add nsw i32 %2, -1
%15 = icmp sgt i32 %14, %4
%16 = select i1 %13, i1 %15, i1 false
br i1 %16, label %17, label %26
17: ; preds = %7
%18 = add nsw i32 %9, 1
%19 = tail call i32 @error_diffuse(i8* %0, i32 %18, i32 %5, i32 %6, i32 7, i32 16)
%20 = add nsw i32 %9, %1
%21 = add nsw i32 %20, -1
%22 = tail call i32 @error_diffuse(i8* %0, i32 %21, i32 %5, i32 %6, i32 3, i32 16)
%23 = tail call i32 @error_diffuse(i8* %0, i32 %20, i32 %5, i32 %6, i32 5, i32 16)
%24 = add nsw i32 %20, 1
%25 = tail call i32 @error_diffuse(i8* %0, i32 %24, i32 %5, i32 %6, i32 1, i32 16)
br label %26
26: ; preds = %17, %7
ret void
}