#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 /*<<< orphan*/ fputc(char, int /*<<< orphan*/);
int /*<<< orphan*/ princhar(int /*<<< orphan*/);
int /*<<< orphan*/ stdout;
scalar_t__ strchr(char *, int /*<<< orphan*/);
void prinstr(char *s) {
  int q = 0;
  char *s2 = s;
  while (*s2 != 0)
    if (strchr("~`$^&*()=\\|[]{};'\"<>?", *s2++) != 0)
      q = 1;
  if (q)
    fputc('"', stdout);
  while (*s != 0)
    princhar(*s++);
  if (q)
    fputc('"', stdout);
}


x86 assembly (clang, -O0):
<prinstr>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
je     118f <prinstr+0x5f>
mov    -0x18(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x18(%rbp)
movsbl (%rax),%esi
lea    0xe8c(%rip),%rdi
call   1030 <strchr@plt>
cmp    $0x0,%rax
je     118a <prinstr+0x5a>
movl   $0x1,-0xc(%rbp)
jmp    114b <prinstr+0x1b>
cmpl   $0x0,-0xc(%rbp)
je     11ac <prinstr+0x7c>
mov    0x2e40(%rip),%rax
mov    (%rax),%esi
mov    $0x22,%edi
call   1040 <fputc@plt>
jmp    11b1 <prinstr+0x81>
mov    -0x8(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
je     11dd <prinstr+0xad>
mov    -0x8(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x8(%rbp)
movsbl (%rax),%edi
call   1050 <princhar@plt>
jmp    11b1 <prinstr+0x81>
cmpl   $0x0,-0xc(%rbp)
je     11fa <prinstr+0xca>
mov    0x2df2(%rip),%rax
mov    (%rax),%esi
mov    $0x22,%edi
call   1040 <fputc@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<prinstr>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    (%rdi),%al
test   %al,%al
je     11d3 <prinstr+0xa3>
mov    %rdi,%r15
lea    0x1(%rdi),%rbx
xor    %ebp,%ebp
lea    0xeae(%rip),%r14
mov    $0x1,%r12d
nopl   0x0(%rax,%rax,1)
movsbl %al,%esi
mov    %r14,%rdi
call   1030 <strchr@plt>
test   %rax,%rax
cmovne %r12d,%ebp
movzbl (%rbx),%eax
add    $0x1,%rbx
test   %al,%al
jne    1160 <prinstr+0x30>
test   %ebp,%ebp
je     1194 <prinstr+0x64>
mov    0x2e58(%rip),%rax
mov    (%rax),%esi
mov    $0x22,%edi
call   1040 <fputc@plt>
mov    (%r15),%al
test   %al,%al
je     11b4 <prinstr+0x84>
add    $0x1,%r15
nop
movsbl %al,%edi
call   1050 <princhar@plt>
movzbl (%r15),%eax
add    $0x1,%r15
test   %al,%al
jne    11a0 <prinstr+0x70>
test   %ebp,%ebp
je     11d3 <prinstr+0xa3>
mov    0x2e21(%rip),%rax
mov    (%rax),%esi
mov    $0x22,%edi
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
jmp    1040 <fputc@plt>
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [22 x i8] c"~`$^&*()=\\|[]{};'\22<>?\00"
@stdout = global i32 0
define void @prinstr(i8* %0) {
%2 = alloca i8*
%3 = alloca i32
%4 = alloca i8*
store i8* %0, i8** %2
store i32 0, i32* %3
%5 = load i8*, i8** %2
store i8* %5, i8** %4
br label %6
6: ; preds = %19, %1
%7 = load i8*, i8** %4
%8 = load i8, i8* %7
%9 = sext i8 %8 to i32
%10 = icmp ne i32 %9, 0
br i1 %10, label %11, label %20
11: ; preds = %6
%12 = load i8*, i8** %4
%13 = getelementptr inbounds i8, i8* %12, i32 1
store i8* %13, i8** %4
%14 = load i8, i8* %12
%15 = sext i8 %14 to i32
%16 = call i64 @strchr(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0), i32 %15)
%17 = icmp ne i64 %16, 0
br i1 %17, label %18, label %19
18: ; preds = %11
store i32 1, i32* %3
br label %19
19: ; preds = %18, %11
br label %6
20: ; preds = %6
%21 = load i32, i32* %3
%22 = icmp ne i32 %21, 0
br i1 %22, label %23, label %26
23: ; preds = %20
%24 = load i32, i32* @stdout
%25 = call i32 @fputc(i8 signext 34, i32 %24)
br label %26
26: ; preds = %23, %20
br label %27
27: ; preds = %32, %26
%28 = load i8*, i8** %2
%29 = load i8, i8* %28
%30 = sext i8 %29 to i32
%31 = icmp ne i32 %30, 0
br i1 %31, label %32, label %38
32: ; preds = %27
%33 = load i8*, i8** %2
%34 = getelementptr inbounds i8, i8* %33, i32 1
store i8* %34, i8** %2
%35 = load i8, i8* %33
%36 = sext i8 %35 to i32
%37 = call i32 @princhar(i32 %36)
br label %27
38: ; preds = %27
%39 = load i32, i32* %3
%40 = icmp ne i32 %39, 0
br i1 %40, label %41, label %44
41: ; preds = %38
%42 = load i32, i32* @stdout
%43 = call i32 @fputc(i8 signext 34, i32 %42)
br label %44
44: ; preds = %41, %38
ret void
}

LLVM IR (-O2):
@.str = [22 x i8] c"~`$^&*()=\\|[]{};'\22<>?\00"
@stdout = global i32 0
define void @prinstr(i8* nocapture %0) {
%2 = load i8, i8* %0
%3 = icmp eq i8 %2, 0
br i1 %3, label %35, label %4
4: ; preds = %1, %4
%5 = phi i8 [ %13, %4 ], [ %2, %1 ]
%6 = phi i8* [ %9, %4 ], [ %0, %1 ]
%7 = phi i32 [ %12, %4 ], [ 0, %1 ]
%8 = sext i8 %5 to i32
%9 = getelementptr inbounds i8, i8* %6, i64 1
%10 = tail call i64 @strchr(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0), i32 %8)
%11 = icmp eq i64 %10, 0
%12 = select i1 %11, i32 %7, i32 1
%13 = load i8, i8* %9
%14 = icmp eq i8 %13, 0
br i1 %14, label %15, label %4
15: ; preds = %4
%16 = icmp eq i32 %12, 0
br i1 %16, label %20, label %17
17: ; preds = %15
%18 = load i32, i32* @stdout
%19 = tail call i32 @fputc(i8 signext 34, i32 %18)
br label %20
20: ; preds = %17, %15
%21 = load i8, i8* %0
%22 = icmp eq i8 %21, 0
br i1 %22, label %31, label %23
23: ; preds = %20, %23
%24 = phi i8 [ %29, %23 ], [ %21, %20 ]
%25 = phi i8* [ %27, %23 ], [ %0, %20 ]
%26 = sext i8 %24 to i32
%27 = getelementptr inbounds i8, i8* %25, i64 1
%28 = tail call i32 @princhar(i32 %26)
%29 = load i8, i8* %27
%30 = icmp eq i8 %29, 0
br i1 %30, label %31, label %23
31: ; preds = %23, %20
br i1 %16, label %35, label %32
32: ; preds = %31
%33 = load i32, i32* @stdout
%34 = tail call i32 @fputc(i8 signext 34, i32 %33)
br label %35
35: ; preds = %1, %32, %31
ret void
}