#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*/ muzzle_profile_diagonal_left(unsigned char *, int, int, int,
                                                int, float *);
int /*<<< orphan*/ muzzle_profile_diagonal_right(unsigned char *, int, int, int,
                                                 int, float *);
int /*<<< orphan*/ muzzle_profile_horizontal(unsigned char *, int, int, int,
                                             int, float *);
void muzzle_profile(unsigned char *img, int image_width, int image_height,
                    int bytesperpixel, int samples, float profile[]) {
  int samples_per_axis = samples / 3;
  muzzle_profile_horizontal(img, image_width, image_height, bytesperpixel,
                            samples_per_axis, profile);
  muzzle_profile_diagonal_right(img, image_width, image_height, bytesperpixel,
                                samples_per_axis, &profile[samples_per_axis]);
  muzzle_profile_diagonal_left(img, image_width, image_height, bytesperpixel,
                               samples_per_axis,
                               &profile[samples_per_axis * 2]);
}


x86 assembly (clang, -O0):
<muzzle_profile>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
mov    %ecx,-0x14(%rbp)
mov    %r8d,-0x18(%rbp)
mov    %r9,-0x20(%rbp)
mov    -0x18(%rbp),%eax
mov    $0x3,%ecx
cltd
idiv   %ecx
mov    %eax,-0x24(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%esi
mov    -0x10(%rbp),%edx
mov    -0x14(%rbp),%ecx
mov    -0x24(%rbp),%r8d
mov    -0x20(%rbp),%r9
call   1040 <muzzle_profile_horizontal@plt>
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%esi
mov    -0x10(%rbp),%edx
mov    -0x14(%rbp),%ecx
mov    -0x24(%rbp),%r8d
mov    -0x20(%rbp),%r9
movslq -0x24(%rbp),%rax
shl    $0x2,%rax
add    %rax,%r9
call   1050 <muzzle_profile_diagonal_right@plt>
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%esi
mov    -0x10(%rbp),%edx
mov    -0x14(%rbp),%ecx
mov    -0x24(%rbp),%r8d
mov    -0x20(%rbp),%r9
mov    -0x24(%rbp),%eax
shl    $0x1,%eax
cltq
shl    $0x2,%rax
add    %rax,%r9
call   1030 <muzzle_profile_diagonal_left@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<muzzle_profile>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %r9,%r15
mov    %ecx,%r14d
mov    %edx,%r12d
mov    %esi,%r13d
mov    %rdi,%rbp
movslq %r8d,%rax
imul   $0x55555556,%rax,%rbx
mov    %rbx,%rax
shr    $0x3f,%rax
shr    $0x20,%rbx
add    %eax,%ebx
mov    %ebx,%r8d
call   1040 <muzzle_profile_horizontal@plt>
movslq %ebx,%rbx
lea    (%r15,%rbx,4),%r9
mov    %rbp,%rdi
mov    %r13d,%esi
mov    %r12d,%edx
mov    %r14d,%ecx
mov    %ebx,%r8d
call   1050 <muzzle_profile_diagonal_right@plt>
lea    (%rbx,%rbx,1),%eax
cltq
lea    (%r15,%rax,4),%r9
mov    %rbp,%rdi
mov    %r13d,%esi
mov    %r12d,%edx
mov    %r14d,%ecx
mov    %ebx,%r8d
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <muzzle_profile_diagonal_left@plt>

LLVM IR (-O0):
define void @muzzle_profile(i8* %0, i32 %1, i32 %2, i32 %3, i32 %4, float* %5) {
%7 = alloca i8*
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
%12 = alloca float*
%13 = alloca i32
store i8* %0, i8** %7
store i32 %1, i32* %8
store i32 %2, i32* %9
store i32 %3, i32* %10
store i32 %4, i32* %11
store float* %5, float** %12
%14 = load i32, i32* %11
%15 = sdiv i32 %14, 3
store i32 %15, i32* %13
%16 = load i8*, i8** %7
%17 = load i32, i32* %8
%18 = load i32, i32* %9
%19 = load i32, i32* %10
%20 = load i32, i32* %13
%21 = load float*, float** %12
%22 = call i32 @muzzle_profile_horizontal(i8* %16, i32 %17, i32 %18, i32 %19, i32 %20, float* %21)
%23 = load i8*, i8** %7
%24 = load i32, i32* %8
%25 = load i32, i32* %9
%26 = load i32, i32* %10
%27 = load i32, i32* %13
%28 = load float*, float** %12
%29 = load i32, i32* %13
%30 = sext i32 %29 to i64
%31 = getelementptr inbounds float, float* %28, i64 %30
%32 = call i32 @muzzle_profile_diagonal_right(i8* %23, i32 %24, i32 %25, i32 %26, i32 %27, float* %31)
%33 = load i8*, i8** %7
%34 = load i32, i32* %8
%35 = load i32, i32* %9
%36 = load i32, i32* %10
%37 = load i32, i32* %13
%38 = load float*, float** %12
%39 = load i32, i32* %13
%40 = mul nsw i32 %39, 2
%41 = sext i32 %40 to i64
%42 = getelementptr inbounds float, float* %38, i64 %41
%43 = call i32 @muzzle_profile_diagonal_left(i8* %33, i32 %34, i32 %35, i32 %36, i32 %37, float* %42)
ret void
}

LLVM IR (-O2):
define void @muzzle_profile(i8* %0, i32 %1, i32 %2, i32 %3, i32 %4, float* %5) {
%7 = sdiv i32 %4, 3
%8 = tail call i32 @muzzle_profile_horizontal(i8* %0, i32 %1, i32 %2, i32 %3, i32 %7, float* %5)
%9 = sext i32 %7 to i64
%10 = getelementptr inbounds float, float* %5, i64 %9
%11 = tail call i32 @muzzle_profile_diagonal_right(i8* %0, i32 %1, i32 %2, i32 %3, i32 %7, float* %10)
%12 = shl nsw i32 %7, 1
%13 = sext i32 %12 to i64
%14 = getelementptr inbounds float, float* %5, i64 %13
%15 = tail call i32 @muzzle_profile_diagonal_left(i8* %0, i32 %1, i32 %2, i32 %3, i32 %7, float* %14)
ret void
}