ptar_to_str(p, s) char *s, *p;
{
  char *x;
  static char temp[200];
  x = &(p[strlen(p) - 1]);
  if (x >= p)
    strcat(s++, " ");
  while (x >= p) {
    if (*x == '(')
      strcat(s, "()");
    else if (*x == '[')
      strcat(s, "[]");
    else {
      sprintf(temp, "(*%s)", s);
      strcpy(s, temp);
    }
    x--;
  }
}


x86 assembly (clang, -O0):
<ptar_to_str>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    -0x10(%rbp),%rdi
call   1040 <strlen@plt>
mov    %rax,%rcx
mov    -0x28(%rbp),%rax
sub    $0x1,%rcx
add    %rcx,%rax
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rax
cmp    -0x10(%rbp),%rax
jb     119c <ptar_to_str+0x5c>
mov    -0x18(%rbp),%rdi
mov    %rdi,%rax
add    $0x1,%rax
mov    %rax,-0x18(%rbp)
lea    0xe69(%rip),%rsi
call   1050 <strcat@plt>
jmp    11a1 <ptar_to_str+0x61>
mov    -0x20(%rbp),%rax
cmp    -0x10(%rbp),%rax
jb     1238 <ptar_to_str+0xf8>
mov    -0x20(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x28,%eax
jne    11d4 <ptar_to_str+0x94>
mov    -0x18(%rbp),%rdi
lea    0xe38(%rip),%rsi
call   1050 <strcat@plt>
jmp    1227 <ptar_to_str+0xe7>
mov    -0x20(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x5b,%eax
jne    11f9 <ptar_to_str+0xb9>
mov    -0x18(%rbp),%rdi
lea    0xe16(%rip),%rsi
call   1050 <strcat@plt>
jmp    1222 <ptar_to_str+0xe2>
mov    -0x18(%rbp),%rdx
lea    0x2e4c(%rip),%rdi
lea    0xdfd(%rip),%rsi
mov    $0x0,%al
call   1060 <sprintf@plt>
mov    -0x18(%rbp),%rdi
lea    0x2e33(%rip),%rsi
call   1030 <strcpy@plt>
jmp    1227 <ptar_to_str+0xe7>
mov    -0x20(%rbp),%rax
add    $0xffffffffffffffff,%rax
mov    %rax,-0x20(%rbp)
jmp    11a1 <ptar_to_str+0x61>
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ptar_to_str>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
mov    %rsi,%r12
mov    %rdi,%r14
call   1040 <strlen@plt>
mov    %rax,%rbx
add    $0xffffffffffffffff,%rbx
js     11e7 <ptar_to_str+0xb7>
add    %r14,%rbx
lea    0x1(%r12),%r15
mov    %r12,%rdi
call   1040 <strlen@plt>
movw   $0x20,(%r12,%rax,1)
lea    0x2ee1(%rip),%r12
lea    0xe90(%rip),%r13
jmp    11a4 <ptar_to_str+0x74>
nopl   0x0(%rax,%rax,1)
mov    %r12,%rdi
mov    %r13,%rsi
mov    %r15,%rdx
xor    %eax,%eax
call   1050 <sprintf@plt>
mov    %r15,%rdi
mov    %r12,%rsi
call   1030 <strcpy@plt>
add    $0xffffffffffffffff,%rbx
cmp    %r14,%rbx
jb     11e7 <ptar_to_str+0xb7>
movzbl (%rbx),%eax
cmp    $0x5b,%al
je     11d0 <ptar_to_str+0xa0>
cmp    $0x28,%al
jne    1180 <ptar_to_str+0x50>
mov    %r15,%rdi
call   1040 <strlen@plt>
movw   $0x2928,(%r15,%rax,1)
movb   $0x0,0x2(%r15,%rax,1)
jmp    119b <ptar_to_str+0x6b>
cs nopw 0x0(%rax,%rax,1)
mov    %r15,%rdi
call   1040 <strlen@plt>
movw   $0x5d5b,(%r15,%rax,1)
movb   $0x0,0x2(%r15,%rax,1)
jmp    119b <ptar_to_str+0x6b>
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@ptar_to_str.temp = internal global [200 x i8] zeroinitializer
@.str = [2 x i8] c" \00"
@.str.1 = [3 x i8] c"()\00"
@.str.2 = [3 x i8] c"[]\00"
@.str.3 = [6 x i8] c"(*%s)\00"
define i32 @ptar_to_str(i8* %0, i8* %1) {
%3 = alloca i32
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i8*
store i8* %0, i8** %4
store i8* %1, i8** %5
%7 = load i8*, i8** %4
%8 = load i8*, i8** %4
%9 = call i64 @strlen(i8* %8)
%10 = sub i64 %9, 1
%11 = getelementptr inbounds i8, i8* %7, i64 %10
store i8* %11, i8** %6
%12 = load i8*, i8** %6
%13 = load i8*, i8** %4
%14 = icmp uge i8* %12, %13
br i1 %14, label %15, label %19
15: ; preds = %2
%16 = load i8*, i8** %5
%17 = getelementptr inbounds i8, i8* %16, i32 1
store i8* %17, i8** %5
%18 = call i8* @strcat(i8* %16, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
br label %19
19: ; preds = %15, %2
br label %20
20: ; preds = %46, %19
%21 = load i8*, i8** %6
%22 = load i8*, i8** %4
%23 = icmp uge i8* %21, %22
br i1 %23, label %24, label %49
24: ; preds = %20
%25 = load i8*, i8** %6
%26 = load i8, i8* %25
%27 = sext i8 %26 to i32
%28 = icmp eq i32 %27, 40
br i1 %28, label %29, label %32
29: ; preds = %24
%30 = load i8*, i8** %5
%31 = call i8* @strcat(i8* %30, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
br label %46
32: ; preds = %24
%33 = load i8*, i8** %6
%34 = load i8, i8* %33
%35 = sext i8 %34 to i32
%36 = icmp eq i32 %35, 91
br i1 %36, label %37, label %40
37: ; preds = %32
%38 = load i8*, i8** %5
%39 = call i8* @strcat(i8* %38, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
br label %45
40: ; preds = %32
%41 = load i8*, i8** %5
%42 = call i32 (i8*, i8*, ...) @sprintf(i8* getelementptr inbounds ([200 x i8], [200 x i8]* @ptar_to_str.temp, i64 0, i64 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0), i8* %41)
%43 = load i8*, i8** %5
%44 = call i8* @strcpy(i8* %43, i8* getelementptr inbounds ([200 x i8], [200 x i8]* @ptar_to_str.temp, i64 0, i64 0))
br label %45
45: ; preds = %40, %37
br label %46
46: ; preds = %45, %29
%47 = load i8*, i8** %6
%48 = getelementptr inbounds i8, i8* %47, i32 -1
store i8* %48, i8** %6
br label %20
49: ; preds = %20
%50 = load i32, i32* %3
ret i32 %50
}

LLVM IR (-O2):
@ptar_to_str.temp = internal global [200 x i8] zeroinitializer
@.str.1 = [3 x i8] c"()\00"
@.str.2 = [3 x i8] c"[]\00"
@.str.3 = [6 x i8] c"(*%s)\00"
define i32 @ptar_to_str(i8* %0, i8* %1) {
%3 = tail call i64 @strlen(i8* dereferenceable(1) %0)
%4 = add i64 %3, -1
%5 = icmp slt i64 %4, 0
br i1 %5, label %27, label %6
6: ; preds = %2
%7 = getelementptr inbounds i8, i8* %0, i64 %4
%8 = getelementptr inbounds i8, i8* %1, i64 1
%9 = tail call i64 @strlen(i8* dereferenceable(1) %1)
%10 = getelementptr i8, i8* %1, i64 %9
%11 = bitcast i8* %10 to i16*
store i16 32, i16* %11
br label %12
12: ; preds = %6, %24
%13 = phi i8* [ %25, %24 ], [ %7, %6 ]
%14 = load i8, i8* %13
switch i8 %14, label %21 [
i8 40, label %15
i8 91, label %18
]
15: ; preds = %12
%16 = tail call i64 @strlen(i8* dereferenceable(1) %8)
%17 = getelementptr i8, i8* %8, i64 %16
tail call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 1 dereferenceable(3) %17, i8* align 1 dereferenceable(3) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i64 3, i1 false)
br label %24
18: ; preds = %12
%19 = tail call i64 @strlen(i8* dereferenceable(1) %8)
%20 = getelementptr i8, i8* %8, i64 %19
tail call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 1 dereferenceable(3) %20, i8* align 1 dereferenceable(3) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i64 3, i1 false)
br label %24
21: ; preds = %12
%22 = tail call i32 (i8*, i8*, ...) @sprintf(i8* dereferenceable(1) getelementptr inbounds ([200 x i8], [200 x i8]* @ptar_to_str.temp, i64 0, i64 0), i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0), i8* %8)
%23 = tail call i8* @strcpy(i8* dereferenceable(1) %8, i8* dereferenceable(1) getelementptr inbounds ([200 x i8], [200 x i8]* @ptar_to_str.temp, i64 0, i64 0))
br label %24
24: ; preds = %18, %21, %15
%25 = getelementptr inbounds i8, i8* %13, i64 -1
%26 = icmp ult i8* %25, %0
br i1 %26, label %27, label %12
27: ; preds = %24, %2
ret i32 undef
}