#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*/ dcs;

/* Variables and functions */
int /*<<< orphan*/ await_c1(int);
char getchar();
char *strdup(char *);
char *read_dcs() {
  await_c1(0x90);
  char dcs[32];
  bool in_esc = false;
  int i = 0;
  for (; i < sizeof(dcs) - 1;) {
    char c = getchar();
    if (c == 0x9c)
      break;
    if (in_esc && c == 0x5c)
      break;
    if (!in_esc && c == 0x1b)
      in_esc = true;
    else {
      dcs[i++] = c;
      in_esc = false;
    }
  }
  dcs[++i] = 0;
  return strdup(dcs);
}


x86 assembly (clang, -O0):
<read_dcs>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    $0x90,%edi
call   1050 <await_c1@plt>
movl   $0x0,-0x24(%rbp)
movl   $0x0,-0x28(%rbp)
movslq -0x28(%rbp),%rax
cmp    $0x1f,%rax
jae    11db <read_dcs+0xab>
mov    $0x0,%al
call   1030 <getchar@plt>
mov    %al,-0x29(%rbp)
movsbl -0x29(%rbp),%eax
cmp    $0x9c,%eax
jne    117c <read_dcs+0x4c>
jmp    11db <read_dcs+0xab>
cmpl   $0x0,-0x24(%rbp)
je     1198 <read_dcs+0x68>
movsbl -0x29(%rbp),%eax
cmp    $0x5c,%eax
jne    1198 <read_dcs+0x68>
jmp    11db <read_dcs+0xab>
cmpl   $0x0,-0x24(%rbp)
jne    11bb <read_dcs+0x8b>
movsbl -0x29(%rbp),%eax
cmp    $0x1b,%eax
jne    11bb <read_dcs+0x8b>
movl   $0x1,-0x24(%rbp)
jmp    11d6 <read_dcs+0xa6>
mov    -0x29(%rbp),%cl
mov    -0x28(%rbp),%eax
mov    %eax,%edx
add    $0x1,%edx
mov    %edx,-0x28(%rbp)
cltq
mov    %cl,-0x20(%rbp,%rax,1)
movl   $0x0,-0x24(%rbp)
jmp    1150 <read_dcs+0x20>
mov    -0x28(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x28(%rbp)
cltq
movb   $0x0,-0x20(%rbp,%rax,1)
lea    -0x20(%rbp),%rdi
call   1040 <strdup@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<read_dcs>:
push   %rbp
push   %r14
push   %rbx
sub    $0x20,%rsp
mov    $0x90,%edi
call   1050 <await_c1@plt>
xor    %ebx,%ebx
xor    %ebp,%ebp
xor    %r14d,%r14d
jmp    1162 <read_dcs+0x32>
nopl   0x0(%rax,%rax,1)
add    $0x1,%r14d
mov    %al,(%rsp,%rbx,1)
xor    %ebp,%ebp
mov    %r14d,%ebx
cmp    $0x1f,%r14d
jae    1180 <read_dcs+0x50>
xor    %eax,%eax
call   1030 <getchar@plt>
test   %ebp,%ebp
je     1171 <read_dcs+0x41>
cmp    $0x5c,%al
je     1180 <read_dcs+0x50>
test   %ebp,%ebp
jne    1150 <read_dcs+0x20>
mov    $0x1,%ebp
cmp    $0x1b,%al
je     1159 <read_dcs+0x29>
jmp    1150 <read_dcs+0x20>
movslq %r14d,%rax
mov    %rsp,%rdi
movb   $0x0,0x1(%rax,%rdi,1)
call   1040 <strdup@plt>
add    $0x20,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
define i8* @read_dcs() {
%1 = alloca [32 x i8]
%2 = alloca i32
%3 = alloca i32
%4 = alloca i8
%5 = call i32 @await_c1(i32 144)
store i32 0, i32* %2
store i32 0, i32* %3
br label %6
6: ; preds = %38, %0
%7 = load i32, i32* %3
%8 = sext i32 %7 to i64
%9 = icmp ult i64 %8, 31
br i1 %9, label %10, label %39
10: ; preds = %6
%11 = call signext i8 (...) @getchar()
store i8 %11, i8* %4
%12 = load i8, i8* %4
%13 = sext i8 %12 to i32
%14 = icmp eq i32 %13, 156
br i1 %14, label %15, label %16
15: ; preds = %10
br label %39
16: ; preds = %10
%17 = load i32, i32* %2
%18 = icmp ne i32 %17, 0
br i1 %18, label %19, label %24
19: ; preds = %16
%20 = load i8, i8* %4
%21 = sext i8 %20 to i32
%22 = icmp eq i32 %21, 92
br i1 %22, label %23, label %24
23: ; preds = %19
br label %39
24: ; preds = %19, %16
%25 = load i32, i32* %2
%26 = icmp ne i32 %25, 0
br i1 %26, label %32, label %27
27: ; preds = %24
%28 = load i8, i8* %4
%29 = sext i8 %28 to i32
%30 = icmp eq i32 %29, 27
br i1 %30, label %31, label %32
31: ; preds = %27
store i32 1, i32* %2
br label %38
32: ; preds = %27, %24
%33 = load i8, i8* %4
%34 = load i32, i32* %3
%35 = add nsw i32 %34, 1
store i32 %35, i32* %3
%36 = sext i32 %34 to i64
%37 = getelementptr inbounds [32 x i8], [32 x i8]* %1, i64 0, i64 %36
store i8 %33, i8* %37
store i32 0, i32* %2
br label %38
38: ; preds = %32, %31
br label %6
39: ; preds = %23, %15, %6
%40 = load i32, i32* %3
%41 = add nsw i32 %40, 1
store i32 %41, i32* %3
%42 = sext i32 %41 to i64
%43 = getelementptr inbounds [32 x i8], [32 x i8]* %1, i64 0, i64 %42
store i8 0, i8* %43
%44 = getelementptr inbounds [32 x i8], [32 x i8]* %1, i64 0, i64 0
%45 = call i8* @strdup(i8* %44)
ret i8* %45
}

LLVM IR (-O2):
define noalias i8* @read_dcs() {
%1 = alloca [32 x i8]
%2 = tail call i32 @await_c1(i32 144)
%3 = getelementptr inbounds [32 x i8], [32 x i8]* %1, i64 0, i64 0
br label %4
4: ; preds = %0, %19
%5 = phi i64 [ 0, %0 ], [ %22, %19 ]
%6 = phi i32 [ 0, %0 ], [ %21, %19 ]
%7 = phi i32 [ 0, %0 ], [ %20, %19 ]
%8 = tail call signext i8 (...) @getchar()
%9 = icmp ne i32 %6, 0
%10 = icmp eq i8 %8, 92
%11 = and i1 %9, %10
br i1 %11, label %24, label %12
12: ; preds = %4
%13 = icmp eq i32 %6, 0
%14 = icmp eq i8 %8, 27
%15 = and i1 %13, %14
br i1 %15, label %19, label %16
16: ; preds = %12
%17 = add nuw nsw i32 %7, 1
%18 = getelementptr inbounds [32 x i8], [32 x i8]* %1, i64 0, i64 %5
store i8 %8, i8* %18
br label %19
19: ; preds = %16, %12
%20 = phi i32 [ %17, %16 ], [ %7, %12 ]
%21 = phi i32 [ 0, %16 ], [ 1, %12 ]
%22 = zext i32 %20 to i64
%23 = icmp ult i32 %20, 31
br i1 %23, label %4, label %24
24: ; preds = %4, %19
%25 = phi i32 [ %7, %4 ], [ %20, %19 ]
%26 = add nsw i32 %25, 1
%27 = sext i32 %26 to i64
%28 = getelementptr inbounds [32 x i8], [32 x i8]* %1, i64 0, i64 %27
store i8 0, i8* %28
%29 = call i8* @strdup(i8* %3)
ret i8* %29
}