#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 */
scalar_t__ isdigit(char);
int /*<<< orphan*/ printf(char *, ...);
do_name(char *p, char *q) {
  *q = '\0';
  if ((q - p > 3) && isdigit(q[-1]) && (q[-2] == '(')) {
    q[-2] = '\0';
    q--;
    printf("<a href=\"%s.%s.html\">", p, q);
    printf("%s(%s)", p, q);
    printf("</a>");
  } else
    printf("%s)", p);
  return 1;
}


x86 assembly (clang, -O0):
<do_name>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x10(%rbp),%rax
movb   $0x0,(%rax)
mov    -0x10(%rbp),%rax
mov    -0x8(%rbp),%rcx
sub    %rcx,%rax
cmp    $0x3,%rax
jle    11c7 <do_name+0xa7>
mov    -0x10(%rbp),%rax
movsbl -0x1(%rax),%edi
call   1030 <isdigit@plt>
cmp    $0x0,%rax
je     11c7 <do_name+0xa7>
mov    -0x10(%rbp),%rax
movsbl -0x2(%rax),%eax
cmp    $0x28,%eax
jne    11c7 <do_name+0xa7>
mov    -0x10(%rbp),%rax
movb   $0x0,-0x2(%rax)
mov    -0x10(%rbp),%rax
add    $0xffffffffffffffff,%rax
mov    %rax,-0x10(%rbp)
mov    -0x8(%rbp),%rsi
mov    -0x10(%rbp),%rdx
lea    0xe69(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x8(%rbp),%rsi
mov    -0x10(%rbp),%rdx
lea    0xe69(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xe62(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    11d9 <do_name+0xb9>
mov    -0x8(%rbp),%rsi
lea    0xe47(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    $0x1,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<do_name>:
push   %r14
push   %rbx
push   %rax
mov    %rdi,%r14
movb   $0x0,(%rsi)
mov    %rsi,%rax
sub    %rdi,%rax
cmp    $0x4,%rax
jl     118d <do_name+0x6d>
mov    %rsi,%rbx
movsbl -0x1(%rsi),%edi
call   1030 <isdigit@plt>
test   %rax,%rax
je     118d <do_name+0x6d>
cmpb   $0x28,-0x2(%rbx)
jne    118d <do_name+0x6d>
movb   $0x0,-0x2(%rbx)
add    $0xffffffffffffffff,%rbx
lea    0xea4(%rip),%rdi
mov    %r14,%rsi
mov    %rbx,%rdx
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xea6(%rip),%rdi
mov    %r14,%rsi
mov    %rbx,%rdx
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xe99(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
jmp    119e <do_name+0x7e>
lea    0xe85(%rip),%rdi
mov    %r14,%rsi
xor    %eax,%eax
call   1040 <printf@plt>
mov    $0x1,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [22 x i8] c"<a href=\22%s.%s.html\22>\00"
@.str.1 = [7 x i8] c"%s(%s)\00"
@.str.2 = [5 x i8] c"</a>\00"
@.str.3 = [4 x i8] c"%s)\00"
define i32 @do_name(i8* %0, i8* %1) {
%3 = alloca i8*
%4 = alloca i8*
store i8* %0, i8** %3
store i8* %1, i8** %4
%5 = load i8*, i8** %4
store i8 0, i8* %5
%6 = load i8*, i8** %4
%7 = load i8*, i8** %3
%8 = ptrtoint i8* %6 to i64
%9 = ptrtoint i8* %7 to i64
%10 = sub i64 %8, %9
%11 = icmp sgt i64 %10, 3
br i1 %11, label %12, label %36
12: ; preds = %2
%13 = load i8*, i8** %4
%14 = getelementptr inbounds i8, i8* %13, i64 -1
%15 = load i8, i8* %14
%16 = call i64 @isdigit(i8 signext %15)
%17 = icmp ne i64 %16, 0
br i1 %17, label %18, label %36
18: ; preds = %12
%19 = load i8*, i8** %4
%20 = getelementptr inbounds i8, i8* %19, i64 -2
%21 = load i8, i8* %20
%22 = sext i8 %21 to i32
%23 = icmp eq i32 %22, 40
br i1 %23, label %24, label %36
24: ; preds = %18
%25 = load i8*, i8** %4
%26 = getelementptr inbounds i8, i8* %25, i64 -2
store i8 0, i8* %26
%27 = load i8*, i8** %4
%28 = getelementptr inbounds i8, i8* %27, i32 -1
store i8* %28, i8** %4
%29 = load i8*, i8** %3
%30 = load i8*, i8** %4
%31 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0), i8* %29, i8* %30)
%32 = load i8*, i8** %3
%33 = load i8*, i8** %4
%34 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), i8* %32, i8* %33)
%35 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0))
br label %39
36: ; preds = %18, %12, %2
%37 = load i8*, i8** %3
%38 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i8* %37)
br label %39
39: ; preds = %36, %24
ret i32 1
}

LLVM IR (-O2):
@.str = [22 x i8] c"<a href=\22%s.%s.html\22>\00"
@.str.1 = [7 x i8] c"%s(%s)\00"
@.str.2 = [5 x i8] c"</a>\00"
@.str.3 = [4 x i8] c"%s)\00"
define i32 @do_name(i8* %0, i8* %1) {
store i8 0, i8* %1
%3 = ptrtoint i8* %1 to i64
%4 = ptrtoint i8* %0 to i64
%5 = sub i64 %3, %4
%6 = icmp sgt i64 %5, 3
br i1 %6, label %7, label %20
7: ; preds = %2
%8 = getelementptr inbounds i8, i8* %1, i64 -1
%9 = load i8, i8* %8
%10 = tail call i64 @isdigit(i8 signext %9)
%11 = icmp eq i64 %10, 0
br i1 %11, label %20, label %12
12: ; preds = %7
%13 = getelementptr inbounds i8, i8* %1, i64 -2
%14 = load i8, i8* %13
%15 = icmp eq i8 %14, 40
br i1 %15, label %16, label %20
16: ; preds = %12
store i8 0, i8* %13
%17 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0), i8* %0, i8* %8)
%18 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), i8* %0, i8* %8)
%19 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0))
br label %22
20: ; preds = %12, %7, %2
%21 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i8* %0)
br label %22
22: ; preds = %20, %16
ret i32 1
}