#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 */
int /*<<< orphan*/ add_cpp_arg(char *);
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ free(char *);
int /*<<< orphan*/ perror(char *);
char *strchr(char *, char);
char *strdup(char const *);
void add_cpp_Wp(const char *arg) {
  char *tmp = strdup(arg);
  char *curr, *end;
  if (!tmp) {
    perror("strdup");
    exit(1);
  }
  curr = tmp;
  do {
    end = strchr(curr, ',');
    if (end)
      *end++ = 0;
    add_cpp_arg(curr);
    curr = end;
  } while (end);
  free(tmp);
}


x86 assembly (clang, -O0):
<add_cpp_Wp>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
call   1080 <strdup@plt>
mov    %rax,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    119a <add_cpp_Wp+0x3a>
lea    0xe75(%rip),%rdi
call   1050 <perror@plt>
mov    $0x1,%edi
call   1070 <exit@plt>
mov    -0x10(%rbp),%rax
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
mov    $0x2c,%esi
call   1040 <strchr@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
je     11d1 <add_cpp_Wp+0x71>
mov    -0x20(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x20(%rbp)
movb   $0x0,(%rax)
mov    -0x18(%rbp),%rdi
call   1060 <add_cpp_arg@plt>
mov    -0x20(%rbp),%rax
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x20(%rbp)
jne    11a2 <add_cpp_Wp+0x42>
mov    -0x10(%rbp),%rdi
call   1030 <free@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<add_cpp_Wp>:
push   %r14
push   %rbx
push   %rax
call   1080 <strdup@plt>
test   %rax,%rax
je     11cb <add_cpp_Wp+0x6b>
mov    %rax,%r14
mov    %rax,%rdi
mov    $0x2c,%esi
call   1040 <strchr@plt>
mov    %r14,%rbx
test   %rax,%rax
je     11b4 <add_cpp_Wp+0x54>
mov    %r14,%rdi
nopl   0x0(%rax)
movb   $0x0,(%rax)
mov    %rax,%rbx
add    $0x1,%rbx
call   1060 <add_cpp_arg@plt>
mov    %rbx,%rdi
mov    $0x2c,%esi
call   1040 <strchr@plt>
mov    %rbx,%rdi
test   %rax,%rax
jne    1190 <add_cpp_Wp+0x30>
mov    %rbx,%rdi
call   1060 <add_cpp_arg@plt>
mov    %r14,%rdi
add    $0x8,%rsp
pop    %rbx
pop    %r14
jmp    1030 <free@plt>
lea    0xe2e(%rip),%rdi
call   1050 <perror@plt>
mov    $0x1,%edi
call   1070 <exit@plt>

LLVM IR (-O0):
@.str = [7 x i8] c"strdup\00"
define void @add_cpp_Wp(i8* %0) {
%2 = alloca i8*
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i8*
store i8* %0, i8** %2
%6 = load i8*, i8** %2
%7 = call i8* @strdup(i8* %6)
store i8* %7, i8** %3
%8 = load i8*, i8** %3
%9 = icmp ne i8* %8, null
br i1 %9, label %13, label %10
10: ; preds = %1
%11 = call i32 @perror(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0))
%12 = call i32 @exit(i32 1)
unreachable
13: ; preds = %1
%14 = load i8*, i8** %3
store i8* %14, i8** %4
br label %15
15: ; preds = %27, %13
%16 = load i8*, i8** %4
%17 = call i8* @strchr(i8* %16, i8 signext 44)
store i8* %17, i8** %5
%18 = load i8*, i8** %5
%19 = icmp ne i8* %18, null
br i1 %19, label %20, label %23
20: ; preds = %15
%21 = load i8*, i8** %5
%22 = getelementptr inbounds i8, i8* %21, i32 1
store i8* %22, i8** %5
store i8 0, i8* %21
br label %23
23: ; preds = %20, %15
%24 = load i8*, i8** %4
%25 = call i32 @add_cpp_arg(i8* %24)
%26 = load i8*, i8** %5
store i8* %26, i8** %4
br label %27
27: ; preds = %23
%28 = load i8*, i8** %5
%29 = icmp ne i8* %28, null
br i1 %29, label %15, label %30
30: ; preds = %27
%31 = load i8*, i8** %3
%32 = call i32 @free(i8* %31)
ret void
}

LLVM IR (-O2):
@.str = [7 x i8] c"strdup\00"
define void @add_cpp_Wp(i8* nocapture %0) {
%2 = tail call i8* @strdup(i8* %0)
%3 = icmp eq i8* %2, null
br i1 %3, label %7, label %4
4: ; preds = %1
%5 = tail call i8* @strchr(i8* dereferenceable(1) %2, i8 signext 44)
%6 = icmp eq i8* %5, null
br i1 %6, label %17, label %10
7: ; preds = %1
%8 = tail call i32 @perror(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0))
%9 = tail call i32 @exit(i32 1)
unreachable
10: ; preds = %4, %10
%11 = phi i8* [ %15, %10 ], [ %5, %4 ]
%12 = phi i8* [ %13, %10 ], [ %2, %4 ]
%13 = getelementptr inbounds i8, i8* %11, i64 1
store i8 0, i8* %11
%14 = tail call i32 @add_cpp_arg(i8* %12)
%15 = tail call i8* @strchr(i8* dereferenceable(1) %13, i8 signext 44)
%16 = icmp eq i8* %15, null
br i1 %16, label %17, label %10
17: ; preds = %10, %4
%18 = phi i8* [ %2, %4 ], [ %13, %10 ]
%19 = tail call i32 @add_cpp_arg(i8* %18)
%20 = tail call i32 @free(i8* %2)
ret void
}