#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 EXIT_FAILURE;
int EXIT_SUCCESS;
int /*<<< orphan*/ equalization_affine(float *, float *, float *, int, int, int,
                                       int, int);
int /*<<< orphan*/ equalization_histo(float *, float *, float *, int, int, int);
int /*<<< orphan*/ equalization_meanp(float *, float *, float *, int, int, int,
                                      int, int);
int /*<<< orphan*/ equalization_meanx(float *, float *, float *, int, int, int,
                                      int, int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, ...);
int /*<<< orphan*/ free(float *);
float *iio_read_image_float_split(char *, int *, int *, int *);
int /*<<< orphan*/ iio_write_image_float_split(char *, float *, int, int, int);
float *malloc(int);
int /*<<< orphan*/ stderr;
scalar_t__ strcmp(char *, char *);
int main(int c, char *v[]) {
  if (c != 5) {
    fprintf(stderr, "usage:\n\t%s ref modified out type\n", *v);
    fprintf(stderr, "type possibilities: histo, affine, meanp, meanx\n");
    return EXIT_FAILURE;
  }
  char *filename_ref = c > 1 ? v[1] : "-";
  char *filename_modified = c > 2 ? v[2] : "-";
  char *filename_out = c > 3 ? v[3] : "-";
  char *equalization_type = c > 4 ? v[4] : "-";
  int w, h, pd;
  float *ref = iio_read_image_float_split(filename_ref, &w, &h, &pd);
  int w2, h2, pd2;
  float *modified =
      iio_read_image_float_split(filename_modified, &w2, &h2, &pd2);
  if (pd != pd2) {
    fprintf(stderr, "Images should have the same number of channel\n");
    return EXIT_FAILURE;
  }
  float *out = malloc(w2 * h2 * pd2 * sizeof *out);
  if (0 == strcmp(equalization_type, "histo")) {
    if (w != w2 || h != h2 || pd != pd2) {
      fprintf(stderr, "Size of images should be the same\n");
      return EXIT_FAILURE;
    }
    equalization_histo(ref, modified, out, w, h, pd);
  } else if (0 == strcmp(equalization_type, "affine"))
    equalization_affine(ref, modified, out, w, h, w2, h2, pd);
  else if (0 == strcmp(equalization_type, "meanp"))
    equalization_meanp(ref, modified, out, w, h, w2, h2, pd);
  else if (0 == strcmp(equalization_type, "meanx"))
    equalization_meanx(ref, modified, out, w, h, w2, h2, pd);
  else {
    fprintf(stderr, "Unknown equalization type\n");
    return EXIT_FAILURE;
  }
  iio_write_image_float_split(filename_out, out, w2, h2, pd2);
  free(ref);
  free(modified);
  free(out);
  return EXIT_SUCCESS;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0xa0,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x5,-0x8(%rbp)
je     1209 <main+0x69>
mov    0x2e16(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    (%rax),%rdx
lea    0xe26(%rip),%rsi
mov    $0x0,%al
call   1090 <fprintf@plt>
mov    0x2df8(%rip),%rax
mov    (%rax),%edi
lea    0xe31(%rip),%rsi
mov    $0x0,%al
call   1090 <fprintf@plt>
mov    0x2dd9(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    154a <main+0x3aa>
cmpl   $0x1,-0x8(%rbp)
jle    1224 <main+0x84>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rax
mov    %rax,-0x70(%rbp)
jmp    1234 <main+0x94>
lea    0xe28(%rip),%rax
mov    %rax,-0x70(%rbp)
jmp    1234 <main+0x94>
mov    -0x70(%rbp),%rax
mov    %rax,-0x18(%rbp)
cmpl   $0x2,-0x8(%rbp)
jle    1257 <main+0xb7>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rax
mov    %rax,-0x78(%rbp)
jmp    1267 <main+0xc7>
lea    0xdf5(%rip),%rax
mov    %rax,-0x78(%rbp)
jmp    1267 <main+0xc7>
mov    -0x78(%rbp),%rax
mov    %rax,-0x20(%rbp)
cmpl   $0x3,-0x8(%rbp)
jle    128a <main+0xea>
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rax
mov    %rax,-0x80(%rbp)
jmp    129a <main+0xfa>
lea    0xdc2(%rip),%rax
mov    %rax,-0x80(%rbp)
jmp    129a <main+0xfa>
mov    -0x80(%rbp),%rax
mov    %rax,-0x28(%rbp)
cmpl   $0x4,-0x8(%rbp)
jle    12c0 <main+0x120>
mov    -0x10(%rbp),%rax
mov    0x20(%rax),%rax
mov    %rax,-0x88(%rbp)
jmp    12d3 <main+0x133>
lea    0xd8c(%rip),%rax
mov    %rax,-0x88(%rbp)
jmp    12d3 <main+0x133>
mov    -0x88(%rbp),%rax
mov    %rax,-0x30(%rbp)
mov    -0x18(%rbp),%rdi
lea    -0x34(%rbp),%rsi
lea    -0x38(%rbp),%rdx
lea    -0x3c(%rbp),%rcx
call   10c0 <iio_read_image_float_split@plt>
mov    %rax,-0x48(%rbp)
mov    -0x20(%rbp),%rdi
lea    -0x4c(%rbp),%rsi
lea    -0x50(%rbp),%rdx
lea    -0x54(%rbp),%rcx
call   10c0 <iio_read_image_float_split@plt>
mov    %rax,-0x60(%rbp)
mov    -0x3c(%rbp),%eax
cmp    -0x54(%rbp),%eax
je     1344 <main+0x1a4>
mov    0x2cbd(%rip),%rax
mov    (%rax),%edi
lea    0xd29(%rip),%rsi
mov    $0x0,%al
call   1090 <fprintf@plt>
mov    0x2c9e(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    154a <main+0x3aa>
mov    -0x4c(%rbp),%eax
imul   -0x50(%rbp),%eax
imul   -0x54(%rbp),%eax
cltq
shl    $0x2,%rax
mov    %eax,%edi
call   10a0 <malloc@plt>
mov    %rax,-0x68(%rbp)
mov    -0x30(%rbp),%rdi
lea    0xd19(%rip),%rsi
call   1070 <strcmp@plt>
mov    %rax,%rcx
xor    %eax,%eax
cmp    %rcx,%rax
jne    13eb <main+0x24b>
mov    -0x34(%rbp),%eax
cmp    -0x4c(%rbp),%eax
jne    13a2 <main+0x202>
mov    -0x38(%rbp),%eax
cmp    -0x50(%rbp),%eax
jne    13a2 <main+0x202>
mov    -0x3c(%rbp),%eax
cmp    -0x54(%rbp),%eax
je     13ca <main+0x22a>
mov    0x2c37(%rip),%rax
mov    (%rax),%edi
lea    0xcd8(%rip),%rsi
mov    $0x0,%al
call   1090 <fprintf@plt>
mov    0x2c18(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    154a <main+0x3aa>
mov    -0x48(%rbp),%rdi
mov    -0x60(%rbp),%rsi
mov    -0x68(%rbp),%rdx
mov    -0x34(%rbp),%ecx
mov    -0x38(%rbp),%r8d
mov    -0x3c(%rbp),%r9d
call   10b0 <equalization_histo@plt>
jmp    150c <main+0x36c>
mov    -0x30(%rbp),%rdi
lea    0xcb7(%rip),%rsi
call   1070 <strcmp@plt>
mov    %rax,%rcx
xor    %eax,%eax
cmp    %rcx,%rax
jne    1439 <main+0x299>
mov    -0x48(%rbp),%rdi
mov    -0x60(%rbp),%rsi
mov    -0x68(%rbp),%rdx
mov    -0x34(%rbp),%ecx
mov    -0x38(%rbp),%r8d
mov    -0x4c(%rbp),%r9d
mov    -0x50(%rbp),%r10d
mov    -0x3c(%rbp),%eax
mov    %r10d,(%rsp)
mov    %eax,0x8(%rsp)
call   1080 <equalization_affine@plt>
jmp    1507 <main+0x367>
mov    -0x30(%rbp),%rdi
lea    0xc70(%rip),%rsi
call   1070 <strcmp@plt>
mov    %rax,%rcx
xor    %eax,%eax
cmp    %rcx,%rax
jne    1487 <main+0x2e7>
mov    -0x48(%rbp),%rdi
mov    -0x60(%rbp),%rsi
mov    -0x68(%rbp),%rdx
mov    -0x34(%rbp),%ecx
mov    -0x38(%rbp),%r8d
mov    -0x4c(%rbp),%r9d
mov    -0x50(%rbp),%r10d
mov    -0x3c(%rbp),%eax
mov    %r10d,(%rsp)
mov    %eax,0x8(%rsp)
call   1040 <equalization_meanp@plt>
jmp    1502 <main+0x362>
mov    -0x30(%rbp),%rdi
lea    0xc28(%rip),%rsi
call   1070 <strcmp@plt>
mov    %rax,%rcx
xor    %eax,%eax
cmp    %rcx,%rax
jne    14d5 <main+0x335>
mov    -0x48(%rbp),%rdi
mov    -0x60(%rbp),%rsi
mov    -0x68(%rbp),%rdx
mov    -0x34(%rbp),%ecx
mov    -0x38(%rbp),%r8d
mov    -0x4c(%rbp),%r9d
mov    -0x50(%rbp),%r10d
mov    -0x3c(%rbp),%eax
mov    %r10d,(%rsp)
mov    %eax,0x8(%rsp)
call   1050 <equalization_meanx@plt>
jmp    14fd <main+0x35d>
mov    0x2b04(%rip),%rax
mov    (%rax),%edi
lea    0xbdb(%rip),%rsi
mov    $0x0,%al
call   1090 <fprintf@plt>
mov    0x2ae5(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    154a <main+0x3aa>
jmp    1502 <main+0x362>
jmp    1507 <main+0x367>
jmp    150c <main+0x36c>
mov    -0x28(%rbp),%rdi
mov    -0x68(%rbp),%rsi
mov    -0x4c(%rbp),%edx
mov    -0x50(%rbp),%ecx
mov    -0x54(%rbp),%r8d
call   1060 <iio_write_image_float_split@plt>
mov    -0x48(%rbp),%rdi
call   1030 <free@plt>
mov    -0x60(%rbp),%rdi
call   1030 <free@plt>
mov    -0x68(%rbp),%rdi
call   1030 <free@plt>
mov    0x2a8b(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0xa0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
cmp    $0x5,%edi
jne    128a <main+0xea>
mov    0x8(%rsi),%rdi
mov    0x10(%rsi),%rbx
mov    0x18(%rsi),%r14
mov    0x20(%rsi),%rbp
lea    0x10(%rsp),%rsi
lea    0xc(%rsp),%rdx
lea    0x8(%rsp),%rcx
call   10c0 <iio_read_image_float_split@plt>
mov    %rax,%r15
lea    0x4(%rsp),%rsi
mov    %rsp,%rdx
lea    0x14(%rsp),%rcx
mov    %rbx,%rdi
call   10c0 <iio_read_image_float_split@plt>
mov    0x8(%rsp),%edi
cmp    0x14(%rsp),%edi
jne    12af <main+0x10f>
mov    %rax,%r13
imul   0x4(%rsp),%edi
imul   (%rsp),%edi
shl    $0x2,%edi
call   10a0 <malloc@plt>
mov    %rax,%r12
lea    0xe63(%rip),%rsi
mov    %rbp,%rdi
call   1070 <strcmp@plt>
test   %rax,%rax
je     12c1 <main+0x121>
lea    0xe74(%rip),%rsi
mov    %rbp,%rdi
call   1070 <strcmp@plt>
test   %rax,%rax
je     1324 <main+0x184>
lea    0xe63(%rip),%rsi
mov    %rbp,%rdi
call   1070 <strcmp@plt>
test   %rax,%rax
je     134b <main+0x1ab>
lea    0xe51(%rip),%rsi
mov    %rbp,%rdi
call   1070 <strcmp@plt>
test   %rax,%rax
je     1372 <main+0x1d2>
mov    0x2d61(%rip),%rax
mov    (%rax),%edi
lea    0xe36(%rip),%rsi
jmp    1305 <main+0x165>
mov    0x2d4f(%rip),%rbx
mov    (%rbx),%edi
mov    (%rsi),%rdx
lea    0xd63(%rip),%rsi
xor    %eax,%eax
call   1090 <fprintf@plt>
mov    (%rbx),%edi
lea    0xd75(%rip),%rsi
jmp    1305 <main+0x165>
mov    0x2d2a(%rip),%rax
mov    (%rax),%edi
lea    0xd94(%rip),%rsi
jmp    1305 <main+0x165>
mov    0x10(%rsp),%ecx
cmp    0x4(%rsp),%ecx
jne    12f5 <main+0x155>
mov    0xc(%rsp),%r8d
cmp    (%rsp),%r8d
jne    12f5 <main+0x155>
mov    0x8(%rsp),%r9d
cmp    0x14(%rsp),%r9d
jne    12f5 <main+0x155>
mov    %r15,%rdi
mov    %r13,%rsi
mov    %r12,%rdx
call   10b0 <equalization_histo@plt>
jmp    139b <main+0x1fb>
mov    0x2ce4(%rip),%rax
mov    (%rax),%edi
lea    0xd83(%rip),%rsi
xor    %eax,%eax
call   1090 <fprintf@plt>
mov    0x2cc5(%rip),%rax
mov    (%rax),%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    0x10(%rsp),%ecx
mov    0xc(%rsp),%r8d
mov    0x4(%rsp),%r9d
mov    (%rsp),%eax
mov    0x8(%rsp),%ebp
mov    %r15,%rdi
mov    %r13,%rsi
mov    %r12,%rdx
push   %rbp
push   %rax
call   1080 <equalization_affine@plt>
jmp    1397 <main+0x1f7>
mov    0x10(%rsp),%ecx
mov    0xc(%rsp),%r8d
mov    0x4(%rsp),%r9d
mov    (%rsp),%eax
mov    0x8(%rsp),%ebp
mov    %r15,%rdi
mov    %r13,%rsi
mov    %r12,%rdx
push   %rbp
push   %rax
call   1040 <equalization_meanp@plt>
jmp    1397 <main+0x1f7>
mov    0x10(%rsp),%ecx
mov    0xc(%rsp),%r8d
mov    0x4(%rsp),%r9d
mov    (%rsp),%eax
mov    0x8(%rsp),%ebp
mov    %r15,%rdi
mov    %r13,%rsi
mov    %r12,%rdx
push   %rbp
push   %rax
call   1050 <equalization_meanx@plt>
add    $0x10,%rsp
mov    0x4(%rsp),%edx
mov    (%rsp),%ecx
mov    0x14(%rsp),%r8d
mov    %r14,%rdi
mov    %r12,%rsi
call   1060 <iio_write_image_float_split@plt>
mov    %r15,%rdi
call   1030 <free@plt>
mov    %r13,%rdi
call   1030 <free@plt>
mov    %r12,%rdi
call   1030 <free@plt>
mov    0x2bff(%rip),%rax
jmp    1313 <main+0x173>

LLVM IR (-O0):
@stderr = global i32 0
@.str = [34 x i8] c"usage:\0A\09%s ref modified out type\0A\00"
@.str.1 = [49 x i8] c"type possibilities: histo, affine, meanp, meanx\0A\00"
@EXIT_FAILURE = global i32 0
@.str.2 = [2 x i8] c"-\00"
@.str.3 = [47 x i8] c"Images should have the same number of channel\0A\00"
@.str.4 = [6 x i8] c"histo\00"
@.str.5 = [35 x i8] c"Size of images should be the same\0A\00"
@.str.6 = [7 x i8] c"affine\00"
@.str.7 = [6 x i8] c"meanp\00"
@.str.8 = [6 x i8] c"meanx\00"
@.str.9 = [27 x i8] c"Unknown equalization type\0A\00"
@EXIT_SUCCESS = global i32 0
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca i8*
%9 = alloca i8*
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32
%13 = alloca float*
%14 = alloca i32
%15 = alloca i32
%16 = alloca i32
%17 = alloca float*
%18 = alloca float*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%19 = load i32, i32* %4
%20 = icmp ne i32 %19, 5
br i1 %20, label %21, label %29
21: ; preds = %2
%22 = load i32, i32* @stderr
%23 = load i8**, i8*** %5
%24 = load i8*, i8** %23
%25 = call i32 (i32, i8*, ...) @fprintf(i32 %22, i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str, i64 0, i64 0), i8* %24)
%26 = load i32, i32* @stderr
%27 = call i32 (i32, i8*, ...) @fprintf(i32 %26, i8* getelementptr inbounds ([49 x i8], [49 x i8]* @.str.1, i64 0, i64 0))
%28 = load i32, i32* @EXIT_FAILURE
store i32 %28, i32* %3
br label %177
29: ; preds = %2
%30 = load i32, i32* %4
%31 = icmp sgt i32 %30, 1
br i1 %31, label %32, label %36
32: ; preds = %29
%33 = load i8**, i8*** %5
%34 = getelementptr inbounds i8*, i8** %33, i64 1
%35 = load i8*, i8** %34
br label %37
36: ; preds = %29
br label %37
37: ; preds = %36, %32
%38 = phi i8* [ %35, %32 ], [ getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0), %36 ]
store i8* %38, i8** %6
%39 = load i32, i32* %4
%40 = icmp sgt i32 %39, 2
br i1 %40, label %41, label %45
41: ; preds = %37
%42 = load i8**, i8*** %5
%43 = getelementptr inbounds i8*, i8** %42, i64 2
%44 = load i8*, i8** %43
br label %46
45: ; preds = %37
br label %46
46: ; preds = %45, %41
%47 = phi i8* [ %44, %41 ], [ getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0), %45 ]
store i8* %47, i8** %7
%48 = load i32, i32* %4
%49 = icmp sgt i32 %48, 3
br i1 %49, label %50, label %54
50: ; preds = %46
%51 = load i8**, i8*** %5
%52 = getelementptr inbounds i8*, i8** %51, i64 3
%53 = load i8*, i8** %52
br label %55
54: ; preds = %46
br label %55
55: ; preds = %54, %50
%56 = phi i8* [ %53, %50 ], [ getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0), %54 ]
store i8* %56, i8** %8
%57 = load i32, i32* %4
%58 = icmp sgt i32 %57, 4
br i1 %58, label %59, label %63
59: ; preds = %55
%60 = load i8**, i8*** %5
%61 = getelementptr inbounds i8*, i8** %60, i64 4
%62 = load i8*, i8** %61
br label %64
63: ; preds = %55
br label %64
64: ; preds = %63, %59
%65 = phi i8* [ %62, %59 ], [ getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0), %63 ]
store i8* %65, i8** %9
%66 = load i8*, i8** %6
%67 = call float* @iio_read_image_float_split(i8* %66, i32* %10, i32* %11, i32* %12)
store float* %67, float** %13
%68 = load i8*, i8** %7
%69 = call float* @iio_read_image_float_split(i8* %68, i32* %14, i32* %15, i32* %16)
store float* %69, float** %17
%70 = load i32, i32* %12
%71 = load i32, i32* %16
%72 = icmp ne i32 %70, %71
br i1 %72, label %73, label %77
73: ; preds = %64
%74 = load i32, i32* @stderr
%75 = call i32 (i32, i8*, ...) @fprintf(i32 %74, i8* getelementptr inbounds ([47 x i8], [47 x i8]* @.str.3, i64 0, i64 0))
%76 = load i32, i32* @EXIT_FAILURE
store i32 %76, i32* %3
br label %177
77: ; preds = %64
%78 = load i32, i32* %14
%79 = load i32, i32* %15
%80 = mul nsw i32 %78, %79
%81 = load i32, i32* %16
%82 = mul nsw i32 %80, %81
%83 = sext i32 %82 to i64
%84 = mul i64 %83, 4
%85 = trunc i64 %84 to i32
%86 = call float* @malloc(i32 %85)
store float* %86, float** %18
%87 = load i8*, i8** %9
%88 = call i64 @strcmp(i8* %87, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0))
%89 = icmp eq i64 0, %88
br i1 %89, label %90, label %114
90: ; preds = %77
%91 = load i32, i32* %10
%92 = load i32, i32* %14
%93 = icmp ne i32 %91, %92
br i1 %93, label %102, label %94
94: ; preds = %90
%95 = load i32, i32* %11
%96 = load i32, i32* %15
%97 = icmp ne i32 %95, %96
br i1 %97, label %102, label %98
98: ; preds = %94
%99 = load i32, i32* %12
%100 = load i32, i32* %16
%101 = icmp ne i32 %99, %100
br i1 %101, label %102, label %106
102: ; preds = %98, %94, %90
%103 = load i32, i32* @stderr
%104 = call i32 (i32, i8*, ...) @fprintf(i32 %103, i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.5, i64 0, i64 0))
%105 = load i32, i32* @EXIT_FAILURE
store i32 %105, i32* %3
br label %177
106: ; preds = %98
%107 = load float*, float** %13
%108 = load float*, float** %17
%109 = load float*, float** %18
%110 = load i32, i32* %10
%111 = load i32, i32* %11
%112 = load i32, i32* %12
%113 = call i32 @equalization_histo(float* %107, float* %108, float* %109, i32 %110, i32 %111, i32 %112)
br label %163
114: ; preds = %77
%115 = load i8*, i8** %9
%116 = call i64 @strcmp(i8* %115, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.6, i64 0, i64 0))
%117 = icmp eq i64 0, %116
br i1 %117, label %118, label %128
118: ; preds = %114
%119 = load float*, float** %13
%120 = load float*, float** %17
%121 = load float*, float** %18
%122 = load i32, i32* %10
%123 = load i32, i32* %11
%124 = load i32, i32* %14
%125 = load i32, i32* %15
%126 = load i32, i32* %12
%127 = call i32 @equalization_affine(float* %119, float* %120, float* %121, i32 %122, i32 %123, i32 %124, i32 %125, i32 %126)
br label %162
128: ; preds = %114
%129 = load i8*, i8** %9
%130 = call i64 @strcmp(i8* %129, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.7, i64 0, i64 0))
%131 = icmp eq i64 0, %130
br i1 %131, label %132, label %142
132: ; preds = %128
%133 = load float*, float** %13
%134 = load float*, float** %17
%135 = load float*, float** %18
%136 = load i32, i32* %10
%137 = load i32, i32* %11
%138 = load i32, i32* %14
%139 = load i32, i32* %15
%140 = load i32, i32* %12
%141 = call i32 @equalization_meanp(float* %133, float* %134, float* %135, i32 %136, i32 %137, i32 %138, i32 %139, i32 %140)
br label %161
142: ; preds = %128
%143 = load i8*, i8** %9
%144 = call i64 @strcmp(i8* %143, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.8, i64 0, i64 0))
%145 = icmp eq i64 0, %144
br i1 %145, label %146, label %156
146: ; preds = %142
%147 = load float*, float** %13
%148 = load float*, float** %17
%149 = load float*, float** %18
%150 = load i32, i32* %10
%151 = load i32, i32* %11
%152 = load i32, i32* %14
%153 = load i32, i32* %15
%154 = load i32, i32* %12
%155 = call i32 @equalization_meanx(float* %147, float* %148, float* %149, i32 %150, i32 %151, i32 %152, i32 %153, i32 %154)
br label %160
156: ; preds = %142
%157 = load i32, i32* @stderr
%158 = call i32 (i32, i8*, ...) @fprintf(i32 %157, i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.9, i64 0, i64 0))
%159 = load i32, i32* @EXIT_FAILURE
store i32 %159, i32* %3
br label %177
160: ; preds = %146
br label %161
161: ; preds = %160, %132
br label %162
162: ; preds = %161, %118
br label %163
163: ; preds = %162, %106
%164 = load i8*, i8** %8
%165 = load float*, float** %18
%166 = load i32, i32* %14
%167 = load i32, i32* %15
%168 = load i32, i32* %16
%169 = call i32 @iio_write_image_float_split(i8* %164, float* %165, i32 %166, i32 %167, i32 %168)
%170 = load float*, float** %13
%171 = call i32 @free(float* %170)
%172 = load float*, float** %17
%173 = call i32 @free(float* %172)
%174 = load float*, float** %18
%175 = call i32 @free(float* %174)
%176 = load i32, i32* @EXIT_SUCCESS
store i32 %176, i32* %3
br label %177
177: ; preds = %163, %156, %102, %73, %21
%178 = load i32, i32* %3
ret i32 %178
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [34 x i8] c"usage:\0A\09%s ref modified out type\0A\00"
@.str.1 = [49 x i8] c"type possibilities: histo, affine, meanp, meanx\0A\00"
@EXIT_FAILURE = global i32 0
@.str.3 = [47 x i8] c"Images should have the same number of channel\0A\00"
@.str.4 = [6 x i8] c"histo\00"
@.str.5 = [35 x i8] c"Size of images should be the same\0A\00"
@.str.6 = [7 x i8] c"affine\00"
@.str.7 = [6 x i8] c"meanp\00"
@.str.8 = [6 x i8] c"meanx\00"
@.str.9 = [27 x i8] c"Unknown equalization type\0A\00"
@EXIT_SUCCESS = global i32 0
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = icmp eq i32 %0, 5
br i1 %9, label %17, label %10
10: ; preds = %2
%11 = load i32, i32* @stderr
%12 = load i8*, i8** %1
%13 = tail call i32 (i32, i8*, ...) @fprintf(i32 %11, i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str, i64 0, i64 0), i8* %12)
%14 = load i32, i32* @stderr
%15 = tail call i32 (i32, i8*, ...) @fprintf(i32 %14, i8* getelementptr inbounds ([49 x i8], [49 x i8]* @.str.1, i64 0, i64 0))
%16 = load i32, i32* @EXIT_FAILURE
br label %110
17: ; preds = %2
%18 = getelementptr inbounds i8*, i8** %1, i64 1
%19 = load i8*, i8** %18
%20 = getelementptr inbounds i8*, i8** %1, i64 2
%21 = load i8*, i8** %20
%22 = getelementptr inbounds i8*, i8** %1, i64 3
%23 = load i8*, i8** %22
%24 = getelementptr inbounds i8*, i8** %1, i64 4
%25 = load i8*, i8** %24
%26 = bitcast i32* %3 to i8*
%27 = bitcast i32* %4 to i8*
%28 = bitcast i32* %5 to i8*
%29 = call float* @iio_read_image_float_split(i8* %19, i32* %3, i32* %4, i32* %5)
%30 = bitcast i32* %6 to i8*
%31 = bitcast i32* %7 to i8*
%32 = bitcast i32* %8 to i8*
%33 = call float* @iio_read_image_float_split(i8* %21, i32* %6, i32* %7, i32* %8)
%34 = load i32, i32* %5
%35 = load i32, i32* %8
%36 = icmp eq i32 %34, %35
br i1 %36, label %40, label %37
37: ; preds = %17
%38 = load i32, i32* @stderr
%39 = call i32 (i32, i8*, ...) @fprintf(i32 %38, i8* getelementptr inbounds ([47 x i8], [47 x i8]* @.str.3, i64 0, i64 0))
br label %107
40: ; preds = %17
%41 = load i32, i32* %6
%42 = load i32, i32* %7
%43 = shl i32 %34, 2
%44 = mul i32 %43, %41
%45 = mul i32 %44, %42
%46 = call float* @malloc(i32 %45)
%47 = call i64 @strcmp(i8* %25, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0))
%48 = icmp eq i64 %47, 0
br i1 %48, label %49, label %66
49: ; preds = %40
%50 = load i32, i32* %3
%51 = load i32, i32* %6
%52 = icmp eq i32 %50, %51
br i1 %52, label %53, label %61
53: ; preds = %49
%54 = load i32, i32* %4
%55 = load i32, i32* %7
%56 = icmp eq i32 %54, %55
br i1 %56, label %57, label %61
57: ; preds = %53
%58 = load i32, i32* %5
%59 = load i32, i32* %8
%60 = icmp eq i32 %58, %59
br i1 %60, label %64, label %61
61: ; preds = %57, %53, %49
%62 = load i32, i32* @stderr
%63 = call i32 (i32, i8*, ...) @fprintf(i32 %62, i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.5, i64 0, i64 0))
br label %107
64: ; preds = %57
%65 = call i32 @equalization_histo(float* %29, float* %33, float* %46, i32 %50, i32 %54, i32 %58)
br label %99
66: ; preds = %40
%67 = call i64 @strcmp(i8* %25, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.6, i64 0, i64 0))
%68 = icmp eq i64 %67, 0
br i1 %68, label %69, label %76
69: ; preds = %66
%70 = load i32, i32* %3
%71 = load i32, i32* %4
%72 = load i32, i32* %6
%73 = load i32, i32* %7
%74 = load i32, i32* %5
%75 = call i32 @equalization_affine(float* %29, float* %33, float* %46, i32 %70, i32 %71, i32 %72, i32 %73, i32 %74)
br label %99
76: ; preds = %66
%77 = call i64 @strcmp(i8* %25, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.7, i64 0, i64 0))
%78 = icmp eq i64 %77, 0
br i1 %78, label %79, label %86
79: ; preds = %76
%80 = load i32, i32* %3
%81 = load i32, i32* %4
%82 = load i32, i32* %6
%83 = load i32, i32* %7
%84 = load i32, i32* %5
%85 = call i32 @equalization_meanp(float* %29, float* %33, float* %46, i32 %80, i32 %81, i32 %82, i32 %83, i32 %84)
br label %99
86: ; preds = %76
%87 = call i64 @strcmp(i8* %25, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.8, i64 0, i64 0))
%88 = icmp eq i64 %87, 0
br i1 %88, label %89, label %96
89: ; preds = %86
%90 = load i32, i32* %3
%91 = load i32, i32* %4
%92 = load i32, i32* %6
%93 = load i32, i32* %7
%94 = load i32, i32* %5
%95 = call i32 @equalization_meanx(float* %29, float* %33, float* %46, i32 %90, i32 %91, i32 %92, i32 %93, i32 %94)
br label %99
96: ; preds = %86
%97 = load i32, i32* @stderr
%98 = call i32 (i32, i8*, ...) @fprintf(i32 %97, i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.9, i64 0, i64 0))
br label %107
99: ; preds = %69, %89, %79, %64
%100 = load i32, i32* %6
%101 = load i32, i32* %7
%102 = load i32, i32* %8
%103 = call i32 @iio_write_image_float_split(i8* %23, float* %46, i32 %100, i32 %101, i32 %102)
%104 = call i32 @free(float* %29)
%105 = call i32 @free(float* %33)
%106 = call i32 @free(float* %46)
br label %107
107: ; preds = %61, %96, %99, %37
%108 = phi i32* [ @EXIT_FAILURE, %37 ], [ @EXIT_FAILURE, %61 ], [ @EXIT_SUCCESS, %99 ], [ @EXIT_FAILURE, %96 ]
%109 = load i32, i32* %108
br label %110
110: ; preds = %107, %10
%111 = phi i32 [ %16, %10 ], [ %109, %107 ]
ret i32 %111
}