#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 *);
void first_part(char *pathname, char *firstpart) {
  char *p = pathname;
  char *p2;
  if (*p == '/') {
    p++;
    if (*p == '\0') {
      firstpart[0] = '\0';
    }
  }
  strcpy(firstpart, p);
  p2 = strchr(firstpart, '/');
  if (p2 == NULL) {
  } else {
    *p2 = '\0';
  }
  return;
}


x86 assembly (clang, -O0):
<first_part>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x2f,%eax
jne    1170 <first_part+0x50>
mov    -0x18(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
jne    116b <first_part+0x4b>
mov    -0x10(%rbp),%rax
movb   $0x0,(%rax)
jmp    1170 <first_part+0x50>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1030 <strcpy@plt>
mov    -0x10(%rbp),%rdi
mov    $0x2f,%esi
call   1040 <strchr@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
jne    119f <first_part+0x7f>
jmp    11a6 <first_part+0x86>
mov    -0x20(%rbp),%rax
movb   $0x0,(%rax)
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<first_part>:
push   %rbx
mov    %rsi,%rbx
cmpb   $0x2f,(%rdi)
jne    1138 <first_part+0x18>
lea    0x1(%rdi),%rsi
cmpb   $0x0,0x1(%rdi)
jne    113b <first_part+0x1b>
movb   $0x0,(%rbx)
jmp    113b <first_part+0x1b>
mov    %rdi,%rsi
mov    %rbx,%rdi
call   1030 <strcpy@plt>
mov    %rbx,%rdi
mov    $0x2f,%esi
call   1040 <strchr@plt>
test   %rax,%rax
je     1158 <first_part+0x38>
movb   $0x0,(%rax)
pop    %rbx
ret

LLVM IR (-O0):
define void @first_part(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
store i8* %7, i8** %5
%8 = load i8*, i8** %5
%9 = load i8, i8* %8
%10 = sext i8 %9 to i32
%11 = icmp eq i32 %10, 47
br i1 %11, label %12, label %23
12: ; preds = %2
%13 = load i8*, i8** %5
%14 = getelementptr inbounds i8, i8* %13, i32 1
store i8* %14, i8** %5
%15 = load i8*, i8** %5
%16 = load i8, i8* %15
%17 = sext i8 %16 to i32
%18 = icmp eq i32 %17, 0
br i1 %18, label %19, label %22
19: ; preds = %12
%20 = load i8*, i8** %4
%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, %2
%24 = load i8*, i8** %4
%25 = load i8*, i8** %5
%26 = call i32 @strcpy(i8* %24, i8* %25)
%27 = load i8*, i8** %4
%28 = call i8* @strchr(i8* %27, i8 signext 47)
store i8* %28, i8** %6
%29 = load i8*, i8** %6
%30 = icmp eq i8* %29, null
br i1 %30, label %31, label %32
31: ; preds = %23
br label %34
32: ; preds = %23
%33 = load i8*, i8** %6
store i8 0, i8* %33
br label %34
34: ; preds = %32, %31
ret void
}

LLVM IR (-O2):
define void @first_part(i8* %0, i8* %1) {
%3 = load i8, i8* %0
%4 = icmp eq i8 %3, 47
br i1 %4, label %5, label %10
5: ; preds = %2
%6 = getelementptr inbounds i8, i8* %0, i64 1
%7 = load i8, i8* %6
%8 = icmp eq i8 %7, 0
br i1 %8, label %9, label %10
9: ; preds = %5
store i8 0, i8* %1
br label %10
10: ; preds = %5, %9, %2
%11 = phi i8* [ %6, %9 ], [ %6, %5 ], [ %0, %2 ]
%12 = tail call i32 @strcpy(i8* %1, i8* %11)
%13 = tail call i8* @strchr(i8* dereferenceable(1) %1, i8 signext 47)
%14 = icmp eq i8* %13, null
br i1 %14, label %16, label %15
15: ; preds = %10
store i8 0, i8* %13
br label %16
16: ; preds = %10, %15
ret void
}