#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*/ Q_strcat(char *, int, char const *);
char *strchr(char *, char);
void ForceClientSkin(char *model, const char *skin) {
  char *p;
  char *q;
  p = strchr(model, '/');
  if (!p || !p[0] || !p[1]) {
    Q_strcat(model, 64, "/");
    Q_strcat(model, 64, "main");
    Q_strcat(model, 64, "/");
    Q_strcat(model, 64, skin);
  } else {
    p++;
    q = strchr(p, '/');
    if (!q || !q[0] || !q[1]) {
      Q_strcat(model, 64, "/");
      Q_strcat(model, 64, skin);
    } else {
      q++;
      *q = '\0';
      Q_strcat(model, 64, skin);
    }
  }
}


x86 assembly (clang, -O0):
<ForceClientSkin>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%rdi
mov    $0x2f,%esi
call   1030 <strchr@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
je     1168 <ForceClientSkin+0x48>
mov    -0x18(%rbp),%rax
cmpb   $0x0,(%rax)
je     1168 <ForceClientSkin+0x48>
mov    -0x18(%rbp),%rax
cmpb   $0x0,0x1(%rax)
jne    11be <ForceClientSkin+0x9e>
mov    -0x8(%rbp),%rdi
mov    $0x40,%esi
lea    0xe88(%rip),%rdx
call   1040 <Q_strcat@plt>
mov    -0x8(%rbp),%rdi
mov    $0x40,%esi
lea    0xe75(%rip),%rdx
call   1040 <Q_strcat@plt>
mov    -0x8(%rbp),%rdi
mov    $0x40,%esi
lea    0xe5e(%rip),%rdx
call   1040 <Q_strcat@plt>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rdx
mov    $0x40,%esi
call   1040 <Q_strcat@plt>
jmp    1258 <ForceClientSkin+0x138>
mov    -0x18(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
mov    $0x2f,%esi
call   1030 <strchr@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
je     1202 <ForceClientSkin+0xe2>
mov    -0x20(%rbp),%rax
cmpb   $0x0,(%rax)
je     1202 <ForceClientSkin+0xe2>
mov    -0x20(%rbp),%rax
cmpb   $0x0,0x1(%rax)
jne    122e <ForceClientSkin+0x10e>
mov    -0x8(%rbp),%rdi
mov    $0x40,%esi
lea    0xdee(%rip),%rdx
call   1040 <Q_strcat@plt>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rdx
mov    $0x40,%esi
call   1040 <Q_strcat@plt>
jmp    1253 <ForceClientSkin+0x133>
mov    -0x20(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rax
movb   $0x0,(%rax)
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rdx
mov    $0x40,%esi
call   1040 <Q_strcat@plt>
jmp    1258 <ForceClientSkin+0x138>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ForceClientSkin>:
push   %r15
push   %r14
push   %rbx
mov    %rsi,%r14
mov    %rdi,%rbx
mov    $0x2f,%esi
call   1030 <strchr@plt>
test   %rax,%rax
je     116c <ForceClientSkin+0x4c>
cmpb   $0x0,(%rax)
je     116c <ForceClientSkin+0x4c>
cmpb   $0x0,0x1(%rax)
je     116c <ForceClientSkin+0x4c>
add    $0x1,%rax
mov    %rax,%rdi
mov    $0x2f,%esi
call   1030 <strchr@plt>
test   %rax,%rax
je     11bc <ForceClientSkin+0x9c>
cmpb   $0x0,(%rax)
je     11bc <ForceClientSkin+0x9c>
cmpb   $0x0,0x1(%rax)
je     11bc <ForceClientSkin+0x9c>
movb   $0x0,0x1(%rax)
jmp    11a7 <ForceClientSkin+0x87>
lea    0xe8d(%rip),%r15
mov    %rbx,%rdi
mov    $0x40,%esi
mov    %r15,%rdx
call   1040 <Q_strcat@plt>
lea    0xe78(%rip),%rdx
mov    %rbx,%rdi
mov    $0x40,%esi
call   1040 <Q_strcat@plt>
mov    %rbx,%rdi
mov    $0x40,%esi
mov    %r15,%rdx
call   1040 <Q_strcat@plt>
mov    %rbx,%rdi
mov    $0x40,%esi
mov    %r14,%rdx
pop    %rbx
pop    %r14
pop    %r15
jmp    1040 <Q_strcat@plt>
lea    0xe3d(%rip),%rdx
mov    %rbx,%rdi
mov    $0x40,%esi
jmp    11a2 <ForceClientSkin+0x82>

LLVM IR (-O0):
@.str = [2 x i8] c"/\00"
@.str.1 = [5 x i8] c"main\00"
define void @ForceClientSkin(i8* %0, i8* %1) {
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i8*
store i8* %0, i8** %3
store i8* %1, i8** %4
%7 = load i8*, i8** %3
%8 = call i8* @strchr(i8* %7, i8 signext 47)
store i8* %8, i8** %5
%9 = load i8*, i8** %5
%10 = icmp ne i8* %9, null
br i1 %10, label %11, label %21
11: ; preds = %2
%12 = load i8*, i8** %5
%13 = getelementptr inbounds i8, i8* %12, i64 0
%14 = load i8, i8* %13
%15 = icmp ne i8 %14, 0
br i1 %15, label %16, label %21
16: ; preds = %11
%17 = load i8*, i8** %5
%18 = getelementptr inbounds i8, i8* %17, i64 1
%19 = load i8, i8* %18
%20 = icmp ne i8 %19, 0
br i1 %20, label %31, label %21
21: ; preds = %16, %11, %2
%22 = load i8*, i8** %3
%23 = call i32 @Q_strcat(i8* %22, i32 64, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%24 = load i8*, i8** %3
%25 = call i32 @Q_strcat(i8* %24, i32 64, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
%26 = load i8*, i8** %3
%27 = call i32 @Q_strcat(i8* %26, i32 64, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%28 = load i8*, i8** %3
%29 = load i8*, i8** %4
%30 = call i32 @Q_strcat(i8* %28, i32 64, i8* %29)
br label %62
31: ; preds = %16
%32 = load i8*, i8** %5
%33 = getelementptr inbounds i8, i8* %32, i32 1
store i8* %33, i8** %5
%34 = load i8*, i8** %5
%35 = call i8* @strchr(i8* %34, i8 signext 47)
store i8* %35, i8** %6
%36 = load i8*, i8** %6
%37 = icmp ne i8* %36, null
br i1 %37, label %38, label %48
38: ; preds = %31
%39 = load i8*, i8** %6
%40 = getelementptr inbounds i8, i8* %39, i64 0
%41 = load i8, i8* %40
%42 = icmp ne i8 %41, 0
br i1 %42, label %43, label %48
43: ; preds = %38
%44 = load i8*, i8** %6
%45 = getelementptr inbounds i8, i8* %44, i64 1
%46 = load i8, i8* %45
%47 = icmp ne i8 %46, 0
br i1 %47, label %54, label %48
48: ; preds = %43, %38, %31
%49 = load i8*, i8** %3
%50 = call i32 @Q_strcat(i8* %49, i32 64, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%51 = load i8*, i8** %3
%52 = load i8*, i8** %4
%53 = call i32 @Q_strcat(i8* %51, i32 64, i8* %52)
br label %61
54: ; preds = %43
%55 = load i8*, i8** %6
%56 = getelementptr inbounds i8, i8* %55, i32 1
store i8* %56, i8** %6
%57 = load i8*, i8** %6
store i8 0, i8* %57
%58 = load i8*, i8** %3
%59 = load i8*, i8** %4
%60 = call i32 @Q_strcat(i8* %58, i32 64, i8* %59)
br label %61
61: ; preds = %54, %48
br label %62
62: ; preds = %61, %21
ret void
}

LLVM IR (-O2):
@.str = [2 x i8] c"/\00"
@.str.1 = [5 x i8] c"main\00"
define void @ForceClientSkin(i8* %0, i8* %1) {
%3 = tail call i8* @strchr(i8* dereferenceable(1) %0, i8 signext 47)
%4 = icmp eq i8* %3, null
br i1 %4, label %12, label %5
5: ; preds = %2
%6 = load i8, i8* %3
%7 = icmp eq i8 %6, 0
br i1 %7, label %12, label %8
8: ; preds = %5
%9 = getelementptr inbounds i8, i8* %3, i64 1
%10 = load i8, i8* %9
%11 = icmp eq i8 %10, 0
br i1 %11, label %12, label %16
12: ; preds = %8, %5, %2
%13 = tail call i32 @Q_strcat(i8* %0, i32 64, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%14 = tail call i32 @Q_strcat(i8* %0, i32 64, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
%15 = tail call i32 @Q_strcat(i8* %0, i32 64, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
br label %29
16: ; preds = %8
%17 = tail call i8* @strchr(i8* %9, i8 signext 47)
%18 = icmp eq i8* %17, null
br i1 %18, label %26, label %19
19: ; preds = %16
%20 = load i8, i8* %17
%21 = icmp eq i8 %20, 0
br i1 %21, label %26, label %22
22: ; preds = %19
%23 = getelementptr inbounds i8, i8* %17, i64 1
%24 = load i8, i8* %23
%25 = icmp eq i8 %24, 0
br i1 %25, label %26, label %28
26: ; preds = %22, %19, %16
%27 = tail call i32 @Q_strcat(i8* %0, i32 64, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
br label %29
28: ; preds = %22
store i8 0, i8* %23
br label %29
29: ; preds = %26, %28, %12
%30 = tail call i32 @Q_strcat(i8* %0, i32 64, i8* %1)
ret void
}