#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 aToi(char const *);
int /*<<< orphan*/ countCharDigits(char const *);
int /*<<< orphan*/ cpyCatch(char *, int);
int /*<<< orphan*/ lenCatch(int);
char *putCatch(char *newStr, const char *putStr) {
  char *oNewStr = newStr;
  while (*putStr)
    switch (*putStr) {
    case '#':
      if (*++putStr == '#')
        *newStr++ = *putStr++;
      else {
        int index = aToi(putStr);
        cpyCatch(newStr, index);
        newStr += lenCatch(index);
        putStr += countCharDigits(putStr);
      }
      break;
    default:
      *newStr++ = *putStr++;
    }
  *newStr = '\0';
  return oNewStr;
}


x86 assembly (clang, -O0):
<putCatch>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x18(%rbp)
mov    -0x10(%rbp),%rax
cmpb   $0x0,(%rax)
je     1230 <putCatch+0xf0>
mov    -0x10(%rbp),%rax
mov    (%rax),%al
sub    $0x23,%al
jne    1209 <putCatch+0xc9>
jmp    1178 <putCatch+0x38>
mov    -0x10(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x10(%rbp)
movsbl 0x1(%rax),%eax
cmp    $0x23,%eax
jne    11bb <putCatch+0x7b>
mov    -0x10(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x10(%rbp)
mov    (%rax),%cl
mov    -0x8(%rbp),%rax
mov    %rax,%rdx
add    $0x1,%rdx
mov    %rdx,-0x8(%rbp)
mov    %cl,(%rax)
jmp    1204 <putCatch+0xc4>
mov    -0x10(%rbp),%rdi
call   1040 <aToi@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x1c(%rbp),%esi
call   1030 <cpyCatch@plt>
mov    -0x1c(%rbp),%edi
call   1060 <lenCatch@plt>
mov    %eax,%ecx
mov    -0x8(%rbp),%rax
movslq %ecx,%rcx
add    %rcx,%rax
mov    %rax,-0x8(%rbp)
mov    -0x10(%rbp),%rdi
call   1050 <countCharDigits@plt>
mov    %eax,%ecx
mov    -0x10(%rbp),%rax
movslq %ecx,%rcx
add    %rcx,%rax
mov    %rax,-0x10(%rbp)
jmp    122b <putCatch+0xeb>
mov    -0x10(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x10(%rbp)
mov    (%rax),%cl
mov    -0x8(%rbp),%rax
mov    %rax,%rdx
add    $0x1,%rdx
mov    %rdx,-0x8(%rbp)
mov    %cl,(%rax)
jmp    1158 <putCatch+0x18>
mov    -0x8(%rbp),%rax
movb   $0x0,(%rax)
mov    -0x18(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<putCatch>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %rsi,%rbx
mov    %rdi,%r14
mov    %rdi,%r15
jmp    1191 <putCatch+0x51>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
add    $0x1,%rbx
mov    %rbx,%rdi
call   1040 <aToi@plt>
mov    %eax,%ebp
mov    %r15,%rdi
mov    %eax,%esi
call   1030 <cpyCatch@plt>
mov    %ebp,%edi
call   1060 <lenCatch@plt>
cltq
add    %rax,%r15
mov    %rbx,%rdi
call   1050 <countCharDigits@plt>
cltq
add    %rax,%rbx
movzbl (%rbx),%eax
cmp    $0x23,%al
je     11b0 <putCatch+0x70>
test   %al,%al
je     11c4 <putCatch+0x84>
add    $0x1,%rbx
mov    %al,(%r15)
add    $0x1,%r15
jmp    1191 <putCatch+0x51>
nopl   0x0(%rax)
cmpb   $0x23,0x1(%rbx)
jne    1160 <putCatch+0x20>
add    $0x2,%rbx
movb   $0x23,(%r15)
add    $0x1,%r15
jmp    1191 <putCatch+0x51>
movb   $0x0,(%r15)
mov    %r14,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define i8* @putCatch(i8* %0, i8* %1) {
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i32
store i8* %0, i8** %3
store i8* %1, i8** %4
%7 = load i8*, i8** %3
store i8* %7, i8** %5
br label %8
8: ; preds = %51, %2
%9 = load i8*, i8** %4
%10 = load i8, i8* %9
%11 = icmp ne i8 %10, 0
br i1 %11, label %12, label %52
12: ; preds = %8
%13 = load i8*, i8** %4
%14 = load i8, i8* %13
%15 = sext i8 %14 to i32
switch i32 %15, label %45 [
i32 35, label %16
]
16: ; preds = %12
%17 = load i8*, i8** %4
%18 = getelementptr inbounds i8, i8* %17, i32 1
store i8* %18, i8** %4
%19 = load i8, i8* %18
%20 = sext i8 %19 to i32
%21 = icmp eq i32 %20, 35
br i1 %21, label %22, label %28
22: ; preds = %16
%23 = load i8*, i8** %4
%24 = getelementptr inbounds i8, i8* %23, i32 1
store i8* %24, i8** %4
%25 = load i8, i8* %23
%26 = load i8*, i8** %3
%27 = getelementptr inbounds i8, i8* %26, i32 1
store i8* %27, i8** %3
store i8 %25, i8* %26
br label %44
28: ; preds = %16
%29 = load i8*, i8** %4
%30 = call i32 @aToi(i8* %29)
store i32 %30, i32* %6
%31 = load i8*, i8** %3
%32 = load i32, i32* %6
%33 = call i32 @cpyCatch(i8* %31, i32 %32)
%34 = load i32, i32* %6
%35 = call i32 @lenCatch(i32 %34)
%36 = load i8*, i8** %3
%37 = sext i32 %35 to i64
%38 = getelementptr inbounds i8, i8* %36, i64 %37
store i8* %38, i8** %3
%39 = load i8*, i8** %4
%40 = call i32 @countCharDigits(i8* %39)
%41 = load i8*, i8** %4
%42 = sext i32 %40 to i64
%43 = getelementptr inbounds i8, i8* %41, i64 %42
store i8* %43, i8** %4
br label %44
44: ; preds = %28, %22
br label %51
45: ; preds = %12
%46 = load i8*, i8** %4
%47 = getelementptr inbounds i8, i8* %46, i32 1
store i8* %47, i8** %4
%48 = load i8, i8* %46
%49 = load i8*, i8** %3
%50 = getelementptr inbounds i8, i8* %49, i32 1
store i8* %50, i8** %3
store i8 %48, i8* %49
br label %51
51: ; preds = %45, %44
br label %8
52: ; preds = %8
%53 = load i8*, i8** %3
store i8 0, i8* %53
%54 = load i8*, i8** %5
ret i8* %54
}

LLVM IR (-O2):
define i8* @putCatch(i8* returned %0, i8* %1) {
br label %3
3: ; preds = %14, %2
%4 = phi i8* [ %1, %2 ], [ %15, %14 ]
%5 = phi i8* [ %0, %2 ], [ %16, %14 ]
%6 = load i8, i8* %4
switch i8 %6, label %26 [
i8 0, label %29
i8 35, label %7
]
7: ; preds = %3
%8 = getelementptr inbounds i8, i8* %4, i64 1
%9 = load i8, i8* %8
%10 = icmp eq i8 %9, 35
br i1 %10, label %11, label %17
11: ; preds = %7
%12 = getelementptr inbounds i8, i8* %4, i64 2
%13 = getelementptr inbounds i8, i8* %5, i64 1
store i8 35, i8* %5
br label %14
14: ; preds = %11, %17, %26
%15 = phi i8* [ %12, %11 ], [ %25, %17 ], [ %27, %26 ]
%16 = phi i8* [ %13, %11 ], [ %22, %17 ], [ %28, %26 ]
br label %3
17: ; preds = %7
%18 = tail call i32 @aToi(i8* %8)
%19 = tail call i32 @cpyCatch(i8* %5, i32 %18)
%20 = tail call i32 @lenCatch(i32 %18)
%21 = sext i32 %20 to i64
%22 = getelementptr inbounds i8, i8* %5, i64 %21
%23 = tail call i32 @countCharDigits(i8* %8)
%24 = sext i32 %23 to i64
%25 = getelementptr inbounds i8, i8* %8, i64 %24
br label %14
26: ; preds = %3
%27 = getelementptr inbounds i8, i8* %4, i64 1
%28 = getelementptr inbounds i8, i8* %5, i64 1
store i8 %6, i8* %5
br label %14
29: ; preds = %3
store i8 0, i8* %5
ret i8* %0
}