#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 I3_token(char const, char *, char *, char *);
void I3_message_convert(char *buffer, const char *txt, char *oname,
                        char *tname) {
  const char *point;
  int skip = 0;
  for (point = txt; *point; point++) {
    if (*point == '$') {
      point++;
      if (*point == '\0')
        point--;
      else
        skip = I3_token(*point, buffer, oname, tname);
      while (skip-- > 0)
        ++buffer;
      continue;
    }
    *buffer = *point;
    *++buffer = '\0';
  }
  *buffer = '\0';
  return;
}


x86 assembly (clang, -O0):
<I3_message_convert>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
movl   $0x0,-0x2c(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rax
cmpb   $0x0,(%rax)
je     11fd <I3_message_convert+0xed>
mov    -0x28(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x24,%eax
jne    11cd <I3_message_convert+0xbd>
mov    -0x28(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
jne    1181 <I3_message_convert+0x71>
mov    -0x28(%rbp),%rax
add    $0xffffffffffffffff,%rax
mov    %rax,-0x28(%rbp)
jmp    119e <I3_message_convert+0x8e>
mov    -0x28(%rbp),%rax
mov    (%rax),%al
mov    -0x8(%rbp),%rsi
mov    -0x18(%rbp),%rdx
mov    -0x20(%rbp),%rcx
movsbl %al,%edi
call   1030 <I3_token@plt>
mov    %eax,-0x2c(%rbp)
jmp    11a3 <I3_message_convert+0x93>
mov    -0x2c(%rbp),%eax
mov    %eax,%ecx
add    $0xffffffff,%ecx
mov    %ecx,-0x2c(%rbp)
cmp    $0x0,%eax
jle    11c8 <I3_message_convert+0xb8>
mov    -0x8(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x8(%rbp)
jmp    11a3 <I3_message_convert+0x93>
jmp    11ec <I3_message_convert+0xdc>
mov    -0x28(%rbp),%rax
mov    (%rax),%cl
mov    -0x8(%rbp),%rax
mov    %cl,(%rax)
mov    -0x8(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x8(%rbp)
movb   $0x0,0x1(%rax)
mov    -0x28(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x28(%rbp)
jmp    1137 <I3_message_convert+0x27>
mov    -0x8(%rbp),%rax
movb   $0x0,(%rax)
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<I3_message_convert>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    %rcx,%r14
mov    %rdx,%r15
mov    %rsi,%rbx
mov    %rdi,%r12
xor    %eax,%eax
jmp    1148 <I3_message_convert+0x38>
nopl   0x0(%rax,%rax,1)
test   %eax,%eax
mov    $0x0,%ecx
cmovs  %eax,%ecx
sub    %ecx,%eax
add    %rax,%r12
add    $0xffffffff,%ecx
add    $0x1,%rbx
mov    %ecx,%eax
movzbl (%rbx),%ecx
cmp    $0x24,%cl
je     1170 <I3_message_convert+0x60>
test   %cl,%cl
je     118f <I3_message_convert+0x7f>
mov    %cl,(%r12)
movb   $0x0,0x1(%r12)
add    $0x1,%r12
add    $0x1,%rbx
jmp    1148 <I3_message_convert+0x38>
nopl   0x0(%rax,%rax,1)
movzbl 0x1(%rbx),%ecx
test   %cl,%cl
je     1130 <I3_message_convert+0x20>
add    $0x1,%rbx
movsbl %cl,%edi
mov    %r12,%rsi
mov    %r15,%rdx
mov    %r14,%rcx
call   1030 <I3_token@plt>
jmp    1130 <I3_message_convert+0x20>
movb   $0x0,(%r12)
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

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

LLVM IR (-O2):
define void @I3_message_convert(i8* %0, i8* nocapture %1, i8* %2, i8* %3) {
br label %5
5: ; preds = %26, %4
%6 = phi i8* [ %0, %4 ], [ %27, %26 ]
%7 = phi i8* [ %1, %4 ], [ %30, %26 ]
%8 = phi i32 [ 0, %4 ], [ %29, %26 ]
%9 = load i8, i8* %7
switch i8 %9, label %24 [
i8 0, label %31
i8 36, label %10
]
10: ; preds = %5
%11 = getelementptr inbounds i8, i8* %7, i64 1
%12 = load i8, i8* %11
%13 = icmp eq i8 %12, 0
br i1 %13, label %16, label %14
14: ; preds = %10
%15 = tail call i32 @I3_token(i8 signext %12, i8* %6, i8* %2, i8* %3)
br label %16
16: ; preds = %10, %14
%17 = phi i8* [ %11, %14 ], [ %7, %10 ]
%18 = phi i32 [ %15, %14 ], [ %8, %10 ]
%19 = call i32 @llvm.smin.i32(i32 %18, i32 0)
%20 = sub i32 %18, %19
%21 = zext i32 %20 to i64
%22 = getelementptr i8, i8* %6, i64 %21
%23 = add i32 %19, -1
br label %26
24: ; preds = %5
store i8 %9, i8* %6
%25 = getelementptr inbounds i8, i8* %6, i64 1
store i8 0, i8* %25
br label %26
26: ; preds = %16, %24
%27 = phi i8* [ %25, %24 ], [ %22, %16 ]
%28 = phi i8* [ %7, %24 ], [ %17, %16 ]
%29 = phi i32 [ %8, %24 ], [ %23, %16 ]
%30 = getelementptr inbounds i8, i8* %28, i64 1
br label %5
31: ; preds = %5
store i8 0, i8* %6
ret void
}