#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 *nohtml(char *);
int /*<<< orphan*/ sprintf(char *, char *, char *, char *);
int /*<<< orphan*/ strcat(char *, char *);
char *strchr(char *, char);
int strlen(char *);
int /*<<< orphan*/ strsncpy(char *, char *, int);
char *strtok(char *, char *);
char *userid_str(char *s) {
  static char buf[512];
  char buf2[256], tmp[256], *ptr, *ptr2;
  strsncpy(tmp, s, 255);
  buf[0] = 0;
  ptr = strtok(tmp, " ,();\r\n\t");
  while (ptr && strlen(buf) < 400) {
    if ((ptr2 = strchr(ptr, '.'))) {
      ptr2[1] = 0;
      strcat(buf, ptr);
    } else {
      ptr = nohtml(ptr);
      sprintf(buf2, "<a href=qry?U=%s>%s</a>", ptr, ptr);
      strcat(buf, buf2);
    }
    ptr = strtok(0, " ,();\r\n\t");
    if (ptr)
      strcat(buf, " ");
  }
  return buf;
}


x86 assembly (clang, -O0):
<userid_str>:
push   %rbp
mov    %rsp,%rbp
sub    $0x230,%rsp
mov    %rdi,-0x8(%rbp)
lea    -0x210(%rbp),%rdi
mov    -0x8(%rbp),%rsi
mov    $0xff,%edx
call   1060 <strsncpy@plt>
movb   $0x0,0x2ed5(%rip)
lea    -0x210(%rbp),%rdi
lea    0xe57(%rip),%rsi
call   1070 <strtok@plt>
mov    %rax,-0x218(%rbp)
xor    %eax,%eax
cmpq   $0x0,-0x218(%rbp)
mov    %al,-0x221(%rbp)
je     11e5 <userid_str+0x75>
lea    0x2e9e(%rip),%rdi
call   1030 <strlen@plt>
cmp    $0x190,%eax
setl   %al
mov    %al,-0x221(%rbp)
mov    -0x221(%rbp),%al
test   $0x1,%al
jne    11f8 <userid_str+0x88>
jmp    12c1 <userid_str+0x151>
mov    -0x218(%rbp),%rdi
mov    $0x2e,%esi
call   1040 <strchr@plt>
mov    %rax,-0x220(%rbp)
cmp    $0x0,%rax
je     123d <userid_str+0xcd>
mov    -0x220(%rbp),%rax
movb   $0x0,0x1(%rax)
mov    -0x218(%rbp),%rsi
lea    0x2e3d(%rip),%rdi
call   1080 <strcat@plt>
jmp    1284 <userid_str+0x114>
mov    -0x218(%rbp),%rdi
call   1050 <nohtml@plt>
mov    %rax,-0x218(%rbp)
lea    -0x110(%rbp),%rdi
mov    -0x218(%rbp),%rdx
mov    -0x218(%rbp),%rcx
lea    0xd9d(%rip),%rsi
call   1090 <sprintf@plt>
lea    -0x110(%rbp),%rsi
lea    0x2df1(%rip),%rdi
call   1080 <strcat@plt>
xor    %eax,%eax
mov    %eax,%edi
lea    0xd71(%rip),%rsi
call   1070 <strtok@plt>
mov    %rax,-0x218(%rbp)
cmpq   $0x0,-0x218(%rbp)
je     12bc <userid_str+0x14c>
lea    0x2dc0(%rip),%rdi
lea    0xd6a(%rip),%rsi
call   1080 <strcat@plt>
jmp    11b5 <userid_str+0x45>
lea    0x2da8(%rip),%rax
add    $0x230,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<userid_str>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x208,%rsp
mov    %rdi,%rsi
mov    %rsp,%rbx
mov    %rbx,%rdi
mov    $0xff,%edx
call   1060 <strsncpy@plt>
movb   $0x0,0x2ed5(%rip)
lea    0xe5e(%rip),%rsi
mov    %rbx,%rdi
call   1070 <strtok@plt>
test   %rax,%rax
je     1273 <userid_str+0x103>
mov    %rax,%rbx
lea    0x2eb3(%rip),%rdi
call   1030 <strlen@plt>
cmp    $0x18f,%eax
jg     1273 <userid_str+0x103>
lea    0x100(%rsp),%r15
lea    0xe2d(%rip),%r14
lea    0x2e8d(%rip),%r12
lea    0xe16(%rip),%r13
lea    0xe30(%rip),%rbp
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    %rbx,%rdi
mov    $0x2e,%esi
call   1040 <strchr@plt>
test   %rax,%rax
je     1220 <userid_str+0xb0>
movb   $0x0,0x1(%rax)
jmp    123c <userid_str+0xcc>
nopl   0x0(%rax,%rax,1)
mov    %rbx,%rdi
call   1050 <nohtml@plt>
mov    %r15,%rdi
mov    %r14,%rsi
mov    %rax,%rdx
mov    %rax,%rcx
call   1090 <sprintf@plt>
mov    %r15,%rbx
mov    %r12,%rdi
mov    %rbx,%rsi
call   1080 <strcat@plt>
xor    %edi,%edi
mov    %r13,%rsi
call   1070 <strtok@plt>
test   %rax,%rax
je     1273 <userid_str+0x103>
mov    %rax,%rbx
mov    %r12,%rdi
mov    %rbp,%rsi
call   1080 <strcat@plt>
mov    %r12,%rdi
call   1030 <strlen@plt>
cmp    $0x190,%eax
jl     1200 <userid_str+0x90>
lea    0x2df6(%rip),%rax
add    $0x208,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@userid_str.buf = internal global [512 x i8] zeroinitializer
@.str = [9 x i8] c" ,();\0D\0A\09\00"
@.str.1 = [24 x i8] c"<a href=qry?U=%s>%s</a>\00"
@.str.2 = [2 x i8] c" \00"
define i8* @userid_str(i8* %0) {
%2 = alloca i8*
%3 = alloca [256 x i8]
%4 = alloca [256 x i8]
%5 = alloca i8*
%6 = alloca i8*
store i8* %0, i8** %2
%7 = getelementptr inbounds [256 x i8], [256 x i8]* %4, i64 0, i64 0
%8 = load i8*, i8** %2
%9 = call i32 @strsncpy(i8* %7, i8* %8, i32 255)
store i8 0, i8* getelementptr inbounds ([512 x i8], [512 x i8]* @userid_str.buf, i64 0, i64 0)
%10 = getelementptr inbounds [256 x i8], [256 x i8]* %4, i64 0, i64 0
%11 = call i8* @strtok(i8* %10, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0))
store i8* %11, i8** %5
br label %12
12: ; preds = %44, %1
%13 = load i8*, i8** %5
%14 = icmp ne i8* %13, null
br i1 %14, label %15, label %18
15: ; preds = %12
%16 = call i32 @strlen(i8* getelementptr inbounds ([512 x i8], [512 x i8]* @userid_str.buf, i64 0, i64 0))
%17 = icmp slt i32 %16, 400
br label %18
18: ; preds = %15, %12
%19 = phi i1 [ false, %12 ], [ %17, %15 ]
br i1 %19, label %20, label %45
20: ; preds = %18
%21 = load i8*, i8** %5
%22 = call i8* @strchr(i8* %21, i8 signext 46)
store i8* %22, i8** %6
%23 = icmp ne i8* %22, null
br i1 %23, label %24, label %29
24: ; preds = %20
%25 = load i8*, i8** %6
%26 = getelementptr inbounds i8, i8* %25, i64 1
store i8 0, i8* %26
%27 = load i8*, i8** %5
%28 = call i32 @strcat(i8* getelementptr inbounds ([512 x i8], [512 x i8]* @userid_str.buf, i64 0, i64 0), i8* %27)
br label %38
29: ; preds = %20
%30 = load i8*, i8** %5
%31 = call i8* @nohtml(i8* %30)
store i8* %31, i8** %5
%32 = getelementptr inbounds [256 x i8], [256 x i8]* %3, i64 0, i64 0
%33 = load i8*, i8** %5
%34 = load i8*, i8** %5
%35 = call i32 @sprintf(i8* %32, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.1, i64 0, i64 0), i8* %33, i8* %34)
%36 = getelementptr inbounds [256 x i8], [256 x i8]* %3, i64 0, i64 0
%37 = call i32 @strcat(i8* getelementptr inbounds ([512 x i8], [512 x i8]* @userid_str.buf, i64 0, i64 0), i8* %36)
br label %38
38: ; preds = %29, %24
%39 = call i8* @strtok(i8* null, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0))
store i8* %39, i8** %5
%40 = load i8*, i8** %5
%41 = icmp ne i8* %40, null
br i1 %41, label %42, label %44
42: ; preds = %38
%43 = call i32 @strcat(i8* getelementptr inbounds ([512 x i8], [512 x i8]* @userid_str.buf, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
br label %44
44: ; preds = %42, %38
br label %12
45: ; preds = %18
ret i8* getelementptr inbounds ([512 x i8], [512 x i8]* @userid_str.buf, i64 0, i64 0)
}

LLVM IR (-O2):
@userid_str.buf = internal global [512 x i8] zeroinitializer
@.str = [9 x i8] c" ,();\0D\0A\09\00"
@.str.1 = [24 x i8] c"<a href=qry?U=%s>%s</a>\00"
@.str.2 = [2 x i8] c" \00"
define i8* @userid_str(i8* %0) {
%2 = alloca [256 x i8]
%3 = alloca [256 x i8]
%4 = getelementptr inbounds [256 x i8], [256 x i8]* %2, i64 0, i64 0
%5 = getelementptr inbounds [256 x i8], [256 x i8]* %3, i64 0, i64 0
%6 = call i32 @strsncpy(i8* %5, i8* %0, i32 255)
store i8 0, i8* getelementptr inbounds ([512 x i8], [512 x i8]* @userid_str.buf, i64 0, i64 0)
%7 = call i8* @strtok(i8* %5, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0))
%8 = icmp eq i8* %7, null
br i1 %8, label %30, label %9
9: ; preds = %1
%10 = call i32 @strlen(i8* getelementptr inbounds ([512 x i8], [512 x i8]* @userid_str.buf, i64 0, i64 0))
%11 = icmp slt i32 %10, 400
br i1 %11, label %12, label %30
12: ; preds = %9, %26
%13 = phi i8* [ %24, %26 ], [ %7, %9 ]
%14 = call i8* @strchr(i8* %13, i8 signext 46)
%15 = icmp eq i8* %14, null
br i1 %15, label %18, label %16
16: ; preds = %12
%17 = getelementptr inbounds i8, i8* %14, i64 1
store i8 0, i8* %17
br label %21
18: ; preds = %12
%19 = call i8* @nohtml(i8* %13)
%20 = call i32 @sprintf(i8* %4, i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @.str.1, i64 0, i64 0), i8* %19, i8* %19)
br label %21
21: ; preds = %18, %16
%22 = phi i8* [ %4, %18 ], [ %13, %16 ]
%23 = call i32 @strcat(i8* getelementptr inbounds ([512 x i8], [512 x i8]* @userid_str.buf, i64 0, i64 0), i8* %22)
%24 = call i8* @strtok(i8* null, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0))
%25 = icmp eq i8* %24, null
br i1 %25, label %30, label %26
26: ; preds = %21
%27 = call i32 @strcat(i8* getelementptr inbounds ([512 x i8], [512 x i8]* @userid_str.buf, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%28 = call i32 @strlen(i8* getelementptr inbounds ([512 x i8], [512 x i8]* @userid_str.buf, i64 0, i64 0))
%29 = icmp slt i32 %28, 400
br i1 %29, label %12, label %30
30: ; preds = %26, %21, %9, %1
ret i8* getelementptr inbounds ([512 x i8], [512 x i8]* @userid_str.buf, i64 0, i64 0)
}