#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 EOF;
int getc(int /*<<< orphan*/ *);
int /*<<< orphan*/ opt_warning(char *);
int opt_getline(char *line, FILE *fp) {
  int c;
  int count = 0;
  while ((c = getc(fp)) != '\n' && c != EOF) {
    *line = (char)c;
    ++line;
    if (++count > 2560 - 3) {
      opt_warning("Options line too long");
      break;
    }
  }
  *line++ = '\0';
  *line++ = '\0';
  return (count);
}


x86 assembly (clang, -O0):
<opt_getline>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
call   1040 <getc@plt>
mov    %eax,%ecx
mov    %ecx,-0x14(%rbp)
xor    %eax,%eax
cmp    $0xa,%ecx
mov    %al,-0x19(%rbp)
je     1165 <opt_getline+0x45>
mov    -0x14(%rbp),%eax
mov    0x2e8b(%rip),%rcx
cmp    (%rcx),%eax
setne  %al
mov    %al,-0x19(%rbp)
mov    -0x19(%rbp),%al
test   $0x1,%al
jne    1175 <opt_getline+0x55>
jmp    11b6 <opt_getline+0x96>
mov    -0x14(%rbp),%eax
mov    %al,%cl
mov    -0x8(%rbp),%rax
mov    %cl,(%rax)
mov    -0x8(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x8(%rbp)
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
cmp    $0x9fd,%eax
jle    11b1 <opt_getline+0x91>
lea    0xe59(%rip),%rdi
call   1030 <opt_warning@plt>
jmp    11b6 <opt_getline+0x96>
jmp    1137 <opt_getline+0x17>
mov    -0x8(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x8(%rbp)
movb   $0x0,(%rax)
mov    -0x8(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x8(%rbp)
movb   $0x0,(%rax)
mov    -0x18(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<opt_getline>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    %rsi,%r15
mov    %rdi,%r14
xor    %ebx,%ebx
mov    0x2eb1(%rip),%r12
nopw   0x0(%rax,%rax,1)
mov    %r15,%rdi
call   1040 <getc@plt>
cmp    $0xa,%eax
je     1179 <opt_getline+0x59>
cmp    (%r12),%eax
je     1179 <opt_getline+0x59>
mov    %al,(%r14,%rbx,1)
add    $0x1,%rbx
cmp    $0x9fe,%ebx
jne    1140 <opt_getline+0x20>
lea    0xe96(%rip),%rdi
call   1030 <opt_warning@plt>
add    %rbx,%r14
mov    $0x9fe,%ebx
jmp    117c <opt_getline+0x5c>
add    %rbx,%r14
movw   $0x0,(%r14)
mov    %ebx,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@EOF = global i32 0
@.str = [22 x i8] c"Options line too long\00"
define i32 @opt_getline(i8* %0, i32* %1) {
%3 = alloca i8*
%4 = alloca i32*
%5 = alloca i32
%6 = alloca i32
store i8* %0, i8** %3
store i32* %1, i32** %4
store i32 0, i32* %6
br label %7
7: ; preds = %28, %2
%8 = load i32*, i32** %4
%9 = call i32 @getc(i32* %8)
store i32 %9, i32* %5
%10 = icmp ne i32 %9, 10
br i1 %10, label %11, label %15
11: ; preds = %7
%12 = load i32, i32* %5
%13 = load i32, i32* @EOF
%14 = icmp ne i32 %12, %13
br label %15
15: ; preds = %11, %7
%16 = phi i1 [ false, %7 ], [ %14, %11 ]
br i1 %16, label %17, label %29
17: ; preds = %15
%18 = load i32, i32* %5
%19 = trunc i32 %18 to i8
%20 = load i8*, i8** %3
store i8 %19, i8* %20
%21 = load i8*, i8** %3
%22 = getelementptr inbounds i8, i8* %21, i32 1
store i8* %22, i8** %3
%23 = load i32, i32* %6
%24 = add nsw i32 %23, 1
store i32 %24, i32* %6
%25 = icmp sgt i32 %24, 2557
br i1 %25, label %26, label %28
26: ; preds = %17
%27 = call i32 @opt_warning(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0))
br label %29
28: ; preds = %17
br label %7
29: ; preds = %26, %15
%30 = load i8*, i8** %3
%31 = getelementptr inbounds i8, i8* %30, i32 1
store i8* %31, i8** %3
store i8 0, i8* %30
%32 = load i8*, i8** %3
%33 = getelementptr inbounds i8, i8* %32, i32 1
store i8* %33, i8** %3
store i8 0, i8* %32
%34 = load i32, i32* %6
ret i32 %34
}

LLVM IR (-O2):
@EOF = global i32 0
@.str = [22 x i8] c"Options line too long\00"
define i32 @opt_getline(i8* nocapture writeonly %0, i32* nocapture %1) {
br label %3
3: ; preds = %11, %2
%4 = phi i8* [ %0, %2 ], [ %13, %11 ]
%5 = phi i32 [ 0, %2 ], [ %14, %11 ]
%6 = tail call i32 @getc(i32* %1)
%7 = icmp ne i32 %6, 10
%8 = load i32, i32* @EOF
%9 = icmp ne i32 %6, %8
%10 = select i1 %7, i1 %9, i1 false
br i1 %10, label %11, label %18
11: ; preds = %3
%12 = trunc i32 %6 to i8
store i8 %12, i8* %4
%13 = getelementptr inbounds i8, i8* %4, i64 1
%14 = add nuw nsw i32 %5, 1
%15 = icmp eq i32 %14, 2558
br i1 %15, label %16, label %3
16: ; preds = %11
%17 = tail call i32 @opt_warning(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0))
br label %18
18: ; preds = %3, %16
%19 = phi i8* [ %13, %16 ], [ %4, %3 ]
%20 = phi i32 [ 2558, %16 ], [ %5, %3 ]
%21 = getelementptr inbounds i8, i8* %19, i64 1
store i8 0, i8* %19
store i8 0, i8* %21
ret i32 %20
}