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

/* Variables and functions */
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fread(short *, int, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ fwrite(int *, int, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ putchar(char);
int /*<<< orphan*/ system(char *);
int main() {
  int i;
  FILE *f;
  f = fopen("alaw.dat", "wb");
  for (i = 0; i < 256; i++)
    fwrite(&i, 1, 1, f);
  fclose(f);
  system("sox -t raw -A -r 8000 -b alaw.dat -t sw alaw.out");
  printf("// Generated by TOOLS/alaw-gen.c\n");
  printf("\nshort alaw2short[]={\n");
  f = fopen("alaw.out", "rb");
  for (i = 0; i < 256; i++) {
    signed short x;
    fread(&x, 2, 1, f);
    printf("%6d", x);
    if (i != 255)
      putchar(',');
    if ((i & 7) == 7)
      printf("\n");
  }
  fclose(f);
  printf("};\n");
  system("sox -t raw -U -r 8000 -b alaw.dat -t sw alaw.out");
  printf("\nshort ulaw2short[]={\n");
  f = fopen("alaw.out", "rb");
  for (i = 0; i < 256; i++) {
    signed short x;
    fread(&x, 2, 1, f);
    printf("%6d", x);
    if (i != 255)
      putchar(',');
    if ((i & 7) == 7)
      printf("\n");
  }
  fclose(f);
  printf("};\n");
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xe7a(%rip),%rdi
lea    0xe7c(%rip),%rsi
call   1080 <fopen@plt>
mov    %rax,-0x10(%rbp)
movl   $0x0,-0x8(%rbp)
cmpl   $0x100,-0x8(%rbp)
jge    11cc <main+0x5c>
mov    -0x10(%rbp),%rcx
lea    -0x8(%rbp),%rdi
mov    $0x1,%edx
mov    %edx,%esi
call   1090 <fwrite@plt>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    119d <main+0x2d>
mov    -0x10(%rbp),%rdi
call   1050 <fclose@plt>
lea    0xe30(%rip),%rdi
call   1060 <system@plt>
lea    0xe55(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
lea    0xe69(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
lea    0xe30(%rip),%rdi
lea    0xe6b(%rip),%rsi
call   1080 <fopen@plt>
mov    %rax,-0x10(%rbp)
movl   $0x0,-0x8(%rbp)
cmpl   $0x100,-0x8(%rbp)
jge    1298 <main+0x128>
mov    -0x10(%rbp),%rcx
lea    -0x12(%rbp),%rdi
mov    $0x2,%esi
mov    $0x1,%edx
call   1040 <fread@plt>
movswl -0x12(%rbp),%esi
lea    0xe2f(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
cmpl   $0xff,-0x8(%rbp)
je     1268 <main+0xf8>
mov    $0x2c,%edi
call   1030 <putchar@plt>
mov    -0x8(%rbp),%eax
and    $0x7,%eax
cmp    $0x7,%eax
jne    1285 <main+0x115>
lea    0xe01(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
jmp    128a <main+0x11a>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    121b <main+0xab>
mov    -0x10(%rbp),%rdi
call   1050 <fclose@plt>
lea    0xdd5(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
lea    0xdcb(%rip),%rdi
call   1060 <system@plt>
lea    0xdf0(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
lea    0xd64(%rip),%rdi
lea    0xd9f(%rip),%rsi
call   1080 <fopen@plt>
mov    %rax,-0x10(%rbp)
movl   $0x0,-0x8(%rbp)
cmpl   $0x100,-0x8(%rbp)
jge    1364 <main+0x1f4>
mov    -0x10(%rbp),%rcx
lea    -0x14(%rbp),%rdi
mov    $0x2,%esi
mov    $0x1,%edx
call   1040 <fread@plt>
movswl -0x14(%rbp),%esi
lea    0xd63(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
cmpl   $0xff,-0x8(%rbp)
je     1334 <main+0x1c4>
mov    $0x2c,%edi
call   1030 <putchar@plt>
mov    -0x8(%rbp),%eax
and    $0x7,%eax
cmp    $0x7,%eax
jne    1351 <main+0x1e1>
lea    0xd35(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
jmp    1356 <main+0x1e6>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    12e7 <main+0x177>
mov    -0x10(%rbp),%rdi
call   1050 <fclose@plt>
lea    0xd09(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
lea    0xe72(%rip),%rdi
lea    0xe74(%rip),%rsi
call   10a0 <fopen@plt>
mov    %rax,%r14
xor    %ebp,%ebp
mov    $0x100,%ebx
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    %ebp,%edi
sar    $0x18,%edi
mov    %r14,%rsi
call   1090 <fputc@plt>
add    $0x1000000,%ebp
add    $0xffffffff,%ebx
jne    11b0 <main+0x30>
mov    %r14,%rdi
call   1060 <fclose@plt>
lea    0xe35(%rip),%rdi
call   1070 <system@plt>
lea    0xe92(%rip),%rdi
call   1040 <puts@plt>
lea    0xea7(%rip),%rdi
call   1040 <puts@plt>
lea    0xe39(%rip),%rdi
lea    0xe3b(%rip),%rsi
call   10a0 <fopen@plt>
mov    %rax,%rbx
lea    0x6(%rsp),%r14
lea    0xe2a(%rip),%r15
xor    %ebp,%ebp
jmp    1235 <main+0xb5>
nopw   0x0(%rax,%rax,1)
mov    $0xa,%edi
call   1030 <putchar@plt>
add    $0x1,%ebp
cmp    $0x100,%ebp
je     1275 <main+0xf5>
mov    %r14,%rdi
mov    $0x2,%esi
mov    $0x1,%edx
mov    %rbx,%rcx
call   1050 <fread@plt>
movswl 0x6(%rsp),%esi
mov    %r15,%rdi
xor    %eax,%eax
call   1080 <printf@plt>
cmp    $0xff,%ebp
je     1220 <main+0xa0>
mov    $0x2c,%edi
call   1030 <putchar@plt>
mov    %ebp,%eax
not    %eax
test   $0x7,%al
je     1220 <main+0xa0>
jmp    122a <main+0xaa>
mov    %rbx,%rdi
call   1060 <fclose@plt>
lea    0xe3e(%rip),%rdi
call   1040 <puts@plt>
lea    0xdb4(%rip),%rdi
call   1070 <system@plt>
lea    0xe10(%rip),%rdi
call   1040 <puts@plt>
lea    0xd8c(%rip),%rdi
lea    0xd8e(%rip),%rsi
call   10a0 <fopen@plt>
mov    %rax,%rbx
lea    0x4(%rsp),%r14
lea    0xd7d(%rip),%r15
xor    %ebp,%ebp
jmp    12e5 <main+0x165>
nopw   0x0(%rax,%rax,1)
mov    $0xa,%edi
call   1030 <putchar@plt>
add    $0x1,%ebp
cmp    $0x100,%ebp
je     1325 <main+0x1a5>
mov    %r14,%rdi
mov    $0x2,%esi
mov    $0x1,%edx
mov    %rbx,%rcx
call   1050 <fread@plt>
movswl 0x4(%rsp),%esi
mov    %r15,%rdi
xor    %eax,%eax
call   1080 <printf@plt>
cmp    $0xff,%ebp
je     12d0 <main+0x150>
mov    $0x2c,%edi
call   1030 <putchar@plt>
mov    %ebp,%eax
not    %eax
test   $0x7,%al
je     12d0 <main+0x150>
jmp    12da <main+0x15a>
mov    %rbx,%rdi
call   1060 <fclose@plt>
lea    0xd8e(%rip),%rdi
call   1040 <puts@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [9 x i8] c"alaw.dat\00"
@.str.1 = [3 x i8] c"wb\00"
@.str.2 = [49 x i8] c"sox -t raw -A -r 8000 -b alaw.dat -t sw alaw.out\00"
@.str.3 = [34 x i8] c"// Generated by TOOLS/alaw-gen.c\0A\00"
@.str.4 = [23 x i8] c"\0Ashort alaw2short[]={\0A\00"
@.str.5 = [9 x i8] c"alaw.out\00"
@.str.6 = [3 x i8] c"rb\00"
@.str.7 = [4 x i8] c"%6d\00"
@.str.8 = [2 x i8] c"\0A\00"
@.str.9 = [4 x i8] c"};\0A\00"
@.str.10 = [49 x i8] c"sox -t raw -U -r 8000 -b alaw.dat -t sw alaw.out\00"
@.str.11 = [23 x i8] c"\0Ashort ulaw2short[]={\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32*
%4 = alloca i16
%5 = alloca i16
store i32 0, i32* %1
%6 = call i32* @fopen(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
store i32* %6, i32** %3
store i32 0, i32* %2
br label %7
7: ; preds = %13, %0
%8 = load i32, i32* %2
%9 = icmp slt i32 %8, 256
br i1 %9, label %10, label %16
10: ; preds = %7
%11 = load i32*, i32** %3
%12 = call i32 @fwrite(i32* %2, i32 1, i32 1, i32* %11)
br label %13
13: ; preds = %10
%14 = load i32, i32* %2
%15 = add nsw i32 %14, 1
store i32 %15, i32* %2
br label %7
16: ; preds = %7
%17 = load i32*, i32** %3
%18 = call i32 @fclose(i32* %17)
%19 = call i32 @system(i8* getelementptr inbounds ([49 x i8], [49 x i8]* @.str.2, i64 0, i64 0))
%20 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.3, i64 0, i64 0))
%21 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.4, i64 0, i64 0))
%22 = call i32* @fopen(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.5, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.6, i64 0, i64 0))
store i32* %22, i32** %3
store i32 0, i32* %2
br label %23
23: ; preds = %43, %16
%24 = load i32, i32* %2
%25 = icmp slt i32 %24, 256
br i1 %25, label %26, label %46
26: ; preds = %23
%27 = load i32*, i32** %3
%28 = call i32 @fread(i16* %4, i32 2, i32 1, i32* %27)
%29 = load i16, i16* %4
%30 = sext i16 %29 to i32
%31 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.7, i64 0, i64 0), i32 %30)
%32 = load i32, i32* %2
%33 = icmp ne i32 %32, 255
br i1 %33, label %34, label %36
34: ; preds = %26
%35 = call i32 @putchar(i8 signext 44)
br label %36
36: ; preds = %34, %26
%37 = load i32, i32* %2
%38 = and i32 %37, 7
%39 = icmp eq i32 %38, 7
br i1 %39, label %40, label %42
40: ; preds = %36
%41 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.8, i64 0, i64 0))
br label %42
42: ; preds = %40, %36
br label %43
43: ; preds = %42
%44 = load i32, i32* %2
%45 = add nsw i32 %44, 1
store i32 %45, i32* %2
br label %23
46: ; preds = %23
%47 = load i32*, i32** %3
%48 = call i32 @fclose(i32* %47)
%49 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.9, i64 0, i64 0))
%50 = call i32 @system(i8* getelementptr inbounds ([49 x i8], [49 x i8]* @.str.10, i64 0, i64 0))
%51 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.11, i64 0, i64 0))
%52 = call i32* @fopen(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.5, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.6, i64 0, i64 0))
store i32* %52, i32** %3
store i32 0, i32* %2
br label %53
53: ; preds = %73, %46
%54 = load i32, i32* %2
%55 = icmp slt i32 %54, 256
br i1 %55, label %56, label %76
56: ; preds = %53
%57 = load i32*, i32** %3
%58 = call i32 @fread(i16* %5, i32 2, i32 1, i32* %57)
%59 = load i16, i16* %5
%60 = sext i16 %59 to i32
%61 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.7, i64 0, i64 0), i32 %60)
%62 = load i32, i32* %2
%63 = icmp ne i32 %62, 255
br i1 %63, label %64, label %66
64: ; preds = %56
%65 = call i32 @putchar(i8 signext 44)
br label %66
66: ; preds = %64, %56
%67 = load i32, i32* %2
%68 = and i32 %67, 7
%69 = icmp eq i32 %68, 7
br i1 %69, label %70, label %72
70: ; preds = %66
%71 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.8, i64 0, i64 0))
br label %72
72: ; preds = %70, %66
br label %73
73: ; preds = %72
%74 = load i32, i32* %2
%75 = add nsw i32 %74, 1
store i32 %75, i32* %2
br label %53
76: ; preds = %53
%77 = load i32*, i32** %3
%78 = call i32 @fclose(i32* %77)
%79 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.9, i64 0, i64 0))
%80 = load i32, i32* %1
ret i32 %80
}

LLVM IR (-O2):
@.str = [9 x i8] c"alaw.dat\00"
@.str.1 = [3 x i8] c"wb\00"
@.str.2 = [49 x i8] c"sox -t raw -A -r 8000 -b alaw.dat -t sw alaw.out\00"
@.str.5 = [9 x i8] c"alaw.out\00"
@.str.6 = [3 x i8] c"rb\00"
@.str.7 = [4 x i8] c"%6d\00"
@.str.10 = [49 x i8] c"sox -t raw -U -r 8000 -b alaw.dat -t sw alaw.out\00"
@str = [33 x i8] c"// Generated by TOOLS/alaw-gen.c\00"
@str.12 = [22 x i8] c"\0Ashort alaw2short[]={\00"
@str.14 = [22 x i8] c"\0Ashort ulaw2short[]={\00"
@str.15 = [3 x i8] c"};\00"
define i32 @main() {
%1 = alloca i16
%2 = alloca i16
%3 = tail call i32* @fopen(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
br label %4
4: ; preds = %0, %4
%5 = phi i32 [ 0, %0 ], [ %9, %4 ]
%6 = shl i32 %5, 24
%7 = ashr exact i32 %6, 24
%8 = tail call i32 @fputc(i32 %7, i32* %3)
%9 = add nuw nsw i32 %5, 1
%10 = icmp eq i32 %9, 256
br i1 %10, label %11, label %4
11: ; preds = %4
%12 = tail call i32 @fclose(i32* %3)
%13 = tail call i32 @system(i8* getelementptr inbounds ([49 x i8], [49 x i8]* @.str.2, i64 0, i64 0))
%14 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([33 x i8], [33 x i8]* @str, i64 0, i64 0))
%15 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @str.12, i64 0, i64 0))
%16 = tail call i32* @fopen(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.5, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.6, i64 0, i64 0))
%17 = bitcast i16* %1 to i8*
br label %18
18: ; preds = %11, %31
%19 = phi i32 [ 0, %11 ], [ %32, %31 ]
%20 = call i32 @fread(i16* %1, i32 2, i32 1, i32* %16)
%21 = load i16, i16* %1
%22 = sext i16 %21 to i32
%23 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.7, i64 0, i64 0), i32 %22)
%24 = icmp eq i32 %19, 255
br i1 %24, label %29, label %25
25: ; preds = %18
%26 = tail call i32 @putchar(i8 signext 44)
%27 = and i32 %19, 7
%28 = icmp eq i32 %27, 7
br i1 %28, label %29, label %31
29: ; preds = %18, %25
%30 = tail call i32 bitcast (i32 (i8)* @putchar to i32 (i32)*)(i32 10)
br label %31
31: ; preds = %29, %25
%32 = add nuw nsw i32 %19, 1
%33 = icmp eq i32 %32, 256
br i1 %33, label %34, label %18
34: ; preds = %31
%35 = tail call i32 @fclose(i32* %16)
%36 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @str.15, i64 0, i64 0))
%37 = tail call i32 @system(i8* getelementptr inbounds ([49 x i8], [49 x i8]* @.str.10, i64 0, i64 0))
%38 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @str.14, i64 0, i64 0))
%39 = tail call i32* @fopen(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.5, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.6, i64 0, i64 0))
%40 = bitcast i16* %2 to i8*
br label %41
41: ; preds = %34, %54
%42 = phi i32 [ 0, %34 ], [ %55, %54 ]
%43 = call i32 @fread(i16* %2, i32 2, i32 1, i32* %39)
%44 = load i16, i16* %2
%45 = sext i16 %44 to i32
%46 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.7, i64 0, i64 0), i32 %45)
%47 = icmp eq i32 %42, 255
br i1 %47, label %52, label %48
48: ; preds = %41
%49 = tail call i32 @putchar(i8 signext 44)
%50 = and i32 %42, 7
%51 = icmp eq i32 %50, 7
br i1 %51, label %52, label %54
52: ; preds = %41, %48
%53 = tail call i32 bitcast (i32 (i8)* @putchar to i32 (i32)*)(i32 10)
br label %54
54: ; preds = %52, %48
%55 = add nuw nsw i32 %42, 1
%56 = icmp eq i32 %55, 256
br i1 %56, label %57, label %41
57: ; preds = %54
%58 = tail call i32 @fclose(i32* %39)
%59 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @str.15, i64 0, i64 0))
ret i32 0
}