#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(float *, int, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ fwrite(float *, int, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ printf(char *, char *);
int main(int argc, char *argv[]) {
  float c, k;
  FILE *in, *out;
  if (argc != 3) {
    printf("Usage: %s <in_C> <out_K>\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(&c, sizeof(float), 1, in);
    if (c == -9999)
      k = -9999;
    else
      k = c + 273.15;
    fwrite(&k, 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    12d7 <main+0x177>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xe7c(%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    0xe5d(%rip),%rdi
call   1050 <printf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    12d7 <main+0x177>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
lea    0xe51(%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    0xe1b(%rip),%rdi
call   1050 <printf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    12d7 <main+0x177>
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    12c5 <main+0x165>
mov    -0x20(%rbp),%rcx
lea    -0x14(%rbp),%rdi
mov    $0x4,%esi
mov    $0x1,%edx
call   1030 <fread@plt>
movss  -0x14(%rbp),%xmm0
movss  0xd96(%rip),%xmm1
ucomiss %xmm1,%xmm0
jne    128b <main+0x12b>
jp     128b <main+0x12b>
movss  0xd7f(%rip),%xmm0
movss  %xmm0,-0x18(%rbp)
jmp    12a9 <main+0x149>
movss  -0x14(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
movsd  0xd6c(%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    1251 <main+0xf1>
mov    0x8(%r15),%rdi
lea    0xea7(%rip),%rsi
call   1070 <fopen@plt>
test   %rax,%rax
je     125d <main+0xfd>
mov    %rax,%rbx
mov    0x10(%r15),%rdi
lea    0xea2(%rip),%rsi
call   1070 <fopen@plt>
test   %rax,%rax
je     1263 <main+0x103>
mov    %rax,%r14
mov    %rbx,%rdi
call   1060 <feof@plt>
test   %eax,%eax
jne    123d <main+0xdd>
lea    0x4(%rsp),%r15
mov    %rsp,%r12
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    %r15,%rdi
mov    $0x4,%esi
mov    $0x1,%edx
mov    %rbx,%rcx
call   1030 <fread@plt>
movss  0x4(%rsp),%xmm0
xorps  %xmm1,%xmm1
cvtss2sd %xmm0,%xmm1
addsd  0xe06(%rip),%xmm1
cvtsd2ss %xmm1,%xmm1
movss  0xe02(%rip),%xmm3
cmpeqss %xmm3,%xmm0
movaps %xmm0,%xmm2
andps  %xmm3,%xmm2
andnps %xmm1,%xmm0
orps   %xmm2,%xmm0
movss  %xmm0,(%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    1278 <main+0x118>
mov    (%r15),%rsi
lea    0xdb1(%rip),%rdi
jmp    126e <main+0x10e>
mov    0x8(%r15),%rsi
jmp    1267 <main+0x107>
mov    0x10(%r15),%rsi
lea    0xdbb(%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 = [26 x i8] c"Usage: %s <in_C> <out_K>\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 float
%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 ([26 x i8], [26 x i8]* @.str, i64 0, i64 0), i8* %15)
store i32 -1, i32* %3
br label %64
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 %64
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 %64
39: ; preds = %28
br label %40
40: ; preds = %56, %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 %59
45: ; preds = %40
%46 = load i32*, i32** %8
%47 = call i32 @fread(float* %6, i32 4, i32 1, i32* %46)
%48 = load float, float* %6
%49 = fcmp oeq float %48, -9.999000e+03
br i1 %49, label %50, label %51
50: ; preds = %45
store float -9.999000e+03, float* %7
br label %56
51: ; preds = %45
%52 = load float, float* %6
%53 = fpext float %52 to double
%54 = fadd double %53, 2.731500e+02
%55 = fptrunc double %54 to float
store float %55, float* %7
br label %56
56: ; preds = %51, %50
%57 = load i32*, i32** %9
%58 = call i32 @fwrite(float* %7, i32 4, i32 1, i32* %57)
br label %40
59: ; preds = %40
%60 = load i32*, i32** %8
%61 = call i32 @fclose(i32* %60)
%62 = load i32*, i32** %9
%63 = call i32 @fclose(i32* %62)
br label %64
64: ; preds = %59, %34, %23, %12
%65 = load i32, i32* %3
ret i32 %65
}

LLVM IR (-O2):
@.str = [26 x i8] c"Usage: %s <in_C> <out_K>\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 float
%4 = alloca float
%5 = bitcast float* %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 ([26 x i8], [26 x i8]* @.str, i64 0, i64 0), i8* %9)
br label %44
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 %44
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 %41
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 %44
30: ; preds = %24, %30
%31 = call i32 @fread(float* %3, i32 4, i32 1, i32* %14)
%32 = load float, float* %3
%33 = fcmp oeq float %32, -9.999000e+03
%34 = fpext float %32 to double
%35 = fadd double %34, 2.731500e+02
%36 = fptrunc double %35 to float
%37 = select i1 %33, float -9.999000e+03, float %36
store float %37, float* %4
%38 = call i32 @fwrite(float* %4, i32 4, i32 1, i32* %22)
%39 = tail call i32 @feof(i32* %14)
%40 = icmp eq i32 %39, 0
br i1 %40, label %30, label %41
41: ; preds = %30, %24
%42 = tail call i32 @fclose(i32* %14)
%43 = tail call i32 @fclose(i32* %22)
br label %44
44: ; preds = %41, %27, %16, %8
%45 = phi i32 [ -1, %8 ], [ -1, %16 ], [ -1, %27 ], [ 0, %41 ]
ret i32 %45
}