#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*/ async_tandem(int, int, int, int, int);
unsigned int atoi(char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *);
int getpid();
int /*<<< orphan*/ printf(char *, unsigned int, int);
int rand();
int /*<<< orphan*/ srand(unsigned int);
int /*<<< orphan*/ stderr;
int time(int /*<<< orphan*/ *);
int main(int argc, char *argv[]) {
  unsigned int seed;
  int ch, n;
  if (argc > 2) {
    fprintf(stderr, "Usage: %s [<seed>]\n", argv[0]);
    return 1;
  }
  if (argc > 1)
    seed = atoi(argv[1]);
  else
    seed = (time(NULL) ^ ((getpid() % 65536) << 16));
  srand(seed);
  printf("CELT codec tests. Random seed: %u (%.4X)\n", seed, rand() % 65536);
  for (n = 6; n < 10; n++) {
    for (ch = 1; ch <= 2; ch++) {
      async_tandem(44100, 1 << n, ch, 47000 * ch, 77000 * ch);
      async_tandem(48000, 1 << n, ch, 47000 * ch, 77000 * ch);
      async_tandem(32000, 1 << n, ch, 31000 * ch, 65000 * ch);
    }
  }
  for (ch = 1; ch <= 2; ch++)
    async_tandem(32000, 320, ch, 31000 * ch, 65000 * ch);
  for (ch = 1; ch <= 2; ch++)
    async_tandem(48000, 480, ch, 31000 * ch, 77000 * ch);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x2,-0x8(%rbp)
jle    11c8 <main+0x48>
mov    0x2e39(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    (%rax),%rdx
lea    0xe49(%rip),%rsi
call   1060 <fprintf@plt>
movl   $0x1,-0x4(%rbp)
jmp    1375 <main+0x1f5>
cmpl   $0x1,-0x8(%rbp)
jle    11e7 <main+0x67>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1090 <atoi@plt>
mov    %eax,-0x14(%rbp)
jmp    120d <main+0x8d>
xor    %eax,%eax
mov    %eax,%edi
call   1070 <time@plt>
mov    %eax,-0x20(%rbp)
mov    $0x0,%al
call   1030 <getpid@plt>
mov    $0x10000,%ecx
cltd
idiv   %ecx
mov    -0x20(%rbp),%eax
shl    $0x10,%edx
xor    %edx,%eax
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%edi
call   1050 <srand@plt>
mov    -0x14(%rbp),%eax
mov    %eax,-0x24(%rbp)
mov    $0x0,%al
call   10a0 <rand@plt>
mov    -0x24(%rbp),%esi
mov    $0x10000,%ecx
cltd
idiv   %ecx
lea    0xde0(%rip),%rdi
call   1040 <printf@plt>
movl   $0x6,-0x1c(%rbp)
cmpl   $0xa,-0x1c(%rbp)
jge    12ee <main+0x16e>
movl   $0x1,-0x18(%rbp)
cmpl   $0x2,-0x18(%rbp)
jg     12db <main+0x15b>
mov    -0x1c(%rbp),%ecx
mov    $0x1,%esi
shl    %cl,%esi
mov    -0x18(%rbp),%edx
imul   $0xb798,-0x18(%rbp),%ecx
imul   $0x12cc8,-0x18(%rbp),%r8d
mov    $0xac44,%edi
call   1080 <async_tandem@plt>
mov    -0x1c(%rbp),%ecx
mov    $0x1,%esi
shl    %cl,%esi
mov    -0x18(%rbp),%edx
imul   $0xb798,-0x18(%rbp),%ecx
imul   $0x12cc8,-0x18(%rbp),%r8d
mov    $0xbb80,%edi
call   1080 <async_tandem@plt>
mov    -0x1c(%rbp),%ecx
mov    $0x1,%esi
shl    %cl,%esi
mov    -0x18(%rbp),%edx
imul   $0x7918,-0x18(%rbp),%ecx
imul   $0xfde8,-0x18(%rbp),%r8d
mov    $0x7d00,%edi
call   1080 <async_tandem@plt>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    1251 <main+0xd1>
jmp    12e0 <main+0x160>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    1240 <main+0xc0>
movl   $0x1,-0x18(%rbp)
cmpl   $0x2,-0x18(%rbp)
jg     132e <main+0x1ae>
mov    -0x18(%rbp),%edx
imul   $0x7918,-0x18(%rbp),%ecx
imul   $0xfde8,-0x18(%rbp),%r8d
mov    $0x7d00,%edi
mov    $0x140,%esi
call   1080 <async_tandem@plt>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    12f5 <main+0x175>
movl   $0x1,-0x18(%rbp)
cmpl   $0x2,-0x18(%rbp)
jg     136e <main+0x1ee>
mov    -0x18(%rbp),%edx
imul   $0x7918,-0x18(%rbp),%ecx
imul   $0x12cc8,-0x18(%rbp),%r8d
mov    $0xbb80,%edi
mov    $0x1e0,%esi
call   1080 <async_tandem@plt>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    1335 <main+0x1b5>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %rbx
push   %rax
cmp    $0x3,%edi
jl     11aa <main+0x2a>
mov    0x2e51(%rip),%rax
mov    (%rax),%edi
mov    (%rsi),%rdx
lea    0xe65(%rip),%rsi
call   1060 <fprintf@plt>
mov    $0x1,%eax
jmp    134b <main+0x1cb>
cmp    $0x2,%edi
jne    11bc <main+0x3c>
mov    0x8(%rsi),%rdi
call   1090 <atoi@plt>
mov    %eax,%ebx
jmp    11d3 <main+0x53>
xor    %edi,%edi
call   1070 <time@plt>
mov    %eax,%ebp
xor    %eax,%eax
call   1030 <getpid@plt>
mov    %eax,%ebx
shl    $0x10,%ebx
xor    %ebp,%ebx
mov    %ebx,%edi
call   1050 <srand@plt>
xor    %eax,%eax
call   10a0 <rand@plt>
lea    0xffff(%rax),%ecx
test   %eax,%eax
cmovns %eax,%ecx
and    $0xffff0000,%ecx
sub    %ecx,%eax
lea    0xe19(%rip),%rdi
mov    %ebx,%esi
mov    %eax,%edx
call   1040 <printf@plt>
mov    $0x6,%ebx
nopl   0x0(%rax)
mov    $0x1,%ebp
mov    %ebx,%ecx
shl    %cl,%ebp
mov    $0xac44,%edi
mov    %ebp,%esi
mov    $0x1,%edx
mov    $0xb798,%ecx
mov    $0x12cc8,%r8d
call   1080 <async_tandem@plt>
mov    $0xbb80,%edi
mov    %ebp,%esi
mov    $0x1,%edx
mov    $0xb798,%ecx
mov    $0x12cc8,%r8d
call   1080 <async_tandem@plt>
mov    $0x7d00,%edi
mov    %ebp,%esi
mov    $0x1,%edx
mov    $0x7918,%ecx
mov    $0xfde8,%r8d
call   1080 <async_tandem@plt>
mov    $0xac44,%edi
mov    %ebp,%esi
mov    $0x2,%edx
mov    $0x16f30,%ecx
mov    $0x25990,%r8d
call   1080 <async_tandem@plt>
mov    $0xbb80,%edi
mov    %ebp,%esi
mov    $0x2,%edx
mov    $0x16f30,%ecx
mov    $0x25990,%r8d
call   1080 <async_tandem@plt>
mov    $0x7d00,%edi
mov    %ebp,%esi
mov    $0x2,%edx
mov    $0xf230,%ecx
mov    $0x1fbd0,%r8d
call   1080 <async_tandem@plt>
add    $0x1,%ebx
cmp    $0xa,%ebx
jne    1210 <main+0x90>
mov    $0x7d00,%edi
mov    $0x140,%esi
mov    $0x1,%edx
mov    $0x7918,%ecx
mov    $0xfde8,%r8d
call   1080 <async_tandem@plt>
mov    $0x7d00,%edi
mov    $0x140,%esi
mov    $0x2,%edx
mov    $0xf230,%ecx
mov    $0x1fbd0,%r8d
call   1080 <async_tandem@plt>
mov    $0xbb80,%edi
mov    $0x1e0,%esi
mov    $0x1,%edx
mov    $0x7918,%ecx
mov    $0x12cc8,%r8d
call   1080 <async_tandem@plt>
mov    $0xbb80,%edi
mov    $0x1e0,%esi
mov    $0x2,%edx
mov    $0xf230,%ecx
mov    $0x25990,%r8d
call   1080 <async_tandem@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@stderr = global i32 0
@.str = [20 x i8] c"Usage: %s [<seed>]\0A\00"
@.str.1 = [42 x i8] c"CELT codec tests. Random seed: %u (%.4X)\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%9 = load i32, i32* %4
%10 = icmp sgt i32 %9, 2
br i1 %10, label %11, label %17
11: ; preds = %2
%12 = load i32, i32* @stderr
%13 = load i8**, i8*** %5
%14 = getelementptr inbounds i8*, i8** %13, i64 0
%15 = load i8*, i8** %14
%16 = call i32 @fprintf(i32 %12, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0), i8* %15)
store i32 1, i32* %3
br label %106
17: ; preds = %2
%18 = load i32, i32* %4
%19 = icmp sgt i32 %18, 1
br i1 %19, label %20, label %25
20: ; preds = %17
%21 = load i8**, i8*** %5
%22 = getelementptr inbounds i8*, i8** %21, i64 1
%23 = load i8*, i8** %22
%24 = call i32 @atoi(i8* %23)
store i32 %24, i32* %6
br label %31
25: ; preds = %17
%26 = call i32 @time(i32* null)
%27 = call i32 (...) @getpid()
%28 = srem i32 %27, 65536
%29 = shl i32 %28, 16
%30 = xor i32 %26, %29
store i32 %30, i32* %6
br label %31
31: ; preds = %25, %20
%32 = load i32, i32* %6
%33 = call i32 @srand(i32 %32)
%34 = load i32, i32* %6
%35 = call i32 (...) @rand()
%36 = srem i32 %35, 65536
%37 = call i32 @printf(i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str.1, i64 0, i64 0), i32 %34, i32 %36)
store i32 6, i32* %8
br label %38
38: ; preds = %74, %31
%39 = load i32, i32* %8
%40 = icmp slt i32 %39, 10
br i1 %40, label %41, label %77
41: ; preds = %38
store i32 1, i32* %7
br label %42
42: ; preds = %70, %41
%43 = load i32, i32* %7
%44 = icmp sle i32 %43, 2
br i1 %44, label %45, label %73
45: ; preds = %42
%46 = load i32, i32* %8
%47 = shl i32 1, %46
%48 = load i32, i32* %7
%49 = load i32, i32* %7
%50 = mul nsw i32 47000, %49
%51 = load i32, i32* %7
%52 = mul nsw i32 77000, %51
%53 = call i32 @async_tandem(i32 44100, i32 %47, i32 %48, i32 %50, i32 %52)
%54 = load i32, i32* %8
%55 = shl i32 1, %54
%56 = load i32, i32* %7
%57 = load i32, i32* %7
%58 = mul nsw i32 47000, %57
%59 = load i32, i32* %7
%60 = mul nsw i32 77000, %59
%61 = call i32 @async_tandem(i32 48000, i32 %55, i32 %56, i32 %58, i32 %60)
%62 = load i32, i32* %8
%63 = shl i32 1, %62
%64 = load i32, i32* %7
%65 = load i32, i32* %7
%66 = mul nsw i32 31000, %65
%67 = load i32, i32* %7
%68 = mul nsw i32 65000, %67
%69 = call i32 @async_tandem(i32 32000, i32 %63, i32 %64, i32 %66, i32 %68)
br label %70
70: ; preds = %45
%71 = load i32, i32* %7
%72 = add nsw i32 %71, 1
store i32 %72, i32* %7
br label %42
73: ; preds = %42
br label %74
74: ; preds = %73
%75 = load i32, i32* %8
%76 = add nsw i32 %75, 1
store i32 %76, i32* %8
br label %38
77: ; preds = %38
store i32 1, i32* %7
br label %78
78: ; preds = %88, %77
%79 = load i32, i32* %7
%80 = icmp sle i32 %79, 2
br i1 %80, label %81, label %91
81: ; preds = %78
%82 = load i32, i32* %7
%83 = load i32, i32* %7
%84 = mul nsw i32 31000, %83
%85 = load i32, i32* %7
%86 = mul nsw i32 65000, %85
%87 = call i32 @async_tandem(i32 32000, i32 320, i32 %82, i32 %84, i32 %86)
br label %88
88: ; preds = %81
%89 = load i32, i32* %7
%90 = add nsw i32 %89, 1
store i32 %90, i32* %7
br label %78
91: ; preds = %78
store i32 1, i32* %7
br label %92
92: ; preds = %102, %91
%93 = load i32, i32* %7
%94 = icmp sle i32 %93, 2
br i1 %94, label %95, label %105
95: ; preds = %92
%96 = load i32, i32* %7
%97 = load i32, i32* %7
%98 = mul nsw i32 31000, %97
%99 = load i32, i32* %7
%100 = mul nsw i32 77000, %99
%101 = call i32 @async_tandem(i32 48000, i32 480, i32 %96, i32 %98, i32 %100)
br label %102
102: ; preds = %95
%103 = load i32, i32* %7
%104 = add nsw i32 %103, 1
store i32 %104, i32* %7
br label %92
105: ; preds = %92
store i32 0, i32* %3
br label %106
106: ; preds = %105, %11
%107 = load i32, i32* %3
ret i32 %107
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [20 x i8] c"Usage: %s [<seed>]\0A\00"
@.str.1 = [42 x i8] c"CELT codec tests. Random seed: %u (%.4X)\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = icmp sgt i32 %0, 2
br i1 %3, label %4, label %8
4: ; preds = %2
%5 = load i32, i32* @stderr
%6 = load i8*, i8** %1
%7 = tail call i32 @fprintf(i32 %5, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0), i8* %6)
br label %41
8: ; preds = %2
%9 = icmp eq i32 %0, 2
br i1 %9, label %10, label %14
10: ; preds = %8
%11 = getelementptr inbounds i8*, i8** %1, i64 1
%12 = load i8*, i8** %11
%13 = tail call i32 @atoi(i8* %12)
br label %19
14: ; preds = %8
%15 = tail call i32 @time(i32* null)
%16 = tail call i32 (...) @getpid()
%17 = shl i32 %16, 16
%18 = xor i32 %17, %15
br label %19
19: ; preds = %14, %10
%20 = phi i32 [ %13, %10 ], [ %18, %14 ]
%21 = tail call i32 @srand(i32 %20)
%22 = tail call i32 (...) @rand()
%23 = srem i32 %22, 65536
%24 = tail call i32 @printf(i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str.1, i64 0, i64 0), i32 %20, i32 %23)
br label %25
25: ; preds = %19, %25
%26 = phi i32 [ 6, %19 ], [ %34, %25 ]
%27 = shl nuw i32 1, %26
%28 = tail call i32 @async_tandem(i32 44100, i32 %27, i32 1, i32 47000, i32 77000)
%29 = tail call i32 @async_tandem(i32 48000, i32 %27, i32 1, i32 47000, i32 77000)
%30 = tail call i32 @async_tandem(i32 32000, i32 %27, i32 1, i32 31000, i32 65000)
%31 = tail call i32 @async_tandem(i32 44100, i32 %27, i32 2, i32 94000, i32 154000)
%32 = tail call i32 @async_tandem(i32 48000, i32 %27, i32 2, i32 94000, i32 154000)
%33 = tail call i32 @async_tandem(i32 32000, i32 %27, i32 2, i32 62000, i32 130000)
%34 = add nuw nsw i32 %26, 1
%35 = icmp eq i32 %34, 10
br i1 %35, label %36, label %25
36: ; preds = %25
%37 = tail call i32 @async_tandem(i32 32000, i32 320, i32 1, i32 31000, i32 65000)
%38 = tail call i32 @async_tandem(i32 32000, i32 320, i32 2, i32 62000, i32 130000)
%39 = tail call i32 @async_tandem(i32 48000, i32 480, i32 1, i32 31000, i32 77000)
%40 = tail call i32 @async_tandem(i32 48000, i32 480, i32 2, i32 62000, i32 154000)
br label %41
41: ; preds = %36, %4
%42 = phi i32 [ 1, %4 ], [ 0, %36 ]
ret i32 %42
}