#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*/ printf(char *, ...);
void main(void) {
  unsigned int base_freq_of_sound = 44100;
  unsigned int note_freq = 20000;
  unsigned int play_rate = 44100;
  unsigned int base_note_freq = 30;
  unsigned int accuracy = 12;
  unsigned int speed;
  unsigned int i, index, length;
  speed = base_freq_of_sound * note_freq;
  printf("%u * %u = %u\n", base_freq_of_sound, note_freq, speed);
  speed /= base_note_freq;
  printf("/= %u = %u\n", base_note_freq, speed);
  speed <<= accuracy;
  printf("<<= %u = %u\n", accuracy, speed);
  speed /= play_rate;
  printf("/= %u = %u\n", play_rate, speed);
  printf("1 << %u = %u\n", accuracy, 1 << accuracy);
  printf("interpolation:");
  length = 10000 << accuracy;
  for (i = 0; i < length; i += speed) {
    index = i >> accuracy;
    printf("%u / %u\n", i % (1 << accuracy), (1 << accuracy));
  }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0xac44,-0x4(%rbp)
movl   $0x4e20,-0x8(%rbp)
movl   $0xac44,-0xc(%rbp)
movl   $0x1e,-0x10(%rbp)
movl   $0xc,-0x14(%rbp)
mov    -0x4(%rbp),%eax
imul   -0x8(%rbp),%eax
mov    %eax,-0x18(%rbp)
mov    -0x4(%rbp),%esi
mov    -0x8(%rbp),%edx
mov    -0x18(%rbp),%ecx
lea    0xeab(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x10(%rbp),%ecx
mov    -0x18(%rbp),%eax
xor    %edx,%edx
div    %ecx
mov    %eax,-0x18(%rbp)
mov    -0x10(%rbp),%esi
mov    -0x18(%rbp),%edx
lea    0xe98(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x14(%rbp),%ecx
mov    -0x18(%rbp),%eax
shl    %cl,%eax
mov    %eax,-0x18(%rbp)
mov    -0x14(%rbp),%esi
mov    -0x18(%rbp),%edx
lea    0xe85(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0xc(%rbp),%ecx
mov    -0x18(%rbp),%eax
xor    %edx,%edx
div    %ecx
mov    %eax,-0x18(%rbp)
mov    -0xc(%rbp),%esi
mov    -0x18(%rbp),%edx
lea    0xe58(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x14(%rbp),%esi
mov    -0x14(%rbp),%ecx
mov    $0x1,%edx
shl    %cl,%edx
lea    0xe56(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe56(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x14(%rbp),%ecx
mov    $0x2710,%eax
shl    %cl,%eax
mov    %eax,-0x24(%rbp)
movl   $0x0,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0x24(%rbp),%eax
jae    124c <main+0x13c>
mov    -0x1c(%rbp),%eax
mov    -0x14(%rbp),%ecx
shr    %cl,%eax
mov    %eax,-0x20(%rbp)
mov    -0x1c(%rbp),%eax
mov    -0x14(%rbp),%ecx
mov    $0x1,%edx
shl    %cl,%edx
mov    %edx,%ecx
xor    %edx,%edx
div    %ecx
mov    %edx,%esi
mov    -0x14(%rbp),%ecx
mov    $0x1,%edx
shl    %cl,%edx
lea    0xe0d(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x18(%rbp),%eax
add    -0x1c(%rbp),%eax
mov    %eax,-0x1c(%rbp)
jmp    11fa <main+0xea>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %rbx
push   %rax
lea    0xee6(%rip),%rdi
mov    $0xac44,%esi
mov    $0x4e20,%edx
mov    $0x34924080,%ecx
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xed7(%rip),%rbx
mov    %rbx,%rdi
mov    $0x1e,%esi
mov    $0x1c09bc0,%edx
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xec8(%rip),%rdi
mov    $0xc,%esi
mov    $0x9bc0000,%edx
xor    %eax,%eax
call   1030 <printf@plt>
mov    %rbx,%rdi
mov    $0xac44,%esi
mov    $0xe77,%edx
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xea9(%rip),%rdi
mov    $0xc,%esi
mov    $0x1000,%edx
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xe9f(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
mov    $0xfffff189,%ebp
lea    0xe9b(%rip),%rbx
nopl   0x0(%rax)
add    $0xe77,%ebp
mov    %ebp,%esi
and    $0xfff,%esi
mov    %rbx,%rdi
mov    $0x1000,%edx
xor    %eax,%eax
call   1030 <printf@plt>
cmp    $0x270f189,%ebp
jb     11b0 <main+0xa0>
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@.str = [14 x i8] c"%u * %u = %u\0A\00"
@.str.1 = [12 x i8] c"/= %u = %u\0A\00"
@.str.2 = [13 x i8] c"<<= %u = %u\0A\00"
@.str.3 = [14 x i8] c"1 << %u = %u\0A\00"
@.str.4 = [15 x i8] c"interpolation:\00"
@.str.5 = [9 x i8] c"%u / %u\0A\00"
define void @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
store i32 44100, i32* %1
store i32 20000, i32* %2
store i32 44100, i32* %3
store i32 30, i32* %4
store i32 12, i32* %5
%10 = load i32, i32* %1
%11 = load i32, i32* %2
%12 = mul i32 %10, %11
store i32 %12, i32* %6
%13 = load i32, i32* %1
%14 = load i32, i32* %2
%15 = load i32, i32* %6
%16 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0), i32 %13, i32 %14, i32 %15)
%17 = load i32, i32* %4
%18 = load i32, i32* %6
%19 = udiv i32 %18, %17
store i32 %19, i32* %6
%20 = load i32, i32* %4
%21 = load i32, i32* %6
%22 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0), i32 %20, i32 %21)
%23 = load i32, i32* %5
%24 = load i32, i32* %6
%25 = shl i32 %24, %23
store i32 %25, i32* %6
%26 = load i32, i32* %5
%27 = load i32, i32* %6
%28 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.2, i64 0, i64 0), i32 %26, i32 %27)
%29 = load i32, i32* %3
%30 = load i32, i32* %6
%31 = udiv i32 %30, %29
store i32 %31, i32* %6
%32 = load i32, i32* %3
%33 = load i32, i32* %6
%34 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0), i32 %32, i32 %33)
%35 = load i32, i32* %5
%36 = load i32, i32* %5
%37 = shl i32 1, %36
%38 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.3, i64 0, i64 0), i32 %35, i32 %37)
%39 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.4, i64 0, i64 0))
%40 = load i32, i32* %5
%41 = shl i32 10000, %40
store i32 %41, i32* %9
store i32 0, i32* %7
br label %42
42: ; preds = %57, %0
%43 = load i32, i32* %7
%44 = load i32, i32* %9
%45 = icmp ult i32 %43, %44
br i1 %45, label %46, label %61
46: ; preds = %42
%47 = load i32, i32* %7
%48 = load i32, i32* %5
%49 = lshr i32 %47, %48
store i32 %49, i32* %8
%50 = load i32, i32* %7
%51 = load i32, i32* %5
%52 = shl i32 1, %51
%53 = urem i32 %50, %52
%54 = load i32, i32* %5
%55 = shl i32 1, %54
%56 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.5, i64 0, i64 0), i32 %53, i32 %55)
br label %57
57: ; preds = %46
%58 = load i32, i32* %6
%59 = load i32, i32* %7
%60 = add i32 %59, %58
store i32 %60, i32* %7
br label %42
61: ; preds = %42
ret void
}

LLVM IR (-O2):
@.str = [14 x i8] c"%u * %u = %u\0A\00"
@.str.1 = [12 x i8] c"/= %u = %u\0A\00"
@.str.2 = [13 x i8] c"<<= %u = %u\0A\00"
@.str.3 = [14 x i8] c"1 << %u = %u\0A\00"
@.str.4 = [15 x i8] c"interpolation:\00"
@.str.5 = [9 x i8] c"%u / %u\0A\00"
define void @main() {
%1 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0), i32 44100, i32 20000, i32 882000000)
%2 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0), i32 30, i32 29400000)
%3 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @.str.2, i64 0, i64 0), i32 12, i32 163315712)
%4 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0), i32 44100, i32 3703)
%5 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @.str.3, i64 0, i64 0), i32 12, i32 4096)
%6 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @.str.4, i64 0, i64 0))
br label %7
7: ; preds = %0, %7
%8 = phi i32 [ 0, %0 ], [ %11, %7 ]
%9 = and i32 %8, 4095
%10 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @.str.5, i64 0, i64 0), i32 %9, i32 4096)
%11 = add nuw nsw i32 %8, 3703
%12 = icmp ult i32 %8, 40956297
br i1 %12, label %7, label %13
13: ; preds = %7
ret void
}