#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 */
struct vc4_opcode {
  int dummy;
};
struct vc4_op_pat {
  int dummy;
};
struct vc4_info {
  int dummy;
};

/* Variables and functions */
int /*<<< orphan*/ free(char *);
void *strchr(char const *, char);
int /*<<< orphan*/ strcpy(char *, char const *);
char *strdup(char const *);
int /*<<< orphan*/ vc4_go_got_one(struct vc4_info *, struct vc4_opcode *,
                                  char const *, struct vc4_op_pat const *);
void vc4_go_got_one_slash(struct vc4_info *info, struct vc4_opcode *op,
                          const char *str, const struct vc4_op_pat *base_pat) {
  const char *c;
  char *p;
  char *q;
  vc4_go_got_one(info, op, str, base_pat);
  if ((c = strchr(str, '/')) == NULL) {
    return;
  }
  p = strdup(str);
  q = strchr(p, '/');
  *q = 0;
  vc4_go_got_one(info, op, p, base_pat);
  strcpy(p, str);
  q = strchr(p, '/');
  q[-2] = q[1];
  q[-1] = q[2];
  q[0] = 0;
  vc4_go_got_one(info, op, p, base_pat);
  free(p);
}


x86 assembly (clang, -O0):
<vc4_go_got_one_slash>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x18(%rbp),%rdx
mov    -0x20(%rbp),%rcx
call   1040 <vc4_go_got_one@plt>
mov    -0x18(%rbp),%rdi
mov    $0x2f,%esi
call   1060 <strchr@plt>
mov    %rax,-0x28(%rbp)
cmp    $0x0,%rax
jne    119e <vc4_go_got_one_slash+0x4e>
jmp    1239 <vc4_go_got_one_slash+0xe9>
mov    -0x18(%rbp),%rdi
call   1070 <strdup@plt>
mov    %rax,-0x30(%rbp)
mov    -0x30(%rbp),%rdi
mov    $0x2f,%esi
call   1060 <strchr@plt>
mov    %rax,-0x38(%rbp)
mov    -0x38(%rbp),%rax
movb   $0x0,(%rax)
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x30(%rbp),%rdx
mov    -0x20(%rbp),%rcx
call   1040 <vc4_go_got_one@plt>
mov    -0x30(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1050 <strcpy@plt>
mov    -0x30(%rbp),%rdi
mov    $0x2f,%esi
call   1060 <strchr@plt>
mov    %rax,-0x38(%rbp)
mov    -0x38(%rbp),%rax
mov    0x1(%rax),%cl
mov    -0x38(%rbp),%rax
mov    %cl,-0x2(%rax)
mov    -0x38(%rbp),%rax
mov    0x2(%rax),%cl
mov    -0x38(%rbp),%rax
mov    %cl,-0x1(%rax)
mov    -0x38(%rbp),%rax
movb   $0x0,(%rax)
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x30(%rbp),%rdx
mov    -0x20(%rbp),%rcx
call   1040 <vc4_go_got_one@plt>
mov    -0x30(%rbp),%rdi
call   1030 <free@plt>
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<vc4_go_got_one_slash>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
mov    %rcx,%r14
mov    %rdx,%r13
mov    %rsi,%r15
mov    %rdi,%r12
call   1040 <vc4_go_got_one@plt>
mov    %r13,%rdi
mov    $0x2f,%esi
call   1060 <strchr@plt>
test   %rax,%rax
je     11ed <vc4_go_got_one_slash+0x9d>
mov    %r13,%rdi
call   1070 <strdup@plt>
mov    %rax,%rbx
mov    %rax,%rdi
mov    $0x2f,%esi
call   1060 <strchr@plt>
movb   $0x0,(%rax)
mov    %r12,%rdi
mov    %r15,%rsi
mov    %rbx,%rdx
mov    %r14,%rcx
call   1040 <vc4_go_got_one@plt>
mov    %rbx,%rdi
mov    %r13,%rsi
call   1050 <strcpy@plt>
mov    %rbx,%rdi
mov    $0x2f,%esi
call   1060 <strchr@plt>
movzwl 0x1(%rax),%ecx
mov    %cx,-0x2(%rax)
movb   $0x0,(%rax)
mov    %r12,%rdi
mov    %r15,%rsi
mov    %rbx,%rdx
mov    %r14,%rcx
call   1040 <vc4_go_got_one@plt>
mov    %rbx,%rdi
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
jmp    1030 <free@plt>
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
%struct.vc4_info = type { i32 }
%struct.vc4_opcode = type { i32 }
%struct.vc4_op_pat = type { i32 }
define void @vc4_go_got_one_slash(%struct.vc4_info* %0, %struct.vc4_opcode* %1, i8* %2, %struct.vc4_op_pat* %3) {
%5 = alloca %struct.vc4_info*
%6 = alloca %struct.vc4_opcode*
%7 = alloca i8*
%8 = alloca %struct.vc4_op_pat*
%9 = alloca i8*
%10 = alloca i8*
%11 = alloca i8*
store %struct.vc4_info* %0, %struct.vc4_info** %5
store %struct.vc4_opcode* %1, %struct.vc4_opcode** %6
store i8* %2, i8** %7
store %struct.vc4_op_pat* %3, %struct.vc4_op_pat** %8
%12 = load %struct.vc4_info*, %struct.vc4_info** %5
%13 = load %struct.vc4_opcode*, %struct.vc4_opcode** %6
%14 = load i8*, i8** %7
%15 = load %struct.vc4_op_pat*, %struct.vc4_op_pat** %8
%16 = call i32 @vc4_go_got_one(%struct.vc4_info* %12, %struct.vc4_opcode* %13, i8* %14, %struct.vc4_op_pat* %15)
%17 = load i8*, i8** %7
%18 = call i8* @strchr(i8* %17, i8 signext 47)
store i8* %18, i8** %9
%19 = icmp eq i8* %18, null
br i1 %19, label %20, label %21
20: ; preds = %4
br label %56
21: ; preds = %4
%22 = load i8*, i8** %7
%23 = call i8* @strdup(i8* %22)
store i8* %23, i8** %10
%24 = load i8*, i8** %10
%25 = call i8* @strchr(i8* %24, i8 signext 47)
store i8* %25, i8** %11
%26 = load i8*, i8** %11
store i8 0, i8* %26
%27 = load %struct.vc4_info*, %struct.vc4_info** %5
%28 = load %struct.vc4_opcode*, %struct.vc4_opcode** %6
%29 = load i8*, i8** %10
%30 = load %struct.vc4_op_pat*, %struct.vc4_op_pat** %8
%31 = call i32 @vc4_go_got_one(%struct.vc4_info* %27, %struct.vc4_opcode* %28, i8* %29, %struct.vc4_op_pat* %30)
%32 = load i8*, i8** %10
%33 = load i8*, i8** %7
%34 = call i32 @strcpy(i8* %32, i8* %33)
%35 = load i8*, i8** %10
%36 = call i8* @strchr(i8* %35, i8 signext 47)
store i8* %36, i8** %11
%37 = load i8*, i8** %11
%38 = getelementptr inbounds i8, i8* %37, i64 1
%39 = load i8, i8* %38
%40 = load i8*, i8** %11
%41 = getelementptr inbounds i8, i8* %40, i64 -2
store i8 %39, i8* %41
%42 = load i8*, i8** %11
%43 = getelementptr inbounds i8, i8* %42, i64 2
%44 = load i8, i8* %43
%45 = load i8*, i8** %11
%46 = getelementptr inbounds i8, i8* %45, i64 -1
store i8 %44, i8* %46
%47 = load i8*, i8** %11
%48 = getelementptr inbounds i8, i8* %47, i64 0
store i8 0, i8* %48
%49 = load %struct.vc4_info*, %struct.vc4_info** %5
%50 = load %struct.vc4_opcode*, %struct.vc4_opcode** %6
%51 = load i8*, i8** %10
%52 = load %struct.vc4_op_pat*, %struct.vc4_op_pat** %8
%53 = call i32 @vc4_go_got_one(%struct.vc4_info* %49, %struct.vc4_opcode* %50, i8* %51, %struct.vc4_op_pat* %52)
%54 = load i8*, i8** %10
%55 = call i32 @free(i8* %54)
br label %56
56: ; preds = %21, %20
ret void
}

LLVM IR (-O2):
%struct.vc4_info = type { i32 }
%struct.vc4_opcode = type { i32 }
%struct.vc4_op_pat = type { i32 }
define void @vc4_go_got_one_slash(%struct.vc4_info* %0, %struct.vc4_opcode* %1, i8* %2, %struct.vc4_op_pat* %3) {
%5 = tail call i32 @vc4_go_got_one(%struct.vc4_info* %0, %struct.vc4_opcode* %1, i8* %2, %struct.vc4_op_pat* %3)
%6 = tail call i8* @strchr(i8* dereferenceable(1) %2, i8 signext 47)
%7 = icmp eq i8* %6, null
br i1 %7, label %22, label %8
8: ; preds = %4
%9 = tail call i8* @strdup(i8* %2)
%10 = tail call i8* @strchr(i8* dereferenceable(1) %9, i8 signext 47)
store i8 0, i8* %10
%11 = tail call i32 @vc4_go_got_one(%struct.vc4_info* %0, %struct.vc4_opcode* %1, i8* %9, %struct.vc4_op_pat* %3)
%12 = tail call i32 @strcpy(i8* %9, i8* %2)
%13 = tail call i8* @strchr(i8* dereferenceable(1) %9, i8 signext 47)
%14 = getelementptr inbounds i8, i8* %13, i64 1
%15 = load i8, i8* %14
%16 = getelementptr inbounds i8, i8* %13, i64 -2
store i8 %15, i8* %16
%17 = getelementptr inbounds i8, i8* %13, i64 2
%18 = load i8, i8* %17
%19 = getelementptr inbounds i8, i8* %13, i64 -1
store i8 %18, i8* %19
store i8 0, i8* %13
%20 = tail call i32 @vc4_go_got_one(%struct.vc4_info* %0, %struct.vc4_opcode* %1, i8* %9, %struct.vc4_op_pat* %3)
%21 = tail call i32 @free(i8* %9)
br label %22
22: ; preds = %4, %8
ret void
}