#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*/ feof(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/ *, char *, ...);
int /*<<< orphan*/ fscanf(int /*<<< orphan*/ *, char *, char *);
int /*<<< orphan*/ printf(char *);
int main(int argc, char *argv[]) {
  char num;
  float scale = 1.0 / 128.f;
  FILE *pi, *po;
  if ((po = fopen("data.ts", "w")) == NULL) {
    printf("ERROR: cannot open output file\n");
  } else if ((pi = fopen(argv[1], "r")) == NULL) {
    printf("ERROR: cannot open input file\n");
  } else {
    fprintf(po, "[");
    while (!feof(pi)) {
      fscanf(pi, "%c", &num);
      fprintf(po, "%f,", num * scale);
    }
    fprintf(po, "0]");
  }
  fclose(pi);
  fclose(po);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movss  0xe82(%rip),%xmm0
movss  %xmm0,-0x18(%rbp)
lea    0xe7a(%rip),%rdi
lea    0xe7b(%rip),%rsi
call   1080 <fopen@plt>
mov    %rax,-0x28(%rbp)
cmp    $0x0,%rax
jne    11b5 <main+0x55>
lea    0xe63(%rip),%rdi
call   1040 <printf@plt>
jmp    126b <main+0x10b>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xe6a(%rip),%rsi
call   1080 <fopen@plt>
mov    %rax,-0x20(%rbp)
cmp    $0x0,%rax
jne    11e8 <main+0x88>
lea    0xe52(%rip),%rdi
call   1040 <printf@plt>
jmp    1266 <main+0x106>
mov    -0x28(%rbp),%rdi
lea    0xe5c(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
mov    -0x20(%rbp),%rdi
call   1070 <feof@plt>
cmp    $0x0,%eax
setne  %al
xor    $0xff,%al
test   $0x1,%al
jne    1218 <main+0xb8>
jmp    1254 <main+0xf4>
mov    -0x20(%rbp),%rdi
lea    0xe2e(%rip),%rsi
lea    -0x11(%rbp),%rdx
call   1050 <fscanf@plt>
mov    -0x28(%rbp),%rdi
movsbl -0x11(%rbp),%eax
cvtsi2ss %eax,%xmm0
mulss  -0x18(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xe0c(%rip),%rsi
mov    $0x1,%al
call   1060 <fprintf@plt>
jmp    11fa <main+0x9a>
mov    -0x28(%rbp),%rdi
lea    0xdf9(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
jmp    126b <main+0x10b>
mov    -0x20(%rbp),%rdi
call   1030 <fclose@plt>
mov    -0x28(%rbp),%rdi
call   1030 <fclose@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x10,%rsp
mov    %rsi,%rbx
lea    0xe6d(%rip),%rdi
lea    0xe6e(%rip),%rsi
call   1090 <fopen@plt>
test   %rax,%rax
je     1286 <main+0x106>
mov    %rax,%r14
mov    0x8(%rbx),%rdi
lea    0xe54(%rip),%rsi
call   1090 <fopen@plt>
mov    %rax,%rbx
test   %rax,%rax
je     125a <main+0xda>
mov    $0x5b,%edi
mov    %r14,%rsi
call   1060 <fputc@plt>
mov    %rbx,%rdi
call   1080 <feof@plt>
test   %eax,%eax
jne    123f <main+0xbf>
lea    0xe25(%rip),%r15
lea    0xf(%rsp),%r12
lea    0xe1c(%rip),%r13
nopw   0x0(%rax,%rax,1)
mov    %rbx,%rdi
mov    %r15,%rsi
mov    %r12,%rdx
call   1050 <fscanf@plt>
movsbl 0xf(%rsp),%eax
xorps  %xmm0,%xmm0
cvtsi2ss %eax,%xmm0
mulss  0xdde(%rip),%xmm0
cvtss2sd %xmm0,%xmm0
mov    %r14,%rdi
mov    %r13,%rsi
mov    $0x1,%al
call   1070 <fprintf@plt>
mov    %rbx,%rdi
call   1080 <feof@plt>
test   %eax,%eax
je     1200 <main+0x80>
lea    0xdd1(%rip),%rdi
mov    $0x2,%esi
mov    $0x1,%edx
mov    %r14,%rcx
call   10a0 <fwrite@plt>
jmp    1266 <main+0xe6>
lea    0xdb9(%rip),%rdi
call   1030 <puts@plt>
mov    %rbx,%rdi
call   1040 <fclose@plt>
mov    %r14,%rdi
call   1040 <fclose@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret
lea    0xdab(%rip),%rdi
call   1030 <puts@plt>

LLVM IR (-O0):
@.str = [8 x i8] c"data.ts\00"
@.str.1 = [2 x i8] c"w\00"
@.str.2 = [32 x i8] c"ERROR: cannot open output file\0A\00"
@.str.3 = [2 x i8] c"r\00"
@.str.4 = [31 x i8] c"ERROR: cannot open input file\0A\00"
@.str.5 = [2 x i8] c"[\00"
@.str.6 = [3 x i8] c"%c\00"
@.str.7 = [4 x i8] c"%f,\00"
@.str.8 = [3 x i8] c"0]\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i8
%7 = alloca float
%8 = alloca i32*
%9 = alloca i32*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store float 7.812500e-03, float* %7
%10 = call i32* @fopen(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %10, i32** %9
%11 = icmp eq i32* %10, null
br i1 %11, label %12, label %14
12: ; preds = %2
%13 = call i32 @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.2, i64 0, i64 0))
br label %45
14: ; preds = %2
%15 = load i8**, i8*** %5
%16 = getelementptr inbounds i8*, i8** %15, i64 1
%17 = load i8*, i8** %16
%18 = call i32* @fopen(i8* %17, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
store i32* %18, i32** %8
%19 = icmp eq i32* %18, null
br i1 %19, label %20, label %22
20: ; preds = %14
%21 = call i32 @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.4, i64 0, i64 0))
br label %44
22: ; preds = %14
%23 = load i32*, i32** %9
%24 = call i32 (i32*, i8*, ...) @fprintf(i32* %23, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0))
br label %25
25: ; preds = %30, %22
%26 = load i32*, i32** %8
%27 = call i32 @feof(i32* %26)
%28 = icmp ne i32 %27, 0
%29 = xor i1 %28, true
br i1 %29, label %30, label %41
30: ; preds = %25
%31 = load i32*, i32** %8
%32 = call i32 @fscanf(i32* %31, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.6, i64 0, i64 0), i8* %6)
%33 = load i32*, i32** %9
%34 = load i8, i8* %6
%35 = sext i8 %34 to i32
%36 = sitofp i32 %35 to float
%37 = load float, float* %7
%38 = fmul float %36, %37
%39 = fpext float %38 to double
%40 = call i32 (i32*, i8*, ...) @fprintf(i32* %33, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.7, i64 0, i64 0), double %39)
br label %25
41: ; preds = %25
%42 = load i32*, i32** %9
%43 = call i32 (i32*, i8*, ...) @fprintf(i32* %42, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.8, i64 0, i64 0))
br label %44
44: ; preds = %41, %20
br label %45
45: ; preds = %44, %12
%46 = load i32*, i32** %8
%47 = call i32 @fclose(i32* %46)
%48 = load i32*, i32** %9
%49 = call i32 @fclose(i32* %48)
ret i32 0
}

LLVM IR (-O2):
@.str = [8 x i8] c"data.ts\00"
@.str.1 = [2 x i8] c"w\00"
@.str.3 = [2 x i8] c"r\00"
@.str.6 = [3 x i8] c"%c\00"
@.str.7 = [4 x i8] c"%f,\00"
@.str.8 = [3 x i8] c"0]\00"
@str = [30 x i8] c"ERROR: cannot open input file\00"
@str.9 = [31 x i8] c"ERROR: cannot open output file\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca i8
%4 = tail call i32* @fopen(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%5 = icmp eq i32* %4, null
br i1 %5, label %6, label %8
6: ; preds = %2
%7 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([31 x i8], [31 x i8]* @str.9, i64 0, i64 0))
unreachable
8: ; preds = %2
%9 = getelementptr inbounds i8*, i8** %1, i64 1
%10 = load i8*, i8** %9
%11 = tail call i32* @fopen(i8* %10, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
%12 = icmp eq i32* %11, null
br i1 %12, label %13, label %15
13: ; preds = %8
%14 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([30 x i8], [30 x i8]* @str, i64 0, i64 0))
br label %30
15: ; preds = %8
%16 = tail call i32 @fputc(i32 91, i32* %4)
%17 = call i32 @feof(i32* %11)
%18 = icmp eq i32 %17, 0
br i1 %18, label %19, label %28
19: ; preds = %15, %19
%20 = call i32 @fscanf(i32* %11, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.6, i64 0, i64 0), i8* %3)
%21 = load i8, i8* %3
%22 = sitofp i8 %21 to float
%23 = fmul float %22, 7.812500e-03
%24 = fpext float %23 to double
%25 = call i32 (i32*, i8*, ...) @fprintf(i32* %4, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.7, i64 0, i64 0), double %24)
%26 = call i32 @feof(i32* %11)
%27 = icmp eq i32 %26, 0
br i1 %27, label %19, label %28
28: ; preds = %19, %15
%29 = call i64 @fwrite(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.8, i64 0, i64 0), i64 2, i64 1, i32* %4)
br label %30
30: ; preds = %13, %28
%31 = call i32 @fclose(i32* %11)
%32 = call i32 @fclose(i32* %4)
ret i32 0
}