#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 */
char *fgets(char *, int, int /*<<< orphan*/ *);
scalar_t__ isalpha(char);
scalar_t__ isspace(char);
char *readLine(char *buf, int bufSize, FILE *f) {
  char *line = fgets(buf, bufSize, f);
  if (!line)
    return NULL;
  while (isspace(*line))
    line++;
  char *end = line;
  while (isalpha(*end))
    end++;
  *end = '\0';
  return (end > line) ? line : NULL;
}


x86 assembly (clang, -O0):
<readLine>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
mov    %rdx,-0x20(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x14(%rbp),%esi
mov    -0x20(%rbp),%rdx
call   1040 <fgets@plt>
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
jne    116f <readLine+0x3f>
movq   $0x0,-0x8(%rbp)
jmp    11ff <readLine+0xcf>
jmp    1174 <readLine+0x44>
mov    -0x28(%rbp),%rax
movsbl (%rax),%edi
call   1030 <isspace@plt>
cmp    $0x0,%rax
je     119b <readLine+0x6b>
mov    -0x28(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x28(%rbp)
jmp    1174 <readLine+0x44>
mov    -0x28(%rbp),%rax
mov    %rax,-0x30(%rbp)
mov    -0x30(%rbp),%rax
movsbl (%rax),%edi
call   1050 <isalpha@plt>
cmp    $0x0,%rax
je     11ca <readLine+0x9a>
mov    -0x30(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x30(%rbp)
jmp    11a3 <readLine+0x73>
mov    -0x30(%rbp),%rax
movb   $0x0,(%rax)
mov    -0x30(%rbp),%rax
cmp    -0x28(%rbp),%rax
jbe    11ec <readLine+0xbc>
mov    -0x28(%rbp),%rax
mov    %rax,-0x38(%rbp)
jmp    11f7 <readLine+0xc7>
xor    %eax,%eax
mov    %rax,-0x38(%rbp)
jmp    11f7 <readLine+0xc7>
mov    -0x38(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<readLine>:
push   %r14
push   %rbx
push   %rax
call   1040 <fgets@plt>
test   %rax,%rax
je     1190 <readLine+0x60>
mov    %rax,%r14
add    $0xffffffffffffffff,%r14
cs nopw 0x0(%rax,%rax,1)
nop
movsbl 0x1(%r14),%edi
add    $0x1,%r14
call   1030 <isspace@plt>
test   %rax,%rax
jne    1150 <readLine+0x20>
lea    -0x1(%r14),%rbx
nopw   0x0(%rax,%rax,1)
movsbl 0x1(%rbx),%edi
add    $0x1,%rbx
call   1050 <isalpha@plt>
test   %rax,%rax
jne    1170 <readLine+0x40>
movb   $0x0,(%rbx)
xor    %eax,%eax
cmp    %r14,%rbx
cmova  %r14,%rax
jmp    1192 <readLine+0x62>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
define i8* @readLine(i8* %0, i32 %1, i32* %2) {
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i32
%7 = alloca i32*
%8 = alloca i8*
%9 = alloca i8*
store i8* %0, i8** %5
store i32 %1, i32* %6
store i32* %2, i32** %7
%10 = load i8*, i8** %5
%11 = load i32, i32* %6
%12 = load i32*, i32** %7
%13 = call i8* @fgets(i8* %10, i32 %11, i32* %12)
store i8* %13, i8** %8
%14 = load i8*, i8** %8
%15 = icmp ne i8* %14, null
br i1 %15, label %17, label %16
16: ; preds = %3
store i8* null, i8** %4
br label %46
17: ; preds = %3
br label %18
18: ; preds = %23, %17
%19 = load i8*, i8** %8
%20 = load i8, i8* %19
%21 = call i64 @isspace(i8 signext %20)
%22 = icmp ne i64 %21, 0
br i1 %22, label %23, label %26
23: ; preds = %18
%24 = load i8*, i8** %8
%25 = getelementptr inbounds i8, i8* %24, i32 1
store i8* %25, i8** %8
br label %18
26: ; preds = %18
%27 = load i8*, i8** %8
store i8* %27, i8** %9
br label %28
28: ; preds = %33, %26
%29 = load i8*, i8** %9
%30 = load i8, i8* %29
%31 = call i64 @isalpha(i8 signext %30)
%32 = icmp ne i64 %31, 0
br i1 %32, label %33, label %36
33: ; preds = %28
%34 = load i8*, i8** %9
%35 = getelementptr inbounds i8, i8* %34, i32 1
store i8* %35, i8** %9
br label %28
36: ; preds = %28
%37 = load i8*, i8** %9
store i8 0, i8* %37
%38 = load i8*, i8** %9
%39 = load i8*, i8** %8
%40 = icmp ugt i8* %38, %39
br i1 %40, label %41, label %43
41: ; preds = %36
%42 = load i8*, i8** %8
br label %44
43: ; preds = %36
br label %44
44: ; preds = %43, %41
%45 = phi i8* [ %42, %41 ], [ null, %43 ]
store i8* %45, i8** %4
br label %46
46: ; preds = %44, %16
%47 = load i8*, i8** %4
ret i8* %47
}

LLVM IR (-O2):
define i8* @readLine(i8* %0, i32 %1, i32* nocapture %2) {
%4 = tail call i8* @fgets(i8* %0, i32 %1, i32* %2)
%5 = icmp eq i8* %4, null
br i1 %5, label %21, label %6
6: ; preds = %3, %6
%7 = phi i8* [ %11, %6 ], [ %4, %3 ]
%8 = load i8, i8* %7
%9 = tail call i64 @isspace(i8 signext %8)
%10 = icmp eq i64 %9, 0
%11 = getelementptr inbounds i8, i8* %7, i64 1
br i1 %10, label %12, label %6
12: ; preds = %6, %12
%13 = phi i8* [ %17, %12 ], [ %7, %6 ]
%14 = load i8, i8* %13
%15 = tail call i64 @isalpha(i8 signext %14)
%16 = icmp eq i64 %15, 0
%17 = getelementptr inbounds i8, i8* %13, i64 1
br i1 %16, label %18, label %12
18: ; preds = %12
store i8 0, i8* %13
%19 = icmp ugt i8* %13, %7
%20 = select i1 %19, i8* %7, i8* null
br label %21
21: ; preds = %3, %18
%22 = phi i8* [ %20, %18 ], [ null, %3 ]
ret i8* %22
}