#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 */

/* Variables and functions */
int BUFSIZ;
int getaline(char *, int);
int /*<<< orphan*/ printf(char *, ...);
int strrcspnl(char *, char const *, int);
int main(void) {
  int len, span;
  char line[BUFSIZ];
  const char *tokens = " ";
  while ((len = getaline(line, BUFSIZ)) != -1) {
    span = strrcspnl(line, tokens, 80);
    printf("%d\n", span);
    printf("%s", line);
  }
  return (0);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    0x2e9a(%rip),%rax
mov    (%rax),%eax
mov    %rsp,%rcx
mov    %rcx,-0x18(%rbp)
mov    %rax,%rdx
add    $0xf,%rdx
and    $0xfffffffffffffff0,%rdx
mov    %rsp,%rcx
sub    %rdx,%rcx
mov    %rcx,-0x30(%rbp)
mov    %rcx,%rsp
mov    %rax,-0x20(%rbp)
lea    0xe8e(%rip),%rax
mov    %rax,-0x28(%rbp)
mov    -0x30(%rbp),%rdi
mov    0x2e5f(%rip),%rax
mov    (%rax),%esi
call   1030 <getaline@plt>
mov    %eax,-0x8(%rbp)
cmp    $0xffffffff,%eax
je     11d1 <main+0xa1>
mov    -0x30(%rbp),%rdi
mov    -0x28(%rbp),%rsi
mov    $0x50,%edx
call   1050 <strrcspnl@plt>
mov    %eax,-0xc(%rbp)
mov    -0xc(%rbp),%esi
lea    0xe4f(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x30(%rbp),%rsi
lea    0xe41(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    1176 <main+0x46>
movl   $0x0,-0x4(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,%rsp
mov    -0x4(%rbp),%eax
mov    %rbp,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
mov    %rsp,%rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    0x2e9b(%rip),%r13
mov    0x0(%r13),%esi
mov    %rsp,%rbx
mov    %rsi,%rax
add    $0xf,%rax
and    $0xfffffffffffffff0,%rax
sub    %rax,%rbx
mov    %rbx,%rsp
mov    %rbx,%rdi
call   1030 <getaline@plt>
cmp    $0xffffffff,%eax
je     11ba <main+0x8a>
lea    0xe8f(%rip),%r14
lea    0xe8a(%rip),%r15
lea    0xe87(%rip),%r12
nop
mov    %rbx,%rdi
mov    %r14,%rsi
mov    $0x50,%edx
call   1050 <strrcspnl@plt>
mov    %r15,%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %r12,%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x0(%r13),%esi
mov    %rbx,%rdi
call   1030 <getaline@plt>
cmp    $0xffffffff,%eax
jne    1180 <main+0x50>
xor    %eax,%eax
lea    -0x28(%rbp),%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@BUFSIZ = global i32 0
@.str = [2 x i8] c" \00"
@.str.1 = [4 x i8] c"%d\0A\00"
@.str.2 = [3 x i8] c"%s\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i8*
%5 = alloca i64
%6 = alloca i8*
store i32 0, i32* %1
%7 = load i32, i32* @BUFSIZ
%8 = zext i32 %7 to i64
%9 = call i8* @llvm.stacksave()
store i8* %9, i8** %4
%10 = alloca i8, i64 %8
store i64 %8, i64* %5
store i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0), i8** %6
br label %11
11: ; preds = %15, %0
%12 = load i32, i32* @BUFSIZ
%13 = call i32 @getaline(i8* %10, i32 %12)
store i32 %13, i32* %2
%14 = icmp ne i32 %13, -1
br i1 %14, label %15, label %21
15: ; preds = %11
%16 = load i8*, i8** %6
%17 = call i32 @strrcspnl(i8* %10, i8* %16, i32 80)
store i32 %17, i32* %3
%18 = load i32, i32* %3
%19 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %18)
%20 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i8* %10)
br label %11
21: ; preds = %11
store i32 0, i32* %1
%22 = load i8*, i8** %4
%23 = load i32, i32* %1
ret i32 %23
}

LLVM IR (-O2):
@BUFSIZ = global i32 0
@.str = [2 x i8] c" \00"
@.str.1 = [4 x i8] c"%d\0A\00"
@.str.2 = [3 x i8] c"%s\00"
define i32 @main() {
%1 = load i32, i32* @BUFSIZ
%2 = zext i32 %1 to i64
%3 = alloca i8, i64 %2
%4 = call i32 @getaline(i8* %3, i32 %1)
%5 = icmp eq i32 %4, -1
br i1 %5, label %13, label %6
6: ; preds = %0, %6
%7 = call i32 @strrcspnl(i8* %3, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0), i32 80)
%8 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %7)
%9 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i8* %3)
%10 = load i32, i32* @BUFSIZ
%11 = call i32 @getaline(i8* %3, i32 %10)
%12 = icmp eq i32 %11, -1
br i1 %12, label %13, label %6
13: ; preds = %6, %0
ret i32 0
}