#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 */
scalar_t__ malloc(int);
char *strchr(char *, char);
int /*<<< orphan*/ strcpy(char *, char *);
char *splitCommand(char *src, char s) {
  int i = 0;
  long num = 0;
  char *re;
  if (src == NULL) {
    return NULL;
  }
  re = strchr(src, s);
  if (re == NULL) {
    return NULL;
  }
  num = re - src;
  re = (char *)malloc(sizeof(char) * (num + 2));
  strcpy(re, src + num + 1);
  src[num] = '\0';
  return re;
}


x86 assembly (clang, -O0):
<splitCommand>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %sil,%al
mov    %rdi,-0x10(%rbp)
mov    %al,-0x11(%rbp)
movl   $0x0,-0x18(%rbp)
movq   $0x0,-0x20(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    1169 <splitCommand+0x39>
movq   $0x0,-0x8(%rbp)
jmp    11e1 <splitCommand+0xb1>
mov    -0x10(%rbp),%rdi
movsbl -0x11(%rbp),%esi
call   1040 <strchr@plt>
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
jne    1192 <splitCommand+0x62>
movq   $0x0,-0x8(%rbp)
jmp    11e1 <splitCommand+0xb1>
mov    -0x28(%rbp),%rax
mov    -0x10(%rbp),%rcx
sub    %rcx,%rax
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rax
add    $0x2,%rax
shl    $0x0,%rax
mov    %eax,%edi
call   1050 <malloc@plt>
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rdi
mov    -0x10(%rbp),%rsi
add    -0x20(%rbp),%rsi
add    $0x1,%rsi
call   1030 <strcpy@plt>
mov    -0x10(%rbp),%rax
mov    -0x20(%rbp),%rcx
movb   $0x0,(%rax,%rcx,1)
mov    -0x28(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<splitCommand>:
push   %r14
push   %rbx
push   %rax
test   %rdi,%rdi
je     1172 <splitCommand+0x42>
mov    %rdi,%rbx
movsbl %sil,%esi
call   1040 <strchr@plt>
test   %rax,%rax
je     1172 <splitCommand+0x42>
mov    %rax,%r14
mov    %r14d,%edi
sub    %ebx,%edi
add    $0x2,%edi
call   1050 <malloc@plt>
mov    %rax,%rbx
mov    %r14,%rsi
add    $0x1,%rsi
mov    %rax,%rdi
call   1030 <strcpy@plt>
movb   $0x0,(%r14)
jmp    1174 <splitCommand+0x44>
xor    %ebx,%ebx
mov    %rbx,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
define i8* @splitCommand(i8* %0, i8 signext %1) {
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i8
%6 = alloca i32
%7 = alloca i64
%8 = alloca i8*
store i8* %0, i8** %4
store i8 %1, i8* %5
store i32 0, i32* %6
store i64 0, i64* %7
%9 = load i8*, i8** %4
%10 = icmp eq i8* %9, null
br i1 %10, label %11, label %12
11: ; preds = %2
store i8* null, i8** %3
br label %41
12: ; preds = %2
%13 = load i8*, i8** %4
%14 = load i8, i8* %5
%15 = call i8* @strchr(i8* %13, i8 signext %14)
store i8* %15, i8** %8
%16 = load i8*, i8** %8
%17 = icmp eq i8* %16, null
br i1 %17, label %18, label %19
18: ; preds = %12
store i8* null, i8** %3
br label %41
19: ; preds = %12
%20 = load i8*, i8** %8
%21 = load i8*, i8** %4
%22 = ptrtoint i8* %20 to i64
%23 = ptrtoint i8* %21 to i64
%24 = sub i64 %22, %23
store i64 %24, i64* %7
%25 = load i64, i64* %7
%26 = add nsw i64 %25, 2
%27 = mul i64 1, %26
%28 = trunc i64 %27 to i32
%29 = call i64 @malloc(i32 %28)
%30 = inttoptr i64 %29 to i8*
store i8* %30, i8** %8
%31 = load i8*, i8** %8
%32 = load i8*, i8** %4
%33 = load i64, i64* %7
%34 = getelementptr inbounds i8, i8* %32, i64 %33
%35 = getelementptr inbounds i8, i8* %34, i64 1
%36 = call i32 @strcpy(i8* %31, i8* %35)
%37 = load i8*, i8** %4
%38 = load i64, i64* %7
%39 = getelementptr inbounds i8, i8* %37, i64 %38
store i8 0, i8* %39
%40 = load i8*, i8** %8
store i8* %40, i8** %3
br label %41
41: ; preds = %19, %18, %11
%42 = load i8*, i8** %3
ret i8* %42
}

LLVM IR (-O2):
define i8* @splitCommand(i8* %0, i8 signext %1) {
%3 = icmp eq i8* %0, null
br i1 %3, label %18, label %4
4: ; preds = %2
%5 = tail call i8* @strchr(i8* %0, i8 signext %1)
%6 = icmp eq i8* %5, null
br i1 %6, label %18, label %7
7: ; preds = %4
%8 = ptrtoint i8* %5 to i64
%9 = ptrtoint i8* %0 to i64
%10 = sub i64 %8, %9
%11 = trunc i64 %10 to i32
%12 = add i32 %11, 2
%13 = tail call i64 @malloc(i32 %12)
%14 = inttoptr i64 %13 to i8*
%15 = getelementptr inbounds i8, i8* %0, i64 %10
%16 = getelementptr inbounds i8, i8* %15, i64 1
%17 = tail call i32 @strcpy(i8* %14, i8* %16)
store i8 0, i8* %15
br label %18
18: ; preds = %4, %2, %7
%19 = phi i8* [ %14, %7 ], [ null, %2 ], [ null, %4 ]
ret i8* %19
}