#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 */
scalar_t__ isspace(char);
int strlen(char *);
bool preprocess(char *cmdline) {
  char *tmp = cmdline + strlen(cmdline);
  while (isspace(*--tmp) && tmp >= cmdline) {
    ;
  }
  if (tmp < cmdline) {
    return false;
  }
  if (*tmp == '&') {
    *tmp = ' ';
    return true;
    ;
  }
  return false;
}


x86 assembly (clang, -O0):
<preprocess>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,%ecx
mov    -0x20(%rbp),%rax
movslq %ecx,%rcx
add    %rcx,%rax
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,%rcx
add    $0xffffffffffffffff,%rcx
mov    %rcx,-0x18(%rbp)
movsbl -0x1(%rax),%edi
call   1040 <isspace@plt>
mov    %rax,%rcx
xor    %eax,%eax
cmp    $0x0,%rcx
mov    %al,-0x21(%rbp)
je     1185 <preprocess+0x65>
mov    -0x18(%rbp),%rax
cmp    -0x10(%rbp),%rax
setae  %al
mov    %al,-0x21(%rbp)
mov    -0x21(%rbp),%al
test   $0x1,%al
jne    1195 <preprocess+0x75>
jmp    119a <preprocess+0x7a>
jmp    114d <preprocess+0x2d>
mov    -0x18(%rbp),%rax
cmp    -0x10(%rbp),%rax
jae    11b4 <preprocess+0x94>
movl   $0x0,-0x4(%rbp)
jmp    11de <preprocess+0xbe>
mov    -0x18(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x26,%eax
jne    11d7 <preprocess+0xb7>
mov    -0x18(%rbp),%rax
movb   $0x20,(%rax)
movl   $0x1,-0x4(%rbp)
jmp    11de <preprocess+0xbe>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<preprocess>:
push   %r14
push   %rbx
push   %rax
mov    %rdi,%r14
call   1030 <strlen@plt>
movslq %eax,%rbx
add    %r14,%rbx
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
movsbl -0x1(%rbx),%edi
add    $0xffffffffffffffff,%rbx
call   1040 <isspace@plt>
cmp    %r14,%rbx
jb     1157 <preprocess+0x37>
test   %rax,%rax
jne    1140 <preprocess+0x20>
xor    %eax,%eax
cmp    %r14,%rbx
jb     116b <preprocess+0x4b>
cmpb   $0x26,(%rbx)
jne    116b <preprocess+0x4b>
movb   $0x20,(%rbx)
mov    $0x1,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
define i32 @preprocess(i8* %0) {
%2 = alloca i32
%3 = alloca i8*
%4 = alloca i8*
store i8* %0, i8** %3
%5 = load i8*, i8** %3
%6 = load i8*, i8** %3
%7 = call i32 @strlen(i8* %6)
%8 = sext i32 %7 to i64
%9 = getelementptr inbounds i8, i8* %5, i64 %8
store i8* %9, i8** %4
br label %10
10: ; preds = %22, %1
%11 = load i8*, i8** %4
%12 = getelementptr inbounds i8, i8* %11, i32 -1
store i8* %12, i8** %4
%13 = load i8, i8* %12
%14 = call i64 @isspace(i8 signext %13)
%15 = icmp ne i64 %14, 0
br i1 %15, label %16, label %20
16: ; preds = %10
%17 = load i8*, i8** %4
%18 = load i8*, i8** %3
%19 = icmp uge i8* %17, %18
br label %20
20: ; preds = %16, %10
%21 = phi i1 [ false, %10 ], [ %19, %16 ]
br i1 %21, label %22, label %23
22: ; preds = %20
br label %10
23: ; preds = %20
%24 = load i8*, i8** %4
%25 = load i8*, i8** %3
%26 = icmp ult i8* %24, %25
br i1 %26, label %27, label %28
27: ; preds = %23
store i32 0, i32* %2
br label %36
28: ; preds = %23
%29 = load i8*, i8** %4
%30 = load i8, i8* %29
%31 = sext i8 %30 to i32
%32 = icmp eq i32 %31, 38
br i1 %32, label %33, label %35
33: ; preds = %28
%34 = load i8*, i8** %4
store i8 32, i8* %34
store i32 1, i32* %2
br label %36
35: ; preds = %28
store i32 0, i32* %2
br label %36
36: ; preds = %35, %33, %27
%37 = load i32, i32* %2
ret i32 %37
}

LLVM IR (-O2):
define i32 @preprocess(i8* %0) {
%2 = tail call i32 @strlen(i8* %0)
%3 = sext i32 %2 to i64
%4 = getelementptr inbounds i8, i8* %0, i64 %3
br label %5
5: ; preds = %5, %1
%6 = phi i8* [ %4, %1 ], [ %7, %5 ]
%7 = getelementptr inbounds i8, i8* %6, i64 -1
%8 = load i8, i8* %7
%9 = tail call i64 @isspace(i8 signext %8)
%10 = icmp ne i64 %9, 0
%11 = icmp uge i8* %7, %0
%12 = and i1 %11, %10
br i1 %12, label %5, label %13
13: ; preds = %5
%14 = icmp ult i8* %7, %0
br i1 %14, label %19, label %15
15: ; preds = %13
%16 = load i8, i8* %7
%17 = icmp eq i8 %16, 38
br i1 %17, label %18, label %19
18: ; preds = %15
store i8 32, i8* %7
br label %19
19: ; preds = %15, %13, %18
%20 = phi i32 [ 1, %18 ], [ 0, %13 ], [ 0, %15 ]
ret i32 %20
}