#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 istrsenvisx(char *, int /*<<< orphan*/ *, char *, int, int, char *,
                int /*<<< orphan*/ *);
char *vis(char *mbdst, int c, int flags, int nextc) {
  char cc[2];
  int ret;
  cc[0] = (char)c;
  cc[1] = (char)nextc;
  ret = istrsenvisx(mbdst, NULL, cc, 1, flags, "", NULL);
  if (ret < 0) {
    return NULL;
  }
  return mbdst + ret;
}


x86 assembly (clang, -O0):
<vis>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
mov    %edx,-0x18(%rbp)
mov    %ecx,-0x1c(%rbp)
mov    -0x14(%rbp),%eax
mov    %al,-0x1e(%rbp)
mov    -0x1c(%rbp),%eax
mov    %al,-0x1d(%rbp)
mov    -0x10(%rbp),%rdi
lea    -0x1e(%rbp),%rdx
mov    -0x18(%rbp),%r8d
xor    %eax,%eax
mov    %eax,%esi
mov    $0x1,%ecx
lea    0xeb3(%rip),%r9
movq   $0x0,(%rsp)
call   1030 <istrsenvisx@plt>
mov    %eax,-0x24(%rbp)
cmpl   $0x0,-0x24(%rbp)
jge    1174 <vis+0x64>
movq   $0x0,-0x8(%rbp)
jmp    1183 <vis+0x73>
mov    -0x10(%rbp),%rax
movslq -0x24(%rbp),%rcx
add    %rcx,%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<vis>:
push   %r14
push   %rbx
sub    $0x18,%rsp
mov    %edx,%r8d
mov    %rdi,%rbx
mov    %sil,0x16(%rsp)
mov    %cl,0x17(%rsp)
movq   $0x0,(%rsp)
lea    0xecb(%rip),%r9
xor    %r14d,%r14d
lea    0x16(%rsp),%rdx
xor    %esi,%esi
mov    $0x1,%ecx
call   1030 <istrsenvisx@plt>
cltq
add    %rax,%rbx
test   %eax,%eax
cmovs  %r14,%rbx
mov    %rbx,%rax
add    $0x18,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [1 x i8] zeroinitializer
define i8* @vis(i8* %0, i32 %1, i32 %2, i32 %3) {
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca [2 x i8]
%11 = alloca i32
store i8* %0, i8** %6
store i32 %1, i32* %7
store i32 %2, i32* %8
store i32 %3, i32* %9
%12 = load i32, i32* %7
%13 = trunc i32 %12 to i8
%14 = getelementptr inbounds [2 x i8], [2 x i8]* %10, i64 0, i64 0
store i8 %13, i8* %14
%15 = load i32, i32* %9
%16 = trunc i32 %15 to i8
%17 = getelementptr inbounds [2 x i8], [2 x i8]* %10, i64 0, i64 1
store i8 %16, i8* %17
%18 = load i8*, i8** %6
%19 = getelementptr inbounds [2 x i8], [2 x i8]* %10, i64 0, i64 0
%20 = load i32, i32* %8
%21 = call i32 @istrsenvisx(i8* %18, i32* null, i8* %19, i32 1, i32 %20, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str, i64 0, i64 0), i32* null)
store i32 %21, i32* %11
%22 = load i32, i32* %11
%23 = icmp slt i32 %22, 0
br i1 %23, label %24, label %25
24: ; preds = %4
store i8* null, i8** %5
br label %30
25: ; preds = %4
%26 = load i8*, i8** %6
%27 = load i32, i32* %11
%28 = sext i32 %27 to i64
%29 = getelementptr inbounds i8, i8* %26, i64 %28
store i8* %29, i8** %5
br label %30
30: ; preds = %25, %24
%31 = load i8*, i8** %5
ret i8* %31
}

LLVM IR (-O2):
@.str = [1 x i8] zeroinitializer
define i8* @vis(i8* %0, i32 %1, i32 %2, i32 %3) {
%5 = alloca [2 x i8]
%6 = getelementptr inbounds [2 x i8], [2 x i8]* %5, i64 0, i64 0
%7 = trunc i32 %1 to i8
store i8 %7, i8* %6
%8 = trunc i32 %3 to i8
%9 = getelementptr inbounds [2 x i8], [2 x i8]* %5, i64 0, i64 1
store i8 %8, i8* %9
%10 = call i32 @istrsenvisx(i8* %0, i32* null, i8* %6, i32 1, i32 %2, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str, i64 0, i64 0), i32* null)
%11 = icmp slt i32 %10, 0
%12 = sext i32 %10 to i64
%13 = getelementptr inbounds i8, i8* %0, i64 %12
%14 = select i1 %11, i8* null, i8* %13
ret i8* %14
}