#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 (!string)
    return NULL;
  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)
cmpq   $0x0,-0x10(%rbp)
jne    1174 <string_input_for_buffer+0x24>
movq   $0x0,-0x8(%rbp)
jmp    12c1 <string_input_for_buffer+0x171>
mov    -0x10(%rbp),%rdi
lea    0xe81(%rip),%rsi
mov    $0x2,%edx
call   1030 <strncmp@plt>
cmp    $0x0,%rax
jne    11a0 <string_input_for_buffer+0x50>
mov    -0x10(%rbp),%rax
mov    %rax,-0x8(%rbp)
jmp    12c1 <string_input_for_buffer+0x171>
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x2f,%eax
jne    1244 <string_input_for_buffer+0xf4>
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     1200 <string_input_for_buffer+0xb0>
cmpq   $0x0,-0x20(%rbp)
je     120d <string_input_for_buffer+0xbd>
mov    -0x18(%rbp),%rax
cmp    -0x20(%rbp),%rax
jbe    120d <string_input_for_buffer+0xbd>
movq   $0x0,-0x8(%rbp)
jmp    12c1 <string_input_for_buffer+0x171>
mov    -0x10(%rbp),%rax
movsbl 0x1(%rax),%eax
cmp    $0x2f,%eax
jne    122f <string_input_for_buffer+0xdf>
mov    -0x10(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x30(%rbp)
jmp    1237 <string_input_for_buffer+0xe7>
mov    -0x10(%rbp),%rax
mov    %rax,-0x30(%rbp)
mov    -0x30(%rbp),%rax
mov    %rax,-0x8(%rbp)
jmp    12c1 <string_input_for_buffer+0x171>
mov    -0x10(%rbp),%rdi
call   1040 <string_is_command_char@plt>
cmp    $0x0,%eax
jne    1263 <string_input_for_buffer+0x113>
mov    -0x10(%rbp),%rax
mov    %rax,-0x8(%rbp)
jmp    12c1 <string_input_for_buffer+0x171>
mov    -0x10(%rbp),%rdi
call   1070 <utf8_next_char@plt>
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
je     1288 <string_input_for_buffer+0x138>
mov    -0x28(%rbp),%rax
cmpb   $0x0,(%rax)
jne    1295 <string_input_for_buffer+0x145>
movq   $0x0,-0x8(%rbp)
jmp    12c1 <string_input_for_buffer+0x171>
mov    -0x10(%rbp),%rdi
mov    -0x28(%rbp),%rsi
call   1060 <utf8_charcmp@plt>
cmp    $0x0,%rax
jne    12b9 <string_input_for_buffer+0x169>
mov    -0x28(%rbp),%rax
mov    %rax,-0x8(%rbp)
jmp    12c1 <string_input_for_buffer+0x171>
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     11e9 <string_input_for_buffer+0x99>
mov    %rdi,%rbx
lea    0xe98(%rip),%rsi
mov    $0x2,%edx
call   1030 <strncmp@plt>
test   %rax,%rax
je     11eb <string_input_for_buffer+0x9b>
cmpb   $0x2f,(%rbx)
jne    11b2 <string_input_for_buffer+0x62>
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     11e9 <string_input_for_buffer+0x99>
test   %rax,%rax
je     11ac <string_input_for_buffer+0x5c>
cmp    %rax,%r15
ja     11e9 <string_input_for_buffer+0x99>
cmpb   $0x2f,0x1(%rbx)
jmp    11e3 <string_input_for_buffer+0x93>
mov    %rbx,%rdi
call   1040 <string_is_command_char@plt>
test   %eax,%eax
je     11eb <string_input_for_buffer+0x9b>
mov    %rbx,%rdi
call   1070 <utf8_next_char@plt>
test   %rax,%rax
je     11e9 <string_input_for_buffer+0x99>
mov    %rax,%r14
cmpb   $0x0,(%rax)
je     11e9 <string_input_for_buffer+0x99>
mov    %rbx,%rdi
mov    %r14,%rsi
call   1060 <utf8_charcmp@plt>
xor    %ebx,%ebx
test   %rax,%rax
cmove  %r14,%rbx
jmp    11eb <string_input_for_buffer+0x9b>
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 = icmp ne i8* %7, null
br i1 %8, label %10, label %9
9: ; preds = %1
store i8* null, i8** %2
br label %77
10: ; preds = %1
%11 = load i8*, i8** %3
%12 = call i64 @strncmp(i8* %11, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 2)
%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 %77
16: ; preds = %10
%17 = load i8*, i8** %3
%18 = getelementptr inbounds i8, i8* %17, i64 0
%19 = load i8, i8* %18
%20 = sext i8 %19 to i32
%21 = icmp eq i32 %20, 47
br i1 %21, label %22, label %52
22: ; preds = %16
%23 = load i8*, i8** %3
%24 = getelementptr inbounds i8, i8* %23, i64 1
%25 = call i8* @strchr(i8* %24, i8 signext 47)
store i8* %25, i8** %4
%26 = load i8*, i8** %3
%27 = getelementptr inbounds i8, i8* %26, i64 1
%28 = call i8* @strchr(i8* %27, i8 signext 32)
store i8* %28, i8** %5
%29 = load i8*, i8** %4
%30 = icmp ne i8* %29, null
br i1 %30, label %31, label %38
31: ; preds = %22
%32 = load i8*, i8** %5
%33 = icmp ne i8* %32, null
br i1 %33, label %34, label %39
34: ; preds = %31
%35 = load i8*, i8** %4
%36 = load i8*, i8** %5
%37 = icmp ugt i8* %35, %36
br i1 %37, label %38, label %39
38: ; preds = %34, %22
store i8* null, i8** %2
br label %77
39: ; preds = %34, %31
%40 = load i8*, i8** %3
%41 = getelementptr inbounds i8, i8* %40, i64 1
%42 = load i8, i8* %41
%43 = sext i8 %42 to i32
%44 = icmp eq i32 %43, 47
br i1 %44, label %45, label %48
45: ; preds = %39
%46 = load i8*, i8** %3
%47 = getelementptr inbounds i8, i8* %46, i64 1
br label %50
48: ; preds = %39
%49 = load i8*, i8** %3
br label %50
50: ; preds = %48, %45
%51 = phi i8* [ %47, %45 ], [ %49, %48 ]
store i8* %51, i8** %2
br label %77
52: ; preds = %16
%53 = load i8*, i8** %3
%54 = call i32 @string_is_command_char(i8* %53)
%55 = icmp ne i32 %54, 0
br i1 %55, label %58, label %56
56: ; preds = %52
%57 = load i8*, i8** %3
store i8* %57, i8** %2
br label %77
58: ; preds = %52
%59 = load i8*, i8** %3
%60 = call i8* @utf8_next_char(i8* %59)
store i8* %60, i8** %6
%61 = load i8*, i8** %6
%62 = icmp ne i8* %61, null
br i1 %62, label %63, label %68
63: ; preds = %58
%64 = load i8*, i8** %6
%65 = getelementptr inbounds i8, i8* %64, i64 0
%66 = load i8, i8* %65
%67 = icmp ne i8 %66, 0
br i1 %67, label %69, label %68
68: ; preds = %63, %58
store i8* null, i8** %2
br label %77
69: ; preds = %63
%70 = load i8*, i8** %3
%71 = load i8*, i8** %6
%72 = call i64 @utf8_charcmp(i8* %70, i8* %71)
%73 = icmp eq i64 %72, 0
br i1 %73, label %74, label %76
74: ; preds = %69
%75 = load i8*, i8** %6
store i8* %75, i8** %2
br label %77
76: ; preds = %69
store i8* null, i8** %2
br label %77
77: ; preds = %76, %74, %68, %56, %50, %38, %14, %9
%78 = load i8*, i8** %2
ret i8* %78
}

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