#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__ isalpha(char);
char *strchr(char *, char);
char *strdash(char *f) {
  static char *pos;
  pos = strchr(f, '-');
  if (pos != NULL) {
    if (isalpha(*(pos + 1)) && *pos == '-') {
      pos = strchr(pos + 1, '-');
    }
  }
  if (pos == NULL) {
    pos = strchr(f, '_');
    if (pos != NULL) {
      if (isalpha(*(pos + 1)) && *pos == '-') {
        pos = strchr(pos + 1, '-');
      }
    }
  }
  return pos;
}


x86 assembly (clang, -O0):
<strdash>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
mov    $0x2d,%esi
call   1030 <strchr@plt>
mov    %rax,0x2ef7(%rip)
cmpq   $0x0,0x2eef(%rip)
je     119d <strdash+0x7d>
mov    0x2ee2(%rip),%rax
movsbl 0x1(%rax),%edi
call   1040 <isalpha@plt>
cmp    $0x0,%rax
je     1198 <strdash+0x78>
mov    0x2ec8(%rip),%rax
movsbl (%rax),%eax
cmp    $0x2d,%eax
jne    1198 <strdash+0x78>
mov    0x2eb5(%rip),%rdi
add    $0x1,%rdi
mov    $0x2d,%esi
call   1030 <strchr@plt>
mov    %rax,0x2ea0(%rip)
jmp    119d <strdash+0x7d>
cmpq   $0x0,0x2e93(%rip)
jne    1221 <strdash+0x101>
mov    -0x8(%rbp),%rdi
mov    $0x5f,%esi
call   1030 <strchr@plt>
mov    %rax,0x2e78(%rip)
cmpq   $0x0,0x2e70(%rip)
je     121c <strdash+0xfc>
mov    0x2e63(%rip),%rax
movsbl 0x1(%rax),%edi
call   1040 <isalpha@plt>
cmp    $0x0,%rax
je     1217 <strdash+0xf7>
mov    0x2e49(%rip),%rax
movsbl (%rax),%eax
cmp    $0x2d,%eax
jne    1217 <strdash+0xf7>
mov    0x2e36(%rip),%rdi
add    $0x1,%rdi
mov    $0x2d,%esi
call   1030 <strchr@plt>
mov    %rax,0x2e21(%rip)
jmp    121c <strdash+0xfc>
jmp    1221 <strdash+0x101>
mov    0x2e10(%rip),%rax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<strdash>:
push   %rbx
mov    %rdi,%rbx
mov    $0x2d,%esi
call   1030 <strchr@plt>
mov    %rax,0x2f03(%rip)
test   %rax,%rax
je     1176 <strdash+0x56>
movsbl 0x1(%rax),%edi
call   1040 <isalpha@plt>
mov    %rax,%rcx
mov    0x2eeb(%rip),%rax
test   %rcx,%rcx
je     116f <strdash+0x4f>
cmpb   $0x2d,(%rax)
jne    1174 <strdash+0x54>
add    $0x1,%rax
mov    %rax,%rdi
mov    $0x2d,%esi
call   1030 <strchr@plt>
mov    %rax,0x2ec9(%rip)
test   %rax,%rax
je     1176 <strdash+0x56>
pop    %rbx
ret
mov    %rbx,%rdi
mov    $0x5f,%esi
call   1030 <strchr@plt>
mov    %rax,0x2eae(%rip)
test   %rax,%rax
je     11c6 <strdash+0xa6>
movsbl 0x1(%rax),%edi
call   1040 <isalpha@plt>
mov    %rax,%rcx
mov    0x2e96(%rip),%rax
test   %rcx,%rcx
je     1174 <strdash+0x54>
cmpb   $0x2d,(%rax)
jne    1174 <strdash+0x54>
add    $0x1,%rax
mov    %rax,%rdi
mov    $0x2d,%esi
call   1030 <strchr@plt>
mov    %rax,0x2e74(%rip)
pop    %rbx
ret
xor    %eax,%eax
pop    %rbx
ret

LLVM IR (-O0):
@strdash.pos = internal global i8* null
define i8* @strdash(i8* %0) {
%2 = alloca i8*
store i8* %0, i8** %2
%3 = load i8*, i8** %2
%4 = call i8* @strchr(i8* %3, i8 signext 45)
store i8* %4, i8** @strdash.pos
%5 = load i8*, i8** @strdash.pos
%6 = icmp ne i8* %5, null
br i1 %6, label %7, label %23
7: ; preds = %1
%8 = load i8*, i8** @strdash.pos
%9 = getelementptr inbounds i8, i8* %8, i64 1
%10 = load i8, i8* %9
%11 = call i64 @isalpha(i8 signext %10)
%12 = icmp ne i64 %11, 0
br i1 %12, label %13, label %22
13: ; preds = %7
%14 = load i8*, i8** @strdash.pos
%15 = load i8, i8* %14
%16 = sext i8 %15 to i32
%17 = icmp eq i32 %16, 45
br i1 %17, label %18, label %22
18: ; preds = %13
%19 = load i8*, i8** @strdash.pos
%20 = getelementptr inbounds i8, i8* %19, i64 1
%21 = call i8* @strchr(i8* %20, i8 signext 45)
store i8* %21, i8** @strdash.pos
br label %22
22: ; preds = %18, %13, %7
br label %23
23: ; preds = %22, %1
%24 = load i8*, i8** @strdash.pos
%25 = icmp eq i8* %24, null
br i1 %25, label %26, label %48
26: ; preds = %23
%27 = load i8*, i8** %2
%28 = call i8* @strchr(i8* %27, i8 signext 95)
store i8* %28, i8** @strdash.pos
%29 = load i8*, i8** @strdash.pos
%30 = icmp ne i8* %29, null
br i1 %30, label %31, label %47
31: ; preds = %26
%32 = load i8*, i8** @strdash.pos
%33 = getelementptr inbounds i8, i8* %32, i64 1
%34 = load i8, i8* %33
%35 = call i64 @isalpha(i8 signext %34)
%36 = icmp ne i64 %35, 0
br i1 %36, label %37, label %46
37: ; preds = %31
%38 = load i8*, i8** @strdash.pos
%39 = load i8, i8* %38
%40 = sext i8 %39 to i32
%41 = icmp eq i32 %40, 45
br i1 %41, label %42, label %46
42: ; preds = %37
%43 = load i8*, i8** @strdash.pos
%44 = getelementptr inbounds i8, i8* %43, i64 1
%45 = call i8* @strchr(i8* %44, i8 signext 45)
store i8* %45, i8** @strdash.pos
br label %46
46: ; preds = %42, %37, %31
br label %47
47: ; preds = %46, %26
br label %48
48: ; preds = %47, %23
%49 = load i8*, i8** @strdash.pos
ret i8* %49
}

LLVM IR (-O2):
@strdash.pos = internal unnamed_addr global i8* null
define i8* @strdash(i8* %0) {
%2 = tail call i8* @strchr(i8* dereferenceable(1) %0, i8 signext 45)
store i8* %2, i8** @strdash.pos
%3 = icmp eq i8* %2, null
br i1 %3, label %19, label %4
4: ; preds = %1
%5 = getelementptr inbounds i8, i8* %2, i64 1
%6 = load i8, i8* %5
%7 = tail call i64 @isalpha(i8 signext %6)
%8 = icmp eq i64 %7, 0
%9 = load i8*, i8** @strdash.pos
br i1 %8, label %16, label %10
10: ; preds = %4
%11 = load i8, i8* %9
%12 = icmp eq i8 %11, 45
br i1 %12, label %13, label %34
13: ; preds = %10
%14 = getelementptr inbounds i8, i8* %9, i64 1
%15 = tail call i8* @strchr(i8* %14, i8 signext 45)
store i8* %15, i8** @strdash.pos
br label %16
16: ; preds = %4, %13
%17 = phi i8* [ %15, %13 ], [ %9, %4 ]
%18 = icmp eq i8* %17, null
br i1 %18, label %19, label %34
19: ; preds = %1, %16
%20 = tail call i8* @strchr(i8* dereferenceable(1) %0, i8 signext 95)
store i8* %20, i8** @strdash.pos
%21 = icmp eq i8* %20, null
br i1 %21, label %34, label %22
22: ; preds = %19
%23 = getelementptr inbounds i8, i8* %20, i64 1
%24 = load i8, i8* %23
%25 = tail call i64 @isalpha(i8 signext %24)
%26 = icmp eq i64 %25, 0
%27 = load i8*, i8** @strdash.pos
br i1 %26, label %34, label %28
28: ; preds = %22
%29 = load i8, i8* %27
%30 = icmp eq i8 %29, 45
br i1 %30, label %31, label %34
31: ; preds = %28
%32 = getelementptr inbounds i8, i8* %27, i64 1
%33 = tail call i8* @strchr(i8* %32, i8 signext 45)
store i8* %33, i8** @strdash.pos
br label %34
34: ; preds = %22, %10, %19, %31, %28, %16
%35 = phi i8* [ %9, %10 ], [ null, %19 ], [ %33, %31 ], [ %27, %28 ], [ %17, %16 ], [ %27, %22 ]
ret i8* %35
}