#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);
char *arg_param(char *arg) {
  if (!arg)
    return NULL;
  char *p = strchr(arg, ':');
  char *c = strchr(arg, ',');
  if (p && (!c || p < c))
    return ++p;
  else if (c)
    return c;
  else
    return p;
}


x86 assembly (clang, -O0):
<arg_param>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    1134 <arg_param+0x24>
movq   $0x0,-0x8(%rbp)
jmp    11b1 <arg_param+0xa1>
mov    -0x10(%rbp),%rdi
mov    $0x3a,%esi
call   1030 <strchr@plt>
mov    %rax,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
mov    $0x2c,%esi
call   1030 <strchr@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x18(%rbp)
je     1191 <arg_param+0x81>
cmpq   $0x0,-0x20(%rbp)
je     117c <arg_param+0x6c>
mov    -0x18(%rbp),%rax
cmp    -0x20(%rbp),%rax
jae    1191 <arg_param+0x81>
mov    -0x18(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x18(%rbp)
mov    %rax,-0x8(%rbp)
jmp    11b1 <arg_param+0xa1>
cmpq   $0x0,-0x20(%rbp)
je     11a9 <arg_param+0x99>
mov    -0x20(%rbp),%rax
mov    %rax,-0x8(%rbp)
jmp    11b1 <arg_param+0xa1>
mov    -0x18(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<arg_param>:
push   %r14
push   %rbx
push   %rax
test   %rdi,%rdi
je     114e <arg_param+0x3e>
mov    %rdi,%rbx
mov    $0x3a,%esi
call   1030 <strchr@plt>
mov    %rax,%r14
mov    %rbx,%rdi
mov    $0x2c,%esi
call   1030 <strchr@plt>
test   %r14,%r14
je     1145 <arg_param+0x35>
test   %rax,%rax
je     1153 <arg_param+0x43>
cmp    %rax,%r14
jb     1153 <arg_param+0x43>
test   %rax,%rax
cmovne %rax,%r14
jmp    1157 <arg_param+0x47>
xor    %r14d,%r14d
jmp    1157 <arg_param+0x47>
add    $0x1,%r14
mov    %r14,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
define i8* @arg_param(i8* %0) {
%2 = alloca i8*
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i8*
store i8* %0, i8** %3
%6 = load i8*, i8** %3
%7 = icmp ne i8* %6, null
br i1 %7, label %9, label %8
8: ; preds = %1
store i8* null, i8** %2
br label %33
9: ; preds = %1
%10 = load i8*, i8** %3
%11 = call i8* @strchr(i8* %10, i8 signext 58)
store i8* %11, i8** %4
%12 = load i8*, i8** %3
%13 = call i8* @strchr(i8* %12, i8 signext 44)
store i8* %13, i8** %5
%14 = load i8*, i8** %4
%15 = icmp ne i8* %14, null
br i1 %15, label %16, label %26
16: ; preds = %9
%17 = load i8*, i8** %5
%18 = icmp ne i8* %17, null
br i1 %18, label %19, label %23
19: ; preds = %16
%20 = load i8*, i8** %4
%21 = load i8*, i8** %5
%22 = icmp ult i8* %20, %21
br i1 %22, label %23, label %26
23: ; preds = %19, %16
%24 = load i8*, i8** %4
%25 = getelementptr inbounds i8, i8* %24, i32 1
store i8* %25, i8** %4
store i8* %25, i8** %2
br label %33
26: ; preds = %19, %9
%27 = load i8*, i8** %5
%28 = icmp ne i8* %27, null
br i1 %28, label %29, label %31
29: ; preds = %26
%30 = load i8*, i8** %5
store i8* %30, i8** %2
br label %33
31: ; preds = %26
%32 = load i8*, i8** %4
store i8* %32, i8** %2
br label %33
33: ; preds = %31, %29, %23, %8
%34 = load i8*, i8** %2
ret i8* %34
}

LLVM IR (-O2):
define i8* @arg_param(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 = tail call i8* @strchr(i8* %0, i8 signext 44)
%6 = icmp eq i8* %4, null
br i1 %6, label %13, label %7
7: ; preds = %3
%8 = icmp eq i8* %5, null
%9 = icmp ult i8* %4, %5
%10 = select i1 %8, i1 true, i1 %9
br i1 %10, label %11, label %13
11: ; preds = %7
%12 = getelementptr inbounds i8, i8* %4, i64 1
br label %16
13: ; preds = %7, %3
%14 = icmp eq i8* %5, null
%15 = select i1 %14, i8* %4, i8* %5
br label %16
16: ; preds = %11, %13, %1
%17 = phi i8* [ null, %1 ], [ %12, %11 ], [ %15, %13 ]
ret i8* %17
}