#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 strlen(char *);
scalar_t__ strncmp(char *, char *, int);
void fixnone(char *str) {
  int i;
  for (i = strlen(str) - 1; i >= 0 && (unsigned char)str[i] <= ' '; i--)
    ;
  if (i == 3 && strncmp(str, "none", 4) == 0)
    str[0] = '\0';
  return;
}


x86 assembly (clang, -O0):
<fixnone>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
call   1040 <strlen@plt>
sub    $0x1,%eax
mov    %eax,-0xc(%rbp)
xor    %eax,%eax
cmpl   $0x0,-0xc(%rbp)
mov    %al,-0xd(%rbp)
jl     115f <fixnone+0x3f>
mov    -0x8(%rbp),%rax
movslq -0xc(%rbp),%rcx
movzbl (%rax,%rcx,1),%eax
cmp    $0x20,%eax
setle  %al
mov    %al,-0xd(%rbp)
mov    -0xd(%rbp),%al
test   $0x1,%al
jne    116f <fixnone+0x4f>
jmp    1182 <fixnone+0x62>
jmp    1174 <fixnone+0x54>
mov    -0xc(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0xc(%rbp)
jmp    113b <fixnone+0x1b>
cmpl   $0x3,-0xc(%rbp)
jne    11b2 <fixnone+0x92>
mov    -0x8(%rbp),%rdi
lea    0xe69(%rip),%rsi
mov    $0x4,%edx
call   1030 <strncmp@plt>
cmp    $0x0,%rax
jne    11b2 <fixnone+0x92>
mov    -0x8(%rbp),%rax
movb   $0x0,(%rax)
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<fixnone>:
push   %rbx
mov    %rdi,%rbx
call   1040 <strlen@plt>
mov    %eax,%eax
nopl   0x0(%rax,%rax,1)
test   %eax,%eax
jle    1160 <fixnone+0x40>
lea    -0x1(%rax),%rcx
cmpb   $0x21,-0x1(%rbx,%rax,1)
mov    %rcx,%rax
jb     1130 <fixnone+0x10>
cmp    $0x3,%ecx
jne    1160 <fixnone+0x40>
lea    0xeb2(%rip),%rsi
mov    %rbx,%rdi
mov    $0x4,%edx
call   1030 <strncmp@plt>
test   %rax,%rax
je     1162 <fixnone+0x42>
pop    %rbx
ret
movb   $0x0,(%rbx)
pop    %rbx
ret

LLVM IR (-O0):
@.str = [5 x i8] c"none\00"
define void @fixnone(i8* %0) {
%2 = alloca i8*
%3 = alloca i32
store i8* %0, i8** %2
%4 = load i8*, i8** %2
%5 = call i32 @strlen(i8* %4)
%6 = sub nsw i32 %5, 1
store i32 %6, i32* %3
br label %7
7: ; preds = %21, %1
%8 = load i32, i32* %3
%9 = icmp sge i32 %8, 0
br i1 %9, label %10, label %18
10: ; preds = %7
%11 = load i8*, i8** %2
%12 = load i32, i32* %3
%13 = sext i32 %12 to i64
%14 = getelementptr inbounds i8, i8* %11, i64 %13
%15 = load i8, i8* %14
%16 = zext i8 %15 to i32
%17 = icmp sle i32 %16, 32
br label %18
18: ; preds = %10, %7
%19 = phi i1 [ false, %7 ], [ %17, %10 ]
br i1 %19, label %20, label %24
20: ; preds = %18
br label %21
21: ; preds = %20
%22 = load i32, i32* %3
%23 = add nsw i32 %22, -1
store i32 %23, i32* %3
br label %7
24: ; preds = %18
%25 = load i32, i32* %3
%26 = icmp eq i32 %25, 3
br i1 %26, label %27, label %34
27: ; preds = %24
%28 = load i8*, i8** %2
%29 = call i64 @strncmp(i8* %28, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i32 4)
%30 = icmp eq i64 %29, 0
br i1 %30, label %31, label %34
31: ; preds = %27
%32 = load i8*, i8** %2
%33 = getelementptr inbounds i8, i8* %32, i64 0
store i8 0, i8* %33
br label %34
34: ; preds = %31, %27, %24
ret void
}

LLVM IR (-O2):
@.str = [5 x i8] c"none\00"
define void @fixnone(i8* %0) {
%2 = tail call i32 @strlen(i8* %0)
%3 = zext i32 %2 to i64
br label %4
4: ; preds = %9, %1
%5 = phi i64 [ %6, %9 ], [ %3, %1 ]
%6 = add nsw i64 %5, -1
%7 = trunc i64 %5 to i32
%8 = icmp sgt i32 %7, 0
br i1 %8, label %9, label %20
9: ; preds = %4
%10 = getelementptr inbounds i8, i8* %0, i64 %6
%11 = load i8, i8* %10
%12 = icmp ult i8 %11, 33
br i1 %12, label %4, label %13
13: ; preds = %9
%14 = trunc i64 %6 to i32
%15 = icmp eq i32 %14, 3
br i1 %15, label %16, label %20
16: ; preds = %13
%17 = tail call i64 @strncmp(i8* %0, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i32 4)
%18 = icmp eq i64 %17, 0
br i1 %18, label %19, label %20
19: ; preds = %16
store i8 0, i8* %0
br label %20
20: ; preds = %4, %19, %16, %13
ret void
}