#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 fgetc(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/ *, char *, ...);
int /*<<< orphan*/ *stderr;
int main() {
  FILE *infile;
  FILE *outfile;
  int x, high, low, count = 0;
  int numchannels = 2;
  infile = fopen("bindata.bin", "rb");
  outfile = fopen("data.out", "w");
  fprintf(stderr, "\n");
  fprintf(outfile, "\n");
  do {
    count++;
    for (x = 1; x < numchannels + 1; x++) {
      low = fgetc(infile);
      high = fgetc(infile) * 256;
      if (!feof(infile)) {
        if (x == 1)
          fprintf(stderr, "Point %i \t", count);
        fprintf(stderr, "Value %2.3f\t", (high + low - 32767) * .0003051850948);
        fprintf(outfile, "Value %2.3f\t",
                (high + low - 32767) * .0003051850948);
        if (x == numchannels) {
          fprintf(stderr, "\n");
          fprintf(outfile, "\n");
        }
      }
    }
  } while (!feof(infile));
  fprintf(stderr, "\n");
  fprintf(outfile, "\n");
  fclose(infile);
  fclose(outfile);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x28(%rbp)
movl   $0x2,-0x2c(%rbp)
lea    0xe94(%rip),%rdi
lea    0xe99(%rip),%rsi
call   1070 <fopen@plt>
mov    %rax,-0x10(%rbp)
lea    0xe8c(%rip),%rdi
lea    0xe8e(%rip),%rsi
call   1070 <fopen@plt>
mov    %rax,-0x18(%rbp)
mov    0x2e3e(%rip),%rax
mov    (%rax),%rdi
lea    0xe76(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
mov    -0x18(%rbp),%rdi
lea    0xe64(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
mov    -0x28(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x28(%rbp)
movl   $0x1,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
mov    -0x2c(%rbp),%ecx
add    $0x1,%ecx
cmp    %ecx,%eax
jge    12e6 <main+0x196>
mov    -0x10(%rbp),%rdi
call   1040 <fgetc@plt>
mov    %eax,-0x24(%rbp)
mov    -0x10(%rbp),%rdi
call   1040 <fgetc@plt>
shl    $0x8,%eax
mov    %eax,-0x20(%rbp)
mov    -0x10(%rbp),%rdi
call   1060 <feof@plt>
cmp    $0x0,%eax
jne    12d3 <main+0x183>
cmpl   $0x1,-0x1c(%rbp)
jne    1238 <main+0xe8>
mov    0x2dbc(%rip),%rax
mov    (%rax),%rdi
mov    -0x28(%rbp),%edx
lea    0xdf3(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
mov    0x2da1(%rip),%rax
mov    (%rax),%rdi
mov    -0x20(%rbp),%eax
add    -0x24(%rbp),%eax
sub    $0x7fff,%eax
cvtsi2sd %eax,%xmm0
movsd  0xda7(%rip),%xmm1
mulsd  %xmm1,%xmm0
lea    0xdcb(%rip),%rsi
mov    $0x1,%al
call   1050 <fprintf@plt>
mov    -0x18(%rbp),%rdi
mov    -0x20(%rbp),%eax
add    -0x24(%rbp),%eax
sub    $0x7fff,%eax
cvtsi2sd %eax,%xmm0
movsd  0xd7a(%rip),%xmm1
mulsd  %xmm1,%xmm0
lea    0xd9e(%rip),%rsi
mov    $0x1,%al
call   1050 <fprintf@plt>
mov    -0x1c(%rbp),%eax
cmp    -0x2c(%rbp),%eax
jne    12ce <main+0x17e>
mov    0x2d35(%rip),%rax
mov    (%rax),%rdi
lea    0xd6d(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
mov    -0x18(%rbp),%rdi
lea    0xd5b(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
jmp    12d3 <main+0x183>
jmp    12d8 <main+0x188>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    11d5 <main+0x85>
jmp    12eb <main+0x19b>
mov    -0x10(%rbp),%rdi
call   1060 <feof@plt>
cmp    $0x0,%eax
setne  %al
xor    $0xff,%al
test   $0x1,%al
jne    11c5 <main+0x75>
mov    0x2cd5(%rip),%rax
mov    (%rax),%rdi
lea    0xd0d(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
mov    -0x18(%rbp),%rdi
lea    0xcfb(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
mov    -0x10(%rbp),%rdi
call   1030 <fclose@plt>
mov    -0x18(%rbp),%rdi
call   1030 <fclose@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
lea    0xe96(%rip),%rdi
lea    0xe9b(%rip),%rsi
call   1080 <fopen@plt>
mov    %rax,%r12
lea    0xe8f(%rip),%rdi
lea    0xe91(%rip),%rsi
call   1080 <fopen@plt>
mov    %rax,%r14
mov    0x2e42(%rip),%rax
mov    (%rax),%rsi
mov    $0xa,%edi
call   1050 <fputc@plt>
mov    $0xa,%edi
mov    %r14,%rsi
call   1050 <fputc@plt>
mov    $0x1,%ebp
jmp    11d3 <main+0x73>
nop
mov    %r12,%rdi
call   1070 <feof@plt>
add    $0x1,%ebp
test   %eax,%eax
jne    12e9 <main+0x189>
mov    %r12,%rdi
call   1040 <fgetc@plt>
mov    %eax,%r13d
mov    %r12,%rdi
call   1040 <fgetc@plt>
mov    %eax,%r15d
mov    %r12,%rdi
call   1070 <feof@plt>
test   %eax,%eax
jne    1256 <main+0xf6>
shl    $0x8,%r15d
mov    0x2de0(%rip),%rbx
mov    (%rbx),%rdi
lea    0xe18(%rip),%rsi
mov    %ebp,%edx
xor    %eax,%eax
call   1060 <fprintf@plt>
mov    (%rbx),%rdi
lea    (%r15,%r13,1),%eax
add    $0xffff8001,%eax
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
mulsd  0xdd2(%rip),%xmm0
movsd  %xmm0,(%rsp)
lea    0xdf3(%rip),%rbx
mov    %rbx,%rsi
mov    $0x1,%al
call   1060 <fprintf@plt>
mov    %r14,%rdi
mov    %rbx,%rsi
movsd  (%rsp),%xmm0
mov    $0x1,%al
call   1060 <fprintf@plt>
mov    %r12,%rdi
call   1040 <fgetc@plt>
mov    %eax,%r15d
mov    %r12,%rdi
call   1040 <fgetc@plt>
mov    %eax,%ebx
mov    %r12,%rdi
call   1070 <feof@plt>
test   %eax,%eax
jne    11c0 <main+0x60>
shl    $0x8,%ebx
mov    0x2d5b(%rip),%r13
mov    0x0(%r13),%rdi
lea    (%r15,%rbx,1),%eax
add    $0xffff8001,%eax
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
mulsd  0xd5f(%rip),%xmm0
movsd  %xmm0,(%rsp)
lea    0xd80(%rip),%rbx
mov    %rbx,%rsi
mov    $0x1,%al
call   1060 <fprintf@plt>
mov    %r14,%rdi
mov    %rbx,%rsi
movsd  (%rsp),%xmm0
mov    $0x1,%al
call   1060 <fprintf@plt>
mov    0x0(%r13),%rsi
mov    $0xa,%edi
call   1050 <fputc@plt>
mov    $0xa,%edi
mov    %r14,%rsi
call   1050 <fputc@plt>
jmp    11c0 <main+0x60>
mov    0x2cf0(%rip),%rax
mov    (%rax),%rsi
mov    $0xa,%edi
call   1050 <fputc@plt>
mov    $0xa,%edi
mov    %r14,%rsi
call   1050 <fputc@plt>
mov    %r12,%rdi
call   1030 <fclose@plt>
mov    %r14,%rdi
call   1030 <fclose@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [12 x i8] c"bindata.bin\00"
@.str.1 = [3 x i8] c"rb\00"
@.str.2 = [9 x i8] c"data.out\00"
@.str.3 = [2 x i8] c"w\00"
@stderr = global i32* null
@.str.4 = [2 x i8] c"\0A\00"
@.str.5 = [11 x i8] c"Point %i \09\00"
@.str.6 = [13 x i8] c"Value %2.3f\09\00"
define i32 @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
store i32 0, i32* %1
store i32 0, i32* %7
store i32 2, i32* %8
%9 = call i32* @fopen(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
store i32* %9, i32** %2
%10 = call i32* @fopen(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
store i32* %10, i32** %3
%11 = load i32*, i32** @stderr
%12 = call i32 (i32*, i8*, ...) @fprintf(i32* %11, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
%13 = load i32*, i32** %3
%14 = call i32 (i32*, i8*, ...) @fprintf(i32* %13, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
br label %15
15: ; preds = %70, %0
%16 = load i32, i32* %7
%17 = add nsw i32 %16, 1
store i32 %17, i32* %7
store i32 1, i32* %4
br label %18
18: ; preds = %66, %15
%19 = load i32, i32* %4
%20 = load i32, i32* %8
%21 = add nsw i32 %20, 1
%22 = icmp slt i32 %19, %21
br i1 %22, label %23, label %69
23: ; preds = %18
%24 = load i32*, i32** %2
%25 = call i32 @fgetc(i32* %24)
store i32 %25, i32* %6
%26 = load i32*, i32** %2
%27 = call i32 @fgetc(i32* %26)
%28 = mul nsw i32 %27, 256
store i32 %28, i32* %5
%29 = load i32*, i32** %2
%30 = call i32 @feof(i32* %29)
%31 = icmp ne i32 %30, 0
br i1 %31, label %65, label %32
32: ; preds = %23
%33 = load i32, i32* %4
%34 = icmp eq i32 %33, 1
br i1 %34, label %35, label %39
35: ; preds = %32
%36 = load i32*, i32** @stderr
%37 = load i32, i32* %7
%38 = call i32 (i32*, i8*, ...) @fprintf(i32* %36, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.5, i64 0, i64 0), i32 %37)
br label %39
39: ; preds = %35, %32
%40 = load i32*, i32** @stderr
%41 = load i32, i32* %5
%42 = load i32, i32* %6
%43 = add nsw i32 %41, %42
%44 = sub nsw i32 %43, 32767
%45 = sitofp i32 %44 to double
%46 = fmul double %45, 0x3F340028005B44F4
%47 = call i32 (i32*, i8*, ...) @fprintf(i32* %40, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.6, i64 0, i64 0), double %46)
%48 = load i32*, i32** %3
%49 = load i32, i32* %5
%50 = load i32, i32* %6
%51 = add nsw i32 %49, %50
%52 = sub nsw i32 %51, 32767
%53 = sitofp i32 %52 to double
%54 = fmul double %53, 0x3F340028005B44F4
%55 = call i32 (i32*, i8*, ...) @fprintf(i32* %48, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.6, i64 0, i64 0), double %54)
%56 = load i32, i32* %4
%57 = load i32, i32* %8
%58 = icmp eq i32 %56, %57
br i1 %58, label %59, label %64
59: ; preds = %39
%60 = load i32*, i32** @stderr
%61 = call i32 (i32*, i8*, ...) @fprintf(i32* %60, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
%62 = load i32*, i32** %3
%63 = call i32 (i32*, i8*, ...) @fprintf(i32* %62, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
br label %64
64: ; preds = %59, %39
br label %65
65: ; preds = %64, %23
br label %66
66: ; preds = %65
%67 = load i32, i32* %4
%68 = add nsw i32 %67, 1
store i32 %68, i32* %4
br label %18
69: ; preds = %18
br label %70
70: ; preds = %69
%71 = load i32*, i32** %2
%72 = call i32 @feof(i32* %71)
%73 = icmp ne i32 %72, 0
%74 = xor i1 %73, true
br i1 %74, label %15, label %75
75: ; preds = %70
%76 = load i32*, i32** @stderr
%77 = call i32 (i32*, i8*, ...) @fprintf(i32* %76, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
%78 = load i32*, i32** %3
%79 = call i32 (i32*, i8*, ...) @fprintf(i32* %78, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
%80 = load i32*, i32** %2
%81 = call i32 @fclose(i32* %80)
%82 = load i32*, i32** %3
%83 = call i32 @fclose(i32* %82)
ret i32 0
}

LLVM IR (-O2):
@.str = [12 x i8] c"bindata.bin\00"
@.str.1 = [3 x i8] c"rb\00"
@.str.2 = [9 x i8] c"data.out\00"
@.str.3 = [2 x i8] c"w\00"
@stderr = global i32* null
@.str.5 = [11 x i8] c"Point %i \09\00"
@.str.6 = [13 x i8] c"Value %2.3f\09\00"
define i32 @main() {
%1 = tail call i32* @fopen(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%2 = tail call i32* @fopen(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
%3 = load i32*, i32** @stderr
%4 = tail call i32 @fputc(i32 10, i32* %3)
%5 = tail call i32 @fputc(i32 10, i32* %2)
br label %6
6: ; preds = %41, %0
%7 = phi i32 [ 0, %0 ], [ %8, %41 ]
%8 = add nuw nsw i32 %7, 1
%9 = tail call i32 @fgetc(i32* %1)
%10 = tail call i32 @fgetc(i32* %1)
%11 = tail call i32 @feof(i32* %1)
%12 = icmp eq i32 %11, 0
br i1 %12, label %13, label %24
13: ; preds = %6
%14 = shl nsw i32 %10, 8
%15 = load i32*, i32** @stderr
%16 = tail call i32 (i32*, i8*, ...) @fprintf(i32* %15, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.5, i64 0, i64 0), i32 %8)
%17 = load i32*, i32** @stderr
%18 = add i32 %9, -32767
%19 = add i32 %18, %14
%20 = sitofp i32 %19 to double
%21 = fmul double %20, 0x3F340028005B44F4
%22 = tail call i32 (i32*, i8*, ...) @fprintf(i32* %17, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.6, i64 0, i64 0), double %21)
%23 = tail call i32 (i32*, i8*, ...) @fprintf(i32* %2, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.6, i64 0, i64 0), double %21)
br label %24
24: ; preds = %13, %6
%25 = tail call i32 @fgetc(i32* %1)
%26 = tail call i32 @fgetc(i32* %1)
%27 = tail call i32 @feof(i32* %1)
%28 = icmp eq i32 %27, 0
br i1 %28, label %29, label %41
29: ; preds = %24
%30 = shl nsw i32 %26, 8
%31 = load i32*, i32** @stderr
%32 = add i32 %25, -32767
%33 = add i32 %32, %30
%34 = sitofp i32 %33 to double
%35 = fmul double %34, 0x3F340028005B44F4
%36 = tail call i32 (i32*, i8*, ...) @fprintf(i32* %31, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.6, i64 0, i64 0), double %35)
%37 = tail call i32 (i32*, i8*, ...) @fprintf(i32* %2, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.6, i64 0, i64 0), double %35)
%38 = load i32*, i32** @stderr
%39 = tail call i32 @fputc(i32 10, i32* %38)
%40 = tail call i32 @fputc(i32 10, i32* %2)
br label %41
41: ; preds = %29, %24
%42 = tail call i32 @feof(i32* %1)
%43 = icmp eq i32 %42, 0
br i1 %43, label %6, label %44
44: ; preds = %41
%45 = load i32*, i32** @stderr
%46 = tail call i32 @fputc(i32 10, i32* %45)
%47 = tail call i32 @fputc(i32 10, i32* %2)
%48 = tail call i32 @fclose(i32* %1)
%49 = tail call i32 @fclose(i32* %2)
ret i32 0
}