#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 */
typedef int /*<<< orphan*/ temp;

/* Variables and functions */
int /*<<< orphan*/ sprintf(char *, char *, char *);
int /*<<< orphan*/ strncpy(char *, char *, int);
char *ok_char(char *src) {
  static char temp[20];
  if (src[0] != '\\' || src[1] == '\\') {
    (void)sprintf(temp, "'%s'", src);
  } else {
    strncpy(temp, src, sizeof(temp) - 1);
    *temp = '0';
  }
  return temp;
}


x86 assembly (clang, -O0):
<ok_char>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x5c,%eax
jne    114d <ok_char+0x2d>
mov    -0x8(%rbp),%rax
movsbl 0x1(%rax),%eax
cmp    $0x5c,%eax
jne    1169 <ok_char+0x49>
mov    -0x8(%rbp),%rdx
lea    0x2ee8(%rip),%rdi
lea    0xea1(%rip),%rsi
call   1040 <sprintf@plt>
jmp    1185 <ok_char+0x65>
mov    -0x8(%rbp),%rsi
lea    0x2ecc(%rip),%rdi
mov    $0x13,%edx
call   1030 <strncpy@plt>
movb   $0x30,0x2ebb(%rip)
lea    0x2eb4(%rip),%rax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ok_char>:
push   %rax
mov    %rdi,%rdx
cmpb   $0x5c,(%rdi)
jne    112f <ok_char+0xf>
cmpb   $0x5c,0x1(%rdx)
jne    1144 <ok_char+0x24>
lea    0x2f0a(%rip),%rdi
lea    0xec3(%rip),%rsi
call   1040 <sprintf@plt>
jmp    115f <ok_char+0x3f>
lea    0x2ef5(%rip),%rdi
mov    %rdx,%rsi
mov    $0x13,%edx
call   1030 <strncpy@plt>
movb   $0x30,0x2ee1(%rip)
lea    0x2eda(%rip),%rax
pop    %rcx
ret

LLVM IR (-O0):
@ok_char.temp = internal global [20 x i8] zeroinitializer
@.str = [5 x i8] c"'%s'\00"
define i8* @ok_char(i8* %0) {
%2 = alloca i8*
store i8* %0, i8** %2
%3 = load i8*, i8** %2
%4 = getelementptr inbounds i8, i8* %3, i64 0
%5 = load i8, i8* %4
%6 = sext i8 %5 to i32
%7 = icmp ne i32 %6, 92
br i1 %7, label %14, label %8
8: ; preds = %1
%9 = load i8*, i8** %2
%10 = getelementptr inbounds i8, i8* %9, i64 1
%11 = load i8, i8* %10
%12 = sext i8 %11 to i32
%13 = icmp eq i32 %12, 92
br i1 %13, label %14, label %17
14: ; preds = %8, %1
%15 = load i8*, i8** %2
%16 = call i32 @sprintf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @ok_char.temp, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i8* %15)
br label %20
17: ; preds = %8
%18 = load i8*, i8** %2
%19 = call i32 @strncpy(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @ok_char.temp, i64 0, i64 0), i8* %18, i32 19)
store i8 48, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @ok_char.temp, i64 0, i64 0)
br label %20
20: ; preds = %17, %14
ret i8* getelementptr inbounds ([20 x i8], [20 x i8]* @ok_char.temp, i64 0, i64 0)
}

LLVM IR (-O2):
@ok_char.temp = internal global [20 x i8] zeroinitializer
@.str = [5 x i8] c"'%s'\00"
define i8* @ok_char(i8* %0) {
%2 = load i8, i8* %0
%3 = icmp eq i8 %2, 92
br i1 %3, label %4, label %8
4: ; preds = %1
%5 = getelementptr inbounds i8, i8* %0, i64 1
%6 = load i8, i8* %5
%7 = icmp eq i8 %6, 92
br i1 %7, label %8, label %10
8: ; preds = %4, %1
%9 = tail call i32 @sprintf(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @ok_char.temp, i64 0, i64 0), i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i8* %0)
br label %12
10: ; preds = %4
%11 = tail call i32 @strncpy(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @ok_char.temp, i64 0, i64 0), i8* %0, i32 19)
store i8 48, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @ok_char.temp, i64 0, i64 0)
br label %12
12: ; preds = %10, %8
ret i8* getelementptr inbounds ([20 x i8], [20 x i8]* @ok_char.temp, i64 0, i64 0)
}