#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 */
scalar_t__ strlen(char const *);
int findExeNameStart(const char *exec_name) {
  int exename_start = (int)strlen(exec_name);
  while ((exename_start > 0) && (exec_name[exename_start] != '\\') &&
         (exec_name[exename_start] != '/')) {
    exename_start--;
  }
  if (exec_name[exename_start] == '\\' || exec_name[exename_start] == '/') {
    return exename_start + 1;
  } else {
    return exename_start;
  }
}


x86 assembly (clang, -O0):
<findExeNameStart>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,-0x14(%rbp)
xor    %eax,%eax
cmpl   $0x0,-0x14(%rbp)
mov    %al,-0x15(%rbp)
jle    1166 <findExeNameStart+0x56>
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
movsbl (%rax,%rcx,1),%ecx
xor    %eax,%eax
cmp    $0x5c,%ecx
mov    %al,-0x15(%rbp)
je     1166 <findExeNameStart+0x56>
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x2f,%eax
setne  %al
mov    %al,-0x15(%rbp)
mov    -0x15(%rbp),%al
test   $0x1,%al
jne    1176 <findExeNameStart+0x66>
jmp    1184 <findExeNameStart+0x74>
mov    -0x14(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x14(%rbp)
jmp    1128 <findExeNameStart+0x18>
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x5c,%eax
je     11ae <findExeNameStart+0x9e>
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x2f,%eax
jne    11bc <findExeNameStart+0xac>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x4(%rbp)
jmp    11c2 <findExeNameStart+0xb2>
mov    -0x14(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<findExeNameStart>:
push   %rbx
mov    %rdi,%rbx
call   1030 <strlen@plt>
test   %eax,%eax
jle    114e <findExeNameStart+0x3e>
mov    %eax,%ecx
add    $0x1,%rcx
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
movzbl -0x1(%rbx,%rcx,1),%edx
cmp    $0x2f,%dl
je     114e <findExeNameStart+0x3e>
cmp    $0x5c,%dl
je     114e <findExeNameStart+0x3e>
add    $0xffffffff,%eax
add    $0xffffffffffffffff,%rcx
cmp    $0x1,%rcx
jg     1130 <findExeNameStart+0x20>
xor    %eax,%eax
movslq %eax,%rcx
mov    (%rbx,%rcx,1),%cl
cmp    $0x5c,%cl
je     115e <findExeNameStart+0x4e>
cmp    $0x2f,%cl
jne    1161 <findExeNameStart+0x51>
add    $0x1,%eax
pop    %rbx
ret

LLVM IR (-O0):
define i32 @findExeNameStart(i8* %0) {
%2 = alloca i32
%3 = alloca i8*
%4 = alloca i32
store i8* %0, i8** %3
%5 = load i8*, i8** %3
%6 = call i64 @strlen(i8* %5)
%7 = trunc i64 %6 to i32
store i32 %7, i32* %4
br label %8
8: ; preds = %29, %1
%9 = load i32, i32* %4
%10 = icmp sgt i32 %9, 0
br i1 %10, label %11, label %27
11: ; preds = %8
%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 ne i32 %17, 92
br i1 %18, label %19, label %27
19: ; preds = %11
%20 = load i8*, i8** %3
%21 = load i32, i32* %4
%22 = sext i32 %21 to i64
%23 = getelementptr inbounds i8, i8* %20, i64 %22
%24 = load i8, i8* %23
%25 = sext i8 %24 to i32
%26 = icmp ne i32 %25, 47
br label %27
27: ; preds = %19, %11, %8
%28 = phi i1 [ false, %11 ], [ false, %8 ], [ %26, %19 ]
br i1 %28, label %29, label %32
29: ; preds = %27
%30 = load i32, i32* %4
%31 = add nsw i32 %30, -1
store i32 %31, i32* %4
br label %8
32: ; preds = %27
%33 = load i8*, i8** %3
%34 = load i32, i32* %4
%35 = sext i32 %34 to i64
%36 = getelementptr inbounds i8, i8* %33, i64 %35
%37 = load i8, i8* %36
%38 = sext i8 %37 to i32
%39 = icmp eq i32 %38, 92
br i1 %39, label %48, label %40
40: ; preds = %32
%41 = load i8*, i8** %3
%42 = load i32, i32* %4
%43 = sext i32 %42 to i64
%44 = getelementptr inbounds i8, i8* %41, i64 %43
%45 = load i8, i8* %44
%46 = sext i8 %45 to i32
%47 = icmp eq i32 %46, 47
br i1 %47, label %48, label %51
48: ; preds = %40, %32
%49 = load i32, i32* %4
%50 = add nsw i32 %49, 1
store i32 %50, i32* %2
br label %53
51: ; preds = %40
%52 = load i32, i32* %4
store i32 %52, i32* %2
br label %53
53: ; preds = %51, %48
%54 = load i32, i32* %2
ret i32 %54
}

LLVM IR (-O2):
define i32 @findExeNameStart(i8* nocapture %0) {
%2 = tail call i64 @strlen(i8* dereferenceable(1) %0)
%3 = trunc i64 %2 to i32
%4 = icmp sgt i32 %3, 0
br i1 %4, label %5, label %16
5: ; preds = %1
%6 = and i64 %2, 4294967295
br label %7
7: ; preds = %5, %11
%8 = phi i64 [ %6, %5 ], [ %12, %11 ]
%9 = getelementptr inbounds i8, i8* %0, i64 %8
%10 = load i8, i8* %9
switch i8 %10, label %11 [
i8 92, label %14
i8 47, label %14
]
11: ; preds = %7
%12 = add nsw i64 %8, -1
%13 = icmp sgt i64 %8, 1
br i1 %13, label %7, label %16
14: ; preds = %7, %7
%15 = trunc i64 %8 to i32
br label %16
16: ; preds = %11, %14, %1
%17 = phi i32 [ %3, %1 ], [ %15, %14 ], [ 0, %11 ]
%18 = sext i32 %17 to i64
%19 = getelementptr inbounds i8, i8* %0, i64 %18
%20 = load i8, i8* %19
switch i8 %20, label %23 [
i8 92, label %21
i8 47, label %21
]
21: ; preds = %16, %16
%22 = add nsw i32 %17, 1
br label %23
23: ; preds = %16, %21
%24 = phi i32 [ %22, %21 ], [ %17, %16 ]
ret i32 %24
}