#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*/ exit(int);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/ *, char *, double, double);
int fscanf(int /*<<< orphan*/ *, char *, double *, double *);
double myfunc(double);
int /*<<< orphan*/ printf(char *, char *, ...);
int main(int argc, char *argv[]) {
  FILE *ifile;
  FILE *ofile;
  double x, y;
  char *infilename;
  char *outfilename;
  int n;
  int ok;
  if (argc < 3) {
    printf("Usage: %s infile outfile\n", argv[0]);
    exit(1);
  } else {
    infilename = argv[1];
    outfilename = argv[2];
  }
  printf("%s: converting %s to %s\n", argv[0], infilename, outfilename);
  ifile = fopen(infilename, "r");
  ofile = fopen(outfilename, "w");
  ok = 1;
  while (ok) {
    n = fscanf(ifile, "%lf%lf", &x, &y);
    if (n == 2) {
      y = myfunc(y);
      fprintf(ofile, "%g %12.5e\n", x, y);
    } else {
      ok = 0;
    }
  }
  fclose(ifile);
  fclose(ofile);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x3,-0x8(%rbp)
jge    11af <main+0x3f>
mov    -0x10(%rbp),%rax
mov    (%rax),%rsi
lea    0xe62(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    $0x1,%edi
call   1090 <exit@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rax
mov    %rax,-0x38(%rbp)
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rax
mov    %rax,-0x40(%rbp)
mov    -0x10(%rbp),%rax
mov    (%rax),%rsi
mov    -0x38(%rbp),%rdx
mov    -0x40(%rbp),%rcx
lea    0xe3d(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x38(%rbp),%rdi
lea    0xe44(%rip),%rsi
call   1080 <fopen@plt>
mov    %rax,-0x18(%rbp)
mov    -0x40(%rbp),%rdi
lea    0xe32(%rip),%rsi
call   1080 <fopen@plt>
mov    %rax,-0x20(%rbp)
movl   $0x1,-0x48(%rbp)
cmpl   $0x0,-0x48(%rbp)
je     127c <main+0x10c>
mov    -0x18(%rbp),%rdi
lea    0xe0f(%rip),%rsi
lea    -0x28(%rbp),%rdx
lea    -0x30(%rbp),%rcx
call   1060 <fscanf@plt>
mov    %eax,-0x44(%rbp)
cmpl   $0x2,-0x44(%rbp)
jne    1270 <main+0x100>
movsd  -0x30(%rbp),%xmm0
call   1050 <myfunc@plt>
movsd  %xmm0,-0x30(%rbp)
mov    -0x20(%rbp),%rdi
movsd  -0x28(%rbp),%xmm0
movsd  -0x30(%rbp),%xmm1
lea    0xdd8(%rip),%rsi
call   1070 <fprintf@plt>
jmp    1277 <main+0x107>
movl   $0x0,-0x48(%rbp)
jmp    1213 <main+0xa3>
mov    -0x18(%rbp),%rdi
call   1030 <fclose@plt>
mov    -0x20(%rbp),%rdi
call   1030 <fclose@plt>
xor    %eax,%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
cmp    $0x2,%edi
jle    126c <main+0xfc>
mov    (%rsi),%rax
mov    0x8(%rsi),%rbx
mov    0x10(%rsi),%rbp
lea    0xe81(%rip),%rdi
mov    %rax,%rsi
mov    %rbx,%rdx
mov    %rbp,%rcx
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xe83(%rip),%rsi
mov    %rbx,%rdi
call   1080 <fopen@plt>
mov    %rax,%rbx
lea    0xe73(%rip),%rsi
mov    %rbp,%rdi
call   1080 <fopen@plt>
mov    %rax,%r14
lea    0xe63(%rip),%rsi
lea    0x10(%rsp),%rdx
lea    0x8(%rsp),%rcx
mov    %rbx,%rdi
call   1060 <fscanf@plt>
cmp    $0x2,%eax
jne    124b <main+0xdb>
lea    0xe4c(%rip),%r15
lea    0xe3e(%rip),%r12
lea    0x10(%rsp),%r13
lea    0x8(%rsp),%rbp
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
movsd  0x8(%rsp),%xmm0
call   1050 <myfunc@plt>
movaps %xmm0,%xmm1
movsd  %xmm0,0x8(%rsp)
movsd  0x10(%rsp),%xmm0
mov    %r14,%rdi
mov    %r15,%rsi
call   1070 <fprintf@plt>
mov    %rbx,%rdi
mov    %r12,%rsi
mov    %r13,%rdx
mov    %rbp,%rcx
call   1060 <fscanf@plt>
cmp    $0x2,%eax
je     1210 <main+0xa0>
mov    %rbx,%rdi
call   1030 <fclose@plt>
mov    %r14,%rdi
call   1030 <fclose@plt>
xor    %eax,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    (%rsi),%rsi
lea    0xd8a(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    $0x1,%edi
call   1090 <exit@plt>

LLVM IR (-O0):
@.str = [26 x i8] c"Usage: %s infile outfile\0A\00"
@.str.1 = [25 x i8] c"%s: converting %s to %s\0A\00"
@.str.2 = [2 x i8] c"r\00"
@.str.3 = [2 x i8] c"w\00"
@.str.4 = [7 x i8] c"%lf%lf\00"
@.str.5 = [11 x i8] c"%g %12.5e\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 double
%10 = alloca i8*
%11 = alloca i8*
%12 = alloca i32
%13 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%14 = load i32, i32* %4
%15 = icmp slt i32 %14, 3
br i1 %15, label %16, label %22
16: ; preds = %2
%17 = load i8**, i8*** %5
%18 = getelementptr inbounds i8*, i8** %17, i64 0
%19 = load i8*, i8** %18
%20 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str, i64 0, i64 0), i8* %19)
%21 = call i32 @exit(i32 1)
unreachable
22: ; preds = %2
%23 = load i8**, i8*** %5
%24 = getelementptr inbounds i8*, i8** %23, i64 1
%25 = load i8*, i8** %24
store i8* %25, i8** %10
%26 = load i8**, i8*** %5
%27 = getelementptr inbounds i8*, i8** %26, i64 2
%28 = load i8*, i8** %27
store i8* %28, i8** %11
br label %29
29: ; preds = %22
%30 = load i8**, i8*** %5
%31 = getelementptr inbounds i8*, i8** %30, i64 0
%32 = load i8*, i8** %31
%33 = load i8*, i8** %10
%34 = load i8*, i8** %11
%35 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.1, i64 0, i64 0), i8* %32, i8* %33, i8* %34)
%36 = load i8*, i8** %10
%37 = call i32* @fopen(i8* %36, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
store i32* %37, i32** %6
%38 = load i8*, i8** %11
%39 = call i32* @fopen(i8* %38, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
store i32* %39, i32** %7
store i32 1, i32* %13
br label %40
40: ; preds = %56, %29
%41 = load i32, i32* %13
%42 = icmp ne i32 %41, 0
br i1 %42, label %43, label %57
43: ; preds = %40
%44 = load i32*, i32** %6
%45 = call i32 @fscanf(i32* %44, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.4, i64 0, i64 0), double* %8, double* %9)
store i32 %45, i32* %12
%46 = load i32, i32* %12
%47 = icmp eq i32 %46, 2
br i1 %47, label %48, label %55
48: ; preds = %43
%49 = load double, double* %9
%50 = call double @myfunc(double %49)
store double %50, double* %9
%51 = load i32*, i32** %7
%52 = load double, double* %8
%53 = load double, double* %9
%54 = call i32 @fprintf(i32* %51, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.5, i64 0, i64 0), double %52, double %53)
br label %56
55: ; preds = %43
store i32 0, i32* %13
br label %56
56: ; preds = %55, %48
br label %40
57: ; preds = %40
%58 = load i32*, i32** %6
%59 = call i32 @fclose(i32* %58)
%60 = load i32*, i32** %7
%61 = call i32 @fclose(i32* %60)
ret i32 0
}

LLVM IR (-O2):
@.str = [26 x i8] c"Usage: %s infile outfile\0A\00"
@.str.1 = [25 x i8] c"%s: converting %s to %s\0A\00"
@.str.2 = [2 x i8] c"r\00"
@.str.3 = [2 x i8] c"w\00"
@.str.4 = [7 x i8] c"%lf%lf\00"
@.str.5 = [11 x i8] c"%g %12.5e\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca double
%4 = alloca double
%5 = bitcast double* %3 to i8*
%6 = bitcast double* %4 to i8*
%7 = icmp slt i32 %0, 3
br i1 %7, label %8, label %12
8: ; preds = %2
%9 = load i8*, i8** %1
%10 = tail call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str, i64 0, i64 0), i8* %9)
%11 = tail call i32 @exit(i32 1)
unreachable
12: ; preds = %2
%13 = getelementptr inbounds i8*, i8** %1, i64 1
%14 = load i8*, i8** %13
%15 = getelementptr inbounds i8*, i8** %1, i64 2
%16 = load i8*, i8** %15
%17 = load i8*, i8** %1
%18 = tail call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.1, i64 0, i64 0), i8* %17, i8* %14, i8* %16)
%19 = tail call i32* @fopen(i8* %14, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%20 = tail call i32* @fopen(i8* %16, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
%21 = call i32 @fscanf(i32* %19, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.4, i64 0, i64 0), double* %3, double* %4)
%22 = icmp eq i32 %21, 2
br i1 %22, label %23, label %30
23: ; preds = %12, %23
%24 = load double, double* %4
%25 = call double @myfunc(double %24)
store double %25, double* %4
%26 = load double, double* %3
%27 = call i32 @fprintf(i32* %20, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.5, i64 0, i64 0), double %26, double %25)
%28 = call i32 @fscanf(i32* %19, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.4, i64 0, i64 0), double* %3, double* %4)
%29 = icmp eq i32 %28, 2
br i1 %29, label %23, label %30
30: ; preds = %23, %12
%31 = call i32 @fclose(i32* %19)
%32 = call i32 @fclose(i32* %20)
ret i32 0
}