#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(void) {
  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\n");
  printf("#ifndef MPLAYER_ALAW_H\n");
  printf("#define MPLAYER_ALAW_H\n");
  printf("\nconst short alaw2short[]={\n");
  f = fopen("alaw.out", "rb");
  for (i = 0; i < 256; i++) {
    signed short x;
    fread(&x, 2, 1, f);
    printf("%7d", 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("\nconst short ulaw2short[]={\n");
  f = fopen("alaw.out", "rb");
  for (i = 0; i < 256; i++) {
    signed short x;
    fread(&x, 2, 1, f);
    printf("%7d", x);
    if (i != 255)
      putchar(',');
    if ((i & 7) == 7)
      printf("\n");
  }
  fclose(f);
  printf("};\n\n");
  printf("#endif /* MPLAYER_ALAW_H */\n");
  return 0;
}


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    0xe6a(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
lea    0xe74(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
lea    0xe7e(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
lea    0xe14(%rip),%rdi
lea    0xe86(%rip),%rsi
call   1080 <fopen@plt>
mov    %rax,-0x10(%rbp)
movl   $0x0,-0x8(%rbp)
cmpl   $0x100,-0x8(%rbp)
jge    12b4 <main+0x144>
mov    -0x10(%rbp),%rcx
lea    -0x12(%rbp),%rdi
mov    $0x2,%esi
mov    $0x1,%edx
call   1040 <fread@plt>
movswl -0x12(%rbp),%esi
lea    0xe4a(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
cmpl   $0xff,-0x8(%rbp)
je     1284 <main+0x114>
mov    $0x2c,%edi
call   1030 <putchar@plt>
mov    -0x8(%rbp),%eax
and    $0x7,%eax
cmp    $0x7,%eax
jne    12a1 <main+0x131>
lea    0xe6f(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
jmp    12a6 <main+0x136>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    1237 <main+0xc7>
mov    -0x10(%rbp),%rdi
call   1050 <fclose@plt>
lea    0xdf0(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
lea    0xde6(%rip),%rdi
call   1060 <system@plt>
lea    0xe0b(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
lea    0xd48(%rip),%rdi
lea    0xdba(%rip),%rsi
call   1080 <fopen@plt>
mov    %rax,-0x10(%rbp)
movl   $0x0,-0x8(%rbp)
cmpl   $0x100,-0x8(%rbp)
jge    1380 <main+0x210>
mov    -0x10(%rbp),%rcx
lea    -0x14(%rbp),%rdi
mov    $0x2,%esi
mov    $0x1,%edx
call   1040 <fread@plt>
movswl -0x14(%rbp),%esi
lea    0xd7e(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
cmpl   $0xff,-0x8(%rbp)
je     1350 <main+0x1e0>
mov    $0x2c,%edi
call   1030 <putchar@plt>
mov    -0x8(%rbp),%eax
and    $0x7,%eax
cmp    $0x7,%eax
jne    136d <main+0x1fd>
lea    0xda3(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
jmp    1372 <main+0x202>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    1303 <main+0x193>
mov    -0x10(%rbp),%rdi
call   1050 <fclose@plt>
lea    0xd76(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
lea    0xd6d(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
xor    %eax,%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    0xea8(%rip),%rdi
call   1040 <puts@plt>
lea    0xeb3(%rip),%rdi
call   1040 <puts@plt>
lea    0xebe(%rip),%rdi
call   1040 <puts@plt>
lea    0xe21(%rip),%rdi
lea    0xe23(%rip),%rsi
call   10a0 <fopen@plt>
mov    %rax,%rbx
lea    0x6(%rsp),%r14
lea    0xe12(%rip),%r15
xor    %ebp,%ebp
jmp    1255 <main+0xd5>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    $0xa,%edi
call   1030 <putchar@plt>
add    $0x1,%ebp
cmp    $0x100,%ebp
je     1295 <main+0x115>
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     1240 <main+0xc0>
mov    $0x2c,%edi
call   1030 <putchar@plt>
mov    %ebp,%eax
not    %eax
test   $0x7,%al
je     1240 <main+0xc0>
jmp    124a <main+0xca>
mov    %rbx,%rdi
call   1060 <fclose@plt>
lea    0xe3d(%rip),%rdi
call   1040 <puts@plt>
lea    0xd94(%rip),%rdi
call   1070 <system@plt>
lea    0xe28(%rip),%rdi
call   1040 <puts@plt>
lea    0xd6c(%rip),%rdi
lea    0xd6e(%rip),%rsi
call   10a0 <fopen@plt>
mov    %rax,%rbx
lea    0x4(%rsp),%r14
lea    0xd5d(%rip),%r15
xor    %ebp,%ebp
jmp    1305 <main+0x185>
nopw   0x0(%rax,%rax,1)
mov    $0xa,%edi
call   1030 <putchar@plt>
add    $0x1,%ebp
cmp    $0x100,%ebp
je     1345 <main+0x1c5>
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     12f0 <main+0x170>
mov    $0x2c,%edi
call   1030 <putchar@plt>
mov    %ebp,%eax
not    %eax
test   $0x7,%al
je     12f0 <main+0x170>
jmp    12fa <main+0x17a>
mov    %rbx,%rdi
call   1060 <fclose@plt>
lea    0xdac(%rip),%rdi
call   1040 <puts@plt>
lea    0xda4(%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 = [35 x i8] c"// Generated by TOOLS/alaw-gen.c\0A\0A\00"
@.str.4 = [24 x i8] c"#ifndef MPLAYER_ALAW_H\0A\00"
@.str.5 = [24 x i8] c"#define MPLAYER_ALAW_H\0A\00"
@.str.6 = [29 x i8] c"\0Aconst short alaw2short[]={\0A\00"
@.str.7 = [9 x i8] c"alaw.out\00"
@.str.8 = [3 x i8] c"rb\00"
@.str.9 = [4 x i8] c"%7d\00"
@.str.10 = [2 x i8] c"\0A\00"
@.str.11 = [4 x i8] c"};\0A\00"
@.str.12 = [49 x i8] c"sox -t raw -U -r 8000 -b alaw.dat -t sw alaw.out\00"
@.str.13 = [29 x i8] c"\0Aconst short ulaw2short[]={\0A\00"
@.str.14 = [5 x i8] c"};\0A\0A\00"
@.str.15 = [29 x i8] c"#endif /* MPLAYER_ALAW_H */\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 ([35 x i8], [35 x i8]* @.str.3, i64 0, i64 0))
%21 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.4, i64 0, i64 0))
%22 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.5, i64 0, i64 0))
%23 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.6, i64 0, i64 0))
%24 = call i32* @fopen(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.7, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.8, i64 0, i64 0))
store i32* %24, i32** %3
store i32 0, i32* %2
br label %25
25: ; preds = %45, %16
%26 = load i32, i32* %2
%27 = icmp slt i32 %26, 256
br i1 %27, label %28, label %48
28: ; preds = %25
%29 = load i32*, i32** %3
%30 = call i32 @fread(i16* %4, i32 2, i32 1, i32* %29)
%31 = load i16, i16* %4
%32 = sext i16 %31 to i32
%33 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.9, i64 0, i64 0), i32 %32)
%34 = load i32, i32* %2
%35 = icmp ne i32 %34, 255
br i1 %35, label %36, label %38
36: ; preds = %28
%37 = call i32 @putchar(i8 signext 44)
br label %38
38: ; preds = %36, %28
%39 = load i32, i32* %2
%40 = and i32 %39, 7
%41 = icmp eq i32 %40, 7
br i1 %41, label %42, label %44
42: ; preds = %38
%43 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.10, i64 0, i64 0))
br label %44
44: ; preds = %42, %38
br label %45
45: ; preds = %44
%46 = load i32, i32* %2
%47 = add nsw i32 %46, 1
store i32 %47, i32* %2
br label %25
48: ; preds = %25
%49 = load i32*, i32** %3
%50 = call i32 @fclose(i32* %49)
%51 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.11, i64 0, i64 0))
%52 = call i32 @system(i8* getelementptr inbounds ([49 x i8], [49 x i8]* @.str.12, i64 0, i64 0))
%53 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.13, i64 0, i64 0))
%54 = call i32* @fopen(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.7, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.8, i64 0, i64 0))
store i32* %54, i32** %3
store i32 0, i32* %2
br label %55
55: ; preds = %75, %48
%56 = load i32, i32* %2
%57 = icmp slt i32 %56, 256
br i1 %57, label %58, label %78
58: ; preds = %55
%59 = load i32*, i32** %3
%60 = call i32 @fread(i16* %5, i32 2, i32 1, i32* %59)
%61 = load i16, i16* %5
%62 = sext i16 %61 to i32
%63 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.9, i64 0, i64 0), i32 %62)
%64 = load i32, i32* %2
%65 = icmp ne i32 %64, 255
br i1 %65, label %66, label %68
66: ; preds = %58
%67 = call i32 @putchar(i8 signext 44)
br label %68
68: ; preds = %66, %58
%69 = load i32, i32* %2
%70 = and i32 %69, 7
%71 = icmp eq i32 %70, 7
br i1 %71, label %72, label %74
72: ; preds = %68
%73 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.10, i64 0, i64 0))
br label %74
74: ; preds = %72, %68
br label %75
75: ; preds = %74
%76 = load i32, i32* %2
%77 = add nsw i32 %76, 1
store i32 %77, i32* %2
br label %55
78: ; preds = %55
%79 = load i32*, i32** %3
%80 = call i32 @fclose(i32* %79)
%81 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.14, i64 0, i64 0))
%82 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.15, i64 0, i64 0))
ret i32 0
}

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