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

/* Variables and functions */
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ feof(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ free(char *);
scalar_t__ getline(char **, size_t *, int /*<<< orphan*/ *);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ scanf(char *, char *);
int main() {
  char path[4096];
  printf("Please enter path to file: ");
  scanf("%s", path);
  FILE *file = fopen(path, "r");
  char buffer[4096 + 1];
  if (file) {
    char *line;
    size_t length = 0;
    int isOdd = 1;
    while (!feof(file)) {
      ssize_t readBytes = getline(&line, &length, file);
      if (readBytes <= 0) {
        break;
      }
      if (isOdd) {
        printf("%s", line);
      }
      isOdd = !isOdd;
    }
    free(line);
  }
  fclose(file);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x2040,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xe77(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    -0x1010(%rbp),%rsi
lea    0xe7e(%rip),%rdi
call   1070 <scanf@plt>
lea    -0x1010(%rbp),%rdi
lea    0xe6e(%rip),%rsi
call   1080 <fopen@plt>
mov    %rax,-0x1018(%rbp)
cmpq   $0x0,-0x1018(%rbp)
je     127f <main+0x10f>
movq   $0x0,-0x2030(%rbp)
movl   $0x1,-0x2034(%rbp)
mov    -0x1018(%rbp),%rdi
call   1060 <feof@plt>
cmp    $0x0,%eax
setne  %al
xor    $0xff,%al
test   $0x1,%al
jne    1201 <main+0x91>
jmp    1273 <main+0x103>
mov    -0x1018(%rbp),%rdx
lea    -0x2028(%rbp),%rdi
lea    -0x2030(%rbp),%rsi
call   1090 <getline@plt>
mov    %rax,-0x2040(%rbp)
cmpq   $0x0,-0x2040(%rbp)
jg     1235 <main+0xc5>
jmp    1273 <main+0x103>
cmpl   $0x0,-0x2034(%rbp)
je     1257 <main+0xe7>
mov    -0x2028(%rbp),%rsi
lea    0xdcc(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
cmpl   $0x0,-0x2034(%rbp)
setne  %al
xor    $0xff,%al
and    $0x1,%al
movzbl %al,%eax
mov    %eax,-0x2034(%rbp)
jmp    11e0 <main+0x70>
mov    -0x2028(%rbp),%rdi
call   1030 <free@plt>
mov    -0x1018(%rbp),%rdi
call   1040 <fclose@plt>
xor    %eax,%eax
add    $0x2040,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x1010,%rsp
lea    0xe7a(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xe88(%rip),%rdi
lea    0x10(%rsp),%rbx
mov    %rbx,%rsi
call   1070 <scanf@plt>
lea    0xe77(%rip),%rsi
mov    %rbx,%rdi
call   1080 <fopen@plt>
mov    %rax,%rbx
test   %rax,%rax
je     121f <main+0xaf>
movq   $0x0,0x8(%rsp)
mov    %rbx,%rdi
call   1060 <feof@plt>
mov    $0x1,%ebp
mov    %rsp,%r14
lea    0x8(%rsp),%r15
lea    0xe3f(%rip),%r12
jmp    11ef <main+0x7f>
nop
xor    $0x1,%ebp
mov    %rbx,%rdi
call   1060 <feof@plt>
test   %eax,%eax
jne    1216 <main+0xa6>
mov    %r14,%rdi
mov    %r15,%rsi
mov    %rbx,%rdx
call   1090 <getline@plt>
test   %rax,%rax
jle    1216 <main+0xa6>
test   %ebp,%ebp
je     11e0 <main+0x70>
mov    (%rsp),%rsi
mov    %r12,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
jmp    11e0 <main+0x70>
mov    (%rsp),%rdi
call   1030 <free@plt>
mov    %rbx,%rdi
call   1040 <fclose@plt>
xor    %eax,%eax
add    $0x1010,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [28 x i8] c"Please enter path to file: \00"
@.str.1 = [3 x i8] c"%s\00"
@.str.2 = [2 x i8] c"r\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [4096 x i8]
%3 = alloca i32*
%4 = alloca [4097 x i8]
%5 = alloca i8*
%6 = alloca i64
%7 = alloca i32
%8 = alloca i64
store i32 0, i32* %1
%9 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str, i64 0, i64 0))
%10 = getelementptr inbounds [4096 x i8], [4096 x i8]* %2, i64 0, i64 0
%11 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %10)
%12 = getelementptr inbounds [4096 x i8], [4096 x i8]* %2, i64 0, i64 0
%13 = call i32* @fopen(i8* %12, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
store i32* %13, i32** %3
%14 = load i32*, i32** %3
%15 = icmp ne i32* %14, null
br i1 %15, label %16, label %42
16: ; preds = %0
store i64 0, i64* %6
store i32 1, i32* %7
br label %17
17: ; preds = %34, %16
%18 = load i32*, i32** %3
%19 = call i32 @feof(i32* %18)
%20 = icmp ne i32 %19, 0
%21 = xor i1 %20, true
br i1 %21, label %22, label %39
22: ; preds = %17
%23 = load i32*, i32** %3
%24 = call i64 @getline(i8** %5, i64* %6, i32* %23)
store i64 %24, i64* %8
%25 = load i64, i64* %8
%26 = icmp sle i64 %25, 0
br i1 %26, label %27, label %28
27: ; preds = %22
br label %39
28: ; preds = %22
%29 = load i32, i32* %7
%30 = icmp ne i32 %29, 0
br i1 %30, label %31, label %34
31: ; preds = %28
%32 = load i8*, i8** %5
%33 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %32)
br label %34
34: ; preds = %31, %28
%35 = load i32, i32* %7
%36 = icmp ne i32 %35, 0
%37 = xor i1 %36, true
%38 = zext i1 %37 to i32
store i32 %38, i32* %7
br label %17
39: ; preds = %27, %17
%40 = load i8*, i8** %5
%41 = call i32 @free(i8* %40)
br label %42
42: ; preds = %39, %0
%43 = load i32*, i32** %3
%44 = call i32 @fclose(i32* %43)
ret i32 0
}

LLVM IR (-O2):
@.str = [28 x i8] c"Please enter path to file: \00"
@.str.1 = [3 x i8] c"%s\00"
@.str.2 = [2 x i8] c"r\00"
define i32 @main() {
%1 = alloca [4096 x i8]
%2 = alloca i8*
%3 = alloca i64
%4 = getelementptr inbounds [4096 x i8], [4096 x i8]* %1, i64 0, i64 0
%5 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([28 x i8], [28 x i8]* @.str, i64 0, i64 0))
%6 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %4)
%7 = call i32* @fopen(i8* %4, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%8 = icmp eq i32* %7, null
br i1 %8, label %30, label %9
9: ; preds = %0
%10 = bitcast i8** %2 to i8*
%11 = bitcast i64* %3 to i8*
store i64 0, i64* %3
%12 = call i32 @feof(i32* %7)
%13 = icmp eq i32 %12, 0
br label %14
14: ; preds = %9, %23
%15 = phi i32 [ %24, %23 ], [ 1, %9 ]
%16 = call i64 @getline(i8** %2, i64* %3, i32* %7)
%17 = icmp slt i64 %16, 1
br i1 %17, label %27, label %18
18: ; preds = %14
%19 = icmp eq i32 %15, 0
br i1 %19, label %23, label %20
20: ; preds = %18
%21 = load i8*, i8** %2
%22 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %21)
br label %23
23: ; preds = %18, %20
%24 = xor i32 %15, 1
%25 = call i32 @feof(i32* %7)
%26 = icmp eq i32 %25, 0
br i1 %26, label %14, label %27
27: ; preds = %14, %23
%28 = load i8*, i8** %2
%29 = call i32 @free(i8* %28)
br label %30
30: ; preds = %27, %0
%31 = call i32 @fclose(i32* %7)
ret i32 0
}