#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 */
typedef int /*<<< orphan*/ uint8_t;

/* Variables and functions */
int /*<<< orphan*/ _calc_mutiple_lines(int *, int /*<<< orphan*/ *, int, int,
                                       int, int);
int /*<<< orphan*/ _calc_single_line(int *, int /*<<< orphan*/ *, int, int,
                                     int);
void _calc_gradients_by_mutiple_lines(int *gradient, uint8_t *image, int width,
                                      int height) {
  int y;
  int num_lines = 1;
  for (y = 1; y < height - 1 - num_lines; y += num_lines) {
    _calc_mutiple_lines(gradient, image, width, height, num_lines, y);
  }
  for (; y < height - 1; y++) {
    _calc_single_line(gradient, image, width, height, y);
  }
}


x86 assembly (clang, -O0):
<_calc_gradients_by_mutiple_lines>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    %ecx,-0x18(%rbp)
movl   $0x1,-0x20(%rbp)
movl   $0x1,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
mov    -0x18(%rbp),%ecx
sub    $0x1,%ecx
sub    -0x20(%rbp),%ecx
cmp    %ecx,%eax
jge    1181 <_calc_gradients_by_mutiple_lines+0x61>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x14(%rbp),%edx
mov    -0x18(%rbp),%ecx
mov    -0x20(%rbp),%r8d
mov    -0x1c(%rbp),%r9d
call   1030 <_calc_mutiple_lines@plt>
mov    -0x20(%rbp),%eax
add    -0x1c(%rbp),%eax
mov    %eax,-0x1c(%rbp)
jmp    1144 <_calc_gradients_by_mutiple_lines+0x24>
jmp    1186 <_calc_gradients_by_mutiple_lines+0x66>
mov    -0x1c(%rbp),%eax
mov    -0x18(%rbp),%ecx
sub    $0x1,%ecx
cmp    %ecx,%eax
jge    11bc <_calc_gradients_by_mutiple_lines+0x9c>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x14(%rbp),%edx
mov    -0x18(%rbp),%ecx
mov    -0x1c(%rbp),%r8d
call   1040 <_calc_single_line@plt>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    1186 <_calc_gradients_by_mutiple_lines+0x66>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<_calc_gradients_by_mutiple_lines>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %ecx,%r13d
mov    %edx,%r14d
mov    %rsi,%r15
mov    %rdi,%r12
mov    $0x1,%ebp
cmp    $0x4,%ecx
jl     1193 <_calc_gradients_by_mutiple_lines+0x73>
lea    -0x2(%r13),%ebp
mov    %r14d,0x4(%rsp)
mov    $0x3,%r14d
sub    %r13d,%r14d
mov    $0x1,%ebx
nopl   0x0(%rax,%rax,1)
mov    %r12,%rdi
mov    %r15,%rsi
mov    0x4(%rsp),%edx
mov    %r13d,%ecx
mov    $0x1,%r8d
mov    %ebx,%r9d
call   1030 <_calc_mutiple_lines@plt>
lea    (%r14,%rbx,1),%eax
add    $0x1,%eax
mov    %ebx,%ecx
add    $0x1,%ecx
mov    %ecx,%ebx
cmp    $0x1,%eax
jne    1160 <_calc_gradients_by_mutiple_lines+0x40>
mov    0x4(%rsp),%r14d
lea    -0x1(%r13),%eax
cmp    %eax,%ebp
jge    11c6 <_calc_gradients_by_mutiple_lines+0xa6>
mov    %r13d,%ebx
neg    %ebx
mov    %r12,%rdi
mov    %r15,%rsi
mov    %r14d,%edx
mov    %r13d,%ecx
mov    %ebp,%r8d
call   1040 <_calc_single_line@plt>
lea    (%rbx,%rbp,1),%eax
add    $0x1,%eax
mov    %ebp,%ecx
add    $0x1,%ecx
mov    %ecx,%ebp
cmp    $0xffffffff,%eax
jne    11a0 <_calc_gradients_by_mutiple_lines+0x80>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define void @_calc_gradients_by_mutiple_lines(i32* %0, i32* %1, i32 %2, i32 %3) {
%5 = alloca i32*
%6 = alloca i32*
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
store i32* %0, i32** %5
store i32* %1, i32** %6
store i32 %2, i32* %7
store i32 %3, i32* %8
store i32 1, i32* %10
store i32 1, i32* %9
br label %11
11: ; preds = %26, %4
%12 = load i32, i32* %9
%13 = load i32, i32* %8
%14 = sub nsw i32 %13, 1
%15 = load i32, i32* %10
%16 = sub nsw i32 %14, %15
%17 = icmp slt i32 %12, %16
br i1 %17, label %18, label %30
18: ; preds = %11
%19 = load i32*, i32** %5
%20 = load i32*, i32** %6
%21 = load i32, i32* %7
%22 = load i32, i32* %8
%23 = load i32, i32* %10
%24 = load i32, i32* %9
%25 = call i32 @_calc_mutiple_lines(i32* %19, i32* %20, i32 %21, i32 %22, i32 %23, i32 %24)
br label %26
26: ; preds = %18
%27 = load i32, i32* %10
%28 = load i32, i32* %9
%29 = add nsw i32 %28, %27
store i32 %29, i32* %9
br label %11
30: ; preds = %11
br label %31
31: ; preds = %43, %30
%32 = load i32, i32* %9
%33 = load i32, i32* %8
%34 = sub nsw i32 %33, 1
%35 = icmp slt i32 %32, %34
br i1 %35, label %36, label %46
36: ; preds = %31
%37 = load i32*, i32** %5
%38 = load i32*, i32** %6
%39 = load i32, i32* %7
%40 = load i32, i32* %8
%41 = load i32, i32* %9
%42 = call i32 @_calc_single_line(i32* %37, i32* %38, i32 %39, i32 %40, i32 %41)
br label %43
43: ; preds = %36
%44 = load i32, i32* %9
%45 = add nsw i32 %44, 1
store i32 %45, i32* %9
br label %31
46: ; preds = %31
ret void
}

LLVM IR (-O2):
define void @_calc_gradients_by_mutiple_lines(i32* %0, i32* %1, i32 %2, i32 %3) {
%5 = add i32 %3, -2
%6 = icmp sgt i32 %3, 3
br i1 %6, label %11, label %7
7: ; preds = %11, %4
%8 = phi i32 [ 1, %4 ], [ %5, %11 ]
%9 = add i32 %3, -1
%10 = icmp slt i32 %8, %9
br i1 %10, label %16, label %21
11: ; preds = %4, %11
%12 = phi i32 [ %14, %11 ], [ 1, %4 ]
%13 = tail call i32 @_calc_mutiple_lines(i32* %0, i32* %1, i32 %2, i32 %3, i32 1, i32 %12)
%14 = add nuw nsw i32 %12, 1
%15 = icmp eq i32 %14, %5
br i1 %15, label %7, label %11
16: ; preds = %7, %16
%17 = phi i32 [ %19, %16 ], [ %8, %7 ]
%18 = tail call i32 @_calc_single_line(i32* %0, i32* %1, i32 %2, i32 %3, i32 %17)
%19 = add nuw i32 %17, 1
%20 = icmp eq i32 %19, %9
br i1 %20, label %21, label %16
21: ; preds = %16, %7
ret void
}