#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*/ Readable(char *);
int /*<<< orphan*/ *fgets(char *, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ strcpy(char *, char *);
void NextLine(FILE *fid, char *cmdstr, int *lno) {
  strcpy(cmdstr, "\0");
  while (!Readable(cmdstr)) {
    if (fgets(cmdstr, 1024, fid) == NULL) {
      strcpy(cmdstr, "EOF");
      break;
    } else {
      (*lno)++;
    }
  }
}


x86 assembly (clang, -O0):
<NextLine>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
lea    0xeb1(%rip),%rsi
call   1030 <strcpy@plt>
mov    -0x10(%rbp),%rdi
call   1050 <Readable@plt>
cmp    $0x0,%eax
setne  %al
xor    $0xff,%al
test   $0x1,%al
jne    1172 <NextLine+0x42>
jmp    11b3 <NextLine+0x83>
mov    -0x10(%rbp),%rdi
mov    -0x8(%rbp),%rdx
mov    $0x400,%esi
call   1040 <fgets@plt>
cmp    $0x0,%rax
jne    11a3 <NextLine+0x73>
mov    -0x10(%rbp),%rdi
lea    0xe69(%rip),%rsi
call   1030 <strcpy@plt>
jmp    11b3 <NextLine+0x83>
mov    -0x18(%rbp),%rax
mov    (%rax),%ecx
add    $0x1,%ecx
mov    %ecx,(%rax)
jmp    1154 <NextLine+0x24>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<NextLine>:
push   %r15
push   %r14
push   %rbx
mov    %rdx,%r14
mov    %rsi,%rbx
mov    %rdi,%r15
lea    0xebb(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strcpy@plt>
nopl   (%rax)
mov    %rbx,%rdi
call   1050 <Readable@plt>
test   %eax,%eax
jne    1177 <NextLine+0x47>
mov    %rbx,%rdi
mov    $0x400,%esi
mov    %r15,%rdx
call   1040 <fgets@plt>
test   %rax,%rax
je     117d <NextLine+0x4d>
addl   $0x1,(%r14)
jmp    1150 <NextLine+0x20>
pop    %rbx
pop    %r14
pop    %r15
ret
lea    0xe7e(%rip),%rsi
mov    %rbx,%rdi
pop    %rbx
pop    %r14
pop    %r15
jmp    1030 <strcpy@plt>

LLVM IR (-O0):
@.str = [2 x i8] zeroinitializer
@.str.1 = [4 x i8] c"EOF\00"
define void @NextLine(i32* %0, i8* %1, i32* %2) {
%4 = alloca i32*
%5 = alloca i8*
%6 = alloca i32*
store i32* %0, i32** %4
store i8* %1, i8** %5
store i32* %2, i32** %6
%7 = load i8*, i8** %5
%8 = call i32 @strcpy(i8* %7, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
br label %9
9: ; preds = %26, %3
%10 = load i8*, i8** %5
%11 = call i32 @Readable(i8* %10)
%12 = icmp ne i32 %11, 0
%13 = xor i1 %12, true
br i1 %13, label %14, label %27
14: ; preds = %9
%15 = load i8*, i8** %5
%16 = load i32*, i32** %4
%17 = call i32* @fgets(i8* %15, i32 1024, i32* %16)
%18 = icmp eq i32* %17, null
br i1 %18, label %19, label %22
19: ; preds = %14
%20 = load i8*, i8** %5
%21 = call i32 @strcpy(i8* %20, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0))
br label %27
22: ; preds = %14
%23 = load i32*, i32** %6
%24 = load i32, i32* %23
%25 = add nsw i32 %24, 1
store i32 %25, i32* %23
br label %26
26: ; preds = %22
br label %9
27: ; preds = %19, %9
ret void
}

LLVM IR (-O2):
@.str = [2 x i8] zeroinitializer
@.str.1 = [4 x i8] c"EOF\00"
define void @NextLine(i32* nocapture %0, i8* %1, i32* nocapture %2) {
%4 = tail call i32 @strcpy(i8* %1, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%5 = tail call i32 @Readable(i8* %1)
%6 = icmp eq i32 %5, 0
br i1 %6, label %7, label %17
7: ; preds = %3, %12
%8 = tail call i32* @fgets(i8* %1, i32 1024, i32* %0)
%9 = icmp eq i32* %8, null
br i1 %9, label %10, label %12
10: ; preds = %7
%11 = tail call i32 @strcpy(i8* %1, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0))
br label %17
12: ; preds = %7
%13 = load i32, i32* %2
%14 = add nsw i32 %13, 1
store i32 %14, i32* %2
%15 = tail call i32 @Readable(i8* %1)
%16 = icmp eq i32 %15, 0
br i1 %16, label %7, label %17
17: ; preds = %12, %3, %10
ret void
}