#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 *QuotPos(char *, char);
int /*<<< orphan*/ free(char *);
int /*<<< orphan*/ strcpy(char *, char *);
char *strdup(char *);
void SplitArg(char *Orig, char *LDest, char *RDest) {
  char *p, *str;
  str = strdup(Orig);
  p = QuotPos(str, ',');
  if (p == NULL) {
    *RDest = '\0';
    strcpy(LDest, str);
  } else {
    *p = '\0';
    strcpy(LDest, str);
    strcpy(RDest, p + 1);
  }
  free(str);
}


x86 assembly (clang, -O0):
<SplitArg>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    -0x8(%rbp),%rdi
call   1060 <strdup@plt>
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rdi
mov    $0x2c,%esi
call   1050 <QuotPos@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
jne    1197 <SplitArg+0x57>
mov    -0x18(%rbp),%rax
movb   $0x0,(%rax)
mov    -0x10(%rbp),%rdi
mov    -0x28(%rbp),%rsi
call   1040 <strcpy@plt>
jmp    11bc <SplitArg+0x7c>
mov    -0x20(%rbp),%rax
movb   $0x0,(%rax)
mov    -0x10(%rbp),%rdi
mov    -0x28(%rbp),%rsi
call   1040 <strcpy@plt>
mov    -0x18(%rbp),%rdi
mov    -0x20(%rbp),%rsi
add    $0x1,%rsi
call   1040 <strcpy@plt>
mov    -0x28(%rbp),%rdi
call   1030 <free@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<SplitArg>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    %rdx,%r14
mov    %rsi,%r15
call   1060 <strdup@plt>
mov    %rax,%r12
mov    %rax,%rdi
mov    $0x2c,%esi
call   1050 <QuotPos@plt>
test   %rax,%rax
je     1185 <SplitArg+0x45>
mov    %rax,%rbx
movb   $0x0,(%rax)
mov    %r15,%rdi
mov    %r12,%rsi
call   1040 <strcpy@plt>
add    $0x1,%rbx
mov    %r14,%rdi
mov    %rbx,%rsi
jmp    118f <SplitArg+0x4f>
movb   $0x0,(%r14)
mov    %r15,%rdi
mov    %r12,%rsi
call   1040 <strcpy@plt>
mov    %r12,%rdi
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
jmp    1030 <free@plt>

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

LLVM IR (-O2):
define void @SplitArg(i8* nocapture %0, i8* %1, i8* %2) {
%4 = tail call i8* @strdup(i8* %0)
%5 = tail call i8* @QuotPos(i8* %4, i8 signext 44)
%6 = icmp eq i8* %5, null
br i1 %6, label %7, label %9
7: ; preds = %3
store i8 0, i8* %2
%8 = tail call i32 @strcpy(i8* %1, i8* %4)
br label %13
9: ; preds = %3
store i8 0, i8* %5
%10 = tail call i32 @strcpy(i8* %1, i8* %4)
%11 = getelementptr inbounds i8, i8* %5, i64 1
%12 = tail call i32 @strcpy(i8* %2, i8* %11)
br label %13
13: ; preds = %9, %7
%14 = tail call i32 @free(i8* %4)
ret void
}