#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 */
int /*<<< orphan*/ memmove(char *, char *, scalar_t__);
scalar_t__ strlen(char *);
char *strstr(char *, char *);
void stripBeerFridgeCgroup(char *currentCgroup) {
  char *foundGroup;
  char *nextSlash;
  if (foundGroup = strstr(currentCgroup, "/beerfridge_")) {
    if (nextSlash = strstr(foundGroup, "/")) {
      memmove(foundGroup, nextSlash, strlen(nextSlash) + 1);
    } else {
      foundGroup[0] = '\0';
    }
  }
}


x86 assembly (clang, -O0):
<stripBeerFridgeCgroup>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
lea    0xeb9(%rip),%rsi
call   1050 <strstr@plt>
mov    %rax,-0x10(%rbp)
cmp    $0x0,%rax
je     11b6 <stripBeerFridgeCgroup+0x86>
mov    -0x10(%rbp),%rdi
lea    0xea8(%rip),%rsi
call   1050 <strstr@plt>
mov    %rax,-0x18(%rbp)
cmp    $0x0,%rax
je     11aa <stripBeerFridgeCgroup+0x7a>
mov    -0x10(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x18(%rbp),%rdi
call   1030 <strlen@plt>
mov    -0x28(%rbp),%rdi
mov    -0x20(%rbp),%rsi
mov    %rax,%rdx
add    $0x1,%rdx
call   1040 <memmove@plt>
jmp    11b1 <stripBeerFridgeCgroup+0x81>
mov    -0x10(%rbp),%rax
movb   $0x0,(%rax)
jmp    11b6 <stripBeerFridgeCgroup+0x86>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<stripBeerFridgeCgroup>:
push   %r14
push   %rbx
push   %rax
lea    0xeb5(%rip),%rsi
call   1060 <strstr@plt>
test   %rax,%rax
je     118e <stripBeerFridgeCgroup+0x4e>
mov    %rax,%rbx
mov    %rax,%rdi
mov    $0x2f,%esi
call   1040 <strchr@plt>
test   %rax,%rax
je     118b <stripBeerFridgeCgroup+0x4b>
mov    %rax,%r14
mov    %rax,%rdi
call   1030 <strlen@plt>
lea    0x1(%rax),%rdx
mov    %rbx,%rdi
mov    %r14,%rsi
add    $0x8,%rsp
pop    %rbx
pop    %r14
jmp    1050 <memmove@plt>
movb   $0x0,(%rbx)
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [13 x i8] c"/beerfridge_\00"
@.str.1 = [2 x i8] c"/\00"
define void @stripBeerFridgeCgroup(i8* %0) {
%2 = alloca i8*
%3 = alloca i8*
%4 = alloca i8*
store i8* %0, i8** %2
%5 = load i8*, i8** %2
%6 = call i8* @strstr(i8* %5, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0))
store i8* %6, i8** %3
%7 = icmp ne i8* %6, null
br i1 %7, label %8, label %23
8: ; preds = %1
%9 = load i8*, i8** %3
%10 = call i8* @strstr(i8* %9, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i8* %10, i8** %4
%11 = icmp ne i8* %10, null
br i1 %11, label %12, label %19
12: ; preds = %8
%13 = load i8*, i8** %3
%14 = load i8*, i8** %4
%15 = load i8*, i8** %4
%16 = call i64 @strlen(i8* %15)
%17 = add nsw i64 %16, 1
%18 = call i32 @memmove(i8* %13, i8* %14, i64 %17)
br label %22
19: ; preds = %8
%20 = load i8*, i8** %3
%21 = getelementptr inbounds i8, i8* %20, i64 0
store i8 0, i8* %21
br label %22
22: ; preds = %19, %12
br label %23
23: ; preds = %22, %1
ret void
}

LLVM IR (-O2):
@.str = [13 x i8] c"/beerfridge_\00"
define void @stripBeerFridgeCgroup(i8* %0) {
%2 = tail call i8* @strstr(i8* dereferenceable(1) %0, i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0))
%3 = icmp eq i8* %2, null
br i1 %3, label %12, label %4
4: ; preds = %1
%5 = tail call i8* @strchr(i8* %2, i32 47)
%6 = icmp eq i8* %5, null
br i1 %6, label %11, label %7
7: ; preds = %4
%8 = tail call i64 @strlen(i8* %5)
%9 = add nsw i64 %8, 1
%10 = tail call i32 @memmove(i8* %2, i8* %5, i64 %9)
br label %12
11: ; preds = %4
store i8 0, i8* %2
br label %12
12: ; preds = %7, %11, %1
ret void
}