#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 strlen(char *);
char *get_subdirectory_string(char *directory) {
  int i;
  for (i = 0; i < strlen(directory) - 1; i++) {
    if (directory[i] == '/') {
      return &directory[i + 1];
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<get_subdirectory_string>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%eax
mov    %eax,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,%ecx
mov    -0x18(%rbp),%eax
sub    $0x1,%ecx
cmp    %ecx,%eax
jge    1183 <get_subdirectory_string+0x73>
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x2f,%eax
jne    1170 <get_subdirectory_string+0x60>
mov    -0x10(%rbp),%rax
mov    -0x14(%rbp),%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
add    %rcx,%rax
mov    %rax,-0x8(%rbp)
jmp    118b <get_subdirectory_string+0x7b>
jmp    1175 <get_subdirectory_string+0x65>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1123 <get_subdirectory_string+0x13>
movq   $0x0,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_subdirectory_string>:
push   %r15
push   %r14
push   %rbx
mov    %rdi,%r15
call   1030 <strlen@plt>
xor    %r14d,%r14d
cmp    $0x2,%eax
jl     1157 <get_subdirectory_string+0x47>
xor    %ebx,%ebx
nopw   0x0(%rax,%rax,1)
cmpb   $0x2f,(%r15,%rbx,1)
je     114f <get_subdirectory_string+0x3f>
add    $0x1,%rbx
mov    %r15,%rdi
call   1030 <strlen@plt>
add    $0xffffffff,%eax
cltq
cmp    %rax,%rbx
jl     1130 <get_subdirectory_string+0x20>
jmp    1157 <get_subdirectory_string+0x47>
lea    (%r15,%rbx,1),%r14
add    $0x1,%r14
mov    %r14,%rax
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define i8* @get_subdirectory_string(i8* %0) {
%2 = alloca i8*
%3 = alloca i8*
%4 = alloca i32
store i8* %0, i8** %3
store i32 0, i32* %4
br label %5
5: ; preds = %26, %1
%6 = load i32, i32* %4
%7 = load i8*, i8** %3
%8 = call i32 @strlen(i8* %7)
%9 = sub nsw i32 %8, 1
%10 = icmp slt i32 %6, %9
br i1 %10, label %11, label %29
11: ; preds = %5
%12 = load i8*, i8** %3
%13 = load i32, i32* %4
%14 = sext i32 %13 to i64
%15 = getelementptr inbounds i8, i8* %12, i64 %14
%16 = load i8, i8* %15
%17 = sext i8 %16 to i32
%18 = icmp eq i32 %17, 47
br i1 %18, label %19, label %25
19: ; preds = %11
%20 = load i8*, i8** %3
%21 = load i32, i32* %4
%22 = add nsw i32 %21, 1
%23 = sext i32 %22 to i64
%24 = getelementptr inbounds i8, i8* %20, i64 %23
store i8* %24, i8** %2
br label %30
25: ; preds = %11
br label %26
26: ; preds = %25
%27 = load i32, i32* %4
%28 = add nsw i32 %27, 1
store i32 %28, i32* %4
br label %5
29: ; preds = %5
store i8* null, i8** %2
br label %30
30: ; preds = %29, %19
%31 = load i8*, i8** %2
ret i8* %31
}

LLVM IR (-O2):
define i8* @get_subdirectory_string(i8* %0) {
%2 = tail call i32 @strlen(i8* %0)
%3 = icmp sgt i32 %2, 1
br i1 %3, label %4, label %18
4: ; preds = %1, %13
%5 = phi i64 [ %9, %13 ], [ 0, %1 ]
%6 = getelementptr inbounds i8, i8* %0, i64 %5
%7 = load i8, i8* %6
%8 = icmp eq i8 %7, 47
%9 = add nuw nsw i64 %5, 1
br i1 %8, label %10, label %13
10: ; preds = %4
%11 = and i64 %9, 4294967295
%12 = getelementptr inbounds i8, i8* %0, i64 %11
br label %18
13: ; preds = %4
%14 = tail call i32 @strlen(i8* %0)
%15 = add nsw i32 %14, -1
%16 = sext i32 %15 to i64
%17 = icmp slt i64 %9, %16
br i1 %17, label %4, label %18
18: ; preds = %13, %1, %10
%19 = phi i8* [ %12, %10 ], [ null, %1 ], [ null, %13 ]
ret i8* %19
}