#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*/ fread(short *, int, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ fwrite(float *, int, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ printf(char *, char *);
int main(int argc, char *argv[]) {
  short int d;
  float f;
  FILE *in, *out;
  if (argc != 3) {
    printf("Usage: %s <in_int> <out_float>\n", argv[0]);
    return -1;
  }
  if ((in = fopen(argv[1], "rb")) == NULL) {
    printf("open file %s error\n", argv[1]);
    return -1;
  }
  if ((out = fopen(argv[2], "wb")) == NULL) {
    printf("open file %s error\n", argv[2]);
    return -1;
  }
  while (!feof(in)) {
    fread(&d, sizeof(short int), 1, in);
    f = d * 0.01 + 273.15;
    fwrite(&f, sizeof(float), 1, out);
  }
  fclose(in);
  fclose(out);
}


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)
cmpl   $0x3,-0x8(%rbp)
je     119f <main+0x3f>
mov    -0x10(%rbp),%rax
mov    (%rax),%rsi
lea    0xe82(%rip),%rdi
call   1050 <printf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    12b4 <main+0x154>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xe82(%rip),%rsi
call   1070 <fopen@plt>
mov    %rax,-0x20(%rbp)
cmp    $0x0,%rax
jne    11e1 <main+0x81>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rsi
lea    0xe63(%rip),%rdi
call   1050 <printf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    12b4 <main+0x154>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
lea    0xe57(%rip),%rsi
call   1070 <fopen@plt>
mov    %rax,-0x28(%rbp)
cmp    $0x0,%rax
jne    1223 <main+0xc3>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rsi
lea    0xe21(%rip),%rdi
call   1050 <printf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    12b4 <main+0x154>
jmp    1228 <main+0xc8>
mov    -0x20(%rbp),%rdi
call   1060 <feof@plt>
cmp    $0x0,%eax
setne  %al
xor    $0xff,%al
test   $0x1,%al
jne    1246 <main+0xe6>
jmp    12a2 <main+0x142>
mov    -0x20(%rbp),%rcx
lea    -0x12(%rbp),%rdi
mov    $0x2,%esi
mov    $0x1,%edx
call   1030 <fread@plt>
movswl -0x12(%rbp),%eax
cvtsi2sd %eax,%xmm0
movsd  0xd93(%rip),%xmm1
mulsd  %xmm1,%xmm0
movsd  0xd8f(%rip),%xmm1
addsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,-0x18(%rbp)
mov    -0x28(%rbp),%rcx
lea    -0x18(%rbp),%rdi
mov    $0x4,%esi
mov    $0x1,%edx
call   1080 <fwrite@plt>
jmp    1228 <main+0xc8>
mov    -0x20(%rbp),%rdi
call   1040 <fclose@plt>
mov    -0x28(%rbp),%rdi
call   1040 <fclose@plt>
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    %rsi,%r15
cmp    $0x3,%edi
jne    1240 <main+0xe0>
mov    0x8(%r15),%rdi
lea    0xeb1(%rip),%rsi
call   1070 <fopen@plt>
test   %rax,%rax
je     124c <main+0xec>
mov    %rax,%rbx
mov    0x10(%r15),%rdi
lea    0xeac(%rip),%rsi
call   1070 <fopen@plt>
test   %rax,%rax
je     1252 <main+0xf2>
mov    %rax,%r14
mov    %rbx,%rdi
call   1060 <feof@plt>
test   %eax,%eax
jne    122c <main+0xcc>
lea    0x2(%rsp),%r15
lea    0x4(%rsp),%r12
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    %r15,%rdi
mov    $0x2,%esi
mov    $0x1,%edx
mov    %rbx,%rcx
call   1030 <fread@plt>
movswl 0x2(%rsp),%eax
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
mulsd  0xe07(%rip),%xmm0
addsd  0xe07(%rip),%xmm0
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,0x4(%rsp)
mov    %r12,%rdi
mov    $0x4,%esi
mov    $0x1,%edx
mov    %r14,%rcx
call   1080 <fwrite@plt>
mov    %rbx,%rdi
call   1060 <feof@plt>
test   %eax,%eax
je     11d0 <main+0x70>
mov    %rbx,%rdi
call   1040 <fclose@plt>
mov    %r14,%rdi
call   1040 <fclose@plt>
xor    %eax,%eax
jmp    1267 <main+0x107>
mov    (%r15),%rsi
lea    0xdc6(%rip),%rdi
jmp    125d <main+0xfd>
mov    0x8(%r15),%rsi
jmp    1256 <main+0xf6>
mov    0x10(%r15),%rsi
lea    0xdd6(%rip),%rdi
call   1050 <printf@plt>
mov    $0xffffffff,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [32 x i8] c"Usage: %s <in_int> <out_float>\0A\00"
@.str.1 = [3 x i8] c"rb\00"
@.str.2 = [20 x i8] c"open file %s error\0A\00"
@.str.3 = [3 x i8] c"wb\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i16
%7 = alloca float
%8 = alloca i32*
%9 = alloca i32*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%10 = load i32, i32* %4
%11 = icmp ne i32 %10, 3
br i1 %11, label %12, label %17
12: ; preds = %2
%13 = load i8**, i8*** %5
%14 = getelementptr inbounds i8*, i8** %13, i64 0
%15 = load i8*, i8** %14
%16 = call i32 @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str, i64 0, i64 0), i8* %15)
store i32 -1, i32* %3
br label %60
17: ; preds = %2
%18 = load i8**, i8*** %5
%19 = getelementptr inbounds i8*, i8** %18, i64 1
%20 = load i8*, i8** %19
%21 = call i32* @fopen(i8* %20, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
store i32* %21, i32** %8
%22 = icmp eq i32* %21, null
br i1 %22, label %23, label %28
23: ; preds = %17
%24 = load i8**, i8*** %5
%25 = getelementptr inbounds i8*, i8** %24, i64 1
%26 = load i8*, i8** %25
%27 = call i32 @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.2, i64 0, i64 0), i8* %26)
store i32 -1, i32* %3
br label %60
28: ; preds = %17
%29 = load i8**, i8*** %5
%30 = getelementptr inbounds i8*, i8** %29, i64 2
%31 = load i8*, i8** %30
%32 = call i32* @fopen(i8* %31, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0))
store i32* %32, i32** %9
%33 = icmp eq i32* %32, null
br i1 %33, label %34, label %39
34: ; preds = %28
%35 = load i8**, i8*** %5
%36 = getelementptr inbounds i8*, i8** %35, i64 2
%37 = load i8*, i8** %36
%38 = call i32 @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.2, i64 0, i64 0), i8* %37)
store i32 -1, i32* %3
br label %60
39: ; preds = %28
br label %40
40: ; preds = %45, %39
%41 = load i32*, i32** %8
%42 = call i32 @feof(i32* %41)
%43 = icmp ne i32 %42, 0
%44 = xor i1 %43, true
br i1 %44, label %45, label %55
45: ; preds = %40
%46 = load i32*, i32** %8
%47 = call i32 @fread(i16* %6, i32 2, i32 1, i32* %46)
%48 = load i16, i16* %6
%49 = sext i16 %48 to i32
%50 = sitofp i32 %49 to double
%51 = call double @llvm.fmuladd.f64(double %50, double 1.000000e-02, double 2.731500e+02)
%52 = fptrunc double %51 to float
store float %52, float* %7
%53 = load i32*, i32** %9
%54 = call i32 @fwrite(float* %7, i32 4, i32 1, i32* %53)
br label %40
55: ; preds = %40
%56 = load i32*, i32** %8
%57 = call i32 @fclose(i32* %56)
%58 = load i32*, i32** %9
%59 = call i32 @fclose(i32* %58)
br label %60
60: ; preds = %55, %34, %23, %12
%61 = load i32, i32* %3
ret i32 %61
}

LLVM IR (-O2):
@.str = [32 x i8] c"Usage: %s <in_int> <out_float>\0A\00"
@.str.1 = [3 x i8] c"rb\00"
@.str.2 = [20 x i8] c"open file %s error\0A\00"
@.str.3 = [3 x i8] c"wb\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca i16
%4 = alloca float
%5 = bitcast i16* %3 to i8*
%6 = bitcast float* %4 to i8*
%7 = icmp eq i32 %0, 3
br i1 %7, label %11, label %8
8: ; preds = %2
%9 = load i8*, i8** %1
%10 = tail call i32 @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str, i64 0, i64 0), i8* %9)
br label %42
11: ; preds = %2
%12 = getelementptr inbounds i8*, i8** %1, i64 1
%13 = load i8*, i8** %12
%14 = tail call i32* @fopen(i8* %13, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%15 = icmp eq i32* %14, null
br i1 %15, label %16, label %19
16: ; preds = %11
%17 = load i8*, i8** %12
%18 = tail call i32 @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.2, i64 0, i64 0), i8* %17)
br label %42
19: ; preds = %11
%20 = getelementptr inbounds i8*, i8** %1, i64 2
%21 = load i8*, i8** %20
%22 = tail call i32* @fopen(i8* %21, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0))
%23 = icmp eq i32* %22, null
br i1 %23, label %27, label %24
24: ; preds = %19
%25 = tail call i32 @feof(i32* %14)
%26 = icmp eq i32 %25, 0
br i1 %26, label %30, label %39
27: ; preds = %19
%28 = load i8*, i8** %20
%29 = tail call i32 @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.2, i64 0, i64 0), i8* %28)
br label %42
30: ; preds = %24, %30
%31 = call i32 @fread(i16* %3, i32 2, i32 1, i32* %14)
%32 = load i16, i16* %3
%33 = sitofp i16 %32 to double
%34 = tail call double @llvm.fmuladd.f64(double %33, double 1.000000e-02, double 2.731500e+02)
%35 = fptrunc double %34 to float
store float %35, float* %4
%36 = call i32 @fwrite(float* %4, i32 4, i32 1, i32* %22)
%37 = tail call i32 @feof(i32* %14)
%38 = icmp eq i32 %37, 0
br i1 %38, label %30, label %39
39: ; preds = %30, %24
%40 = tail call i32 @fclose(i32* %14)
%41 = tail call i32 @fclose(i32* %22)
br label %42
42: ; preds = %39, %27, %16, %8
%43 = phi i32 [ -1, %8 ], [ -1, %16 ], [ -1, %27 ], [ 0, %39 ]
ret i32 %43
}