#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*/
aan_normalizar_canal_unsigned_char(unsigned char *, unsigned char *, int, int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
int /*<<< orphan*/ free(unsigned char *);
scalar_t__ malloc(int);
int /*<<< orphan*/ memcpy(void *, void const *, int);
int /*<<< orphan*/ stderr;
void aan_normalizar_imagen_unsigned_char(unsigned char *red,
                                         unsigned char *green,
                                         unsigned char *blue, int width,
                                         int height) {
  if (!red || !green || !blue) {
    fprintf(stderr, "Ninguno de los canales puede ser NULL");
    return;
  }
  if (width < 1 || height < 1) {
    fprintf(stderr, "La anchura y la altura del canal deben ser mayores que 0");
    return;
  }
  unsigned char *tmp =
      (unsigned char *)malloc(sizeof(unsigned char) * width * height);
  aan_normalizar_canal_unsigned_char(red, tmp, width, height);
  memcpy((void *)red, (const void *)tmp,
         sizeof(unsigned char) * width * height);
  aan_normalizar_canal_unsigned_char(green, tmp, width, height);
  memcpy((void *)green, (const void *)tmp,
         sizeof(unsigned char) * width * height);
  aan_normalizar_canal_unsigned_char(blue, tmp, width, height);
  memcpy((void *)blue, (const void *)tmp,
         sizeof(unsigned char) * width * height);
  free(tmp);
}


x86 assembly (clang, -O0):
<aan_normalizar_imagen_unsigned_char>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %ecx,-0x1c(%rbp)
mov    %r8d,-0x20(%rbp)
cmpq   $0x0,-0x8(%rbp)
je     118c <aan_normalizar_imagen_unsigned_char+0x3c>
cmpq   $0x0,-0x10(%rbp)
je     118c <aan_normalizar_imagen_unsigned_char+0x3c>
cmpq   $0x0,-0x18(%rbp)
jne    11a6 <aan_normalizar_imagen_unsigned_char+0x56>
mov    0x2e4d(%rip),%rax
mov    (%rax),%edi
lea    0xe64(%rip),%rsi
call   1050 <fprintf@plt>
jmp    128e <aan_normalizar_imagen_unsigned_char+0x13e>
cmpl   $0x1,-0x1c(%rbp)
jl     11ba <aan_normalizar_imagen_unsigned_char+0x6a>
cmpl   $0x1,-0x20(%rbp)
jge    11d4 <aan_normalizar_imagen_unsigned_char+0x84>
mov    0x2e1f(%rip),%rax
mov    (%rax),%edi
lea    0xe5c(%rip),%rsi
call   1050 <fprintf@plt>
jmp    128e <aan_normalizar_imagen_unsigned_char+0x13e>
movslq -0x1c(%rbp),%rax
shl    $0x0,%rax
movslq -0x20(%rbp),%rcx
imul   %rcx,%rax
mov    %eax,%edi
call   1070 <malloc@plt>
mov    %rax,-0x28(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x28(%rbp),%rsi
mov    -0x1c(%rbp),%edx
mov    -0x20(%rbp),%ecx
call   1040 <aan_normalizar_canal_unsigned_char@plt>
mov    -0x8(%rbp),%rdi
mov    -0x28(%rbp),%rsi
movslq -0x1c(%rbp),%rax
shl    $0x0,%rax
movslq -0x20(%rbp),%rcx
imul   %rcx,%rax
mov    %eax,%edx
call   1060 <memcpy@plt>
mov    -0x10(%rbp),%rdi
mov    -0x28(%rbp),%rsi
mov    -0x1c(%rbp),%edx
mov    -0x20(%rbp),%ecx
call   1040 <aan_normalizar_canal_unsigned_char@plt>
mov    -0x10(%rbp),%rdi
mov    -0x28(%rbp),%rsi
movslq -0x1c(%rbp),%rax
shl    $0x0,%rax
movslq -0x20(%rbp),%rcx
imul   %rcx,%rax
mov    %eax,%edx
call   1060 <memcpy@plt>
mov    -0x18(%rbp),%rdi
mov    -0x28(%rbp),%rsi
mov    -0x1c(%rbp),%edx
mov    -0x20(%rbp),%ecx
call   1040 <aan_normalizar_canal_unsigned_char@plt>
mov    -0x18(%rbp),%rdi
mov    -0x28(%rbp),%rsi
movslq -0x1c(%rbp),%rax
shl    $0x0,%rax
movslq -0x20(%rbp),%rcx
imul   %rcx,%rax
mov    %eax,%edx
call   1060 <memcpy@plt>
mov    -0x28(%rbp),%rdi
call   1030 <free@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<aan_normalizar_imagen_unsigned_char>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
test   %rdi,%rdi
je     1220 <aan_normalizar_imagen_unsigned_char+0xd0>
mov    %rsi,%rbp
test   %rsi,%rsi
je     1220 <aan_normalizar_imagen_unsigned_char+0xd0>
test   %rdx,%rdx
je     1220 <aan_normalizar_imagen_unsigned_char+0xd0>
mov    %ecx,%r13d
test   %ecx,%ecx
jle    1232 <aan_normalizar_imagen_unsigned_char+0xe2>
mov    %r8d,%r15d
test   %r8d,%r8d
jle    1232 <aan_normalizar_imagen_unsigned_char+0xe2>
mov    %rdi,%r14
mov    %r15d,%r12d
imul   %r13d,%r12d
mov    %r12d,%edi
mov    %rdx,(%rsp)
call   1070 <malloc@plt>
mov    %rax,%rbx
mov    %r14,%rdi
mov    %rax,%rsi
mov    %r13d,%edx
mov    %r15d,%ecx
call   1040 <aan_normalizar_canal_unsigned_char@plt>
mov    %r14,%rdi
mov    %rbx,%rsi
mov    %r12d,%edx
call   1060 <memcpy@plt>
mov    %rbp,%rdi
mov    %rbx,%rsi
mov    %r13d,%edx
mov    %r15d,%ecx
call   1040 <aan_normalizar_canal_unsigned_char@plt>
mov    %rbp,%rdi
mov    %rbx,%rsi
mov    %r12d,%edx
call   1060 <memcpy@plt>
mov    (%rsp),%rbp
mov    %rbp,%rdi
mov    %rbx,%rsi
mov    %r13d,%edx
mov    %r15d,%ecx
call   1040 <aan_normalizar_canal_unsigned_char@plt>
mov    %rbp,%rdi
mov    %rbx,%rsi
mov    %r12d,%edx
call   1060 <memcpy@plt>
mov    %rbx,%rdi
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <free@plt>
mov    0x2db9(%rip),%rax
mov    (%rax),%edi
lea    0xdd0(%rip),%rsi
jmp    1242 <aan_normalizar_imagen_unsigned_char+0xf2>
mov    0x2da7(%rip),%rax
mov    (%rax),%edi
lea    0xde4(%rip),%rsi
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1050 <fprintf@plt>

LLVM IR (-O0):
@stderr = global i32 0
@.str = [38 x i8] c"Ninguno de los canales puede ser NULL\00"
@.str.1 = [57 x i8] c"La anchura y la altura del canal deben ser mayores que 0\00"
define void @aan_normalizar_imagen_unsigned_char(i8* %0, i8* %1, i8* %2, i32 %3, i32 %4) {
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca i8*
%9 = alloca i32
%10 = alloca i32
%11 = alloca i8*
store i8* %0, i8** %6
store i8* %1, i8** %7
store i8* %2, i8** %8
store i32 %3, i32* %9
store i32 %4, i32* %10
%12 = load i8*, i8** %6
%13 = icmp ne i8* %12, null
br i1 %13, label %14, label %20
14: ; preds = %5
%15 = load i8*, i8** %7
%16 = icmp ne i8* %15, null
br i1 %16, label %17, label %20
17: ; preds = %14
%18 = load i8*, i8** %8
%19 = icmp ne i8* %18, null
br i1 %19, label %23, label %20
20: ; preds = %17, %14, %5
%21 = load i32, i32* @stderr
%22 = call i32 @fprintf(i32 %21, i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str, i64 0, i64 0))
br label %89
23: ; preds = %17
%24 = load i32, i32* %9
%25 = icmp slt i32 %24, 1
br i1 %25, label %29, label %26
26: ; preds = %23
%27 = load i32, i32* %10
%28 = icmp slt i32 %27, 1
br i1 %28, label %29, label %32
29: ; preds = %26, %23
%30 = load i32, i32* @stderr
%31 = call i32 @fprintf(i32 %30, i8* getelementptr inbounds ([57 x i8], [57 x i8]* @.str.1, i64 0, i64 0))
br label %89
32: ; preds = %26
%33 = load i32, i32* %9
%34 = sext i32 %33 to i64
%35 = mul i64 1, %34
%36 = load i32, i32* %10
%37 = sext i32 %36 to i64
%38 = mul i64 %35, %37
%39 = trunc i64 %38 to i32
%40 = call i64 @malloc(i32 %39)
%41 = inttoptr i64 %40 to i8*
store i8* %41, i8** %11
%42 = load i8*, i8** %6
%43 = load i8*, i8** %11
%44 = load i32, i32* %9
%45 = load i32, i32* %10
%46 = call i32 @aan_normalizar_canal_unsigned_char(i8* %42, i8* %43, i32 %44, i32 %45)
%47 = load i8*, i8** %6
%48 = load i8*, i8** %11
%49 = load i32, i32* %9
%50 = sext i32 %49 to i64
%51 = mul i64 1, %50
%52 = load i32, i32* %10
%53 = sext i32 %52 to i64
%54 = mul i64 %51, %53
%55 = trunc i64 %54 to i32
%56 = call i32 @memcpy(i8* %47, i8* %48, i32 %55)
%57 = load i8*, i8** %7
%58 = load i8*, i8** %11
%59 = load i32, i32* %9
%60 = load i32, i32* %10
%61 = call i32 @aan_normalizar_canal_unsigned_char(i8* %57, i8* %58, i32 %59, i32 %60)
%62 = load i8*, i8** %7
%63 = load i8*, i8** %11
%64 = load i32, i32* %9
%65 = sext i32 %64 to i64
%66 = mul i64 1, %65
%67 = load i32, i32* %10
%68 = sext i32 %67 to i64
%69 = mul i64 %66, %68
%70 = trunc i64 %69 to i32
%71 = call i32 @memcpy(i8* %62, i8* %63, i32 %70)
%72 = load i8*, i8** %8
%73 = load i8*, i8** %11
%74 = load i32, i32* %9
%75 = load i32, i32* %10
%76 = call i32 @aan_normalizar_canal_unsigned_char(i8* %72, i8* %73, i32 %74, i32 %75)
%77 = load i8*, i8** %8
%78 = load i8*, i8** %11
%79 = load i32, i32* %9
%80 = sext i32 %79 to i64
%81 = mul i64 1, %80
%82 = load i32, i32* %10
%83 = sext i32 %82 to i64
%84 = mul i64 %81, %83
%85 = trunc i64 %84 to i32
%86 = call i32 @memcpy(i8* %77, i8* %78, i32 %85)
%87 = load i8*, i8** %11
%88 = call i32 @free(i8* %87)
br label %89
89: ; preds = %32, %29, %20
ret void
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [38 x i8] c"Ninguno de los canales puede ser NULL\00"
@.str.1 = [57 x i8] c"La anchura y la altura del canal deben ser mayores que 0\00"
define void @aan_normalizar_imagen_unsigned_char(i8* %0, i8* %1, i8* %2, i32 %3, i32 %4) {
%6 = icmp ne i8* %0, null
%7 = icmp ne i8* %1, null
%8 = and i1 %6, %7
%9 = icmp ne i8* %2, null
%10 = and i1 %8, %9
br i1 %10, label %14, label %11
11: ; preds = %5
%12 = load i32, i32* @stderr
%13 = tail call i32 @fprintf(i32 %12, i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str, i64 0, i64 0))
br label %32
14: ; preds = %5
%15 = icmp slt i32 %3, 1
%16 = icmp slt i32 %4, 1
%17 = or i1 %15, %16
br i1 %17, label %18, label %21
18: ; preds = %14
%19 = load i32, i32* @stderr
%20 = tail call i32 @fprintf(i32 %19, i8* getelementptr inbounds ([57 x i8], [57 x i8]* @.str.1, i64 0, i64 0))
br label %32
21: ; preds = %14
%22 = mul i32 %4, %3
%23 = tail call i64 @malloc(i32 %22)
%24 = inttoptr i64 %23 to i8*
%25 = tail call i32 @aan_normalizar_canal_unsigned_char(i8* %0, i8* %24, i32 %3, i32 %4)
%26 = tail call i32 @memcpy(i8* %0, i8* %24, i32 %22)
%27 = tail call i32 @aan_normalizar_canal_unsigned_char(i8* %1, i8* %24, i32 %3, i32 %4)
%28 = tail call i32 @memcpy(i8* %1, i8* %24, i32 %22)
%29 = tail call i32 @aan_normalizar_canal_unsigned_char(i8* %2, i8* %24, i32 %3, i32 %4)
%30 = tail call i32 @memcpy(i8* %2, i8* %24, i32 %22)
%31 = tail call i32 @free(i8* %24)
br label %32
32: ; preds = %21, %18, %11
ret void
}