#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(unsigned char *, int, int, int, int, float *);
int /*<<< orphan*/ printf(char *, ...);
void muzzle_csv(unsigned char *img, int image_width, int image_height,
                int bytesperpixel, int positive) {
  int i, samples = 128 * 3;
  float profile[128 * 3];
  muzzle_profile(img, image_width, image_height, bytesperpixel, samples,
                 profile);
  for (i = 0; i < samples; i++) {
    printf("%.4f", profile[i]);
    if (i < samples - 1)
      printf(",");
  }
  if (positive > -1)
    printf(",%d\n", positive);
}


x86 assembly (clang, -O0):
<muzzle_csv>:
push   %rbp
mov    %rsp,%rbp
sub    $0x620,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
mov    %ecx,-0x14(%rbp)
mov    %r8d,-0x18(%rbp)
movl   $0x180,-0x20(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%esi
mov    -0x10(%rbp),%edx
mov    -0x14(%rbp),%ecx
mov    -0x20(%rbp),%r8d
lea    -0x620(%rbp),%r9
call   1030 <muzzle_profile@plt>
movl   $0x0,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0x20(%rbp),%eax
jge    11c4 <muzzle_csv+0xa4>
movslq -0x1c(%rbp),%rax
movss  -0x620(%rbp,%rax,4),%xmm0
ff ff
cvtss2sd %xmm0,%xmm0
lea    0xe75(%rip),%rdi
mov    $0x1,%al
call   1040 <printf@plt>
mov    -0x1c(%rbp),%eax
mov    -0x20(%rbp),%ecx
sub    $0x1,%ecx
cmp    %ecx,%eax
jge    11b1 <muzzle_csv+0x91>
lea    0xe5b(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    11b6 <muzzle_csv+0x96>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    1167 <muzzle_csv+0x47>
cmpl   $0xffffffff,-0x18(%rbp)
jle    11df <muzzle_csv+0xbf>
mov    -0x18(%rbp),%esi
lea    0xe2f(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
add    $0x620,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<muzzle_csv>:
push   %rbp
push   %r14
push   %rbx
sub    $0x600,%rsp
mov    %r8d,%r14d
mov    %rsp,%r9
mov    $0x180,%r8d
call   1040 <muzzle_profile@plt>
movss  (%rsp),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xea4(%rip),%rbx
mov    %rbx,%rdi
mov    $0x1,%al
call   1050 <printf@plt>
mov    $0x1,%ebp
nopl   0x0(%rax,%rax,1)
mov    $0x2c,%edi
call   1030 <putchar@plt>
movss  (%rsp,%rbp,4),%xmm0
cvtss2sd %xmm0,%xmm0
mov    %rbx,%rdi
mov    $0x1,%al
call   1050 <printf@plt>
add    $0x1,%rbp
cmp    $0x180,%rbp
jne    1170 <muzzle_csv+0x40>
test   %r14d,%r14d
js     11b0 <muzzle_csv+0x80>
lea    0xe5f(%rip),%rdi
mov    %r14d,%esi
xor    %eax,%eax
call   1050 <printf@plt>
add    $0x600,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@.str = [5 x i8] c"%.4f\00"
@.str.1 = [2 x i8] c",\00"
@.str.2 = [5 x i8] c",%d\0A\00"
define void @muzzle_csv(i8* %0, i32 %1, i32 %2, i32 %3, i32 %4) {
%6 = alloca i8*
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32
%13 = alloca [384 x float]
store i8* %0, i8** %6
store i32 %1, i32* %7
store i32 %2, i32* %8
store i32 %3, i32* %9
store i32 %4, i32* %10
store i32 384, i32* %12
%14 = load i8*, i8** %6
%15 = load i32, i32* %7
%16 = load i32, i32* %8
%17 = load i32, i32* %9
%18 = load i32, i32* %12
%19 = getelementptr inbounds [384 x float], [384 x float]* %13, i64 0, i64 0
%20 = call i32 @muzzle_profile(i8* %14, i32 %15, i32 %16, i32 %17, i32 %18, float* %19)
store i32 0, i32* %11
br label %21
21: ; preds = %39, %5
%22 = load i32, i32* %11
%23 = load i32, i32* %12
%24 = icmp slt i32 %22, %23
br i1 %24, label %25, label %42
25: ; preds = %21
%26 = load i32, i32* %11
%27 = sext i32 %26 to i64
%28 = getelementptr inbounds [384 x float], [384 x float]* %13, i64 0, i64 %27
%29 = load float, float* %28
%30 = fpext float %29 to double
%31 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), double %30)
%32 = load i32, i32* %11
%33 = load i32, i32* %12
%34 = sub nsw i32 %33, 1
%35 = icmp slt i32 %32, %34
br i1 %35, label %36, label %38
36: ; preds = %25
%37 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
br label %38
38: ; preds = %36, %25
br label %39
39: ; preds = %38
%40 = load i32, i32* %11
%41 = add nsw i32 %40, 1
store i32 %41, i32* %11
br label %21
42: ; preds = %21
%43 = load i32, i32* %10
%44 = icmp sgt i32 %43, -1
br i1 %44, label %45, label %48
45: ; preds = %42
%46 = load i32, i32* %10
%47 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i32 %46)
br label %48
48: ; preds = %45, %42
ret void
}

LLVM IR (-O2):
@.str = [5 x i8] c"%.4f\00"
@.str.2 = [5 x i8] c",%d\0A\00"
define void @muzzle_csv(i8* %0, i32 %1, i32 %2, i32 %3, i32 %4) {
%6 = alloca [384 x float]
%7 = bitcast [384 x float]* %6 to i8*
%8 = getelementptr inbounds [384 x float], [384 x float]* %6, i64 0, i64 0
%9 = call i32 @muzzle_profile(i8* %0, i32 %1, i32 %2, i32 %3, i32 384, float* %8)
%10 = getelementptr inbounds [384 x float], [384 x float]* %6, i64 0, i64 0
%11 = load float, float* %10
%12 = fpext float %11 to double
%13 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), double %12)
br label %14
14: ; preds = %5, %14
%15 = phi i64 [ 0, %5 ], [ %17, %14 ]
%16 = call i32 @putchar(i32 44)
%17 = add nuw nsw i64 %15, 1
%18 = getelementptr inbounds [384 x float], [384 x float]* %6, i64 0, i64 %17
%19 = load float, float* %18
%20 = fpext float %19 to double
%21 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), double %20)
%22 = icmp eq i64 %17, 383
br i1 %22, label %23, label %14
23: ; preds = %14
%24 = icmp sgt i32 %4, -1
br i1 %24, label %25, label %27
25: ; preds = %23
%26 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i32 %4)
br label %27
27: ; preds = %25, %23
ret void
}