#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 *, char);
scalar_t__ strcmp(char *, char *);
char *get_rpart(char *str) {
  if (!str || strcmp(str, "None") == 0)
    return str;
  char *tmp = strchr(str, ':');
  if (!tmp)
    return str;
  return (++tmp);
}


x86 assembly (clang, -O0):
<get_rpart>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
je     1151 <get_rpart+0x31>
mov    -0x10(%rbp),%rdi
lea    0xebe(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%rax
jne    115e <get_rpart+0x3e>
mov    -0x10(%rbp),%rax
mov    %rax,-0x8(%rbp)
jmp    1198 <get_rpart+0x78>
mov    -0x10(%rbp),%rdi
mov    $0x3a,%esi
call   1030 <strchr@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    1188 <get_rpart+0x68>
mov    -0x10(%rbp),%rax
mov    %rax,-0x8(%rbp)
jmp    1198 <get_rpart+0x78>
mov    -0x18(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x18(%rbp)
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_rpart>:
push   %rbx
test   %rdi,%rdi
je     1154 <get_rpart+0x34>
mov    %rdi,%rbx
lea    0xed0(%rip),%rsi
call   1040 <strcmp@plt>
test   %rax,%rax
je     1156 <get_rpart+0x36>
mov    %rbx,%rdi
mov    $0x3a,%esi
call   1030 <strchr@plt>
lea    0x1(%rax),%rcx
test   %rax,%rax
cmovne %rcx,%rbx
jmp    1156 <get_rpart+0x36>
xor    %ebx,%ebx
mov    %rbx,%rax
pop    %rbx
ret

LLVM IR (-O0):
@.str = [5 x i8] c"None\00"
define i8* @get_rpart(i8* %0) {
%2 = alloca i8*
%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 %7, label %11
7: ; preds = %1
%8 = load i8*, i8** %3
%9 = call i64 @strcmp(i8* %8, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
%10 = icmp eq i64 %9, 0
br i1 %10, label %11, label %13
11: ; preds = %7, %1
%12 = load i8*, i8** %3
store i8* %12, i8** %2
br label %23
13: ; preds = %7
%14 = load i8*, i8** %3
%15 = call i8* @strchr(i8* %14, i8 signext 58)
store i8* %15, i8** %4
%16 = load i8*, i8** %4
%17 = icmp ne i8* %16, null
br i1 %17, label %20, label %18
18: ; preds = %13
%19 = load i8*, i8** %3
store i8* %19, i8** %2
br label %23
20: ; preds = %13
%21 = load i8*, i8** %4
%22 = getelementptr inbounds i8, i8* %21, i32 1
store i8* %22, i8** %4
store i8* %22, i8** %2
br label %23
23: ; preds = %20, %18, %11
%24 = load i8*, i8** %2
ret i8* %24
}

LLVM IR (-O2):
@.str = [5 x i8] c"None\00"
define i8* @get_rpart(i8* %0) {
%2 = icmp eq i8* %0, null
br i1 %2, label %11, label %3
3: ; preds = %1
%4 = tail call i64 @strcmp(i8* %0, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
%5 = icmp eq i64 %4, 0
br i1 %5, label %11, label %6
6: ; preds = %3
%7 = tail call i8* @strchr(i8* %0, i8 signext 58)
%8 = icmp eq i8* %7, null
%9 = getelementptr inbounds i8, i8* %7, i64 1
%10 = select i1 %8, i8* %0, i8* %9
br label %11
11: ; preds = %1, %3, %6
%12 = phi i8* [ %10, %6 ], [ %0, %3 ], [ null, %1 ]
ret i8* %12
}