#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 */
char *strchr(char const *, char);
scalar_t__ strcmp(char const *, char *);
int /*<<< orphan*/ string_is_command_char(char const *);
scalar_t__ strncmp(char const *, char *, int);
scalar_t__ utf8_charcmp(char const *, char const *);
char *utf8_next_char(char const *);
const char *string_input_for_buffer(const char *string) {
  char *pos_slash, *pos_space;
  const char *next_char;
  if (!string)
    return NULL;
  if (strcmp(string, "/") == 0)
    return string;
  if (strncmp(string, "/ ", 2) == 0)
    return string;
  if (strncmp(string, "/*", 2) == 0)
    return string;
  if (string[0] == '/') {
    pos_slash = strchr(string + 1, '/');
    pos_space = strchr(string + 1, ' ');
    if (!pos_slash || (pos_space && pos_slash > pos_space))
      return NULL;
    return (string[1] == '/') ? string + 1 : string;
  }
  if (!string_is_command_char(string))
    return string;
  next_char = utf8_next_char(string);
  if (!next_char || !next_char[0])
    return string;
  if (next_char[0] == ' ')
    return string;
  if (utf8_charcmp(string, next_char) == 0)
    return next_char;
  return NULL;
}


x86 assembly (clang, -O0):
<string_input_for_buffer>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    1184 <string_input_for_buffer+0x24>
movq   $0x0,-0x8(%rbp)
jmp    1341 <string_input_for_buffer+0x1e1>
mov    -0x10(%rbp),%rdi
lea    0xe71(%rip),%rsi
call   1070 <strcmp@plt>
cmp    $0x0,%rax
jne    11ab <string_input_for_buffer+0x4b>
mov    -0x10(%rbp),%rax
mov    %rax,-0x8(%rbp)
jmp    1341 <string_input_for_buffer+0x1e1>
mov    -0x10(%rbp),%rdi
lea    0xe4c(%rip),%rsi
mov    $0x2,%edx
call   1030 <strncmp@plt>
cmp    $0x0,%rax
jne    11d7 <string_input_for_buffer+0x77>
mov    -0x10(%rbp),%rax
mov    %rax,-0x8(%rbp)
jmp    1341 <string_input_for_buffer+0x1e1>
mov    -0x10(%rbp),%rdi
lea    0xe23(%rip),%rsi
mov    $0x2,%edx
call   1030 <strncmp@plt>
cmp    $0x0,%rax
jne    1203 <string_input_for_buffer+0xa3>
mov    -0x10(%rbp),%rax
mov    %rax,-0x8(%rbp)
jmp    1341 <string_input_for_buffer+0x1e1>
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x2f,%eax
jne    12a7 <string_input_for_buffer+0x147>
mov    -0x10(%rbp),%rdi
add    $0x1,%rdi
mov    $0x2f,%esi
call   1050 <strchr@plt>
mov    %rax,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
add    $0x1,%rdi
mov    $0x20,%esi
call   1050 <strchr@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x18(%rbp)
je     1263 <string_input_for_buffer+0x103>
cmpq   $0x0,-0x20(%rbp)
je     1270 <string_input_for_buffer+0x110>
mov    -0x18(%rbp),%rax
cmp    -0x20(%rbp),%rax
jbe    1270 <string_input_for_buffer+0x110>
movq   $0x0,-0x8(%rbp)
jmp    1341 <string_input_for_buffer+0x1e1>
mov    -0x10(%rbp),%rax
movsbl 0x1(%rax),%eax
cmp    $0x2f,%eax
jne    1292 <string_input_for_buffer+0x132>
mov    -0x10(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x30(%rbp)
jmp    129a <string_input_for_buffer+0x13a>
mov    -0x10(%rbp),%rax
mov    %rax,-0x30(%rbp)
mov    -0x30(%rbp),%rax
mov    %rax,-0x8(%rbp)
jmp    1341 <string_input_for_buffer+0x1e1>
mov    -0x10(%rbp),%rdi
call   1040 <string_is_command_char@plt>
cmp    $0x0,%eax
jne    12c6 <string_input_for_buffer+0x166>
mov    -0x10(%rbp),%rax
mov    %rax,-0x8(%rbp)
jmp    1341 <string_input_for_buffer+0x1e1>
mov    -0x10(%rbp),%rdi
call   1080 <utf8_next_char@plt>
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
je     12eb <string_input_for_buffer+0x18b>
mov    -0x28(%rbp),%rax
cmpb   $0x0,(%rax)
jne    12f8 <string_input_for_buffer+0x198>
mov    -0x10(%rbp),%rax
mov    %rax,-0x8(%rbp)
jmp    1341 <string_input_for_buffer+0x1e1>
mov    -0x28(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x20,%eax
jne    1315 <string_input_for_buffer+0x1b5>
mov    -0x10(%rbp),%rax
mov    %rax,-0x8(%rbp)
jmp    1341 <string_input_for_buffer+0x1e1>
mov    -0x10(%rbp),%rdi
mov    -0x28(%rbp),%rsi
call   1060 <utf8_charcmp@plt>
cmp    $0x0,%rax
jne    1339 <string_input_for_buffer+0x1d9>
mov    -0x28(%rbp),%rax
mov    %rax,-0x8(%rbp)
jmp    1341 <string_input_for_buffer+0x1e1>
movq   $0x0,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<string_input_for_buffer>:
push   %r15
push   %r14
push   %rbx
test   %rdi,%rdi
je     11e5 <string_input_for_buffer+0x85>
mov    %rdi,%rbx
lea    0xe8c(%rip),%rsi
call   1070 <strcmp@plt>
test   %rax,%rax
je     11e7 <string_input_for_buffer+0x87>
lea    0xe7d(%rip),%rsi
mov    %rbx,%rdi
mov    $0x2,%edx
call   1030 <strncmp@plt>
test   %rax,%rax
je     11e7 <string_input_for_buffer+0x87>
lea    0xe67(%rip),%rsi
mov    %rbx,%rdi
mov    $0x2,%edx
call   1030 <strncmp@plt>
test   %rax,%rax
je     11e7 <string_input_for_buffer+0x87>
cmpb   $0x2f,(%rbx)
jne    11f0 <string_input_for_buffer+0x90>
lea    0x1(%rbx),%r14
mov    %r14,%rdi
mov    $0x2f,%esi
call   1050 <strchr@plt>
mov    %rax,%r15
mov    %r14,%rdi
mov    $0x20,%esi
call   1050 <strchr@plt>
test   %r15,%r15
je     11e5 <string_input_for_buffer+0x85>
test   %rax,%rax
je     1223 <string_input_for_buffer+0xc3>
cmp    %rax,%r15
jbe    1223 <string_input_for_buffer+0xc3>
xor    %ebx,%ebx
mov    %rbx,%rax
pop    %rbx
pop    %r14
pop    %r15
ret
mov    %rbx,%rdi
call   1040 <string_is_command_char@plt>
test   %eax,%eax
je     11e7 <string_input_for_buffer+0x87>
mov    %rbx,%rdi
call   1080 <utf8_next_char@plt>
test   %rax,%rax
je     11e7 <string_input_for_buffer+0x87>
mov    %rax,%r14
testb  $0xdf,(%rax)
je     11e7 <string_input_for_buffer+0x87>
mov    %rbx,%rdi
mov    %r14,%rsi
call   1060 <utf8_charcmp@plt>
xor    %ebx,%ebx
test   %rax,%rax
jmp    1227 <string_input_for_buffer+0xc7>
cmpb   $0x2f,0x1(%rbx)
cmove  %r14,%rbx
jmp    11e7 <string_input_for_buffer+0x87>

LLVM IR (-O0):
@.str = [2 x i8] c"/\00"
@.str.1 = [3 x i8] c"/ \00"
@.str.2 = [3 x i8] c"/*\00"
define i8* @string_input_for_buffer(i8* %0) {
%2 = alloca i8*
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i8*
store i8* %0, i8** %3
%7 = load i8*, i8** %3
%8 = icmp ne i8* %7, null
br i1 %8, label %10, label %9
9: ; preds = %1
store i8* null, i8** %2
br label %98
10: ; preds = %1
%11 = load i8*, i8** %3
%12 = call i64 @strcmp(i8* %11, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%13 = icmp eq i64 %12, 0
br i1 %13, label %14, label %16
14: ; preds = %10
%15 = load i8*, i8** %3
store i8* %15, i8** %2
br label %98
16: ; preds = %10
%17 = load i8*, i8** %3
%18 = call i64 @strncmp(i8* %17, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32 2)
%19 = icmp eq i64 %18, 0
br i1 %19, label %20, label %22
20: ; preds = %16
%21 = load i8*, i8** %3
store i8* %21, i8** %2
br label %98
22: ; preds = %16
%23 = load i8*, i8** %3
%24 = call i64 @strncmp(i8* %23, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32 2)
%25 = icmp eq i64 %24, 0
br i1 %25, label %26, label %28
26: ; preds = %22
%27 = load i8*, i8** %3
store i8* %27, i8** %2
br label %98
28: ; preds = %22
%29 = load i8*, i8** %3
%30 = getelementptr inbounds i8, i8* %29, i64 0
%31 = load i8, i8* %30
%32 = sext i8 %31 to i32
%33 = icmp eq i32 %32, 47
br i1 %33, label %34, label %64
34: ; preds = %28
%35 = load i8*, i8** %3
%36 = getelementptr inbounds i8, i8* %35, i64 1
%37 = call i8* @strchr(i8* %36, i8 signext 47)
store i8* %37, i8** %4
%38 = load i8*, i8** %3
%39 = getelementptr inbounds i8, i8* %38, i64 1
%40 = call i8* @strchr(i8* %39, i8 signext 32)
store i8* %40, i8** %5
%41 = load i8*, i8** %4
%42 = icmp ne i8* %41, null
br i1 %42, label %43, label %50
43: ; preds = %34
%44 = load i8*, i8** %5
%45 = icmp ne i8* %44, null
br i1 %45, label %46, label %51
46: ; preds = %43
%47 = load i8*, i8** %4
%48 = load i8*, i8** %5
%49 = icmp ugt i8* %47, %48
br i1 %49, label %50, label %51
50: ; preds = %46, %34
store i8* null, i8** %2
br label %98
51: ; preds = %46, %43
%52 = load i8*, i8** %3
%53 = getelementptr inbounds i8, i8* %52, i64 1
%54 = load i8, i8* %53
%55 = sext i8 %54 to i32
%56 = icmp eq i32 %55, 47
br i1 %56, label %57, label %60
57: ; preds = %51
%58 = load i8*, i8** %3
%59 = getelementptr inbounds i8, i8* %58, i64 1
br label %62
60: ; preds = %51
%61 = load i8*, i8** %3
br label %62
62: ; preds = %60, %57
%63 = phi i8* [ %59, %57 ], [ %61, %60 ]
store i8* %63, i8** %2
br label %98
64: ; preds = %28
%65 = load i8*, i8** %3
%66 = call i32 @string_is_command_char(i8* %65)
%67 = icmp ne i32 %66, 0
br i1 %67, label %70, label %68
68: ; preds = %64
%69 = load i8*, i8** %3
store i8* %69, i8** %2
br label %98
70: ; preds = %64
%71 = load i8*, i8** %3
%72 = call i8* @utf8_next_char(i8* %71)
store i8* %72, i8** %6
%73 = load i8*, i8** %6
%74 = icmp ne i8* %73, null
br i1 %74, label %75, label %80
75: ; preds = %70
%76 = load i8*, i8** %6
%77 = getelementptr inbounds i8, i8* %76, i64 0
%78 = load i8, i8* %77
%79 = icmp ne i8 %78, 0
br i1 %79, label %82, label %80
80: ; preds = %75, %70
%81 = load i8*, i8** %3
store i8* %81, i8** %2
br label %98
82: ; preds = %75
%83 = load i8*, i8** %6
%84 = getelementptr inbounds i8, i8* %83, i64 0
%85 = load i8, i8* %84
%86 = sext i8 %85 to i32
%87 = icmp eq i32 %86, 32
br i1 %87, label %88, label %90
88: ; preds = %82
%89 = load i8*, i8** %3
store i8* %89, i8** %2
br label %98
90: ; preds = %82
%91 = load i8*, i8** %3
%92 = load i8*, i8** %6
%93 = call i64 @utf8_charcmp(i8* %91, i8* %92)
%94 = icmp eq i64 %93, 0
br i1 %94, label %95, label %97
95: ; preds = %90
%96 = load i8*, i8** %6
store i8* %96, i8** %2
br label %98
97: ; preds = %90
store i8* null, i8** %2
br label %98
98: ; preds = %97, %95, %88, %80, %68, %62, %50, %26, %20, %14, %9
%99 = load i8*, i8** %2
ret i8* %99
}

LLVM IR (-O2):
@.str = [2 x i8] c"/\00"
@.str.1 = [3 x i8] c"/ \00"
@.str.2 = [3 x i8] c"/*\00"
define i8* @string_input_for_buffer(i8* %0) {
%2 = icmp eq i8* %0, null
br i1 %2, label %40, label %3
3: ; preds = %1
%4 = tail call i64 @strcmp(i8* %0, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%5 = icmp eq i64 %4, 0
br i1 %5, label %40, label %6
6: ; preds = %3
%7 = tail call i64 @strncmp(i8* %0, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32 2)
%8 = icmp eq i64 %7, 0
br i1 %8, label %40, label %9
9: ; preds = %6
%10 = tail call i64 @strncmp(i8* %0, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32 2)
%11 = icmp eq i64 %10, 0
br i1 %11, label %40, label %12
12: ; preds = %9
%13 = load i8, i8* %0
%14 = icmp eq i8 %13, 47
br i1 %14, label %15, label %28
15: ; preds = %12
%16 = getelementptr inbounds i8, i8* %0, i64 1
%17 = tail call i8* @strchr(i8* %16, i8 signext 47)
%18 = tail call i8* @strchr(i8* %16, i8 signext 32)
%19 = icmp eq i8* %17, null
br i1 %19, label %40, label %20
20: ; preds = %15
%21 = icmp ne i8* %18, null
%22 = icmp ugt i8* %17, %18
%23 = select i1 %21, i1 %22, i1 false
br i1 %23, label %40, label %24
24: ; preds = %20
%25 = load i8, i8* %16
%26 = icmp eq i8 %25, 47
%27 = select i1 %26, i8* %16, i8* %0
br label %40
28: ; preds = %12
%29 = tail call i32 @string_is_command_char(i8* %0)
%30 = icmp eq i32 %29, 0
br i1 %30, label %40, label %31
31: ; preds = %28
%32 = tail call i8* @utf8_next_char(i8* %0)
%33 = icmp eq i8* %32, null
br i1 %33, label %40, label %34
34: ; preds = %31
%35 = load i8, i8* %32
switch i8 %35, label %36 [
i8 0, label %40
i8 32, label %40
]
36: ; preds = %34
%37 = tail call i64 @utf8_charcmp(i8* %0, i8* %32)
%38 = icmp eq i64 %37, 0
%39 = select i1 %38, i8* %32, i8* null
br label %40
40: ; preds = %36, %34, %34, %31, %28, %15, %20, %9, %6, %3, %1, %24
%41 = phi i8* [ %27, %24 ], [ null, %1 ], [ %0, %3 ], [ %0, %6 ], [ %0, %9 ], [ null, %20 ], [ null, %15 ], [ %0, %28 ], [ %0, %34 ], [ %0, %31 ], [ %0, %34 ], [ %39, %36 ]
ret i8* %41
}