#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 */
char *space_out(char *);
char *get_arg_with_spaces(char *s, char *arg) {
  int nest = 0;
  s = space_out(s);
  while (*s) {
    if (*s == '\\' && s[1] == ';') {
      *arg++ = *s++;
    } else if (*s == ';' && nest == 0) {
      break;
    } else if (*s == '{') {
      nest++;
    } else if (*s == '}') {
      nest--;
    }
    *arg++ = *s++;
  }
  *arg = '\0';
  return s;
}


x86 assembly (clang, -O0):
<get_arg_with_spaces>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
mov    -0x8(%rbp),%rdi
call   1030 <space_out@plt>
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
cmpb   $0x0,(%rax)
je     1215 <get_arg_with_spaces+0x105>
mov    -0x8(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x5c,%eax
jne    1189 <get_arg_with_spaces+0x79>
mov    -0x8(%rbp),%rax
movsbl 0x1(%rax),%eax
cmp    $0x3b,%eax
jne    1189 <get_arg_with_spaces+0x79>
mov    -0x8(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x8(%rbp)
mov    (%rax),%cl
mov    -0x10(%rbp),%rax
mov    %rax,%rdx
add    $0x1,%rdx
mov    %rdx,-0x10(%rbp)
mov    %cl,(%rax)
jmp    11ee <get_arg_with_spaces+0xde>
mov    -0x8(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x3b,%eax
jne    11a8 <get_arg_with_spaces+0x98>
cmpl   $0x0,-0x14(%rbp)
jne    11a8 <get_arg_with_spaces+0x98>
jmp    1215 <get_arg_with_spaces+0x105>
mov    -0x8(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x7b,%eax
jne    11c6 <get_arg_with_spaces+0xb6>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    11e4 <get_arg_with_spaces+0xd4>
mov    -0x8(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x7d,%eax
jne    11df <get_arg_with_spaces+0xcf>
mov    -0x14(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x14(%rbp)
jmp    11e4 <get_arg_with_spaces+0xd4>
jmp    11e9 <get_arg_with_spaces+0xd9>
jmp    11ee <get_arg_with_spaces+0xde>
mov    -0x8(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x8(%rbp)
mov    (%rax),%cl
mov    -0x10(%rbp),%rax
mov    %rax,%rdx
add    $0x1,%rdx
mov    %rdx,-0x10(%rbp)
mov    %cl,(%rax)
jmp    1134 <get_arg_with_spaces+0x24>
mov    -0x10(%rbp),%rax
movb   $0x0,(%rax)
mov    -0x8(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_arg_with_spaces>:
push   %rbx
mov    %rsi,%rbx
call   1030 <space_out@plt>
xor    %ecx,%ecx
jmp    113a <get_arg_with_spaces+0x2a>
add    $0xffffffff,%ecx
mov    $0x7d,%dl
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
add    $0x1,%rax
mov    %dl,(%rbx)
add    $0x1,%rbx
movzbl (%rax),%edx
cmp    $0x5c,%dl
je     1160 <get_arg_with_spaces+0x50>
test   %dl,%dl
je     1178 <get_arg_with_spaces+0x68>
cmp    $0x3b,%dl
jne    114f <get_arg_with_spaces+0x3f>
test   %ecx,%ecx
je     1178 <get_arg_with_spaces+0x68>
cmp    $0x7d,%dl
je     111d <get_arg_with_spaces+0xd>
cmp    $0x7b,%dl
jne    1130 <get_arg_with_spaces+0x20>
add    $0x1,%ecx
mov    $0x7b,%dl
jmp    1130 <get_arg_with_spaces+0x20>
mov    $0x5c,%dl
cmpb   $0x3b,0x1(%rax)
jne    1130 <get_arg_with_spaces+0x20>
add    $0x1,%rax
movb   $0x5c,(%rbx)
add    $0x1,%rbx
movzbl (%rax),%edx
jmp    1130 <get_arg_with_spaces+0x20>
movb   $0x0,(%rbx)
pop    %rbx
ret

LLVM IR (-O0):
define i8* @get_arg_with_spaces(i8* %0, i8* %1) {
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i32
store i8* %0, i8** %3
store i8* %1, i8** %4
store i32 0, i32* %5
%6 = load i8*, i8** %3
%7 = call i8* @space_out(i8* %6)
store i8* %7, i8** %3
br label %8
8: ; preds = %57, %2
%9 = load i8*, i8** %3
%10 = load i8, i8* %9
%11 = icmp ne i8 %10, 0
br i1 %11, label %12, label %63
12: ; preds = %8
%13 = load i8*, i8** %3
%14 = load i8, i8* %13
%15 = sext i8 %14 to i32
%16 = icmp eq i32 %15, 92
br i1 %16, label %17, label %29
17: ; preds = %12
%18 = load i8*, i8** %3
%19 = getelementptr inbounds i8, i8* %18, i64 1
%20 = load i8, i8* %19
%21 = sext i8 %20 to i32
%22 = icmp eq i32 %21, 59
br i1 %22, label %23, label %29
23: ; preds = %17
%24 = load i8*, i8** %3
%25 = getelementptr inbounds i8, i8* %24, i32 1
store i8* %25, i8** %3
%26 = load i8, i8* %24
%27 = load i8*, i8** %4
%28 = getelementptr inbounds i8, i8* %27, i32 1
store i8* %28, i8** %4
store i8 %26, i8* %27
br label %57
29: ; preds = %17, %12
%30 = load i8*, i8** %3
%31 = load i8, i8* %30
%32 = sext i8 %31 to i32
%33 = icmp eq i32 %32, 59
br i1 %33, label %34, label %38
34: ; preds = %29
%35 = load i32, i32* %5
%36 = icmp eq i32 %35, 0
br i1 %36, label %37, label %38
37: ; preds = %34
br label %63
38: ; preds = %34, %29
%39 = load i8*, i8** %3
%40 = load i8, i8* %39
%41 = sext i8 %40 to i32
%42 = icmp eq i32 %41, 123
br i1 %42, label %43, label %46
43: ; preds = %38
%44 = load i32, i32* %5
%45 = add nsw i32 %44, 1
store i32 %45, i32* %5
br label %55
46: ; preds = %38
%47 = load i8*, i8** %3
%48 = load i8, i8* %47
%49 = sext i8 %48 to i32
%50 = icmp eq i32 %49, 125
br i1 %50, label %51, label %54
51: ; preds = %46
%52 = load i32, i32* %5
%53 = add nsw i32 %52, -1
store i32 %53, i32* %5
br label %54
54: ; preds = %51, %46
br label %55
55: ; preds = %54, %43
br label %56
56: ; preds = %55
br label %57
57: ; preds = %56, %23
%58 = load i8*, i8** %3
%59 = getelementptr inbounds i8, i8* %58, i32 1
store i8* %59, i8** %3
%60 = load i8, i8* %58
%61 = load i8*, i8** %4
%62 = getelementptr inbounds i8, i8* %61, i32 1
store i8* %62, i8** %4
store i8 %60, i8* %61
br label %8
63: ; preds = %37, %8
%64 = load i8*, i8** %4
store i8 0, i8* %64
%65 = load i8*, i8** %3
ret i8* %65
}

LLVM IR (-O2):
define i8* @get_arg_with_spaces(i8* %0, i8* nocapture writeonly %1) {
%3 = tail call i8* @space_out(i8* %0)
br label %4
4: ; preds = %25, %2
%5 = phi i8* [ %3, %2 ], [ %30, %25 ]
%6 = phi i8* [ %1, %2 ], [ %31, %25 ]
%7 = phi i32 [ 0, %2 ], [ %29, %25 ]
%8 = load i8, i8* %5
switch i8 %8, label %16 [
i8 0, label %32
i8 92, label %9
]
9: ; preds = %4
%10 = getelementptr inbounds i8, i8* %5, i64 1
%11 = load i8, i8* %10
%12 = icmp eq i8 %11, 59
br i1 %12, label %13, label %25
13: ; preds = %9
%14 = getelementptr inbounds i8, i8* %6, i64 1
store i8 92, i8* %6
%15 = load i8, i8* %10
br label %25
16: ; preds = %4
%17 = icmp eq i8 %8, 59
%18 = icmp eq i32 %7, 0
%19 = select i1 %17, i1 %18, i1 false
br i1 %19, label %32, label %20
20: ; preds = %16
switch i8 %8, label %25 [
i8 123, label %21
i8 125, label %23
]
21: ; preds = %20
%22 = add nsw i32 %7, 1
br label %25
23: ; preds = %20
%24 = add nsw i32 %7, -1
br label %25
25: ; preds = %9, %20, %23, %21, %13
%26 = phi i8 [ %15, %13 ], [ 123, %21 ], [ 125, %23 ], [ %8, %20 ], [ 92, %9 ]
%27 = phi i8* [ %10, %13 ], [ %5, %21 ], [ %5, %23 ], [ %5, %20 ], [ %5, %9 ]
%28 = phi i8* [ %14, %13 ], [ %6, %21 ], [ %6, %23 ], [ %6, %20 ], [ %6, %9 ]
%29 = phi i32 [ %7, %13 ], [ %22, %21 ], [ %24, %23 ], [ %7, %20 ], [ %7, %9 ]
%30 = getelementptr inbounds i8, i8* %27, i64 1
%31 = getelementptr inbounds i8, i8* %28, i64 1
store i8 %26, i8* %28
br label %4
32: ; preds = %4, %16
store i8 0, i8* %6
ret i8* %5
}