#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);
int /*<<< orphan*/ string_is_command_char(char const *);
scalar_t__ strncmp(char const *, char *, int);
scalar_t__ utf8_charcmp(char const *, char *);
char *utf8_next_char(char const *);
const char *string_input_for_buffer(const char *string) {
  char *pos_slash, *pos_space, *next_char;
  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 NULL;
  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)
mov    -0x10(%rbp),%rdi
lea    0xe99(%rip),%rsi
mov    $0x2,%edx
call   1030 <strncmp@plt>
cmp    $0x0,%rax
jne    1188 <string_input_for_buffer+0x38>
mov    -0x10(%rbp),%rax
mov    %rax,-0x8(%rbp)
jmp    12a9 <string_input_for_buffer+0x159>
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x2f,%eax
jne    122c <string_input_for_buffer+0xdc>
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     11e8 <string_input_for_buffer+0x98>
cmpq   $0x0,-0x20(%rbp)
je     11f5 <string_input_for_buffer+0xa5>
mov    -0x18(%rbp),%rax
cmp    -0x20(%rbp),%rax
jbe    11f5 <string_input_for_buffer+0xa5>
movq   $0x0,-0x8(%rbp)
jmp    12a9 <string_input_for_buffer+0x159>
mov    -0x10(%rbp),%rax
movsbl 0x1(%rax),%eax
cmp    $0x2f,%eax
jne    1217 <string_input_for_buffer+0xc7>
mov    -0x10(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x30(%rbp)
jmp    121f <string_input_for_buffer+0xcf>
mov    -0x10(%rbp),%rax
mov    %rax,-0x30(%rbp)
mov    -0x30(%rbp),%rax
mov    %rax,-0x8(%rbp)
jmp    12a9 <string_input_for_buffer+0x159>
mov    -0x10(%rbp),%rdi
call   1040 <string_is_command_char@plt>
cmp    $0x0,%eax
jne    124b <string_input_for_buffer+0xfb>
mov    -0x10(%rbp),%rax
mov    %rax,-0x8(%rbp)
jmp    12a9 <string_input_for_buffer+0x159>
mov    -0x10(%rbp),%rdi
call   1070 <utf8_next_char@plt>
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
je     1270 <string_input_for_buffer+0x120>
mov    -0x28(%rbp),%rax
cmpb   $0x0,(%rax)
jne    127d <string_input_for_buffer+0x12d>
movq   $0x0,-0x8(%rbp)
jmp    12a9 <string_input_for_buffer+0x159>
mov    -0x10(%rbp),%rdi
mov    -0x28(%rbp),%rsi
call   1060 <utf8_charcmp@plt>
cmp    $0x0,%rax
jne    12a1 <string_input_for_buffer+0x151>
mov    -0x28(%rbp),%rax
mov    %rax,-0x8(%rbp)
jmp    12a9 <string_input_for_buffer+0x159>
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
mov    %rdi,%rbx
lea    0xea1(%rip),%rsi
mov    $0x2,%edx
call   1030 <strncmp@plt>
test   %rax,%rax
je     11e2 <string_input_for_buffer+0x92>
cmpb   $0x2f,(%rbx)
jne    11a9 <string_input_for_buffer+0x59>
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     11e0 <string_input_for_buffer+0x90>
test   %rax,%rax
je     11a3 <string_input_for_buffer+0x53>
cmp    %rax,%r15
ja     11e0 <string_input_for_buffer+0x90>
cmpb   $0x2f,0x1(%rbx)
jmp    11da <string_input_for_buffer+0x8a>
mov    %rbx,%rdi
call   1040 <string_is_command_char@plt>
test   %eax,%eax
je     11e2 <string_input_for_buffer+0x92>
mov    %rbx,%rdi
call   1070 <utf8_next_char@plt>
test   %rax,%rax
je     11e0 <string_input_for_buffer+0x90>
mov    %rax,%r14
cmpb   $0x0,(%rax)
je     11e0 <string_input_for_buffer+0x90>
mov    %rbx,%rdi
mov    %r14,%rsi
call   1060 <utf8_charcmp@plt>
xor    %ebx,%ebx
test   %rax,%rax
cmove  %r14,%rbx
jmp    11e2 <string_input_for_buffer+0x92>
xor    %ebx,%ebx
mov    %rbx,%rax
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [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 = call i64 @strncmp(i8* %7, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 2)
%9 = icmp eq i64 %8, 0
br i1 %9, label %10, label %12
10: ; preds = %1
%11 = load i8*, i8** %3
store i8* %11, i8** %2
br label %73
12: ; preds = %1
%13 = load i8*, i8** %3
%14 = getelementptr inbounds i8, i8* %13, i64 0
%15 = load i8, i8* %14
%16 = sext i8 %15 to i32
%17 = icmp eq i32 %16, 47
br i1 %17, label %18, label %48
18: ; preds = %12
%19 = load i8*, i8** %3
%20 = getelementptr inbounds i8, i8* %19, i64 1
%21 = call i8* @strchr(i8* %20, i8 signext 47)
store i8* %21, i8** %4
%22 = load i8*, i8** %3
%23 = getelementptr inbounds i8, i8* %22, i64 1
%24 = call i8* @strchr(i8* %23, i8 signext 32)
store i8* %24, i8** %5
%25 = load i8*, i8** %4
%26 = icmp ne i8* %25, null
br i1 %26, label %27, label %34
27: ; preds = %18
%28 = load i8*, i8** %5
%29 = icmp ne i8* %28, null
br i1 %29, label %30, label %35
30: ; preds = %27
%31 = load i8*, i8** %4
%32 = load i8*, i8** %5
%33 = icmp ugt i8* %31, %32
br i1 %33, label %34, label %35
34: ; preds = %30, %18
store i8* null, i8** %2
br label %73
35: ; preds = %30, %27
%36 = load i8*, i8** %3
%37 = getelementptr inbounds i8, i8* %36, i64 1
%38 = load i8, i8* %37
%39 = sext i8 %38 to i32
%40 = icmp eq i32 %39, 47
br i1 %40, label %41, label %44
41: ; preds = %35
%42 = load i8*, i8** %3
%43 = getelementptr inbounds i8, i8* %42, i64 1
br label %46
44: ; preds = %35
%45 = load i8*, i8** %3
br label %46
46: ; preds = %44, %41
%47 = phi i8* [ %43, %41 ], [ %45, %44 ]
store i8* %47, i8** %2
br label %73
48: ; preds = %12
%49 = load i8*, i8** %3
%50 = call i32 @string_is_command_char(i8* %49)
%51 = icmp ne i32 %50, 0
br i1 %51, label %54, label %52
52: ; preds = %48
%53 = load i8*, i8** %3
store i8* %53, i8** %2
br label %73
54: ; preds = %48
%55 = load i8*, i8** %3
%56 = call i8* @utf8_next_char(i8* %55)
store i8* %56, i8** %6
%57 = load i8*, i8** %6
%58 = icmp ne i8* %57, null
br i1 %58, label %59, label %64
59: ; preds = %54
%60 = load i8*, i8** %6
%61 = getelementptr inbounds i8, i8* %60, i64 0
%62 = load i8, i8* %61
%63 = icmp ne i8 %62, 0
br i1 %63, label %65, label %64
64: ; preds = %59, %54
store i8* null, i8** %2
br label %73
65: ; preds = %59
%66 = load i8*, i8** %3
%67 = load i8*, i8** %6
%68 = call i64 @utf8_charcmp(i8* %66, i8* %67)
%69 = icmp eq i64 %68, 0
br i1 %69, label %70, label %72
70: ; preds = %65
%71 = load i8*, i8** %6
store i8* %71, i8** %2
br label %73
72: ; preds = %65
store i8* null, i8** %2
br label %73
73: ; preds = %72, %70, %64, %52, %46, %34, %10
%74 = load i8*, i8** %2
ret i8* %74
}

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