#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 */
typedef int /*<<< orphan*/ newname;

/* Variables and functions */
int /*<<< orphan*/ snprintf(char *, int, char *, char const *const);
scalar_t__ strchr(char *, char const);
const char *irc_normalize_room_name(const char *const name) {
  static char newname[2048];
  if (strchr("#+&", *name))
    return (name);
  snprintf(newname, sizeof(newname), "#%s", name);
  return (newname);
}


x86 assembly (clang, -O0):
<irc_normalize_room_name>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rax
lea    0xec9(%rip),%rdi
movsbl (%rax),%esi
call   1030 <strchr@plt>
cmp    $0x0,%rax
je     1156 <irc_normalize_room_name+0x36>
mov    -0x10(%rbp),%rax
mov    %rax,-0x8(%rbp)
jmp    117d <irc_normalize_room_name+0x5d>
mov    -0x10(%rbp),%rcx
lea    0x2edf(%rip),%rdi
mov    $0x800,%esi
lea    0xe97(%rip),%rdx
call   1040 <snprintf@plt>
lea    0x2ec7(%rip),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<irc_normalize_room_name>:
push   %r14
push   %rbx
push   %rax
mov    %rdi,%rbx
movsbl (%rdi),%esi
lea    0xecf(%rip),%rdi
call   1030 <strchr@plt>
test   %rax,%rax
jne    115c <irc_normalize_room_name+0x3c>
lea    0x2efe(%rip),%r14
lea    0xebb(%rip),%rdx
mov    %r14,%rdi
mov    $0x800,%esi
mov    %rbx,%rcx
call   1040 <snprintf@plt>
mov    %r14,%rbx
mov    %rbx,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@irc_normalize_room_name.newname = internal global [2048 x i8] zeroinitializer
@.str = [4 x i8] c"#+&\00"
@.str.1 = [4 x i8] c"#%s\00"
define i8* @irc_normalize_room_name(i8* %0) {
%2 = alloca i8*
%3 = alloca i8*
store i8* %0, i8** %3
%4 = load i8*, i8** %3
%5 = load i8, i8* %4
%6 = call i64 @strchr(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8 signext %5)
%7 = icmp ne i64 %6, 0
br i1 %7, label %8, label %10
8: ; preds = %1
%9 = load i8*, i8** %3
store i8* %9, i8** %2
br label %13
10: ; preds = %1
%11 = load i8*, i8** %3
%12 = call i32 @snprintf(i8* getelementptr inbounds ([2048 x i8], [2048 x i8]* @irc_normalize_room_name.newname, i64 0, i64 0), i32 2048, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8* %11)
store i8* getelementptr inbounds ([2048 x i8], [2048 x i8]* @irc_normalize_room_name.newname, i64 0, i64 0), i8** %2
br label %13
13: ; preds = %10, %8
%14 = load i8*, i8** %2
ret i8* %14
}

LLVM IR (-O2):
@irc_normalize_room_name.newname = internal global [2048 x i8] zeroinitializer
@.str = [4 x i8] c"#+&\00"
@.str.1 = [4 x i8] c"#%s\00"
define i8* @irc_normalize_room_name(i8* %0) {
%2 = load i8, i8* %0
%3 = tail call i64 @strchr(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8 signext %2)
%4 = icmp eq i64 %3, 0
br i1 %4, label %5, label %7
5: ; preds = %1
%6 = tail call i32 @snprintf(i8* getelementptr inbounds ([2048 x i8], [2048 x i8]* @irc_normalize_room_name.newname, i64 0, i64 0), i32 2048, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8* %0)
br label %7
7: ; preds = %1, %5
%8 = phi i8* [ getelementptr inbounds ([2048 x i8], [2048 x i8]* @irc_normalize_room_name.newname, i64 0, i64 0), %5 ], [ %0, %1 ]
ret i8* %8
}