#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 *strchr(char *, char);
int /*<<< orphan*/ strcpy(char *, char *);
int strlen(char *);
int get_groupname(char *input, char *output) {
  char *cc;
  output[0] = 0;
  strcpy(output, input);
  cc = strchr(output, '\r');
  if (cc)
    *cc = 0;
  cc = strchr(output, '\n');
  if (cc)
    *cc = 0;
  cc = strchr(output, ' ');
  if (cc)
    *cc = '_';
  return strlen(output);
}


x86 assembly (clang, -O0):
<get_groupname>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x10(%rbp),%rax
movb   $0x0,(%rax)
mov    -0x10(%rbp),%rdi
mov    -0x8(%rbp),%rsi
call   1030 <strcpy@plt>
mov    -0x10(%rbp),%rdi
mov    $0xd,%esi
call   1050 <strchr@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
je     1178 <get_groupname+0x48>
mov    -0x18(%rbp),%rax
movb   $0x0,(%rax)
mov    -0x10(%rbp),%rdi
mov    $0xa,%esi
call   1050 <strchr@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
je     119c <get_groupname+0x6c>
mov    -0x18(%rbp),%rax
movb   $0x0,(%rax)
mov    -0x10(%rbp),%rdi
mov    $0x20,%esi
call   1050 <strchr@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
je     11c0 <get_groupname+0x90>
mov    -0x18(%rbp),%rax
movb   $0x5f,(%rax)
mov    -0x10(%rbp),%rdi
call   1040 <strlen@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_groupname>:
push   %rbx
mov    %rsi,%rbx
mov    %rdi,%rsi
movb   $0x0,(%rbx)
mov    %rbx,%rdi
call   1030 <strcpy@plt>
mov    %rbx,%rdi
mov    $0xd,%esi
call   1050 <strchr@plt>
test   %rax,%rax
je     1157 <get_groupname+0x27>
movb   $0x0,(%rax)
mov    %rbx,%rdi
mov    $0xa,%esi
call   1050 <strchr@plt>
test   %rax,%rax
je     116c <get_groupname+0x3c>
movb   $0x0,(%rax)
mov    %rbx,%rdi
mov    $0x20,%esi
call   1050 <strchr@plt>
test   %rax,%rax
je     1181 <get_groupname+0x51>
movb   $0x5f,(%rax)
mov    %rbx,%rdi
pop    %rbx
jmp    1040 <strlen@plt>

LLVM IR (-O0):
define i32 @get_groupname(i8* %0, i8* %1) {
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i8*
store i8* %0, i8** %3
store i8* %1, i8** %4
%6 = load i8*, i8** %4
%7 = getelementptr inbounds i8, i8* %6, i64 0
store i8 0, i8* %7
%8 = load i8*, i8** %4
%9 = load i8*, i8** %3
%10 = call i32 @strcpy(i8* %8, i8* %9)
%11 = load i8*, i8** %4
%12 = call i8* @strchr(i8* %11, i8 signext 13)
store i8* %12, i8** %5
%13 = load i8*, i8** %5
%14 = icmp ne i8* %13, null
br i1 %14, label %15, label %17
15: ; preds = %2
%16 = load i8*, i8** %5
store i8 0, i8* %16
br label %17
17: ; preds = %15, %2
%18 = load i8*, i8** %4
%19 = call i8* @strchr(i8* %18, i8 signext 10)
store i8* %19, i8** %5
%20 = load i8*, i8** %5
%21 = icmp ne i8* %20, null
br i1 %21, label %22, label %24
22: ; preds = %17
%23 = load i8*, i8** %5
store i8 0, i8* %23
br label %24
24: ; preds = %22, %17
%25 = load i8*, i8** %4
%26 = call i8* @strchr(i8* %25, i8 signext 32)
store i8* %26, i8** %5
%27 = load i8*, i8** %5
%28 = icmp ne i8* %27, null
br i1 %28, label %29, label %31
29: ; preds = %24
%30 = load i8*, i8** %5
store i8 95, i8* %30
br label %31
31: ; preds = %29, %24
%32 = load i8*, i8** %4
%33 = call i32 @strlen(i8* %32)
ret i32 %33
}

LLVM IR (-O2):
define i32 @get_groupname(i8* %0, i8* %1) {
store i8 0, i8* %1
%3 = tail call i32 @strcpy(i8* %1, i8* %0)
%4 = tail call i8* @strchr(i8* %1, i8 signext 13)
%5 = icmp eq i8* %4, null
br i1 %5, label %7, label %6
6: ; preds = %2
store i8 0, i8* %4
br label %7
7: ; preds = %6, %2
%8 = tail call i8* @strchr(i8* %1, i8 signext 10)
%9 = icmp eq i8* %8, null
br i1 %9, label %11, label %10
10: ; preds = %7
store i8 0, i8* %8
br label %11
11: ; preds = %10, %7
%12 = tail call i8* @strchr(i8* %1, i8 signext 32)
%13 = icmp eq i8* %12, null
br i1 %13, label %15, label %14
14: ; preds = %11
store i8 95, i8* %12
br label %15
15: ; preds = %14, %11
%16 = tail call i32 @strlen(i8* %1)
ret i32 %16
}