#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 get_char_utf8(char const **);
scalar_t__ iscntrl(char const);
scalar_t__ isdigit(char const);
scalar_t__ isspace(char const);
scalar_t__ isupper(char const);
scalar_t__ strchr(char const *, char const);
int /*<<< orphan*/ strcmp(char const *, char *);
int needs_quoting(const char *s) {
  if (!*s)
    return 1;
  if (!strcmp(s, "[]") || !strcmp(s, "{}") || !strcmp(s, ":-"))
    return 0;
  static const char chars[] = "%_\"'`|,()[]{}";
  if (isupper(*s) || isdigit(*s) || isspace(*s) || iscntrl(*s) ||
      strchr(chars, *s))
    return 1;
  while (*s) {
    int ch = get_char_utf8(&s);
    if (isspace(ch) || iscntrl(ch) || (ch == '.'))
      return 1;
  }
  return 0;
}


x86 assembly (clang, -O0):
<needs_quoting>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rax
cmpb   $0x0,(%rax)
jne    1195 <needs_quoting+0x25>
movl   $0x1,-0x4(%rbp)
jmp    12d7 <needs_quoting+0x167>
mov    -0x10(%rbp),%rdi
lea    0xe60(%rip),%rsi
call   1080 <strcmp@plt>
cmp    $0x0,%eax
je     11e0 <needs_quoting+0x70>
mov    -0x10(%rbp),%rdi
lea    0xe4a(%rip),%rsi
call   1080 <strcmp@plt>
cmp    $0x0,%eax
je     11e0 <needs_quoting+0x70>
mov    -0x10(%rbp),%rdi
lea    0xe34(%rip),%rsi
call   1080 <strcmp@plt>
cmp    $0x0,%eax
jne    11ec <needs_quoting+0x7c>
movl   $0x0,-0x4(%rbp)
jmp    12d7 <needs_quoting+0x167>
mov    -0x10(%rbp),%rax
movsbl (%rax),%edi
call   1090 <isupper@plt>
cmp    $0x0,%rax
jne    1261 <needs_quoting+0xf1>
mov    -0x10(%rbp),%rax
movsbl (%rax),%edi
call   1030 <isdigit@plt>
cmp    $0x0,%rax
jne    1261 <needs_quoting+0xf1>
mov    -0x10(%rbp),%rax
movsbl (%rax),%edi
call   1070 <isspace@plt>
cmp    $0x0,%rax
jne    1261 <needs_quoting+0xf1>
mov    -0x10(%rbp),%rax
movsbl (%rax),%edi
call   1040 <iscntrl@plt>
cmp    $0x0,%rax
jne    1261 <needs_quoting+0xf1>
mov    -0x10(%rbp),%rax
lea    0xdba(%rip),%rdi
movsbl (%rax),%esi
call   1050 <strchr@plt>
cmp    $0x0,%rax
je     126d <needs_quoting+0xfd>
movl   $0x1,-0x4(%rbp)
jmp    12d7 <needs_quoting+0x167>
jmp    1272 <needs_quoting+0x102>
mov    -0x10(%rbp),%rax
cmpb   $0x0,(%rax)
je     12d0 <needs_quoting+0x160>
lea    -0x10(%rbp),%rdi
call   1060 <get_char_utf8@plt>
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%eax
movsbl %al,%edi
call   1070 <isspace@plt>
cmp    $0x0,%rax
jne    12bf <needs_quoting+0x14f>
mov    -0x14(%rbp),%eax
movsbl %al,%edi
call   1040 <iscntrl@plt>
cmp    $0x0,%rax
jne    12bf <needs_quoting+0x14f>
cmpl   $0x2e,-0x14(%rbp)
jne    12cb <needs_quoting+0x15b>
movl   $0x1,-0x4(%rbp)
jmp    12d7 <needs_quoting+0x167>
jmp    1272 <needs_quoting+0x102>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<needs_quoting>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %rdi,(%rsp)
mov    (%rdi),%r14b
mov    $0x1,%ebp
test   %r14b,%r14b
je     125a <needs_quoting+0xea>
mov    %rdi,%rbx
lea    0xe6a(%rip),%rsi
call   1080 <strcmp@plt>
test   %eax,%eax
je     1258 <needs_quoting+0xe8>
lea    0xe59(%rip),%rsi
mov    %rbx,%rdi
call   1080 <strcmp@plt>
test   %eax,%eax
je     1258 <needs_quoting+0xe8>
lea    0xe45(%rip),%rsi
mov    %rbx,%rdi
call   1080 <strcmp@plt>
test   %eax,%eax
je     1258 <needs_quoting+0xe8>
movsbl %r14b,%edi
call   1090 <isupper@plt>
test   %rax,%rax
jne    125a <needs_quoting+0xea>
movsbl (%rbx),%edi
call   1030 <isdigit@plt>
test   %rax,%rax
jne    125a <needs_quoting+0xea>
movsbl (%rbx),%edi
call   1070 <isspace@plt>
test   %rax,%rax
jne    125a <needs_quoting+0xea>
movsbl (%rbx),%edi
call   1040 <iscntrl@plt>
test   %rax,%rax
jne    125a <needs_quoting+0xea>
movsbl (%rbx),%esi
lea    0xdf9(%rip),%rdi
call   1050 <strchr@plt>
test   %rax,%rax
jne    125a <needs_quoting+0xea>
cmpb   $0x0,(%rbx)
je     1258 <needs_quoting+0xe8>
mov    %rsp,%r14
mov    %r14,%rdi
call   1060 <get_char_utf8@plt>
mov    %eax,%r15d
movsbl %r15b,%ebx
mov    %ebx,%edi
call   1070 <isspace@plt>
test   %rax,%rax
jne    125a <needs_quoting+0xea>
mov    %ebx,%edi
call   1040 <iscntrl@plt>
test   %rax,%rax
jne    125a <needs_quoting+0xea>
cmp    $0x2e,%r15d
je     125a <needs_quoting+0xea>
mov    (%rsp),%rax
cmpb   $0x0,(%rax)
jne    1222 <needs_quoting+0xb2>
xor    %ebp,%ebp
mov    %ebp,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [3 x i8] c"[]\00"
@.str.1 = [3 x i8] c"{}\00"
@.str.2 = [3 x i8] c":-\00"
@needs_quoting.chars = internal constant [14 x i8] c"%_\22'`|,()[]{}\00"
define i32 @needs_quoting(i8* %0) {
%2 = alloca i32
%3 = alloca i8*
%4 = alloca i32
store i8* %0, i8** %3
%5 = load i8*, i8** %3
%6 = load i8, i8* %5
%7 = icmp ne i8 %6, 0
br i1 %7, label %9, label %8
8: ; preds = %1
store i32 1, i32* %2
br label %70
9: ; preds = %1
%10 = load i8*, i8** %3
%11 = call i32 @strcmp(i8* %10, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%12 = icmp ne i32 %11, 0
br i1 %12, label %13, label %21
13: ; preds = %9
%14 = load i8*, i8** %3
%15 = call i32 @strcmp(i8* %14, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%16 = icmp ne i32 %15, 0
br i1 %16, label %17, label %21
17: ; preds = %13
%18 = load i8*, i8** %3
%19 = call i32 @strcmp(i8* %18, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
%20 = icmp ne i32 %19, 0
br i1 %20, label %22, label %21
21: ; preds = %17, %13, %9
store i32 0, i32* %2
br label %70
22: ; preds = %17
%23 = load i8*, i8** %3
%24 = load i8, i8* %23
%25 = call i64 @isupper(i8 signext %24)
%26 = icmp ne i64 %25, 0
br i1 %26, label %47, label %27
27: ; preds = %22
%28 = load i8*, i8** %3
%29 = load i8, i8* %28
%30 = call i64 @isdigit(i8 signext %29)
%31 = icmp ne i64 %30, 0
br i1 %31, label %47, label %32
32: ; preds = %27
%33 = load i8*, i8** %3
%34 = load i8, i8* %33
%35 = call i64 @isspace(i8 signext %34)
%36 = icmp ne i64 %35, 0
br i1 %36, label %47, label %37
37: ; preds = %32
%38 = load i8*, i8** %3
%39 = load i8, i8* %38
%40 = call i64 @iscntrl(i8 signext %39)
%41 = icmp ne i64 %40, 0
br i1 %41, label %47, label %42
42: ; preds = %37
%43 = load i8*, i8** %3
%44 = load i8, i8* %43
%45 = call i64 @strchr(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @needs_quoting.chars, i64 0, i64 0), i8 signext %44)
%46 = icmp ne i64 %45, 0
br i1 %46, label %47, label %48
47: ; preds = %42, %37, %32, %27, %22
store i32 1, i32* %2
br label %70
48: ; preds = %42
br label %49
49: ; preds = %68, %48
%50 = load i8*, i8** %3
%51 = load i8, i8* %50
%52 = icmp ne i8 %51, 0
br i1 %52, label %53, label %69
53: ; preds = %49
%54 = call i32 @get_char_utf8(i8** %3)
store i32 %54, i32* %4
%55 = load i32, i32* %4
%56 = trunc i32 %55 to i8
%57 = call i64 @isspace(i8 signext %56)
%58 = icmp ne i64 %57, 0
br i1 %58, label %67, label %59
59: ; preds = %53
%60 = load i32, i32* %4
%61 = trunc i32 %60 to i8
%62 = call i64 @iscntrl(i8 signext %61)
%63 = icmp ne i64 %62, 0
br i1 %63, label %67, label %64
64: ; preds = %59
%65 = load i32, i32* %4
%66 = icmp eq i32 %65, 46
br i1 %66, label %67, label %68
67: ; preds = %64, %59, %53
store i32 1, i32* %2
br label %70
68: ; preds = %64
br label %49
69: ; preds = %49
store i32 0, i32* %2
br label %70
70: ; preds = %69, %67, %47, %21, %8
%71 = load i32, i32* %2
ret i32 %71
}

LLVM IR (-O2):
@.str = [3 x i8] c"[]\00"
@.str.1 = [3 x i8] c"{}\00"
@.str.2 = [3 x i8] c":-\00"
@needs_quoting.chars = internal constant [14 x i8] c"%_\22'`|,()[]{}\00"
define i32 @needs_quoting(i8* %0) {
%2 = alloca i8*
store i8* %0, i8** %2
%3 = load i8, i8* %0
%4 = icmp eq i8 %3, 0
br i1 %4, label %50, label %5
5: ; preds = %1
%6 = tail call i32 @strcmp(i8* %0, i8* dereferenceable(3) getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%7 = icmp eq i32 %6, 0
br i1 %7, label %50, label %8
8: ; preds = %5
%9 = tail call i32 @strcmp(i8* %0, i8* dereferenceable(3) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%10 = icmp eq i32 %9, 0
br i1 %10, label %50, label %11
11: ; preds = %8
%12 = tail call i32 @strcmp(i8* %0, i8* dereferenceable(3) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
%13 = icmp eq i32 %12, 0
br i1 %13, label %50, label %14
14: ; preds = %11
%15 = tail call i64 @isupper(i8 signext %3)
%16 = icmp eq i64 %15, 0
br i1 %16, label %17, label %50
17: ; preds = %14
%18 = load i8, i8* %0
%19 = tail call i64 @isdigit(i8 signext %18)
%20 = icmp eq i64 %19, 0
br i1 %20, label %21, label %50
21: ; preds = %17
%22 = load i8, i8* %0
%23 = tail call i64 @isspace(i8 signext %22)
%24 = icmp eq i64 %23, 0
br i1 %24, label %25, label %50
25: ; preds = %21
%26 = load i8, i8* %0
%27 = tail call i64 @iscntrl(i8 signext %26)
%28 = icmp eq i64 %27, 0
br i1 %28, label %29, label %50
29: ; preds = %25
%30 = load i8, i8* %0
%31 = tail call i64 @strchr(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @needs_quoting.chars, i64 0, i64 0), i8 signext %30)
%32 = icmp eq i64 %31, 0
br i1 %32, label %33, label %50
33: ; preds = %29
%34 = load i8, i8* %0
%35 = icmp eq i8 %34, 0
br i1 %35, label %50, label %36
36: ; preds = %33, %46
%37 = call i32 @get_char_utf8(i8** %2)
%38 = trunc i32 %37 to i8
%39 = call i64 @isspace(i8 signext %38)
%40 = icmp eq i64 %39, 0
br i1 %40, label %41, label %50
41: ; preds = %36
%42 = call i64 @iscntrl(i8 signext %38)
%43 = icmp eq i64 %42, 0
%44 = icmp ne i32 %37, 46
%45 = select i1 %43, i1 %44, i1 false
br i1 %45, label %46, label %50
46: ; preds = %41
%47 = load i8*, i8** %2
%48 = load i8, i8* %47
%49 = icmp eq i8 %48, 0
br i1 %49, label %50, label %36
50: ; preds = %46, %36, %41, %33, %14, %17, %21, %25, %29, %5, %8, %11, %1
%51 = phi i32 [ 1, %1 ], [ 0, %11 ], [ 0, %8 ], [ 0, %5 ], [ 1, %29 ], [ 1, %25 ], [ 1, %21 ], [ 1, %17 ], [ 1, %14 ], [ 0, %33 ], [ 1, %41 ], [ 1, %36 ], [ 0, %46 ]
ret i32 %51
}