#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 *DupStr(char const *);
char *strchr(char const *, char);
char *HasIndex(const char *str, char *index_char) {
  char *comma;
  comma = strchr(str, ',');
  if (comma) {
    char *a;
    a = DupStr(str);
    comma = strchr(a, ',');
    *comma++ = 0;
    *index_char = *comma;
    return a;
  } else {
    return NULL;
  }
}


x86 assembly (clang, -O0):
<HasIndex>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
mov    $0x2c,%esi
call   1030 <strchr@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
je     1197 <HasIndex+0x77>
mov    -0x10(%rbp),%rdi
call   1040 <DupStr@plt>
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rdi
mov    $0x2c,%esi
call   1030 <strchr@plt>
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x20(%rbp)
movb   $0x0,(%rax)
mov    -0x20(%rbp),%rax
mov    (%rax),%cl
mov    -0x18(%rbp),%rax
mov    %cl,(%rax)
mov    -0x28(%rbp),%rax
mov    %rax,-0x8(%rbp)
jmp    119f <HasIndex+0x7f>
movq   $0x0,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<HasIndex>:
push   %r14
push   %rbx
push   %rax
mov    %rsi,%r14
mov    %rdi,%rbx
mov    $0x2c,%esi
call   1030 <strchr@plt>
test   %rax,%rax
je     115c <HasIndex+0x3c>
mov    %rbx,%rdi
call   1040 <DupStr@plt>
mov    %rax,%rbx
mov    %rax,%rdi
mov    $0x2c,%esi
call   1030 <strchr@plt>
movb   $0x0,(%rax)
mov    0x1(%rax),%al
mov    %al,(%r14)
jmp    115e <HasIndex+0x3e>
xor    %ebx,%ebx
mov    %rbx,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

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

LLVM IR (-O2):
define i8* @HasIndex(i8* %0, i8* nocapture writeonly %1) {
%3 = tail call i8* @strchr(i8* dereferenceable(1) %0, i8 signext 44)
%4 = icmp eq i8* %3, null
br i1 %4, label %10, label %5
5: ; preds = %2
%6 = tail call i8* @DupStr(i8* %0)
%7 = tail call i8* @strchr(i8* dereferenceable(1) %6, i8 signext 44)
%8 = getelementptr inbounds i8, i8* %7, i64 1
store i8 0, i8* %7
%9 = load i8, i8* %8
store i8 %9, i8* %1
br label %10
10: ; preds = %2, %5
%11 = phi i8* [ %6, %5 ], [ null, %2 ]
ret i8* %11
}