#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*/ putstr(char const *);
void write_func(const char *func) {
  const char *lastslash = 0;
  for (const char *src = func; *src; ++src) {
    if (*src == '/')
      lastslash = src;
  }
  if (*++lastslash) {
    func = lastslash;
  }
  putstr(func);
}


x86 assembly (clang, -O0):
<write_func>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
movq   $0x0,-0x10(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rax
cmpb   $0x0,(%rax)
je     1167 <write_func+0x57>
mov    -0x18(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x2f,%eax
jne    1151 <write_func+0x41>
mov    -0x18(%rbp),%rax
mov    %rax,-0x10(%rbp)
jmp    1156 <write_func+0x46>
mov    -0x18(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x18(%rbp)
jmp    112c <write_func+0x1c>
mov    -0x10(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x10(%rbp)
cmpb   $0x0,0x1(%rax)
je     1188 <write_func+0x78>
mov    -0x10(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
call   1030 <putstr@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<write_func>:
xor    %ecx,%ecx
mov    %rdi,%rax
jmp    1127 <write_func+0x17>
nopw   0x0(%rax,%rax,1)
mov    %rax,%rcx
add    $0x1,%rax
movzbl (%rax),%edx
cmp    $0x2f,%dl
je     1120 <write_func+0x10>
test   %dl,%dl
jne    1123 <write_func+0x13>
lea    0x1(%rcx),%rax
cmpb   $0x0,0x1(%rcx)
cmove  %rdi,%rax
mov    %rax,%rdi
jmp    1030 <putstr@plt>

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

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