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

/* Variables and functions */
int atoi(char *);
int createtable(int, int /*<<< orphan*/ *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ writesource(int /*<<< orphan*/ *, int);
int main(int argc, char *argv[]) {
  uint16_t table[128];
  (void)argc;
  (void)argv;
  if (argc != 2) {
    fprintf(stderr, "Usage: gennotes <samplerate>\n");
    return -1;
  }
  int fs = atoi(argv[1]);
  int len = createtable(fs, table);
  writesource(table, len);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x220,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x2,-0x8(%rbp)
je     1184 <main+0x44>
mov    0x2e76(%rip),%rax
mov    (%rax),%edi
lea    0xe8d(%rip),%rsi
call   1030 <fprintf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    11c8 <main+0x88>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1050 <atoi@plt>
mov    %eax,-0x214(%rbp)
mov    -0x214(%rbp),%edi
lea    -0x210(%rbp),%rsi
call   1040 <createtable@plt>
mov    %eax,-0x218(%rbp)
lea    -0x210(%rbp),%rdi
mov    -0x218(%rbp),%esi
call   1060 <writesource@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x220,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x200,%rsp
cmp    $0x2,%edi
jne    1171 <main+0x31>
mov    0x8(%rsi),%rdi
call   1050 <atoi@plt>
mov    %rsp,%rbx
mov    %eax,%edi
mov    %rbx,%rsi
call   1040 <createtable@plt>
mov    %rbx,%rdi
mov    %eax,%esi
call   1060 <writesource@plt>
xor    %eax,%eax
jmp    118b <main+0x4b>
mov    0x2e68(%rip),%rax
mov    (%rax),%edi
lea    0xe7f(%rip),%rsi
call   1030 <fprintf@plt>
mov    $0xffffffff,%eax
add    $0x200,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@stderr = global i32 0
@.str = [30 x i8] c"Usage: gennotes <samplerate>\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca [128 x 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 = load i8**, i8*** %5
%11 = load i32, i32* %4
%12 = icmp ne i32 %11, 2
br i1 %12, label %13, label %16
13: ; preds = %2
%14 = load i32, i32* @stderr
%15 = call i32 @fprintf(i32 %14, i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str, i64 0, i64 0))
store i32 -1, i32* %3
br label %27
16: ; preds = %2
%17 = load i8**, i8*** %5
%18 = getelementptr inbounds i8*, i8** %17, i64 1
%19 = load i8*, i8** %18
%20 = call i32 @atoi(i8* %19)
store i32 %20, i32* %7
%21 = load i32, i32* %7
%22 = getelementptr inbounds [128 x i32], [128 x i32]* %6, i64 0, i64 0
%23 = call i32 @createtable(i32 %21, i32* %22)
store i32 %23, i32* %8
%24 = getelementptr inbounds [128 x i32], [128 x i32]* %6, i64 0, i64 0
%25 = load i32, i32* %8
%26 = call i32 @writesource(i32* %24, i32 %25)
store i32 0, i32* %3
br label %27
27: ; preds = %16, %13
%28 = load i32, i32* %3
ret i32 %28
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [30 x i8] c"Usage: gennotes <samplerate>\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca [128 x i32]
%4 = bitcast [128 x i32]* %3 to i8*
%5 = icmp eq i32 %0, 2
br i1 %5, label %9, label %6
6: ; preds = %2
%7 = load i32, i32* @stderr
%8 = tail call i32 @fprintf(i32 %7, i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str, i64 0, i64 0))
br label %16
9: ; preds = %2
%10 = getelementptr inbounds i8*, i8** %1, i64 1
%11 = load i8*, i8** %10
%12 = tail call i32 @atoi(i8* %11)
%13 = getelementptr inbounds [128 x i32], [128 x i32]* %3, i64 0, i64 0
%14 = call i32 @createtable(i32 %12, i32* %13)
%15 = call i32 @writesource(i32* %13, i32 %14)
br label %16
16: ; preds = %9, %6
%17 = phi i32 [ -1, %6 ], [ 0, %9 ]
ret i32 %17
}