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

/* Variables and functions */
char *fgets(char *, int, int /*<<< orphan*/ *);
scalar_t__ isspace(char);
int /*<<< orphan*/ memset(char *, int /*<<< orphan*/, int);
int strlen(char *);
char *nextinput(FILE *infile) {
  static char inputline[256];
  char *eol;
  int idx;
  memset(inputline, 0, sizeof(inputline));
  eol = fgets(inputline, sizeof(inputline), infile);
  if (eol == NULL) {
    return NULL;
  }
  for (idx = strlen(inputline) - 1; isspace(inputline[idx]); idx--) {
    inputline[idx] = '\000';
  }
  return inputline;
}


x86 assembly (clang, -O0):
<nextinput>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
lea    0x2efd(%rip),%rdi
xor    %esi,%esi
mov    $0x100,%edx
call   1040 <memset@plt>
mov    -0x10(%rbp),%rdx
lea    0x2ee6(%rip),%rdi
mov    $0x100,%esi
call   1060 <fgets@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    1190 <nextinput+0x50>
movq   $0x0,-0x8(%rbp)
jmp    11e8 <nextinput+0xa8>
lea    0x2eb9(%rip),%rdi
call   1030 <strlen@plt>
sub    $0x1,%eax
mov    %eax,-0x1c(%rbp)
movslq -0x1c(%rbp),%rcx
lea    0x2ea3(%rip),%rax
movsbl (%rax,%rcx,1),%edi
call   1050 <isspace@plt>
cmp    $0x0,%rax
je     11dd <nextinput+0x9d>
movslq -0x1c(%rbp),%rcx
lea    0x2e85(%rip),%rax
movb   $0x0,(%rax,%rcx,1)
mov    -0x1c(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x1c(%rbp)
jmp    11a2 <nextinput+0x62>
lea    0x2e6c(%rip),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<nextinput>:
push   %r15
push   %r14
push   %rbx
mov    %rdi,%r14
lea    0x2f01(%rip),%r15
mov    %r15,%rdi
xor    %esi,%esi
mov    $0x100,%edx
call   1040 <memset@plt>
mov    %r15,%rdi
mov    $0x100,%esi
mov    %r14,%rdx
call   1060 <fgets@plt>
test   %rax,%rax
je     11b7 <nextinput+0x77>
mov    %r15,%rdi
call   1030 <strlen@plt>
movslq %eax,%rbx
movsbl -0x1(%rbx,%r15,1),%edi
call   1050 <isspace@plt>
test   %rax,%rax
je     11ba <nextinput+0x7a>
add    $0xffffffffffffffff,%rbx
lea    0x2eb7(%rip),%r15
add    %r15,%rbx
nopl   0x0(%rax)
movb   $0x0,(%rbx)
movsbl -0x1(%rbx),%edi
add    $0xffffffffffffffff,%rbx
call   1050 <isspace@plt>
test   %rax,%rax
jne    11a0 <nextinput+0x60>
jmp    11ba <nextinput+0x7a>
xor    %r15d,%r15d
mov    %r15,%rax
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@nextinput.inputline = internal global [256 x i8] zeroinitializer
define i8* @nextinput(i32* %0) {
%2 = alloca i8*
%3 = alloca i32*
%4 = alloca i8*
%5 = alloca i32
store i32* %0, i32** %3
%6 = call i32 @memset(i8* getelementptr inbounds ([256 x i8], [256 x i8]* @nextinput.inputline, i64 0, i64 0), i32 0, i32 256)
%7 = load i32*, i32** %3
%8 = call i8* @fgets(i8* getelementptr inbounds ([256 x i8], [256 x i8]* @nextinput.inputline, i64 0, i64 0), i32 256, i32* %7)
store i8* %8, i8** %4
%9 = load i8*, i8** %4
%10 = icmp eq i8* %9, null
br i1 %10, label %11, label %12
11: ; preds = %1
store i8* null, i8** %2
br label %30
12: ; preds = %1
%13 = call i32 @strlen(i8* getelementptr inbounds ([256 x i8], [256 x i8]* @nextinput.inputline, i64 0, i64 0))
%14 = sub nsw i32 %13, 1
store i32 %14, i32* %5
br label %15
15: ; preds = %26, %12
%16 = load i32, i32* %5
%17 = sext i32 %16 to i64
%18 = getelementptr inbounds [256 x i8], [256 x i8]* @nextinput.inputline, i64 0, i64 %17
%19 = load i8, i8* %18
%20 = call i64 @isspace(i8 signext %19)
%21 = icmp ne i64 %20, 0
br i1 %21, label %22, label %29
22: ; preds = %15
%23 = load i32, i32* %5
%24 = sext i32 %23 to i64
%25 = getelementptr inbounds [256 x i8], [256 x i8]* @nextinput.inputline, i64 0, i64 %24
store i8 0, i8* %25
br label %26
26: ; preds = %22
%27 = load i32, i32* %5
%28 = add nsw i32 %27, -1
store i32 %28, i32* %5
br label %15
29: ; preds = %15
store i8* getelementptr inbounds ([256 x i8], [256 x i8]* @nextinput.inputline, i64 0, i64 0), i8** %2
br label %30
30: ; preds = %29, %11
%31 = load i8*, i8** %2
ret i8* %31
}

LLVM IR (-O2):
@nextinput.inputline = internal global [256 x i8] zeroinitializer
define i8* @nextinput(i32* nocapture %0) {
%2 = tail call i32 @memset(i8* getelementptr inbounds ([256 x i8], [256 x i8]* @nextinput.inputline, i64 0, i64 0), i32 0, i32 256)
%3 = tail call i8* @fgets(i8* getelementptr inbounds ([256 x i8], [256 x i8]* @nextinput.inputline, i64 0, i64 0), i32 256, i32* %0)
%4 = icmp eq i8* %3, null
br i1 %4, label %21, label %5
5: ; preds = %1
%6 = tail call i32 @strlen(i8* getelementptr inbounds ([256 x i8], [256 x i8]* @nextinput.inputline, i64 0, i64 0))
%7 = add nsw i32 %6, -1
%8 = sext i32 %7 to i64
%9 = getelementptr inbounds [256 x i8], [256 x i8]* @nextinput.inputline, i64 0, i64 %8
%10 = load i8, i8* %9
%11 = tail call i64 @isspace(i8 signext %10)
%12 = icmp eq i64 %11, 0
br i1 %12, label %21, label %13
13: ; preds = %5, %13
%14 = phi i64 [ %16, %13 ], [ %8, %5 ]
%15 = phi i8* [ %17, %13 ], [ %9, %5 ]
store i8 0, i8* %15
%16 = add i64 %14, -1
%17 = getelementptr inbounds [256 x i8], [256 x i8]* @nextinput.inputline, i64 0, i64 %16
%18 = load i8, i8* %17
%19 = tail call i64 @isspace(i8 signext %18)
%20 = icmp eq i64 %19, 0
br i1 %20, label %21, label %13
21: ; preds = %13, %5, %1
%22 = phi i8* [ null, %1 ], [ getelementptr inbounds ([256 x i8], [256 x i8]* @nextinput.inputline, i64 0, i64 0), %5 ], [ getelementptr inbounds ([256 x i8], [256 x i8]* @nextinput.inputline, i64 0, i64 0), %13 ]
ret i8* %22
}