#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 *, char);
void break_args(char *s, char *arg1, char *arg2) {
  char *ns;
  ns = strchr(s, ',');
  if (ns) {
    *ns++ = '\0';
    while ((*arg2++ = *ns++) != '\0')
      ;
  } else {
    ns = s;
    while ((*arg2++ = *ns++) != '\0')
      ;
  };
  while ((*arg1++ = *s++) != '\0')
    ;
}


x86 assembly (clang, -O0):
<break_args>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    -0x8(%rbp),%rdi
mov    $0x2c,%esi
call   1030 <strchr@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
je     118b <break_args+0x7b>
mov    -0x20(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x20(%rbp)
movb   $0x0,(%rax)
mov    -0x20(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x20(%rbp)
mov    (%rax),%al
mov    -0x18(%rbp),%rcx
mov    %rcx,%rdx
add    $0x1,%rdx
mov    %rdx,-0x18(%rbp)
mov    %al,(%rcx)
movsbl %al,%eax
cmp    $0x0,%eax
je     1186 <break_args+0x76>
jmp    1153 <break_args+0x43>
jmp    11cb <break_args+0xbb>
mov    -0x8(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x20(%rbp)
mov    (%rax),%al
mov    -0x18(%rbp),%rcx
mov    %rcx,%rdx
add    $0x1,%rdx
mov    %rdx,-0x18(%rbp)
mov    %al,(%rcx)
movsbl %al,%eax
cmp    $0x0,%eax
je     11c6 <break_args+0xb6>
jmp    1193 <break_args+0x83>
jmp    11cb <break_args+0xbb>
jmp    11d0 <break_args+0xc0>
mov    -0x8(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x8(%rbp)
mov    (%rax),%al
mov    -0x10(%rbp),%rcx
mov    %rcx,%rdx
add    $0x1,%rdx
mov    %rdx,-0x10(%rbp)
mov    %al,(%rcx)
movsbl %al,%eax
cmp    $0x0,%eax
je     1203 <break_args+0xf3>
jmp    11d0 <break_args+0xc0>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<break_args>:
push   %r15
push   %r14
push   %rbx
mov    %rdx,%r15
mov    %rsi,%r14
mov    %rdi,%rbx
mov    $0x2c,%esi
call   1030 <strchr@plt>
test   %rax,%rax
je     1153 <break_args+0x43>
movb   $0x0,(%rax)
xor    %ecx,%ecx
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
movzbl 0x1(%rax,%rcx,1),%edx
mov    %dl,(%r15,%rcx,1)
add    $0x1,%rcx
test   %dl,%dl
jne    1140 <break_args+0x30>
jmp    1170 <break_args+0x60>
xor    %eax,%eax
cs nopw 0x0(%rax,%rax,1)
nop
movzbl (%rbx,%rax,1),%ecx
mov    %cl,(%r15,%rax,1)
add    $0x1,%rax
test   %cl,%cl
jne    1160 <break_args+0x50>
xor    %eax,%eax
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
movzbl (%rbx,%rax,1),%ecx
mov    %cl,(%r14,%rax,1)
add    $0x1,%rax
test   %cl,%cl
jne    1180 <break_args+0x70>
pop    %rbx
pop    %r14
pop    %r15
ret

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

LLVM IR (-O2):
define void @break_args(i8* %0, i8* nocapture writeonly %1, i8* nocapture writeonly %2) {
%4 = tail call i8* @strchr(i8* dereferenceable(1) %0, i8 signext 44)
%5 = icmp eq i8* %4, null
br i1 %5, label %14, label %6
6: ; preds = %3
store i8 0, i8* %4
br label %7
7: ; preds = %7, %6
%8 = phi i8* [ %2, %6 ], [ %12, %7 ]
%9 = phi i8* [ %4, %6 ], [ %10, %7 ]
%10 = getelementptr inbounds i8, i8* %9, i64 1
%11 = load i8, i8* %10
%12 = getelementptr inbounds i8, i8* %8, i64 1
store i8 %11, i8* %8
%13 = icmp eq i8 %11, 0
br i1 %13, label %21, label %7
14: ; preds = %3, %14
%15 = phi i8* [ %19, %14 ], [ %2, %3 ]
%16 = phi i8* [ %17, %14 ], [ %0, %3 ]
%17 = getelementptr inbounds i8, i8* %16, i64 1
%18 = load i8, i8* %16
%19 = getelementptr inbounds i8, i8* %15, i64 1
store i8 %18, i8* %15
%20 = icmp eq i8 %18, 0
br i1 %20, label %21, label %14
21: ; preds = %7, %14
br label %22
22: ; preds = %21, %22
%23 = phi i8* [ %25, %22 ], [ %0, %21 ]
%24 = phi i8* [ %27, %22 ], [ %1, %21 ]
%25 = getelementptr inbounds i8, i8* %23, i64 1
%26 = load i8, i8* %23
%27 = getelementptr inbounds i8, i8* %24, i64 1
store i8 %26, i8* %24
%28 = icmp eq i8 %26, 0
br i1 %28, label %29, label %22
29: ; preds = %22
ret void
}