#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 _getNextAudioPeak(int);
char _getNextByte() {
  int ref_sig_val, value_sig_val;
  char b = 0;
  for (int bitpos = 0; bitpos < 8; ++bitpos) {
    ref_sig_val = _getNextAudioPeak(8);
    value_sig_val = _getNextAudioPeak(8);
    if (0 == ref_sig_val * value_sig_val) {
      return 0;
    }
    if (value_sig_val > ref_sig_val) {
      b |= 1 << bitpos;
    }
  }
  return b;
}


x86 assembly (clang, -O0):
<_getNextByte>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movb   $0x0,-0xd(%rbp)
movl   $0x0,-0x14(%rbp)
cmpl   $0x8,-0x14(%rbp)
jge    1195 <_getNextByte+0x85>
mov    $0x8,%edi
call   1030 <_getNextAudioPeak@plt>
mov    %eax,-0x8(%rbp)
mov    $0x8,%edi
call   1030 <_getNextAudioPeak@plt>
mov    %eax,-0xc(%rbp)
mov    -0x8(%rbp),%ecx
imul   -0xc(%rbp),%ecx
xor    %eax,%eax
cmp    %ecx,%eax
jne    1161 <_getNextByte+0x51>
movb   $0x0,-0x1(%rbp)
jmp    119b <_getNextByte+0x8b>
mov    -0xc(%rbp),%eax
cmp    -0x8(%rbp),%eax
jle    1182 <_getNextByte+0x72>
mov    -0x14(%rbp),%ecx
mov    $0x1,%eax
shl    %cl,%eax
mov    %eax,%ecx
movsbl -0xd(%rbp),%eax
or     %ecx,%eax
mov    %al,-0xd(%rbp)
jmp    1187 <_getNextByte+0x77>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1123 <_getNextByte+0x13>
mov    -0xd(%rbp),%al
mov    %al,-0x1(%rbp)
movsbl -0x1(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<_getNextByte>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x28,%rsp
mov    $0x8,%edi
call   1030 <_getNextAudioPeak@plt>
mov    %eax,%r13d
mov    $0x8,%edi
call   1030 <_getNextAudioPeak@plt>
mov    %eax,%ebp
imul   %r13d,%eax
test   %eax,%eax
je     12de <_getNextByte+0x1ce>
mov    $0x8,%edi
call   1030 <_getNextAudioPeak@plt>
mov    %eax,%r14d
mov    $0x8,%edi
call   1030 <_getNextAudioPeak@plt>
mov    %eax,%r15d
imul   %r14d,%eax
test   %eax,%eax
je     12de <_getNextByte+0x1ce>
mov    $0x8,%edi
call   1030 <_getNextAudioPeak@plt>
mov    %eax,%ebx
mov    $0x8,%edi
call   1030 <_getNextAudioPeak@plt>
mov    %eax,%ecx
imul   %ebx,%ecx
test   %ecx,%ecx
je     12de <_getNextByte+0x1ce>
mov    %eax,0x20(%rsp)
mov    $0x8,%edi
call   1030 <_getNextAudioPeak@plt>
mov    %eax,%r12d
mov    $0x8,%edi
call   1030 <_getNextAudioPeak@plt>
mov    %eax,%ecx
mov    %r12d,0x24(%rsp)
imul   %r12d,%ecx
test   %ecx,%ecx
je     12de <_getNextByte+0x1ce>
mov    %eax,0x1c(%rsp)
mov    $0x8,%edi
call   1030 <_getNextAudioPeak@plt>
mov    %eax,%r12d
mov    $0x8,%edi
call   1030 <_getNextAudioPeak@plt>
mov    %eax,%ecx
mov    %r12d,0x18(%rsp)
imul   %r12d,%ecx
test   %ecx,%ecx
je     12de <_getNextByte+0x1ce>
mov    %eax,0x14(%rsp)
mov    $0x8,%edi
call   1030 <_getNextAudioPeak@plt>
mov    %eax,%r12d
mov    $0x8,%edi
call   1030 <_getNextAudioPeak@plt>
mov    %eax,%ecx
mov    %r12d,0x10(%rsp)
imul   %r12d,%ecx
test   %ecx,%ecx
je     12de <_getNextByte+0x1ce>
mov    %eax,0xc(%rsp)
mov    $0x8,%edi
call   1030 <_getNextAudioPeak@plt>
mov    %eax,%r12d
mov    $0x8,%edi
call   1030 <_getNextAudioPeak@plt>
mov    %eax,%ecx
imul   %r12d,%ecx
test   %ecx,%ecx
je     12de <_getNextByte+0x1ce>
mov    %eax,0x4(%rsp)
mov    %r12d,0x8(%rsp)
mov    $0x8,%edi
call   1030 <_getNextAudioPeak@plt>
mov    %eax,%r12d
mov    $0x8,%edi
call   1030 <_getNextAudioPeak@plt>
mov    %eax,%ecx
imul   %r12d,%ecx
test   %ecx,%ecx
je     12de <_getNextByte+0x1ce>
mov    0x4(%rsp),%ecx
cmp    0x8(%rsp),%ecx
setg   %sil
shl    $0x6,%sil
mov    0xc(%rsp),%ecx
cmp    0x10(%rsp),%ecx
setg   %dil
shl    $0x5,%dil
mov    0x14(%rsp),%ecx
cmp    0x18(%rsp),%ecx
setg   %r8b
shl    $0x4,%r8b
mov    0x1c(%rsp),%ecx
cmp    0x24(%rsp),%ecx
setg   %r9b
shl    $0x3,%r9b
cmp    %ebx,0x20(%rsp)
setg   %cl
shl    $0x2,%cl
cmp    %r14d,%r15d
setg   %dl
add    %dl,%dl
cmp    %r13d,%ebp
setg   %bl
or     %dl,%bl
or     %cl,%bl
or     %r9b,%bl
or     %r8b,%bl
or     %dil,%bl
cmp    %r12d,%eax
setg   %al
shl    $0x7,%al
or     %sil,%al
or     %bl,%al
jmp    12e0 <_getNextByte+0x1d0>
xor    %eax,%eax
add    $0x28,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define signext i8 @_getNextByte() {
%1 = alloca i8
%2 = alloca i32
%3 = alloca i32
%4 = alloca i8
%5 = alloca i32
store i8 0, i8* %4
store i32 0, i32* %5
br label %6
6: ; preds = %29, %0
%7 = load i32, i32* %5
%8 = icmp slt i32 %7, 8
br i1 %8, label %9, label %32
9: ; preds = %6
%10 = call i32 @_getNextAudioPeak(i32 8)
store i32 %10, i32* %2
%11 = call i32 @_getNextAudioPeak(i32 8)
store i32 %11, i32* %3
%12 = load i32, i32* %2
%13 = load i32, i32* %3
%14 = mul nsw i32 %12, %13
%15 = icmp eq i32 0, %14
br i1 %15, label %16, label %17
16: ; preds = %9
store i8 0, i8* %1
br label %34
17: ; preds = %9
%18 = load i32, i32* %3
%19 = load i32, i32* %2
%20 = icmp sgt i32 %18, %19
br i1 %20, label %21, label %28
21: ; preds = %17
%22 = load i32, i32* %5
%23 = shl i32 1, %22
%24 = load i8, i8* %4
%25 = sext i8 %24 to i32
%26 = or i32 %25, %23
%27 = trunc i32 %26 to i8
store i8 %27, i8* %4
br label %28
28: ; preds = %21, %17
br label %29
29: ; preds = %28
%30 = load i32, i32* %5
%31 = add nsw i32 %30, 1
store i32 %31, i32* %5
br label %6
32: ; preds = %6
%33 = load i8, i8* %4
store i8 %33, i8* %1
br label %34
34: ; preds = %32, %16
%35 = load i8, i8* %1
ret i8 %35
}

LLVM IR (-O2):
define signext i8 @_getNextByte() {
%1 = tail call i32 @_getNextAudioPeak(i32 8)
%2 = tail call i32 @_getNextAudioPeak(i32 8)
%3 = mul nsw i32 %2, %1
%4 = icmp eq i32 %3, 0
br i1 %4, label %64, label %5
5: ; preds = %0
%6 = tail call i32 @_getNextAudioPeak(i32 8)
%7 = tail call i32 @_getNextAudioPeak(i32 8)
%8 = mul nsw i32 %7, %6
%9 = icmp eq i32 %8, 0
br i1 %9, label %64, label %10
10: ; preds = %5
%11 = tail call i32 @_getNextAudioPeak(i32 8)
%12 = tail call i32 @_getNextAudioPeak(i32 8)
%13 = mul nsw i32 %12, %11
%14 = icmp eq i32 %13, 0
br i1 %14, label %64, label %15
15: ; preds = %10
%16 = tail call i32 @_getNextAudioPeak(i32 8)
%17 = tail call i32 @_getNextAudioPeak(i32 8)
%18 = mul nsw i32 %17, %16
%19 = icmp eq i32 %18, 0
br i1 %19, label %64, label %20
20: ; preds = %15
%21 = tail call i32 @_getNextAudioPeak(i32 8)
%22 = tail call i32 @_getNextAudioPeak(i32 8)
%23 = mul nsw i32 %22, %21
%24 = icmp eq i32 %23, 0
br i1 %24, label %64, label %25
25: ; preds = %20
%26 = tail call i32 @_getNextAudioPeak(i32 8)
%27 = tail call i32 @_getNextAudioPeak(i32 8)
%28 = mul nsw i32 %27, %26
%29 = icmp eq i32 %28, 0
br i1 %29, label %64, label %30
30: ; preds = %25
%31 = tail call i32 @_getNextAudioPeak(i32 8)
%32 = tail call i32 @_getNextAudioPeak(i32 8)
%33 = mul nsw i32 %32, %31
%34 = icmp eq i32 %33, 0
br i1 %34, label %64, label %35
35: ; preds = %30
%36 = tail call i32 @_getNextAudioPeak(i32 8)
%37 = tail call i32 @_getNextAudioPeak(i32 8)
%38 = mul nsw i32 %37, %36
%39 = icmp eq i32 %38, 0
br i1 %39, label %64, label %40
40: ; preds = %35
%41 = icmp sgt i32 %32, %31
%42 = select i1 %41, i8 64, i8 0
%43 = icmp sgt i32 %27, %26
%44 = select i1 %43, i8 32, i8 0
%45 = icmp sgt i32 %22, %21
%46 = select i1 %45, i8 16, i8 0
%47 = icmp sgt i32 %17, %16
%48 = select i1 %47, i8 8, i8 0
%49 = icmp sgt i32 %12, %11
%50 = select i1 %49, i8 4, i8 0
%51 = icmp sgt i32 %7, %6
%52 = select i1 %51, i8 2, i8 0
%53 = icmp sgt i32 %2, %1
%54 = zext i1 %53 to i8
%55 = or i8 %52, %54
%56 = or i8 %50, %55
%57 = or i8 %48, %56
%58 = or i8 %46, %57
%59 = or i8 %44, %58
%60 = or i8 %42, %59
%61 = icmp sgt i32 %37, %36
%62 = select i1 %61, i8 -128, i8 0
%63 = or i8 %62, %60
br label %64
64: ; preds = %40, %35, %30, %25, %20, %15, %10, %5, %0
%65 = phi i8 [ 0, %0 ], [ 0, %5 ], [ 0, %10 ], [ 0, %15 ], [ 0, %20 ], [ 0, %25 ], [ 0, %30 ], [ 0, %35 ], [ %63, %40 ]
ret i8 %65
}