#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*/ exit(int);
int /*<<< orphan*/ mjpeg_error(char *, ...);
int average_coeff(unsigned int input_length, unsigned int output_length,
                  unsigned int *coeff) {
  int last_coeff = 0, remaining_coeff, still_to_go = 0, in, out, non_zero = 0,
      nb;
  unsigned int *non_zero_p = NULL;
  unsigned int *pointer;
  if ((output_length > input_length) || (input_length == 0) ||
      (output_length == 0) || (coeff == NULL)) {
    mjpeg_error("Function average_coeff : arguments are wrong");
    mjpeg_error("input length = %d, output length = %d, input = %p",
                input_length, output_length, coeff);
    exit(1);
  }
  pointer = coeff;
  if (output_length == 1) {
    *pointer = input_length;
    pointer++;
    for (in = 0; in < input_length; in++) {
      *pointer = 1;
      pointer++;
    }
  } else {
    for (in = 0; in < output_length; in++) {
      non_zero = 0;
      non_zero_p = pointer;
      pointer++;
      still_to_go = input_length;
      if (last_coeff > 0) {
        remaining_coeff = output_length - last_coeff;
        *pointer = remaining_coeff;
        pointer++;
        non_zero++;
        still_to_go -= remaining_coeff;
      }
      nb = (still_to_go / output_length);
      for (out = 0; out < nb; out++) {
        *pointer = output_length;
        pointer++;
      }
      still_to_go -= nb * output_length;
      non_zero += nb;
      if ((last_coeff = still_to_go) != 0) {
        *pointer = last_coeff;
        pointer++;
        non_zero++;
        *non_zero_p = non_zero;
      } else {
        if (in != output_length - 1) {
          mjpeg_error("There is a common divider between %d and %d\n This "
                      "should not be the case",
                      input_length, output_length);
          exit(1);
        }
      }
    }
    *non_zero_p = non_zero;
    if (still_to_go != 0) {
      mjpeg_error("Function average_coeff : calculus doesn't stop right : %d",
                  still_to_go);
    }
  }
  return (0);
}


x86 assembly (clang, -O0):
<average_coeff>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %rdx,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
movl   $0x0,-0x1c(%rbp)
movl   $0x0,-0x28(%rbp)
movq   $0x0,-0x38(%rbp)
mov    -0x8(%rbp),%eax
cmp    -0x4(%rbp),%eax
ja     117a <average_coeff+0x5a>
cmpl   $0x0,-0x4(%rbp)
je     117a <average_coeff+0x5a>
cmpl   $0x0,-0x8(%rbp)
je     117a <average_coeff+0x5a>
cmpq   $0x0,-0x10(%rbp)
jne    11aa <average_coeff+0x8a>
lea    0xe7f(%rip),%rdi
mov    $0x0,%al
call   1030 <mjpeg_error@plt>
mov    -0x4(%rbp),%esi
mov    -0x8(%rbp),%edx
mov    -0x10(%rbp),%rcx
lea    0xe94(%rip),%rdi
mov    $0x0,%al
call   1030 <mjpeg_error@plt>
mov    $0x1,%edi
call   1040 <exit@plt>
mov    -0x10(%rbp),%rax
mov    %rax,-0x40(%rbp)
cmpl   $0x1,-0x8(%rbp)
jne    120d <average_coeff+0xed>
mov    -0x4(%rbp),%ecx
mov    -0x40(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x40(%rbp),%rax
add    $0x4,%rax
mov    %rax,-0x40(%rbp)
movl   $0x0,-0x20(%rbp)
mov    -0x20(%rbp),%eax
cmp    -0x4(%rbp),%eax
jae    1208 <average_coeff+0xe8>
mov    -0x40(%rbp),%rax
movl   $0x1,(%rax)
mov    -0x40(%rbp),%rax
add    $0x4,%rax
mov    %rax,-0x40(%rbp)
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    11d8 <average_coeff+0xb8>
jmp    1381 <average_coeff+0x261>
movl   $0x0,-0x20(%rbp)
mov    -0x20(%rbp),%eax
cmp    -0x8(%rbp),%eax
jae    1358 <average_coeff+0x238>
movl   $0x0,-0x28(%rbp)
mov    -0x40(%rbp),%rax
mov    %rax,-0x38(%rbp)
mov    -0x40(%rbp),%rax
add    $0x4,%rax
mov    %rax,-0x40(%rbp)
mov    -0x4(%rbp),%eax
mov    %eax,-0x1c(%rbp)
cmpl   $0x0,-0x14(%rbp)
jle    127d <average_coeff+0x15d>
mov    -0x8(%rbp),%eax
sub    -0x14(%rbp),%eax
mov    %eax,-0x18(%rbp)
mov    -0x18(%rbp),%ecx
mov    -0x40(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x40(%rbp),%rax
add    $0x4,%rax
mov    %rax,-0x40(%rbp)
mov    -0x28(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x28(%rbp)
mov    -0x18(%rbp),%ecx
mov    -0x1c(%rbp),%eax
sub    %ecx,%eax
mov    %eax,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
xor    %edx,%edx
divl   -0x8(%rbp)
mov    %eax,-0x2c(%rbp)
movl   $0x0,-0x24(%rbp)
mov    -0x24(%rbp),%eax
cmp    -0x2c(%rbp),%eax
jge    12be <average_coeff+0x19e>
mov    -0x8(%rbp),%ecx
mov    -0x40(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x40(%rbp),%rax
add    $0x4,%rax
mov    %rax,-0x40(%rbp)
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    128f <average_coeff+0x16f>
mov    -0x2c(%rbp),%ecx
imul   -0x8(%rbp),%ecx
mov    -0x1c(%rbp),%eax
sub    %ecx,%eax
mov    %eax,-0x1c(%rbp)
mov    -0x2c(%rbp),%eax
add    -0x28(%rbp),%eax
mov    %eax,-0x28(%rbp)
mov    -0x1c(%rbp),%eax
mov    %eax,-0x14(%rbp)
cmp    $0x0,%eax
je     1311 <average_coeff+0x1f1>
mov    -0x14(%rbp),%ecx
mov    -0x40(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x40(%rbp),%rax
add    $0x4,%rax
mov    %rax,-0x40(%rbp)
mov    -0x28(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x28(%rbp)
mov    -0x28(%rbp),%ecx
mov    -0x38(%rbp),%rax
mov    %ecx,(%rax)
jmp    1345 <average_coeff+0x225>
mov    -0x20(%rbp),%eax
mov    -0x8(%rbp),%ecx
sub    $0x1,%ecx
cmp    %ecx,%eax
je     1340 <average_coeff+0x220>
mov    -0x4(%rbp),%esi
mov    -0x8(%rbp),%edx
lea    0xd30(%rip),%rdi
mov    $0x0,%al
call   1030 <mjpeg_error@plt>
mov    $0x1,%edi
call   1040 <exit@plt>
jmp    1345 <average_coeff+0x225>
jmp    134a <average_coeff+0x22a>
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    1214 <average_coeff+0xf4>
mov    -0x28(%rbp),%ecx
mov    -0x38(%rbp),%rax
mov    %ecx,(%rax)
cmpl   $0x0,-0x1c(%rbp)
je     137c <average_coeff+0x25c>
mov    -0x1c(%rbp),%esi
lea    0xd33(%rip),%rdi
mov    $0x0,%al
call   1030 <mjpeg_error@plt>
jmp    1381 <average_coeff+0x261>
xor    %eax,%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<average_coeff>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rdx,%rbx
mov    %esi,%r15d
mov    %edi,%r14d
lea    -0x1(%r15),%eax
mov    %eax,0x4(%rsp)
cmp    %edi,%eax
jae    14c0 <average_coeff+0x3a0>
test   %rbx,%rbx
je     14c0 <average_coeff+0x3a0>
cmp    $0x1,%r15d
jne    1195 <average_coeff+0x75>
mov    %r14d,(%rbx)
lea    -0x1(%r14),%ecx
xor    %eax,%eax
cmp    $0x7,%ecx
jb     146d <average_coeff+0x34d>
add    $0x1,%rcx
mov    %rcx,%rax
and    $0xfffffffffffffff8,%rax
lea    -0x8(%rax),%rdi
mov    %rdi,%rsi
shr    $0x3,%rsi
add    $0x1,%rsi
mov    %esi,%edx
and    $0x7,%edx
cmp    $0x38,%rdi
jae    138f <average_coeff+0x26f>
xor    %edi,%edi
jmp    1426 <average_coeff+0x306>
movd   %r15d,%xmm0
pshufd $0x0,%xmm0,%xmm0
xor    %edx,%edx
xor    %r10d,%r10d
jmp    11ca <average_coeff+0xaa>
cs nopw 0x0(%rax,%rax,1)
mov    %edx,(%rbx)
add    $0x4,%rbx
add    $0x1,%eax
mov    %eax,(%r12)
add    $0x1,%r10d
cmp    %r15d,%r10d
je     137a <average_coeff+0x25a>
mov    %rbx,%r12
test   %edx,%edx
jle    11f0 <average_coeff+0xd0>
mov    %r15d,%ecx
sub    %edx,%ecx
mov    %ecx,0x4(%r12)
lea    0x8(%r12),%rbx
mov    %r14d,%eax
sub    %ecx,%eax
mov    $0x1,%r11d
jmp    11fb <average_coeff+0xdb>
nopl   (%rax)
lea    0x4(%r12),%rbx
mov    %r14d,%eax
xor    %r11d,%r11d
xor    %edx,%edx
div    %r15d
test   %eax,%eax
jle    134e <average_coeff+0x22e>
lea    -0x1(%rax),%r13d
xor    %ecx,%ecx
cmp    $0x7,%r13d
jb     1340 <average_coeff+0x220>
add    $0x1,%r13
mov    %r13,%rcx
movabs $0x1fffffff8,%rsi
and    %rsi,%rcx
lea    -0x8(%rcx),%rsi
mov    %rsi,%rbp
shr    $0x3,%rbp
add    $0x1,%rbp
mov    %ebp,%edi
and    $0x7,%edi
cmp    $0x38,%rsi
jae    124e <average_coeff+0x12e>
xor    %r8d,%r8d
jmp    1308 <average_coeff+0x1e8>
movabs $0x3ffffffffffffff8,%rsi
ff ff 3f
and    %rsi,%rbp
xor    %r8d,%r8d
xor    %r9d,%r9d
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
movdqu %xmm0,(%rbx,%r8,4)
movdqu %xmm0,0x10(%rbx,%r8,4)
movdqu %xmm0,0x20(%rbx,%r8,4)
movdqu %xmm0,0x30(%rbx,%r8,4)
movdqu %xmm0,0x40(%rbx,%r8,4)
movdqu %xmm0,0x50(%rbx,%r8,4)
movdqu %xmm0,0x60(%rbx,%r8,4)
movdqu %xmm0,0x70(%rbx,%r8,4)
movdqu %xmm0,0x80(%rbx,%r8,4)
movdqu %xmm0,0x90(%rbx,%r8,4)
movdqu %xmm0,0xa0(%rbx,%r8,4)
movdqu %xmm0,0xb0(%rbx,%r8,4)
movdqu %xmm0,0xc0(%rbx,%r8,4)
movdqu %xmm0,0xd0(%rbx,%r8,4)
movdqu %xmm0,0xe0(%rbx,%r8,4)
movdqu %xmm0,0xf0(%rbx,%r8,4)
add    $0x40,%r8
add    $0x8,%r9
cmp    %rbp,%r9
jne    1270 <average_coeff+0x150>
test   %rdi,%rdi
je     1337 <average_coeff+0x217>
lea    (%rbx,%r8,4),%rbp
add    $0x10,%rbp
xor    %esi,%esi
nopw   0x0(%rax,%rax,1)
movdqu %xmm0,-0x10(%rbp)
movdqu %xmm0,0x0(%rbp)
add    $0x1,%rsi
add    $0x20,%rbp
cmp    %rdi,%rsi
jne    1320 <average_coeff+0x200>
lea    (%rbx,%rcx,4),%rbx
cmp    %rcx,%r13
je     134e <average_coeff+0x22e>
mov    %r15d,(%rbx)
add    $0x4,%rbx
add    $0x1,%ecx
cmp    %eax,%ecx
jne    1340 <average_coeff+0x220>
add    %r11d,%eax
test   %edx,%edx
jne    11b0 <average_coeff+0x90>
cmp    0x4(%rsp),%r10d
jne    14a2 <average_coeff+0x382>
add    $0x1,%r10d
cmp    %r15d,%r10d
jne    11ca <average_coeff+0xaa>
mov    %eax,(%r12)
jmp    1491 <average_coeff+0x371>
lea    0xd37(%rip),%rdi
mov    %edx,%esi
xor    %eax,%eax
call   1030 <mjpeg_error@plt>
jmp    1491 <average_coeff+0x371>
and    $0xfffffffffffffff8,%rsi
xor    %edi,%edi
movdqa 0xc63(%rip),%xmm0
nopl   (%rax)
movdqu %xmm0,0x4(%rbx,%rdi,4)
movdqu %xmm0,0x14(%rbx,%rdi,4)
movdqu %xmm0,0x24(%rbx,%rdi,4)
movdqu %xmm0,0x34(%rbx,%rdi,4)
movdqu %xmm0,0x44(%rbx,%rdi,4)
movdqu %xmm0,0x54(%rbx,%rdi,4)
movdqu %xmm0,0x64(%rbx,%rdi,4)
movdqu %xmm0,0x74(%rbx,%rdi,4)
movdqu %xmm0,0x84(%rbx,%rdi,4)
movdqu %xmm0,0x94(%rbx,%rdi,4)
movdqu %xmm0,0xa4(%rbx,%rdi,4)
movdqu %xmm0,0xb4(%rbx,%rdi,4)
movdqu %xmm0,0xc4(%rbx,%rdi,4)
movdqu %xmm0,0xd4(%rbx,%rdi,4)
movdqu %xmm0,0xe4(%rbx,%rdi,4)
movdqu %xmm0,0xf4(%rbx,%rdi,4)
add    $0x40,%rdi
add    $0xfffffffffffffff8,%rsi
jne    13a0 <average_coeff+0x280>
test   %rdx,%rdx
je     1464 <average_coeff+0x344>
lea    (%rbx,%rdi,4),%rsi
add    $0x14,%rsi
shl    $0x5,%rdx
xor    %edi,%edi
movdqa 0xbbf(%rip),%xmm0
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
movdqu %xmm0,-0x10(%rsi,%rdi,1)
movdqu %xmm0,(%rsi,%rdi,1)
add    $0x20,%rdi
cmp    %rdi,%rdx
jne    1450 <average_coeff+0x330>
cmp    %rax,%rcx
je     1491 <average_coeff+0x371>
lea    (%rbx,%rax,4),%rbx
sub    %eax,%r14d
xor    %eax,%eax
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
movl   $0x1,0x4(%rbx,%rax,4)
add    $0x1,%rax
cmp    %eax,%r14d
jne    1480 <average_coeff+0x360>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xbc6(%rip),%rdi
mov    %r14d,%esi
mov    %r15d,%edx
xor    %eax,%eax
call   1030 <mjpeg_error@plt>
mov    $0x1,%edi
call   1040 <exit@plt>
lea    0xb49(%rip),%rdi
xor    %eax,%eax
call   1030 <mjpeg_error@plt>
lea    0xb68(%rip),%rdi
mov    %r14d,%esi
mov    %r15d,%edx
mov    %rbx,%rcx
xor    %eax,%eax
call   1030 <mjpeg_error@plt>
mov    $0x1,%edi
call   1040 <exit@plt>

LLVM IR (-O0):
@.str = [45 x i8] c"Function average_coeff : arguments are wrong\00"
@.str.1 = [50 x i8] c"input length = %d, output length = %d, input = %p\00"
@.str.2 = [73 x i8] c"There is a common divider between %d and %d\0A This should not be the case\00"
@.str.3 = [58 x i8] c"Function average_coeff : calculus doesn't stop right : %d\00"
define i32 @average_coeff(i32 %0, i32 %1, i32* %2) {
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32*
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32
%13 = alloca i32
%14 = alloca i32*
%15 = alloca i32*
store i32 %0, i32* %4
store i32 %1, i32* %5
store i32* %2, i32** %6
store i32 0, i32* %7
store i32 0, i32* %9
store i32 0, i32* %12
store i32* null, i32** %14
%16 = load i32, i32* %5
%17 = load i32, i32* %4
%18 = icmp ugt i32 %16, %17
br i1 %18, label %28, label %19
19: ; preds = %3
%20 = load i32, i32* %4
%21 = icmp eq i32 %20, 0
br i1 %21, label %28, label %22
22: ; preds = %19
%23 = load i32, i32* %5
%24 = icmp eq i32 %23, 0
br i1 %24, label %28, label %25
25: ; preds = %22
%26 = load i32*, i32** %6
%27 = icmp eq i32* %26, null
br i1 %27, label %28, label %35
28: ; preds = %25, %22, %19, %3
%29 = call i32 (i8*, ...) @mjpeg_error(i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str, i64 0, i64 0))
%30 = load i32, i32* %4
%31 = load i32, i32* %5
%32 = load i32*, i32** %6
%33 = call i32 (i8*, ...) @mjpeg_error(i8* getelementptr inbounds ([50 x i8], [50 x i8]* @.str.1, i64 0, i64 0), i32 %30, i32 %31, i32* %32)
%34 = call i32 @exit(i32 1)
unreachable
35: ; preds = %25
%36 = load i32*, i32** %6
store i32* %36, i32** %15
%37 = load i32, i32* %5
%38 = icmp eq i32 %37, 1
br i1 %38, label %39, label %56
39: ; preds = %35
%40 = load i32, i32* %4
%41 = load i32*, i32** %15
store i32 %40, i32* %41
%42 = load i32*, i32** %15
%43 = getelementptr inbounds i32, i32* %42, i32 1
store i32* %43, i32** %15
store i32 0, i32* %10
br label %44
44: ; preds = %52, %39
%45 = load i32, i32* %10
%46 = load i32, i32* %4
%47 = icmp ult i32 %45, %46
br i1 %47, label %48, label %55
48: ; preds = %44
%49 = load i32*, i32** %15
store i32 1, i32* %49
%50 = load i32*, i32** %15
%51 = getelementptr inbounds i32, i32* %50, i32 1
store i32* %51, i32** %15
br label %52
52: ; preds = %48
%53 = load i32, i32* %10
%54 = add nsw i32 %53, 1
store i32 %54, i32* %10
br label %44
55: ; preds = %44
br label %141
56: ; preds = %35
store i32 0, i32* %10
br label %57
57: ; preds = %129, %56
%58 = load i32, i32* %10
%59 = load i32, i32* %5
%60 = icmp ult i32 %58, %59
br i1 %60, label %61, label %132
61: ; preds = %57
store i32 0, i32* %12
%62 = load i32*, i32** %15
store i32* %62, i32** %14
%63 = load i32*, i32** %15
%64 = getelementptr inbounds i32, i32* %63, i32 1
store i32* %64, i32** %15
%65 = load i32, i32* %4
store i32 %65, i32* %9
%66 = load i32, i32* %7
%67 = icmp sgt i32 %66, 0
br i1 %67, label %68, label %81
68: ; preds = %61
%69 = load i32, i32* %5
%70 = load i32, i32* %7
%71 = sub i32 %69, %70
store i32 %71, i32* %8
%72 = load i32, i32* %8
%73 = load i32*, i32** %15
store i32 %72, i32* %73
%74 = load i32*, i32** %15
%75 = getelementptr inbounds i32, i32* %74, i32 1
store i32* %75, i32** %15
%76 = load i32, i32* %12
%77 = add nsw i32 %76, 1
store i32 %77, i32* %12
%78 = load i32, i32* %8
%79 = load i32, i32* %9
%80 = sub nsw i32 %79, %78
store i32 %80, i32* %9
br label %81
81: ; preds = %68, %61
%82 = load i32, i32* %9
%83 = load i32, i32* %5
%84 = udiv i32 %82, %83
store i32 %84, i32* %13
store i32 0, i32* %11
br label %85
85: ; preds = %94, %81
%86 = load i32, i32* %11
%87 = load i32, i32* %13
%88 = icmp slt i32 %86, %87
br i1 %88, label %89, label %97
89: ; preds = %85
%90 = load i32, i32* %5
%91 = load i32*, i32** %15
store i32 %90, i32* %91
%92 = load i32*, i32** %15
%93 = getelementptr inbounds i32, i32* %92, i32 1
store i32* %93, i32** %15
br label %94
94: ; preds = %89
%95 = load i32, i32* %11
%96 = add nsw i32 %95, 1
store i32 %96, i32* %11
br label %85
97: ; preds = %85
%98 = load i32, i32* %13
%99 = load i32, i32* %5
%100 = mul i32 %98, %99
%101 = load i32, i32* %9
%102 = sub i32 %101, %100
store i32 %102, i32* %9
%103 = load i32, i32* %13
%104 = load i32, i32* %12
%105 = add nsw i32 %104, %103
store i32 %105, i32* %12
%106 = load i32, i32* %9
store i32 %106, i32* %7
%107 = icmp ne i32 %106, 0
br i1 %107, label %108, label %117
108: ; preds = %97
%109 = load i32, i32* %7
%110 = load i32*, i32** %15
store i32 %109, i32* %110
%111 = load i32*, i32** %15
%112 = getelementptr inbounds i32, i32* %111, i32 1
store i32* %112, i32** %15
%113 = load i32, i32* %12
%114 = add nsw i32 %113, 1
store i32 %114, i32* %12
%115 = load i32, i32* %12
%116 = load i32*, i32** %14
store i32 %115, i32* %116
br label %128
117: ; preds = %97
%118 = load i32, i32* %10
%119 = load i32, i32* %5
%120 = sub i32 %119, 1
%121 = icmp ne i32 %118, %120
br i1 %121, label %122, label %127
122: ; preds = %117
%123 = load i32, i32* %4
%124 = load i32, i32* %5
%125 = call i32 (i8*, ...) @mjpeg_error(i8* getelementptr inbounds ([73 x i8], [73 x i8]* @.str.2, i64 0, i64 0), i32 %123, i32 %124)
%126 = call i32 @exit(i32 1)
unreachable
127: ; preds = %117
br label %128
128: ; preds = %127, %108
br label %129
129: ; preds = %128
%130 = load i32, i32* %10
%131 = add nsw i32 %130, 1
store i32 %131, i32* %10
br label %57
132: ; preds = %57
%133 = load i32, i32* %12
%134 = load i32*, i32** %14
store i32 %133, i32* %134
%135 = load i32, i32* %9
%136 = icmp ne i32 %135, 0
br i1 %136, label %137, label %140
137: ; preds = %132
%138 = load i32, i32* %9
%139 = call i32 (i8*, ...) @mjpeg_error(i8* getelementptr inbounds ([58 x i8], [58 x i8]* @.str.3, i64 0, i64 0), i32 %138)
br label %140
140: ; preds = %137, %132
br label %141
141: ; preds = %140, %55
ret i32 0
}

LLVM IR (-O2):
@.str = [45 x i8] c"Function average_coeff : arguments are wrong\00"
@.str.1 = [50 x i8] c"input length = %d, output length = %d, input = %p\00"
@.str.2 = [73 x i8] c"There is a common divider between %d and %d\0A This should not be the case\00"
@.str.3 = [58 x i8] c"Function average_coeff : calculus doesn't stop right : %d\00"
define i32 @average_coeff(i32 %0, i32 %1, i32* %2) {
%4 = add i32 %1, -1
%5 = icmp uge i32 %4, %0
%6 = icmp eq i32* %2, null
%7 = or i1 %5, %6
br i1 %7, label %8, label %12
8: ; preds = %3
%9 = tail call i32 (i8*, ...) @mjpeg_error(i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str, i64 0, i64 0))
%10 = tail call i32 (i8*, ...) @mjpeg_error(i8* getelementptr inbounds ([50 x i8], [50 x i8]* @.str.1, i64 0, i64 0), i32 %0, i32 %1, i32* %2)
%11 = tail call i32 @exit(i32 1)
unreachable
12: ; preds = %3
%13 = icmp eq i32 %1, 1
br i1 %13, label %19, label %14
14: ; preds = %12
%15 = insertelement <4 x i32> poison, i32 %1, i64 0
%16 = shufflevector <4 x i32> %15, <4 x i32> poison, <4 x i32> zeroinitializer
%17 = insertelement <4 x i32> poison, i32 %1, i64 0
%18 = shufflevector <4 x i32> %17, <4 x i32> poison, <4 x i32> zeroinitializer
br label %114
19: ; preds = %12
store i32 %0, i32* %2
%20 = add i32 %0, -1
%21 = zext i32 %20 to i64
%22 = add nuw nsw i64 %21, 1
%23 = icmp ult i32 %20, 7
br i1 %23, label %105, label %24
24: ; preds = %19
%25 = and i64 %22, 8589934584
%26 = getelementptr i32, i32* %2, i64 %25
%27 = trunc i64 %25 to i32
%28 = add nsw i64 %25, -8
%29 = lshr exact i64 %28, 3
%30 = add nuw nsw i64 %29, 1
%31 = and i64 %30, 7
%32 = icmp ult i64 %28, 56
br i1 %32, label %88, label %33
33: ; preds = %24
%34 = and i64 %30, 4611686018427387896
%35 = getelementptr i32, i32* %2, i64 1
%36 = getelementptr i32, i32* %2, i64 1
%37 = getelementptr i32, i32* %2, i64 1
%38 = getelementptr i32, i32* %2, i64 1
%39 = getelementptr i32, i32* %2, i64 1
%40 = getelementptr i32, i32* %2, i64 1
%41 = getelementptr i32, i32* %2, i64 1
%42 = getelementptr i32, i32* %2, i64 1
br label %43
43: ; preds = %43, %33
%44 = phi i64 [ 0, %33 ], [ %85, %43 ]
%45 = phi i64 [ 0, %33 ], [ %86, %43 ]
%46 = getelementptr inbounds i32, i32* %35, i64 %44
%47 = bitcast i32* %46 to <4 x i32>*
store <4 x i32> <i32 1, i32 1, i32 1, i32 1>, <4 x i32>* %47
%48 = getelementptr inbounds i32, i32* %46, i64 4
%49 = bitcast i32* %48 to <4 x i32>*
store <4 x i32> <i32 1, i32 1, i32 1, i32 1>, <4 x i32>* %49
%50 = or i64 %44, 8
%51 = getelementptr inbounds i32, i32* %36, i64 %50
%52 = bitcast i32* %51 to <4 x i32>*
store <4 x i32> <i32 1, i32 1, i32 1, i32 1>, <4 x i32>* %52
%53 = getelementptr inbounds i32, i32* %51, i64 4
%54 = bitcast i32* %53 to <4 x i32>*
store <4 x i32> <i32 1, i32 1, i32 1, i32 1>, <4 x i32>* %54
%55 = or i64 %44, 16
%56 = getelementptr inbounds i32, i32* %37, i64 %55
%57 = bitcast i32* %56 to <4 x i32>*
store <4 x i32> <i32 1, i32 1, i32 1, i32 1>, <4 x i32>* %57
%58 = getelementptr inbounds i32, i32* %56, i64 4
%59 = bitcast i32* %58 to <4 x i32>*
store <4 x i32> <i32 1, i32 1, i32 1, i32 1>, <4 x i32>* %59
%60 = or i64 %44, 24
%61 = getelementptr inbounds i32, i32* %38, i64 %60
%62 = bitcast i32* %61 to <4 x i32>*
store <4 x i32> <i32 1, i32 1, i32 1, i32 1>, <4 x i32>* %62
%63 = getelementptr inbounds i32, i32* %61, i64 4
%64 = bitcast i32* %63 to <4 x i32>*
store <4 x i32> <i32 1, i32 1, i32 1, i32 1>, <4 x i32>* %64
%65 = or i64 %44, 32
%66 = getelementptr inbounds i32, i32* %39, i64 %65
%67 = bitcast i32* %66 to <4 x i32>*
store <4 x i32> <i32 1, i32 1, i32 1, i32 1>, <4 x i32>* %67
%68 = getelementptr inbounds i32, i32* %66, i64 4
%69 = bitcast i32* %68 to <4 x i32>*
store <4 x i32> <i32 1, i32 1, i32 1, i32 1>, <4 x i32>* %69
%70 = or i64 %44, 40
%71 = getelementptr inbounds i32, i32* %40, i64 %70
%72 = bitcast i32* %71 to <4 x i32>*
store <4 x i32> <i32 1, i32 1, i32 1, i32 1>, <4 x i32>* %72
%73 = getelementptr inbounds i32, i32* %71, i64 4
%74 = bitcast i32* %73 to <4 x i32>*
store <4 x i32> <i32 1, i32 1, i32 1, i32 1>, <4 x i32>* %74
%75 = or i64 %44, 48
%76 = getelementptr inbounds i32, i32* %41, i64 %75
%77 = bitcast i32* %76 to <4 x i32>*
store <4 x i32> <i32 1, i32 1, i32 1, i32 1>, <4 x i32>* %77
%78 = getelementptr inbounds i32, i32* %76, i64 4
%79 = bitcast i32* %78 to <4 x i32>*
store <4 x i32> <i32 1, i32 1, i32 1, i32 1>, <4 x i32>* %79
%80 = or i64 %44, 56
%81 = getelementptr inbounds i32, i32* %42, i64 %80
%82 = bitcast i32* %81 to <4 x i32>*
store <4 x i32> <i32 1, i32 1, i32 1, i32 1>, <4 x i32>* %82
%83 = getelementptr inbounds i32, i32* %81, i64 4
%84 = bitcast i32* %83 to <4 x i32>*
store <4 x i32> <i32 1, i32 1, i32 1, i32 1>, <4 x i32>* %84
%85 = add nuw i64 %44, 64
%86 = add nuw i64 %45, 8
%87 = icmp eq i64 %86, %34
br i1 %87, label %88, label %43
88: ; preds = %43, %24
%89 = phi i64 [ 0, %24 ], [ %85, %43 ]
%90 = icmp eq i64 %31, 0
br i1 %90, label %103, label %91
91: ; preds = %88
%92 = getelementptr i32, i32* %2, i64 1
br label %93
93: ; preds = %93, %91
%94 = phi i64 [ %89, %91 ], [ %100, %93 ]
%95 = phi i64 [ 0, %91 ], [ %101, %93 ]
%96 = getelementptr inbounds i32, i32* %92, i64 %94
%97 = bitcast i32* %96 to <4 x i32>*
store <4 x i32> <i32 1, i32 1, i32 1, i32 1>, <4 x i32>* %97
%98 = getelementptr inbounds i32, i32* %96, i64 4
%99 = bitcast i32* %98 to <4 x i32>*
store <4 x i32> <i32 1, i32 1, i32 1, i32 1>, <4 x i32>* %99
%100 = add nuw i64 %94, 8
%101 = add i64 %95, 1
%102 = icmp eq i64 %101, %31
br i1 %102, label %103, label %93
103: ; preds = %93, %88
%104 = icmp eq i64 %22, %25
br i1 %104, label %240, label %105
105: ; preds = %19, %103
%106 = phi i32* [ %2, %19 ], [ %26, %103 ]
%107 = phi i32 [ 0, %19 ], [ %27, %103 ]
br label %108
108: ; preds = %105, %108
%109 = phi i32* [ %111, %108 ], [ %106, %105 ]
%110 = phi i32 [ %112, %108 ], [ %107, %105 ]
%111 = getelementptr inbounds i32, i32* %109, i64 1
store i32 1, i32* %111
%112 = add nuw nsw i32 %110, 1
%113 = icmp eq i32 %112, %0
br i1 %113, label %240, label %108
114: ; preds = %229, %14
%115 = phi i32* [ %2, %14 ], [ %230, %229 ]
%116 = phi i32 [ 0, %14 ], [ %129, %229 ]
%117 = phi i32 [ 0, %14 ], [ %231, %229 ]
%118 = getelementptr inbounds i32, i32* %115, i64 1
%119 = icmp sgt i32 %116, 0
br i1 %119, label %120, label %124
120: ; preds = %114
%121 = sub i32 %1, %116
store i32 %121, i32* %118
%122 = getelementptr inbounds i32, i32* %115, i64 2
%123 = sub nsw i32 %0, %121
br label %124
124: ; preds = %120, %114
%125 = phi i32 [ %123, %120 ], [ %0, %114 ]
%126 = phi i32 [ 1, %120 ], [ 0, %114 ]
%127 = phi i32* [ %122, %120 ], [ %118, %114 ]
%128 = udiv i32 %125, %1
%129 = urem i32 %125, %1
%130 = icmp sgt i32 %128, 0
br i1 %130, label %131, label %216
131: ; preds = %124
%132 = add i32 %128, -1
%133 = zext i32 %132 to i64
%134 = add nuw nsw i64 %133, 1
%135 = icmp ult i32 %132, 7
br i1 %135, label %207, label %136
136: ; preds = %131
%137 = and i64 %134, 8589934584
%138 = getelementptr i32, i32* %127, i64 %137
%139 = trunc i64 %137 to i32
%140 = add nsw i64 %137, -8
%141 = lshr exact i64 %140, 3
%142 = add nuw nsw i64 %141, 1
%143 = and i64 %142, 7
%144 = icmp ult i64 %140, 56
br i1 %144, label %192, label %145
145: ; preds = %136
%146 = and i64 %142, 4611686018427387896
br label %147
147: ; preds = %147, %145
%148 = phi i64 [ 0, %145 ], [ %189, %147 ]
%149 = phi i64 [ 0, %145 ], [ %190, %147 ]
%150 = getelementptr i32, i32* %127, i64 %148
%151 = bitcast i32* %150 to <4 x i32>*
store <4 x i32> %16, <4 x i32>* %151
%152 = getelementptr i32, i32* %150, i64 4
%153 = bitcast i32* %152 to <4 x i32>*
store <4 x i32> %18, <4 x i32>* %153
%154 = or i64 %148, 8
%155 = getelementptr i32, i32* %127, i64 %154
%156 = bitcast i32* %155 to <4 x i32>*
store <4 x i32> %16, <4 x i32>* %156
%157 = getelementptr i32, i32* %155, i64 4
%158 = bitcast i32* %157 to <4 x i32>*
store <4 x i32> %18, <4 x i32>* %158
%159 = or i64 %148, 16
%160 = getelementptr i32, i32* %127, i64 %159
%161 = bitcast i32* %160 to <4 x i32>*
store <4 x i32> %16, <4 x i32>* %161
%162 = getelementptr i32, i32* %160, i64 4
%163 = bitcast i32* %162 to <4 x i32>*
store <4 x i32> %18, <4 x i32>* %163
%164 = or i64 %148, 24
%165 = getelementptr i32, i32* %127, i64 %164
%166 = bitcast i32* %165 to <4 x i32>*
store <4 x i32> %16, <4 x i32>* %166
%167 = getelementptr i32, i32* %165, i64 4
%168 = bitcast i32* %167 to <4 x i32>*
store <4 x i32> %18, <4 x i32>* %168
%169 = or i64 %148, 32
%170 = getelementptr i32, i32* %127, i64 %169
%171 = bitcast i32* %170 to <4 x i32>*
store <4 x i32> %16, <4 x i32>* %171
%172 = getelementptr i32, i32* %170, i64 4
%173 = bitcast i32* %172 to <4 x i32>*
store <4 x i32> %18, <4 x i32>* %173
%174 = or i64 %148, 40
%175 = getelementptr i32, i32* %127, i64 %174
%176 = bitcast i32* %175 to <4 x i32>*
store <4 x i32> %16, <4 x i32>* %176
%177 = getelementptr i32, i32* %175, i64 4
%178 = bitcast i32* %177 to <4 x i32>*
store <4 x i32> %18, <4 x i32>* %178
%179 = or i64 %148, 48
%180 = getelementptr i32, i32* %127, i64 %179
%181 = bitcast i32* %180 to <4 x i32>*
store <4 x i32> %16, <4 x i32>* %181
%182 = getelementptr i32, i32* %180, i64 4
%183 = bitcast i32* %182 to <4 x i32>*
store <4 x i32> %18, <4 x i32>* %183
%184 = or i64 %148, 56
%185 = getelementptr i32, i32* %127, i64 %184
%186 = bitcast i32* %185 to <4 x i32>*
store <4 x i32> %16, <4 x i32>* %186
%187 = getelementptr i32, i32* %185, i64 4
%188 = bitcast i32* %187 to <4 x i32>*
store <4 x i32> %18, <4 x i32>* %188
%189 = add nuw i64 %148, 64
%190 = add nuw i64 %149, 8
%191 = icmp eq i64 %190, %146
br i1 %191, label %192, label %147
192: ; preds = %147, %136
%193 = phi i64 [ 0, %136 ], [ %189, %147 ]
%194 = icmp eq i64 %143, 0
br i1 %194, label %205, label %195
195: ; preds = %192, %195
%196 = phi i64 [ %202, %195 ], [ %193, %192 ]
%197 = phi i64 [ %203, %195 ], [ 0, %192 ]
%198 = getelementptr i32, i32* %127, i64 %196
%199 = bitcast i32* %198 to <4 x i32>*
store <4 x i32> %16, <4 x i32>* %199
%200 = getelementptr i32, i32* %198, i64 4
%201 = bitcast i32* %200 to <4 x i32>*
store <4 x i32> %18, <4 x i32>* %201
%202 = add nuw i64 %196, 8
%203 = add i64 %197, 1
%204 = icmp eq i64 %203, %143
br i1 %204, label %205, label %195
205: ; preds = %195, %192
%206 = icmp eq i64 %134, %137
br i1 %206, label %216, label %207
207: ; preds = %131, %205
%208 = phi i32* [ %127, %131 ], [ %138, %205 ]
%209 = phi i32 [ 0, %131 ], [ %139, %205 ]
br label %210
210: ; preds = %207, %210
%211 = phi i32* [ %213, %210 ], [ %208, %207 ]
%212 = phi i32 [ %214, %210 ], [ %209, %207 ]
store i32 %1, i32* %211
%213 = getelementptr inbounds i32, i32* %211, i64 1
%214 = add nuw nsw i32 %212, 1
%215 = icmp eq i32 %214, %128
br i1 %215, label %216, label %210
216: ; preds = %210, %205, %124
%217 = phi i32* [ %127, %124 ], [ %138, %205 ], [ %213, %210 ]
%218 = mul i32 %128, %1
%219 = add nsw i32 %128, %126
%220 = icmp eq i32 %129, 0
br i1 %220, label %221, label %232
221: ; preds = %216
%222 = icmp eq i32 %117, %4
br i1 %222, label %226, label %223
223: ; preds = %221
%224 = tail call i32 (i8*, ...) @mjpeg_error(i8* getelementptr inbounds ([73 x i8], [73 x i8]* @.str.2, i64 0, i64 0), i32 %0, i32 %1)
%225 = tail call i32 @exit(i32 1)
unreachable
226: ; preds = %221
%227 = add nuw i32 %117, 1
%228 = icmp eq i32 %227, %1
br i1 %228, label %237, label %229
229: ; preds = %226, %232
%230 = phi i32* [ %217, %226 ], [ %233, %232 ]
%231 = phi i32 [ %227, %226 ], [ %235, %232 ]
br label %114
232: ; preds = %216
store i32 %129, i32* %217
%233 = getelementptr inbounds i32, i32* %217, i64 1
%234 = add nsw i32 %219, 1
store i32 %234, i32* %115
%235 = add nuw i32 %117, 1
%236 = icmp eq i32 %235, %1
br i1 %236, label %238, label %229
237: ; preds = %226
store i32 %219, i32* %115
br label %240
238: ; preds = %232
%239 = tail call i32 (i8*, ...) @mjpeg_error(i8* getelementptr inbounds ([58 x i8], [58 x i8]* @.str.3, i64 0, i64 0), i32 %129)
br label %240
240: ; preds = %108, %103, %237, %238
ret i32 0
}