#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__ id_invalid(char *);
int /*<<< orphan*/ sprintf(char *, char *, ...);
int strlen(char *);
char *vbbuser2bbsid(char *user, int i) {
  static char buf[128];
  switch (i) {
  case 99999:
    return "FreeWizard";
  }
  if (id_invalid(user) || (strlen(user) > 11)) {
    sprintf(buf, "vbuser%d.", i);
  } else {
    sprintf(buf, "%s.", user);
  }
  return buf;
}


x86 assembly (clang, -O0):
<vbbuser2bbsid>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
mov    -0x14(%rbp),%eax
sub    $0x1869f,%eax
jne    1162 <vbbuser2bbsid+0x32>
jmp    1152 <vbbuser2bbsid+0x22>
lea    0xea7(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    11c8 <vbbuser2bbsid+0x98>
mov    -0x10(%rbp),%rdi
call   1040 <id_invalid@plt>
cmp    $0x0,%rax
jne    1187 <vbbuser2bbsid+0x57>
mov    -0x10(%rbp),%rdi
call   1030 <strlen@plt>
cmp    $0xb,%eax
jle    11a4 <vbbuser2bbsid+0x74>
mov    -0x14(%rbp),%edx
lea    0x2ebf(%rip),%rdi
lea    0xe73(%rip),%rsi
mov    $0x0,%al
call   1050 <sprintf@plt>
jmp    11bd <vbbuser2bbsid+0x8d>
mov    -0x10(%rbp),%rdx
lea    0x2ea1(%rip),%rdi
lea    0xe5f(%rip),%rsi
mov    $0x0,%al
call   1050 <sprintf@plt>
lea    0x2e8c(%rip),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<vbbuser2bbsid>:
push   %rbp
push   %r14
push   %rbx
cmp    $0x1869f,%esi
jne    1145 <vbbuser2bbsid+0x15>
lea    0xebd(%rip),%rbx
jmp    1198 <vbbuser2bbsid+0x68>
mov    %esi,%ebp
mov    %rdi,%r14
call   1040 <id_invalid@plt>
test   %rax,%rax
jne    1161 <vbbuser2bbsid+0x31>
mov    %r14,%rdi
call   1030 <strlen@plt>
cmp    $0xc,%eax
jl     117d <vbbuser2bbsid+0x4d>
lea    0x2ee8(%rip),%rbx
lea    0xe9c(%rip),%rsi
mov    %rbx,%rdi
mov    %ebp,%edx
xor    %eax,%eax
call   1050 <sprintf@plt>
jmp    1198 <vbbuser2bbsid+0x68>
lea    0x2ecc(%rip),%rbx
lea    0xe8a(%rip),%rsi
mov    %rbx,%rdi
mov    %r14,%rdx
xor    %eax,%eax
call   1050 <sprintf@plt>
mov    %rbx,%rax
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@vbbuser2bbsid.buf = internal global [128 x i8] zeroinitializer
@.str = [11 x i8] c"FreeWizard\00"
@.str.1 = [10 x i8] c"vbuser%d.\00"
@.str.2 = [4 x i8] c"%s.\00"
define i8* @vbbuser2bbsid(i8* %0, i32 %1) {
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i32
store i8* %0, i8** %4
store i32 %1, i32* %5
%6 = load i32, i32* %5
switch i32 %6, label %8 [
i32 99999, label %7
]
7: ; preds = %2
store i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i8** %3
br label %23
8: ; preds = %2
%9 = load i8*, i8** %4
%10 = call i64 @id_invalid(i8* %9)
%11 = icmp ne i64 %10, 0
br i1 %11, label %16, label %12
12: ; preds = %8
%13 = load i8*, i8** %4
%14 = call i32 @strlen(i8* %13)
%15 = icmp sgt i32 %14, 11
br i1 %15, label %16, label %19
16: ; preds = %12, %8
%17 = load i32, i32* %5
%18 = call i32 (i8*, i8*, ...) @sprintf(i8* getelementptr inbounds ([128 x i8], [128 x i8]* @vbbuser2bbsid.buf, i64 0, i64 0), i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0), i32 %17)
br label %22
19: ; preds = %12
%20 = load i8*, i8** %4
%21 = call i32 (i8*, i8*, ...) @sprintf(i8* getelementptr inbounds ([128 x i8], [128 x i8]* @vbbuser2bbsid.buf, i64 0, i64 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i8* %20)
br label %22
22: ; preds = %19, %16
store i8* getelementptr inbounds ([128 x i8], [128 x i8]* @vbbuser2bbsid.buf, i64 0, i64 0), i8** %3
br label %23
23: ; preds = %22, %7
%24 = load i8*, i8** %3
ret i8* %24
}

LLVM IR (-O2):
@vbbuser2bbsid.buf = internal global [128 x i8] zeroinitializer
@.str = [11 x i8] c"FreeWizard\00"
@.str.1 = [10 x i8] c"vbuser%d.\00"
@.str.2 = [4 x i8] c"%s.\00"
define i8* @vbbuser2bbsid(i8* %0, i32 %1) {
%3 = icmp eq i32 %1, 99999
br i1 %3, label %14, label %4
4: ; preds = %2
%5 = tail call i64 @id_invalid(i8* %0)
%6 = icmp eq i64 %5, 0
br i1 %6, label %7, label %10
7: ; preds = %4
%8 = tail call i32 @strlen(i8* %0)
%9 = icmp sgt i32 %8, 11
br i1 %9, label %10, label %12
10: ; preds = %7, %4
%11 = tail call i32 (i8*, i8*, ...) @sprintf(i8* dereferenceable(1) getelementptr inbounds ([128 x i8], [128 x i8]* @vbbuser2bbsid.buf, i64 0, i64 0), i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0), i32 %1)
br label %14
12: ; preds = %7
%13 = tail call i32 (i8*, i8*, ...) @sprintf(i8* dereferenceable(1) getelementptr inbounds ([128 x i8], [128 x i8]* @vbbuser2bbsid.buf, i64 0, i64 0), i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i8* %0)
br label %14
14: ; preds = %10, %12, %2
%15 = phi i8* [ getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), %2 ], [ getelementptr inbounds ([128 x i8], [128 x i8]* @vbbuser2bbsid.buf, i64 0, i64 0), %12 ], [ getelementptr inbounds ([128 x i8], [128 x i8]* @vbbuser2bbsid.buf, i64 0, i64 0), %10 ]
ret i8* %15
}