#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 const *, char);
int strlen(char const *);
int get_display_name_length(const char *name) {
  const char *m;
  if (!name)
    return 0;
  m = strchr(name, ':');
  if (m) {
    m = strchr(m, '.');
    if (m)
      return m - name;
  }
  return strlen(name);
}


x86 assembly (clang, -O0):
<get_display_name_length>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    1143 <get_display_name_length+0x23>
movl   $0x0,-0x4(%rbp)
jmp    11a1 <get_display_name_length+0x81>
mov    -0x10(%rbp),%rdi
mov    $0x3a,%esi
call   1040 <strchr@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
je     1195 <get_display_name_length+0x75>
mov    -0x18(%rbp),%rdi
mov    $0x2e,%esi
call   1040 <strchr@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
je     1190 <get_display_name_length+0x70>
mov    -0x18(%rbp),%rax
mov    -0x10(%rbp),%rcx
sub    %rcx,%rax
mov    %eax,-0x4(%rbp)
jmp    11a1 <get_display_name_length+0x81>
jmp    1195 <get_display_name_length+0x75>
mov    -0x10(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_display_name_length>:
push   %rbx
test   %rdi,%rdi
je     114e <get_display_name_length+0x2e>
mov    %rdi,%rbx
mov    $0x3a,%esi
call   1040 <strchr@plt>
test   %rax,%rax
je     1152 <get_display_name_length+0x32>
mov    %rax,%rdi
mov    $0x2e,%esi
call   1040 <strchr@plt>
test   %rax,%rax
je     1152 <get_display_name_length+0x32>
sub    %ebx,%eax
pop    %rbx
ret
xor    %eax,%eax
pop    %rbx
ret
mov    %rbx,%rdi
pop    %rbx
jmp    1030 <strlen@plt>

LLVM IR (-O0):
define i32 @get_display_name_length(i8* %0) {
%2 = alloca i32
%3 = alloca i8*
%4 = alloca i8*
store i8* %0, i8** %3
%5 = load i8*, i8** %3
%6 = icmp ne i8* %5, null
br i1 %6, label %8, label %7
7: ; preds = %1
store i32 0, i32* %2
br label %29
8: ; preds = %1
%9 = load i8*, i8** %3
%10 = call i8* @strchr(i8* %9, i8 signext 58)
store i8* %10, i8** %4
%11 = load i8*, i8** %4
%12 = icmp ne i8* %11, null
br i1 %12, label %13, label %26
13: ; preds = %8
%14 = load i8*, i8** %4
%15 = call i8* @strchr(i8* %14, i8 signext 46)
store i8* %15, i8** %4
%16 = load i8*, i8** %4
%17 = icmp ne i8* %16, null
br i1 %17, label %18, label %25
18: ; preds = %13
%19 = load i8*, i8** %4
%20 = load i8*, i8** %3
%21 = ptrtoint i8* %19 to i64
%22 = ptrtoint i8* %20 to i64
%23 = sub i64 %21, %22
%24 = trunc i64 %23 to i32
store i32 %24, i32* %2
br label %29
25: ; preds = %13
br label %26
26: ; preds = %25, %8
%27 = load i8*, i8** %3
%28 = call i32 @strlen(i8* %27)
store i32 %28, i32* %2
br label %29
29: ; preds = %26, %18, %7
%30 = load i32, i32* %2
ret i32 %30
}

LLVM IR (-O2):
define i32 @get_display_name_length(i8* %0) {
%2 = icmp eq i8* %0, null
br i1 %2, label %16, label %3
3: ; preds = %1
%4 = tail call i8* @strchr(i8* %0, i8 signext 58)
%5 = icmp eq i8* %4, null
br i1 %5, label %14, label %6
6: ; preds = %3
%7 = tail call i8* @strchr(i8* %4, i8 signext 46)
%8 = icmp eq i8* %7, null
br i1 %8, label %14, label %9
9: ; preds = %6
%10 = ptrtoint i8* %7 to i64
%11 = ptrtoint i8* %0 to i64
%12 = sub i64 %10, %11
%13 = trunc i64 %12 to i32
br label %16
14: ; preds = %6, %3
%15 = tail call i32 @strlen(i8* %0)
br label %16
16: ; preds = %1, %14, %9
%17 = phi i32 [ %13, %9 ], [ %15, %14 ], [ 0, %1 ]
ret i32 %17
}