#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*/ int32_t;

/* Variables and functions */
int abs(int /*<<< orphan*/);
extern void find_audio_click_32bit_stereo(const unsigned char *p_audio,
                                          int *p_click1, int *p_offset1,
                                          int *p_click2, int *p_offset2) {
  int audio_size = 1920 * 4 * 2;
  int found1 = 0, moderate1_off = -1;
  int found2 = 0, moderate2_off = -1;
  int threshold = 0x1b000000;
  int mod_threshold = 0x06000000;
  int i;
  for (i = 0; i < audio_size; i += 8) {
    int32_t samp1 = *(int32_t *)(p_audio + i);
    int32_t samp2 = *(int32_t *)(p_audio + i + 4);
    if (abs(samp1) > mod_threshold && moderate1_off == -1)
      moderate1_off = i / (4 * 2);
    if (abs(samp2) > mod_threshold && moderate2_off == -1)
      moderate2_off = i / (4 * 2);
    if (abs(samp1) > threshold && !found1) {
      *p_click1 = 1;
      *p_offset1 = moderate1_off;
      found1 = 1;
    }
    if (abs(samp2) > threshold && !found2) {
      *p_click2 = 1;
      *p_offset2 = moderate2_off;
      found2 = 1;
    }
    if (found1 && found2)
      return;
  }
  *p_click1 = 0;
  *p_offset1 = -1;
  *p_click2 = 0;
  *p_offset2 = -1;
  return;
}


x86 assembly (clang, -O0):
<find_audio_click_32bit_stereo>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    %r8,-0x28(%rbp)
movl   $0x3c00,-0x2c(%rbp)
movl   $0x0,-0x30(%rbp)
movl   $0xffffffff,-0x34(%rbp)
movl   $0x0,-0x38(%rbp)
movl   $0xffffffff,-0x3c(%rbp)
movl   $0x1b000000,-0x40(%rbp)
movl   $0x6000000,-0x44(%rbp)
movl   $0x0,-0x48(%rbp)
mov    -0x48(%rbp),%eax
cmp    -0x2c(%rbp),%eax
jge    1275 <find_audio_click_32bit_stereo+0x165>
mov    -0x8(%rbp),%rax
movslq -0x48(%rbp),%rcx
mov    (%rax,%rcx,1),%eax
mov    %eax,-0x4c(%rbp)
mov    -0x8(%rbp),%rax
movslq -0x48(%rbp),%rcx
mov    0x4(%rax,%rcx,1),%eax
mov    %eax,-0x50(%rbp)
mov    -0x4c(%rbp),%edi
call   1030 <abs@plt>
cmp    -0x44(%rbp),%eax
jle    11b6 <find_audio_click_32bit_stereo+0xa6>
cmpl   $0xffffffff,-0x34(%rbp)
jne    11b6 <find_audio_click_32bit_stereo+0xa6>
mov    -0x48(%rbp),%eax
mov    $0x8,%ecx
cltd
idiv   %ecx
mov    %eax,-0x34(%rbp)
mov    -0x50(%rbp),%edi
call   1030 <abs@plt>
cmp    -0x44(%rbp),%eax
jle    11df <find_audio_click_32bit_stereo+0xcf>
cmpl   $0xffffffff,-0x3c(%rbp)
jne    11df <find_audio_click_32bit_stereo+0xcf>
mov    -0x48(%rbp),%eax
mov    $0x8,%ecx
cltd
idiv   %ecx
mov    %eax,-0x3c(%rbp)
mov    -0x4c(%rbp),%edi
call   1030 <abs@plt>
cmp    -0x40(%rbp),%eax
jle    1214 <find_audio_click_32bit_stereo+0x104>
cmpl   $0x0,-0x30(%rbp)
jne    1214 <find_audio_click_32bit_stereo+0x104>
mov    -0x10(%rbp),%rax
movl   $0x1,(%rax)
mov    -0x34(%rbp),%ecx
mov    -0x18(%rbp),%rax
mov    %ecx,(%rax)
movl   $0x1,-0x30(%rbp)
mov    -0x50(%rbp),%edi
call   1030 <abs@plt>
cmp    -0x40(%rbp),%eax
jle    1249 <find_audio_click_32bit_stereo+0x139>
cmpl   $0x0,-0x38(%rbp)
jne    1249 <find_audio_click_32bit_stereo+0x139>
mov    -0x20(%rbp),%rax
movl   $0x1,(%rax)
mov    -0x3c(%rbp),%ecx
mov    -0x28(%rbp),%rax
mov    %ecx,(%rax)
movl   $0x1,-0x38(%rbp)
cmpl   $0x0,-0x30(%rbp)
je     1262 <find_audio_click_32bit_stereo+0x152>
cmpl   $0x0,-0x38(%rbp)
je     1262 <find_audio_click_32bit_stereo+0x152>
jmp    129d <find_audio_click_32bit_stereo+0x18d>
jmp    1267 <find_audio_click_32bit_stereo+0x157>
mov    -0x48(%rbp),%eax
add    $0x8,%eax
mov    %eax,-0x48(%rbp)
jmp    1164 <find_audio_click_32bit_stereo+0x54>
mov    -0x10(%rbp),%rax
movl   $0x0,(%rax)
mov    -0x18(%rbp),%rax
movl   $0xffffffff,(%rax)
mov    -0x20(%rbp),%rax
movl   $0x0,(%rax)
mov    -0x28(%rbp),%rax
movl   $0xffffffff,(%rax)
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<find_audio_click_32bit_stereo>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    $0xffffffff,%r9d
mov    $0xfffffffffffffff8,%r12
xor    %r10d,%r10d
xor    %r15d,%r15d
xor    %r14d,%r14d
mov    $0xffffffff,%r11d
jmp    1145 <find_audio_click_32bit_stereo+0x45>
cs nopw 0x0(%rax,%rax,1)
add    $0x8,%r12
add    $0x1,%r10d
cmp    $0x3bf7,%r12
ja     11d3 <find_audio_click_32bit_stereo+0xd3>
mov    0x8(%rdi,%r12,1),%ebx
mov    %ebx,%ebp
neg    %ebp
cmovs  %ebx,%ebp
mov    %r9d,%ebx
cmp    $0xffffffff,%r9d
cmove  %r10d,%r9d
cmp    $0x6000001,%ebp
cmovb  %ebx,%r9d
mov    0xc(%rdi,%r12,1),%eax
mov    %eax,%ebx
neg    %ebx
cmovs  %eax,%ebx
mov    %r11d,%eax
cmp    $0xffffffff,%r11d
cmove  %r10d,%r11d
cmp    $0x6000001,%ebx
cmovb  %eax,%r11d
cmp    $0x1b000001,%ebp
jb     11a3 <find_audio_click_32bit_stereo+0xa3>
test   %r15d,%r15d
jne    11a3 <find_audio_click_32bit_stereo+0xa3>
movl   $0x1,(%rsi)
mov    %r9d,(%rdx)
mov    $0x1,%r15d
cmp    $0x1b000001,%ebx
jb     11bf <find_audio_click_32bit_stereo+0xbf>
test   %r14d,%r14d
jne    11bf <find_audio_click_32bit_stereo+0xbf>
movl   $0x1,(%rcx)
mov    %r11d,(%r8)
mov    $0x1,%r14d
test   %r15d,%r15d
je     1130 <find_audio_click_32bit_stereo+0x30>
test   %r14d,%r14d
je     1130 <find_audio_click_32bit_stereo+0x30>
jmp    11ec <find_audio_click_32bit_stereo+0xec>
movl   $0x0,(%rsi)
movl   $0xffffffff,(%rdx)
movl   $0x0,(%rcx)
movl   $0xffffffff,(%r8)
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define void @find_audio_click_32bit_stereo(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 i32
%14 = alloca i32
%15 = alloca i32
%16 = alloca i32
%17 = alloca i32
%18 = alloca i32
%19 = alloca i32
%20 = alloca i32
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 15360, i32* %11
store i32 0, i32* %12
store i32 -1, i32* %13
store i32 0, i32* %14
store i32 -1, i32* %15
store i32 452984832, i32* %16
store i32 100663296, i32* %17
store i32 0, i32* %18
br label %21
21: ; preds = %92, %5
%22 = load i32, i32* %18
%23 = load i32, i32* %11
%24 = icmp slt i32 %22, %23
br i1 %24, label %25, label %95
25: ; preds = %21
%26 = load i8*, i8** %6
%27 = load i32, i32* %18
%28 = sext i32 %27 to i64
%29 = getelementptr inbounds i8, i8* %26, i64 %28
%30 = bitcast i8* %29 to i32*
%31 = load i32, i32* %30
store i32 %31, i32* %19
%32 = load i8*, i8** %6
%33 = load i32, i32* %18
%34 = sext i32 %33 to i64
%35 = getelementptr inbounds i8, i8* %32, i64 %34
%36 = getelementptr inbounds i8, i8* %35, i64 4
%37 = bitcast i8* %36 to i32*
%38 = load i32, i32* %37
store i32 %38, i32* %20
%39 = load i32, i32* %19
%40 = call i32 @abs(i32 %39)
%41 = load i32, i32* %17
%42 = icmp sgt i32 %40, %41
br i1 %42, label %43, label %49
43: ; preds = %25
%44 = load i32, i32* %13
%45 = icmp eq i32 %44, -1
br i1 %45, label %46, label %49
46: ; preds = %43
%47 = load i32, i32* %18
%48 = sdiv i32 %47, 8
store i32 %48, i32* %13
br label %49
49: ; preds = %46, %43, %25
%50 = load i32, i32* %20
%51 = call i32 @abs(i32 %50)
%52 = load i32, i32* %17
%53 = icmp sgt i32 %51, %52
br i1 %53, label %54, label %60
54: ; preds = %49
%55 = load i32, i32* %15
%56 = icmp eq i32 %55, -1
br i1 %56, label %57, label %60
57: ; preds = %54
%58 = load i32, i32* %18
%59 = sdiv i32 %58, 8
store i32 %59, i32* %15
br label %60
60: ; preds = %57, %54, %49
%61 = load i32, i32* %19
%62 = call i32 @abs(i32 %61)
%63 = load i32, i32* %16
%64 = icmp sgt i32 %62, %63
br i1 %64, label %65, label %72
65: ; preds = %60
%66 = load i32, i32* %12
%67 = icmp ne i32 %66, 0
br i1 %67, label %72, label %68
68: ; preds = %65
%69 = load i32*, i32** %7
store i32 1, i32* %69
%70 = load i32, i32* %13
%71 = load i32*, i32** %8
store i32 %70, i32* %71
store i32 1, i32* %12
br label %72
72: ; preds = %68, %65, %60
%73 = load i32, i32* %20
%74 = call i32 @abs(i32 %73)
%75 = load i32, i32* %16
%76 = icmp sgt i32 %74, %75
br i1 %76, label %77, label %84
77: ; preds = %72
%78 = load i32, i32* %14
%79 = icmp ne i32 %78, 0
br i1 %79, label %84, label %80
80: ; preds = %77
%81 = load i32*, i32** %9
store i32 1, i32* %81
%82 = load i32, i32* %15
%83 = load i32*, i32** %10
store i32 %82, i32* %83
store i32 1, i32* %14
br label %84
84: ; preds = %80, %77, %72
%85 = load i32, i32* %12
%86 = icmp ne i32 %85, 0
br i1 %86, label %87, label %91
87: ; preds = %84
%88 = load i32, i32* %14
%89 = icmp ne i32 %88, 0
br i1 %89, label %90, label %91
90: ; preds = %87
br label %100
91: ; preds = %87, %84
br label %92
92: ; preds = %91
%93 = load i32, i32* %18
%94 = add nsw i32 %93, 8
store i32 %94, i32* %18
br label %21
95: ; preds = %21
%96 = load i32*, i32** %7
store i32 0, i32* %96
%97 = load i32*, i32** %8
store i32 -1, i32* %97
%98 = load i32*, i32** %9
store i32 0, i32* %98
%99 = load i32*, i32** %10
store i32 -1, i32* %99
br label %100
100: ; preds = %95, %90
ret void
}

LLVM IR (-O2):
define void @find_audio_click_32bit_stereo(i8* nocapture %0, i32* nocapture writeonly %1, i32* nocapture writeonly %2, i32* nocapture writeonly %3, i32* nocapture writeonly %4) {
br label %9
6: ; preds = %43
%7 = add nuw nsw i64 %10, 8
%8 = icmp ult i64 %10, 15352
br i1 %8, label %9, label %48
9: ; preds = %5, %6
%10 = phi i64 [ 0, %5 ], [ %7, %6 ]
%11 = phi i32 [ 0, %5 ], [ %38, %6 ]
%12 = phi i32 [ -1, %5 ], [ %27, %6 ]
%13 = phi i32 [ 0, %5 ], [ %44, %6 ]
%14 = phi i32 [ -1, %5 ], [ %32, %6 ]
%15 = getelementptr inbounds i8, i8* %0, i64 %10
%16 = bitcast i8* %15 to i32*
%17 = load i32, i32* %16
%18 = getelementptr inbounds i8, i8* %15, i64 4
%19 = bitcast i8* %18 to i32*
%20 = load i32, i32* %19
%21 = tail call i32 @llvm.abs.i32(i32 %17, i1 true)
%22 = icmp ugt i32 %21, 100663296
%23 = icmp eq i32 %12, -1
%24 = select i1 %22, i1 %23, i1 false
%25 = lshr exact i64 %10, 3
%26 = trunc i64 %25 to i32
%27 = select i1 %24, i32 %26, i32 %12
%28 = tail call i32 @llvm.abs.i32(i32 %20, i1 true)
%29 = icmp ugt i32 %28, 100663296
%30 = icmp eq i32 %14, -1
%31 = select i1 %29, i1 %30, i1 false
%32 = select i1 %31, i32 %26, i32 %14
%33 = icmp ult i32 %21, 452984833
%34 = icmp ne i32 %11, 0
%35 = select i1 %33, i1 true, i1 %34
br i1 %35, label %37, label %36
36: ; preds = %9
store i32 1, i32* %1
store i32 %27, i32* %2
br label %37
37: ; preds = %36, %9
%38 = phi i32 [ %11, %9 ], [ 1, %36 ]
%39 = icmp ult i32 %28, 452984833
%40 = icmp ne i32 %13, 0
%41 = select i1 %39, i1 true, i1 %40
br i1 %41, label %43, label %42
42: ; preds = %37
store i32 1, i32* %3
store i32 %32, i32* %4
br label %43
43: ; preds = %42, %37
%44 = phi i32 [ %13, %37 ], [ 1, %42 ]
%45 = icmp ne i32 %38, 0
%46 = icmp ne i32 %44, 0
%47 = select i1 %45, i1 %46, i1 false
br i1 %47, label %49, label %6
48: ; preds = %6
store i32 0, i32* %1
store i32 -1, i32* %2
store i32 0, i32* %3
store i32 -1, i32* %4
br label %49
49: ; preds = %43, %48
ret void
}