#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 */
double atof(char *);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/ *, char *, char *, double);
scalar_t__ getline(int /*<<< orphan*/ *, char *, int);
int /*<<< orphan*/ perror(char *);
int main(int argc, char *argv[]) {
  FILE *in, *out;
  in = fopen("input.dat", "r");
  if (in == NULL) {
    perror("input.dat");
    return 1;
  }
  out = fopen("output.dat", "w");
  if (out == NULL) {
    perror("output.dat");
    return 1;
  }
  double val;
  char str[128];
  while (getline(in, str, 128) > 0) {
    val = atof(str);
    fprintf(out, "atof('%s') = %g\n", str, val);
  }
  fclose(in);
  fclose(out);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0xb0,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    0xe80(%rip),%rdi
lea    0xe83(%rip),%rsi
call   1060 <fopen@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    11b3 <main+0x53>
lea    0xe5e(%rip),%rdi
call   1070 <perror@plt>
movl   $0x1,-0x4(%rbp)
jmp    125c <main+0xfc>
lea    0xe52(%rip),%rdi
lea    0xe56(%rip),%rsi
call   1060 <fopen@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
jne    11ed <main+0x8d>
lea    0xe30(%rip),%rdi
call   1070 <perror@plt>
movl   $0x1,-0x4(%rbp)
jmp    125c <main+0xfc>
jmp    11f2 <main+0x92>
mov    -0x18(%rbp),%rdi
lea    -0xb0(%rbp),%rsi
mov    $0x80,%edx
call   1080 <getline@plt>
cmp    $0x0,%rax
jle    1243 <main+0xe3>
lea    -0xb0(%rbp),%rdi
call   1030 <atof@plt>
movsd  %xmm0,-0x28(%rbp)
mov    -0x20(%rbp),%rdi
lea    -0xb0(%rbp),%rdx
movsd  -0x28(%rbp),%xmm0
lea    0xde0(%rip),%rsi
call   1050 <fprintf@plt>
jmp    11f2 <main+0x92>
mov    -0x18(%rbp),%rdi
call   1040 <fclose@plt>
mov    -0x20(%rbp),%rdi
call   1040 <fclose@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0xb0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x88,%rsp
lea    0xe8b(%rip),%rdi
lea    0xe8e(%rip),%rsi
call   1060 <fopen@plt>
test   %rax,%rax
je     121c <main+0xbc>
mov    %rax,%r14
lea    0xe78(%rip),%rdi
lea    0xe7c(%rip),%rsi
call   1060 <fopen@plt>
test   %rax,%rax
je     1225 <main+0xc5>
mov    %rax,%r15
mov    %rsp,%rsi
mov    %r14,%rdi
mov    $0x80,%edx
call   1080 <getline@plt>
test   %rax,%rax
jle    11fb <main+0x9b>
mov    %rsp,%rbx
lea    0xe4e(%rip),%r12
nopl   0x0(%rax,%rax,1)
mov    %rbx,%rdi
call   1030 <atof@plt>
mov    %r15,%rdi
mov    %r12,%rsi
mov    %rbx,%rdx
call   1050 <fprintf@plt>
mov    %r14,%rdi
mov    %rbx,%rsi
mov    $0x80,%edx
call   1080 <getline@plt>
test   %rax,%rax
jg     11d0 <main+0x70>
mov    %r14,%rdi
call   1040 <fclose@plt>
mov    %r15,%rdi
call   1040 <fclose@plt>
xor    %eax,%eax
add    $0x88,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret
lea    0xddd(%rip),%rdi
jmp    122c <main+0xcc>
lea    0xde0(%rip),%rdi
call   1070 <perror@plt>
mov    $0x1,%eax
jmp    120d <main+0xad>

LLVM IR (-O0):
@.str = [10 x i8] c"input.dat\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [11 x i8] c"output.dat\00"
@.str.3 = [2 x i8] c"w\00"
@.str.4 = [17 x i8] c"atof('%s') = %g\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32*
%7 = alloca i32*
%8 = alloca double
%9 = alloca [128 x i8]
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%10 = call i32* @fopen(i8* getelementptr inbounds ([10 x i8], [10 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** %6
%11 = load i32*, i32** %6
%12 = icmp eq i32* %11, null
br i1 %12, label %13, label %15
13: ; preds = %2
%14 = call i32 @perror(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0))
store i32 1, i32* %3
br label %39
15: ; preds = %2
%16 = call i32* @fopen(i8* getelementptr inbounds ([11 x i8], [11 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* %16, i32** %7
%17 = load i32*, i32** %7
%18 = icmp eq i32* %17, null
br i1 %18, label %19, label %21
19: ; preds = %15
%20 = call i32 @perror(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.2, i64 0, i64 0))
store i32 1, i32* %3
br label %39
21: ; preds = %15
br label %22
22: ; preds = %27, %21
%23 = load i32*, i32** %6
%24 = getelementptr inbounds [128 x i8], [128 x i8]* %9, i64 0, i64 0
%25 = call i64 @getline(i32* %23, i8* %24, i32 128)
%26 = icmp sgt i64 %25, 0
br i1 %26, label %27, label %34
27: ; preds = %22
%28 = getelementptr inbounds [128 x i8], [128 x i8]* %9, i64 0, i64 0
%29 = call double @atof(i8* %28)
store double %29, double* %8
%30 = load i32*, i32** %7
%31 = getelementptr inbounds [128 x i8], [128 x i8]* %9, i64 0, i64 0
%32 = load double, double* %8
%33 = call i32 @fprintf(i32* %30, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.4, i64 0, i64 0), i8* %31, double %32)
br label %22
34: ; preds = %22
%35 = load i32*, i32** %6
%36 = call i32 @fclose(i32* %35)
%37 = load i32*, i32** %7
%38 = call i32 @fclose(i32* %37)
store i32 0, i32* %3
br label %39
39: ; preds = %34, %19, %13
%40 = load i32, i32* %3
ret i32 %40
}

LLVM IR (-O2):
@.str = [10 x i8] c"input.dat\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [11 x i8] c"output.dat\00"
@.str.3 = [2 x i8] c"w\00"
@.str.4 = [17 x i8] c"atof('%s') = %g\0A\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca [128 x i8]
%4 = tail call i32* @fopen(i8* getelementptr inbounds ([10 x i8], [10 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 @perror(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0))
br label %25
8: ; preds = %2
%9 = tail call i32* @fopen(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
%10 = icmp eq i32* %9, null
br i1 %10, label %11, label %13
11: ; preds = %8
%12 = tail call i32 @perror(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.2, i64 0, i64 0))
br label %25
13: ; preds = %8
%14 = getelementptr inbounds [128 x i8], [128 x i8]* %3, i64 0, i64 0
%15 = call i64 @getline(i32* %4, i8* %14, i32 128)
%16 = icmp sgt i64 %15, 0
br i1 %16, label %17, label %22
17: ; preds = %13, %17
%18 = call double @atof(i8* %14)
%19 = call i32 @fprintf(i32* %9, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.4, i64 0, i64 0), i8* %14, double %18)
%20 = call i64 @getline(i32* %4, i8* %14, i32 128)
%21 = icmp sgt i64 %20, 0
br i1 %21, label %17, label %22
22: ; preds = %17, %13
%23 = call i32 @fclose(i32* %4)
%24 = call i32 @fclose(i32* %9)
br label %25
25: ; preds = %22, %11, %6
%26 = phi i32 [ 1, %6 ], [ 1, %11 ], [ 0, %22 ]
ret i32 %26
}