#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);
const char *get_city_name_from_address(const char *address) {
  const char *p = NULL;
  if (!address || !(*address))
    return NULL;
  p = strchr(address, ',');
  if (!p)
    return address;
  while ((*p) && ((' ' == (*p)) || (',' == (*p)) || ('\t' == (*p))))
    p++;
  return p;
}


x86 assembly (clang, -O0):
<get_city_name_from_address>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
movq   $0x0,-0x18(%rbp)
cmpq   $0x0,-0x10(%rbp)
je     113c <get_city_name_from_address+0x2c>
mov    -0x10(%rbp),%rax
cmpb   $0x0,(%rax)
jne    1149 <get_city_name_from_address+0x39>
movq   $0x0,-0x8(%rbp)
jmp    1202 <get_city_name_from_address+0xf2>
mov    -0x10(%rbp),%rdi
mov    $0x2c,%esi
call   1030 <strchr@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    1173 <get_city_name_from_address+0x63>
mov    -0x10(%rbp),%rax
mov    %rax,-0x8(%rbp)
jmp    1202 <get_city_name_from_address+0xf2>
jmp    1178 <get_city_name_from_address+0x68>
mov    -0x18(%rbp),%rax
movsbl (%rax),%ecx
xor    %eax,%eax
cmp    $0x0,%ecx
mov    %al,-0x19(%rbp)
je     11d9 <get_city_name_from_address+0xc9>
mov    -0x18(%rbp),%rax
movsbl (%rax),%edx
mov    $0x1,%al
mov    $0x20,%ecx
cmp    %edx,%ecx
mov    %al,-0x1a(%rbp)
je     11d3 <get_city_name_from_address+0xc3>
mov    -0x18(%rbp),%rax
movsbl (%rax),%edx
mov    $0x1,%al
mov    $0x2c,%ecx
cmp    %edx,%ecx
mov    %al,-0x1a(%rbp)
je     11d3 <get_city_name_from_address+0xc3>
mov    -0x18(%rbp),%rax
movsbl (%rax),%ecx
mov    $0x9,%eax
cmp    %ecx,%eax
sete   %al
mov    %al,-0x1a(%rbp)
mov    -0x1a(%rbp),%al
mov    %al,-0x19(%rbp)
mov    -0x19(%rbp),%al
test   $0x1,%al
jne    11e9 <get_city_name_from_address+0xd9>
jmp    11fa <get_city_name_from_address+0xea>
mov    -0x18(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x18(%rbp)
jmp    1178 <get_city_name_from_address+0x68>
mov    -0x18(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_city_name_from_address>:
push   %rbx
test   %rdi,%rdi
je     1155 <get_city_name_from_address+0x45>
mov    %rdi,%rbx
cmpb   $0x0,(%rdi)
je     1155 <get_city_name_from_address+0x45>
mov    %rbx,%rdi
mov    $0x2c,%esi
call   1030 <strchr@plt>
test   %rax,%rax
je     1157 <get_city_name_from_address+0x47>
movabs $0x100100000200,%rcx
mov    %rax,%rbx
nopl   (%rax)
movzbl (%rbx),%eax
cmp    $0x2c,%rax
ja     1157 <get_city_name_from_address+0x47>
bt     %rax,%rcx
jae    1157 <get_city_name_from_address+0x47>
add    $0x1,%rbx
jmp    1140 <get_city_name_from_address+0x30>
xor    %ebx,%ebx
mov    %rbx,%rax
pop    %rbx
ret

LLVM IR (-O0):
define i8* @get_city_name_from_address(i8* %0) {
%2 = alloca i8*
%3 = alloca i8*
%4 = alloca i8*
store i8* %0, i8** %3
store i8* null, i8** %4
%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 = load i8, i8* %8
%10 = icmp ne i8 %9, 0
br i1 %10, label %12, label %11
11: ; preds = %7, %1
store i8* null, i8** %2
br label %49
12: ; preds = %7
%13 = load i8*, i8** %3
%14 = call i8* @strchr(i8* %13, i8 signext 44)
store i8* %14, i8** %4
%15 = load i8*, i8** %4
%16 = icmp ne i8* %15, null
br i1 %16, label %19, label %17
17: ; preds = %12
%18 = load i8*, i8** %3
store i8* %18, i8** %2
br label %49
19: ; preds = %12
br label %20
20: ; preds = %44, %19
%21 = load i8*, i8** %4
%22 = load i8, i8* %21
%23 = sext i8 %22 to i32
%24 = icmp ne i32 %23, 0
br i1 %24, label %25, label %42
25: ; preds = %20
%26 = load i8*, i8** %4
%27 = load i8, i8* %26
%28 = sext i8 %27 to i32
%29 = icmp eq i32 32, %28
br i1 %29, label %40, label %30
30: ; preds = %25
%31 = load i8*, i8** %4
%32 = load i8, i8* %31
%33 = sext i8 %32 to i32
%34 = icmp eq i32 44, %33
br i1 %34, label %40, label %35
35: ; preds = %30
%36 = load i8*, i8** %4
%37 = load i8, i8* %36
%38 = sext i8 %37 to i32
%39 = icmp eq i32 9, %38
br label %40
40: ; preds = %35, %30, %25
%41 = phi i1 [ true, %30 ], [ true, %25 ], [ %39, %35 ]
br label %42
42: ; preds = %40, %20
%43 = phi i1 [ false, %20 ], [ %41, %40 ]
br i1 %43, label %44, label %47
44: ; preds = %42
%45 = load i8*, i8** %4
%46 = getelementptr inbounds i8, i8* %45, i32 1
store i8* %46, i8** %4
br label %20
47: ; preds = %42
%48 = load i8*, i8** %4
store i8* %48, i8** %2
br label %49
49: ; preds = %47, %17, %11
%50 = load i8*, i8** %2
ret i8* %50
}

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