#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 */
long M_PI;
int /*<<< orphan*/ printf(char *, short, short);
double sin(long);
int main(int argc, char *argv[]) {
  long i;
  double R = 48000;
  double C = 261.62;
  int j;
  for (j = 0; j < 7200; j++) {
    for (i = 0; i < 4800; i++) {
      double v = sin(i * 2 * M_PI / R * C);
      short v2 = v * 127.0;
      printf("%c%c", (v2 << 8) & 0xff, v2 & 0xff);
    }
    for (i = 0; i < 48000 - 4800; i++) {
      double v = 0;
      short v2 = v * 127.0;
      printf("%c%c", (v2 << 8) & 0xff, v2 & 0xff);
    }
  }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movsd  0xeca(%rip),%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  0xeb5(%rip),%xmm0
movsd  %xmm0,-0x28(%rbp)
movl   $0x0,-0x2c(%rbp)
cmpl   $0x1c20,-0x2c(%rbp)
jge    128e <main+0x16e>
movq   $0x0,-0x18(%rbp)
cmpq   $0x12c0,-0x18(%rbp)
jge    1209 <main+0xe9>
mov    -0x18(%rbp),%rax
mov    0x2e63(%rip),%rcx
mov    (%rcx),%rcx
imul   %rcx,%rax
add    %rax,%rax
cvtsi2sd %rax,%xmm0
movsd  -0x20(%rbp),%xmm1
divsd  %xmm1,%xmm0
movsd  -0x28(%rbp),%xmm1
mulsd  %xmm1,%xmm0
cvttsd2si %xmm0,%rdi
call   1040 <sin@plt>
movsd  %xmm0,-0x38(%rbp)
movsd  -0x38(%rbp),%xmm0
movsd  0xe4e(%rip),%xmm1
mulsd  %xmm1,%xmm0
cvttsd2si %xmm0,%eax
mov    %ax,-0x3a(%rbp)
movswl -0x3a(%rbp),%eax
shl    $0x8,%eax
and    $0xff,%eax
mov    %ax,%cx
movswl -0x3a(%rbp),%eax
and    $0xff,%eax
lea    0xe2b(%rip),%rdi
movswl %cx,%esi
movswl %ax,%edx
call   1030 <printf@plt>
mov    -0x18(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x18(%rbp)
jmp    116c <main+0x4c>
movq   $0x0,-0x18(%rbp)
cmpq   $0xa8c0,-0x18(%rbp)
jge    127b <main+0x15b>
movq   $0x0,-0x48(%rbp)
movsd  -0x48(%rbp),%xmm0
movsd  0xddc(%rip),%xmm1
mulsd  %xmm1,%xmm0
cvttsd2si %xmm0,%eax
mov    %ax,-0x4a(%rbp)
movswl -0x4a(%rbp),%eax
shl    $0x8,%eax
and    $0xff,%eax
mov    %ax,%cx
movswl -0x4a(%rbp),%eax
and    $0xff,%eax
lea    0xdb9(%rip),%rdi
movswl %cx,%esi
movswl %ax,%edx
call   1030 <printf@plt>
mov    -0x18(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x18(%rbp)
jmp    1211 <main+0xf1>
jmp    1280 <main+0x160>
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
jmp    1157 <main+0x37>
mov    -0x4(%rbp),%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
xor    %r14d,%r14d
mov    0x2eb6(%rip),%r15
lea    0xedf(%rip),%r12
nopl   0x0(%rax)
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    (%r15),%rax
imul   %rbx,%rax
xorps  %xmm0,%xmm0
cvtsi2sd %rax,%xmm0
divsd  0xe99(%rip),%xmm0
mulsd  0xe99(%rip),%xmm0
cvttsd2si %xmm0,%rdi
call   1040 <sin@plt>
mulsd  0xe8f(%rip),%xmm0
cvttsd2si %xmm0,%eax
movzbl %al,%edx
mov    %r12,%rdi
xor    %esi,%esi
call   1030 <printf@plt>
add    $0x2,%rbx
cmp    $0x2580,%rbx
jne    1150 <main+0x30>
mov    $0xa8c0,%ebx
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    %r12,%rdi
xor    %esi,%esi
xor    %edx,%edx
call   1030 <printf@plt>
add    $0xffffffffffffffff,%rbx
jne    11b0 <main+0x90>
add    $0x1,%r14d
cmp    $0x1c20,%r14d
jne    1140 <main+0x20>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@M_PI = global i64 0
@.str = [5 x i8] c"%c%c\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i64
%7 = alloca double
%8 = alloca double
%9 = alloca i32
%10 = alloca double
%11 = alloca i16
%12 = alloca double
%13 = alloca i16
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store double 4.800000e+04, double* %7
store double 2.616200e+02, double* %8
store i32 0, i32* %9
br label %14
14: ; preds = %71, %2
%15 = load i32, i32* %9
%16 = icmp slt i32 %15, 7200
br i1 %16, label %17, label %74
17: ; preds = %14
store i64 0, i64* %6
br label %18
18: ; preds = %46, %17
%19 = load i64, i64* %6
%20 = icmp slt i64 %19, 4800
br i1 %20, label %21, label %49
21: ; preds = %18
%22 = load i64, i64* %6
%23 = mul nsw i64 %22, 2
%24 = load i64, i64* @M_PI
%25 = mul nsw i64 %23, %24
%26 = sitofp i64 %25 to double
%27 = load double, double* %7
%28 = fdiv double %26, %27
%29 = load double, double* %8
%30 = fmul double %28, %29
%31 = fptosi double %30 to i64
%32 = call double @sin(i64 %31)
store double %32, double* %10
%33 = load double, double* %10
%34 = fmul double %33, 1.270000e+02
%35 = fptosi double %34 to i16
store i16 %35, i16* %11
%36 = load i16, i16* %11
%37 = sext i16 %36 to i32
%38 = shl i32 %37, 8
%39 = and i32 %38, 255
%40 = trunc i32 %39 to i16
%41 = load i16, i16* %11
%42 = sext i16 %41 to i32
%43 = and i32 %42, 255
%44 = trunc i32 %43 to i16
%45 = call i32 @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i16 signext %40, i16 signext %44)
br label %46
46: ; preds = %21
%47 = load i64, i64* %6
%48 = add nsw i64 %47, 1
store i64 %48, i64* %6
br label %18
49: ; preds = %18
store i64 0, i64* %6
br label %50
50: ; preds = %67, %49
%51 = load i64, i64* %6
%52 = icmp slt i64 %51, 43200
br i1 %52, label %53, label %70
53: ; preds = %50
store double 0.000000e+00, double* %12
%54 = load double, double* %12
%55 = fmul double %54, 1.270000e+02
%56 = fptosi double %55 to i16
store i16 %56, i16* %13
%57 = load i16, i16* %13
%58 = sext i16 %57 to i32
%59 = shl i32 %58, 8
%60 = and i32 %59, 255
%61 = trunc i32 %60 to i16
%62 = load i16, i16* %13
%63 = sext i16 %62 to i32
%64 = and i32 %63, 255
%65 = trunc i32 %64 to i16
%66 = call i32 @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i16 signext %61, i16 signext %65)
br label %67
67: ; preds = %53
%68 = load i64, i64* %6
%69 = add nsw i64 %68, 1
store i64 %69, i64* %6
br label %50
70: ; preds = %50
br label %71
71: ; preds = %70
%72 = load i32, i32* %9
%73 = add nsw i32 %72, 1
store i32 %73, i32* %9
br label %14
74: ; preds = %14
%75 = load i32, i32* %3
ret i32 %75
}

LLVM IR (-O2):
@M_PI = global i64 0
@.str = [5 x i8] c"%c%c\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
br label %3
3: ; preds = %2, %26
%4 = phi i32 [ 0, %2 ], [ %27, %26 ]
br label %5
5: ; preds = %3, %5
%6 = phi i64 [ 0, %3 ], [ %19, %5 ]
%7 = shl nuw nsw i64 %6, 1
%8 = load i64, i64* @M_PI
%9 = mul nsw i64 %7, %8
%10 = sitofp i64 %9 to double
%11 = fdiv double %10, 4.800000e+04
%12 = fmul double %11, 2.616200e+02
%13 = fptosi double %12 to i64
%14 = tail call double @sin(i64 %13)
%15 = fmul double %14, 1.270000e+02
%16 = fptosi double %15 to i16
%17 = and i16 %16, 255
%18 = tail call i32 @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i16 signext 0, i16 signext %17)
%19 = add nuw nsw i64 %6, 1
%20 = icmp eq i64 %19, 4800
br i1 %20, label %21, label %5
21: ; preds = %5, %21
%22 = phi i64 [ %24, %21 ], [ 0, %5 ]
%23 = tail call i32 @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i16 signext 0, i16 signext 0)
%24 = add nuw nsw i64 %22, 1
%25 = icmp eq i64 %24, 43200
br i1 %25, label %26, label %21
26: ; preds = %21
%27 = add nuw nsw i32 %4, 1
%28 = icmp eq i32 %27, 7200
br i1 %28, label %29, label %3
29: ; preds = %26
ret i32 0
}