#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*/ ssize_t;
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int EXIT_SUCCESS;
int /*<<< orphan*/ error(char *);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ feof(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/ *, char *, ...);
int /*<<< orphan*/ free(char *);
int /*<<< orphan*/ read_line(char **, size_t *, int /*<<< orphan*/ *);
int main() {
  char *srcFileName = "oddLines.txt";
  char *destFileName = "dest.txt";
  FILE *srcFile = fopen(srcFileName, "r");
  if (!srcFile) {
    error(srcFileName);
  }
  FILE *dest = fopen(destFileName, "w");
  if (!dest) {
    error(destFileName);
  }
  char *buffer = NULL;
  size_t size = 0;
  int lineNumber = 1;
  ssize_t byteRead;
  while (!feof(srcFile)) {
    byteRead = read_line(&buffer, &size, srcFile);
    fprintf(dest, "%3d ", lineNumber);
    fprintf(dest, "%s\n", buffer);
    lineNumber++;
  }
  free(buffer);
  fclose(srcFile);
  fclose(dest);
  return (EXIT_SUCCESS);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xe7a(%rip),%rax
mov    %rax,-0x10(%rbp)
lea    0xe7c(%rip),%rax
mov    %rax,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
lea    0xe76(%rip),%rsi
call   1090 <fopen@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
jne    11bd <main+0x4d>
mov    -0x10(%rbp),%rdi
call   1080 <error@plt>
mov    -0x18(%rbp),%rdi
lea    0xe50(%rip),%rsi
call   1090 <fopen@plt>
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
jne    11e5 <main+0x75>
mov    -0x18(%rbp),%rdi
call   1080 <error@plt>
movq   $0x0,-0x30(%rbp)
movq   $0x0,-0x38(%rbp)
movl   $0x1,-0x3c(%rbp)
mov    -0x20(%rbp),%rdi
call   1060 <feof@plt>
cmp    $0x0,%eax
setne  %al
xor    $0xff,%al
test   $0x1,%al
jne    121a <main+0xaa>
jmp    1267 <main+0xf7>
mov    -0x20(%rbp),%rdx
lea    -0x30(%rbp),%rdi
lea    -0x38(%rbp),%rsi
call   1070 <read_line@plt>
mov    %eax,-0x40(%rbp)
mov    -0x28(%rbp),%rdi
mov    -0x3c(%rbp),%edx
lea    0xdde(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
mov    -0x28(%rbp),%rdi
mov    -0x30(%rbp),%rdx
lea    0xdcd(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
mov    -0x3c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x3c(%rbp)
jmp    11fc <main+0x8c>
mov    -0x30(%rbp),%rdi
call   1030 <free@plt>
mov    -0x20(%rbp),%rdi
call   1040 <fclose@plt>
mov    -0x28(%rbp),%rdi
call   1040 <fclose@plt>
mov    0x2d57(%rip),%rax
mov    (%rax),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
lea    0xe7b(%rip),%rdi
lea    0xe8a(%rip),%rsi
call   1090 <fopen@plt>
mov    %rax,%r14
test   %rax,%rax
jne    11a5 <main+0x35>
lea    0xe60(%rip),%rdi
call   1080 <error@plt>
lea    0xe61(%rip),%rdi
lea    0xe65(%rip),%rsi
call   1090 <fopen@plt>
mov    %rax,%rbx
test   %rax,%rax
jne    11cc <main+0x5c>
lea    0xe46(%rip),%rdi
call   1080 <error@plt>
movq   $0x0,0x8(%rsp)
movq   $0x0,0x10(%rsp)
mov    %r14,%rdi
call   1060 <feof@plt>
test   %eax,%eax
je     11ee <main+0x7e>
xor    %edi,%edi
jmp    1255 <main+0xe5>
mov    $0x1,%ebp
lea    0x10(%rsp),%r12
lea    0xe1b(%rip),%r13
lea    0xe19(%rip),%r15
cs nopw 0x0(%rax,%rax,1)
lea    0x8(%rsp),%rdi
mov    %r12,%rsi
mov    %r14,%rdx
call   1070 <read_line@plt>
mov    %rbx,%rdi
mov    %r13,%rsi
mov    %ebp,%edx
xor    %eax,%eax
call   1050 <fprintf@plt>
mov    0x8(%rsp),%rdx
mov    %rbx,%rdi
mov    %r15,%rsi
xor    %eax,%eax
call   1050 <fprintf@plt>
add    $0x1,%ebp
mov    %r14,%rdi
call   1060 <feof@plt>
test   %eax,%eax
je     1210 <main+0xa0>
mov    0x8(%rsp),%rdi
call   1030 <free@plt>
mov    %r14,%rdi
call   1040 <fclose@plt>
mov    %rbx,%rdi
call   1040 <fclose@plt>
mov    0x2d6f(%rip),%rax
mov    (%rax),%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [13 x i8] c"oddLines.txt\00"
@.str.1 = [9 x i8] c"dest.txt\00"
@.str.2 = [2 x i8] c"r\00"
@.str.3 = [2 x i8] c"w\00"
@.str.4 = [5 x i8] c"%3d \00"
@.str.5 = [4 x i8] c"%s\0A\00"
@EXIT_SUCCESS = global i32 0
define i32 @main() {
%1 = alloca i32
%2 = alloca i8*
%3 = alloca i8*
%4 = alloca i32*
%5 = alloca i32*
%6 = alloca i8*
%7 = alloca i64
%8 = alloca i32
%9 = alloca i32
store i32 0, i32* %1
store i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), i8** %2
store i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), i8** %3
%10 = load i8*, i8** %2
%11 = call i32* @fopen(i8* %10, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
store i32* %11, i32** %4
%12 = load i32*, i32** %4
%13 = icmp ne i32* %12, null
br i1 %13, label %17, label %14
14: ; preds = %0
%15 = load i8*, i8** %2
%16 = call i32 @error(i8* %15)
br label %17
17: ; preds = %14, %0
%18 = load i8*, i8** %3
%19 = call i32* @fopen(i8* %18, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
store i32* %19, i32** %5
%20 = load i32*, i32** %5
%21 = icmp ne i32* %20, null
br i1 %21, label %25, label %22
22: ; preds = %17
%23 = load i8*, i8** %3
%24 = call i32 @error(i8* %23)
br label %25
25: ; preds = %22, %17
store i8* null, i8** %6
store i64 0, i64* %7
store i32 1, i32* %8
br label %26
26: ; preds = %31, %25
%27 = load i32*, i32** %4
%28 = call i32 @feof(i32* %27)
%29 = icmp ne i32 %28, 0
%30 = xor i1 %29, true
br i1 %30, label %31, label %42
31: ; preds = %26
%32 = load i32*, i32** %4
%33 = call i32 @read_line(i8** %6, i64* %7, i32* %32)
store i32 %33, i32* %9
%34 = load i32*, i32** %5
%35 = load i32, i32* %8
%36 = call i32 (i32*, i8*, ...) @fprintf(i32* %34, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0), i32 %35)
%37 = load i32*, i32** %5
%38 = load i8*, i8** %6
%39 = call i32 (i32*, i8*, ...) @fprintf(i32* %37, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.5, i64 0, i64 0), i8* %38)
%40 = load i32, i32* %8
%41 = add nsw i32 %40, 1
store i32 %41, i32* %8
br label %26
42: ; preds = %26
%43 = load i8*, i8** %6
%44 = call i32 @free(i8* %43)
%45 = load i32*, i32** %4
%46 = call i32 @fclose(i32* %45)
%47 = load i32*, i32** %5
%48 = call i32 @fclose(i32* %47)
%49 = load i32, i32* @EXIT_SUCCESS
ret i32 %49
}

LLVM IR (-O2):
@.str = [13 x i8] c"oddLines.txt\00"
@.str.1 = [9 x i8] c"dest.txt\00"
@.str.2 = [2 x i8] c"r\00"
@.str.3 = [2 x i8] c"w\00"
@.str.4 = [5 x i8] c"%3d \00"
@.str.5 = [4 x i8] c"%s\0A\00"
@EXIT_SUCCESS = global i32 0
define i32 @main() {
%1 = alloca i8*
%2 = alloca i64
%3 = tail call i32* @fopen(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%4 = icmp eq i32* %3, null
br i1 %4, label %5, label %7
5: ; preds = %0
%6 = tail call i32 @error(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0))
br label %7
7: ; preds = %5, %0
%8 = tail call i32* @fopen(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
%9 = icmp eq i32* %8, null
br i1 %9, label %10, label %12
10: ; preds = %7
%11 = tail call i32 @error(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0))
br label %12
12: ; preds = %10, %7
%13 = bitcast i8** %1 to i8*
store i8* null, i8** %1
%14 = bitcast i64* %2 to i8*
store i64 0, i64* %2
%15 = call i32 @feof(i32* %3)
%16 = icmp eq i32 %15, 0
br i1 %16, label %17, label %28
17: ; preds = %12, %17
%18 = phi i32 [ %23, %17 ], [ 1, %12 ]
%19 = call i32 @read_line(i8** %1, i64* %2, i32* %3)
%20 = call i32 (i32*, i8*, ...) @fprintf(i32* %8, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0), i32 %18)
%21 = load i8*, i8** %1
%22 = call i32 (i32*, i8*, ...) @fprintf(i32* %8, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.5, i64 0, i64 0), i8* %21)
%23 = add nuw nsw i32 %18, 1
%24 = call i32 @feof(i32* %3)
%25 = icmp eq i32 %24, 0
br i1 %25, label %17, label %26
26: ; preds = %17
%27 = load i8*, i8** %1
br label %28
28: ; preds = %26, %12
%29 = phi i8* [ %27, %26 ], [ null, %12 ]
%30 = call i32 @free(i8* %29)
%31 = call i32 @fclose(i32* %3)
%32 = call i32 @fclose(i32* %8)
%33 = load i32, i32* @EXIT_SUCCESS
ret i32 %33
}