#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 *strchrnul(char const *, int);
const char *iter_comma_list(const char **next, int c) {
  while (**next == c)
    (*next)++;
  if (!**next)
    return NULL;
  const char *start = *next;
  *next = strchrnul(*next, c);
  return start;
}


x86 assembly (clang, -O0):
<iter_comma_list>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
mov    -0x10(%rbp),%rax
mov    (%rax),%rax
movsbl (%rax),%eax
cmp    -0x14(%rbp),%eax
jne    1145 <iter_comma_list+0x35>
mov    -0x10(%rbp),%rax
mov    (%rax),%rcx
add    $0x1,%rcx
mov    %rcx,(%rax)
jmp    111f <iter_comma_list+0xf>
mov    -0x10(%rbp),%rax
mov    (%rax),%rax
cmpb   $0x0,(%rax)
jne    1162 <iter_comma_list+0x52>
movq   $0x0,-0x8(%rbp)
jmp    118e <iter_comma_list+0x7e>
mov    -0x10(%rbp),%rax
mov    (%rax),%rax
mov    %rax,-0x20(%rbp)
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
mov    -0x14(%rbp),%esi
call   1030 <strchrnul@plt>
mov    %rax,%rcx
mov    -0x10(%rbp),%rax
mov    %rcx,(%rax)
mov    -0x20(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<iter_comma_list>:
push   %r14
push   %rbx
push   %rax
mov    %rdi,%r14
mov    (%rdi),%rbx
movsbl (%rbx),%eax
cmp    %esi,%eax
jne    1142 <iter_comma_list+0x32>
add    $0x1,%rbx
cs nopw 0x0(%rax,%rax,1)
nop
mov    %rbx,(%r14)
movsbl (%rbx),%eax
add    $0x1,%rbx
cmp    %esi,%eax
je     1130 <iter_comma_list+0x20>
add    $0xffffffffffffffff,%rbx
test   %al,%al
je     1153 <iter_comma_list+0x43>
mov    %rbx,%rdi
call   1030 <strchrnul@plt>
mov    %rax,(%r14)
jmp    1155 <iter_comma_list+0x45>
xor    %ebx,%ebx
mov    %rbx,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
define i8* @iter_comma_list(i8** %0, i32 %1) {
%3 = alloca i8*
%4 = alloca i8**
%5 = alloca i32
%6 = alloca i8*
store i8** %0, i8*** %4
store i32 %1, i32* %5
br label %7
7: ; preds = %14, %2
%8 = load i8**, i8*** %4
%9 = load i8*, i8** %8
%10 = load i8, i8* %9
%11 = sext i8 %10 to i32
%12 = load i32, i32* %5
%13 = icmp eq i32 %11, %12
br i1 %13, label %14, label %18
14: ; preds = %7
%15 = load i8**, i8*** %4
%16 = load i8*, i8** %15
%17 = getelementptr inbounds i8, i8* %16, i32 1
store i8* %17, i8** %15
br label %7
18: ; preds = %7
%19 = load i8**, i8*** %4
%20 = load i8*, i8** %19
%21 = load i8, i8* %20
%22 = icmp ne i8 %21, 0
br i1 %22, label %24, label %23
23: ; preds = %18
store i8* null, i8** %3
br label %33
24: ; preds = %18
%25 = load i8**, i8*** %4
%26 = load i8*, i8** %25
store i8* %26, i8** %6
%27 = load i8**, i8*** %4
%28 = load i8*, i8** %27
%29 = load i32, i32* %5
%30 = call i8* @strchrnul(i8* %28, i32 %29)
%31 = load i8**, i8*** %4
store i8* %30, i8** %31
%32 = load i8*, i8** %6
store i8* %32, i8** %3
br label %33
33: ; preds = %24, %23
%34 = load i8*, i8** %3
ret i8* %34
}

LLVM IR (-O2):
define i8* @iter_comma_list(i8** nocapture %0, i32 %1) {
%3 = load i8*, i8** %0
%4 = load i8, i8* %3
%5 = sext i8 %4 to i32
%6 = icmp eq i32 %5, %1
br i1 %6, label %7, label %13
7: ; preds = %2, %7
%8 = phi i8* [ %9, %7 ], [ %3, %2 ]
%9 = getelementptr inbounds i8, i8* %8, i64 1
store i8* %9, i8** %0
%10 = load i8, i8* %9
%11 = sext i8 %10 to i32
%12 = icmp eq i32 %11, %1
br i1 %12, label %7, label %13
13: ; preds = %7, %2
%14 = phi i8* [ %3, %2 ], [ %9, %7 ]
%15 = phi i8 [ %4, %2 ], [ %10, %7 ]
%16 = icmp eq i8 %15, 0
br i1 %16, label %19, label %17
17: ; preds = %13
%18 = tail call i8* @strchrnul(i8* %14, i32 %1)
store i8* %18, i8** %0
br label %19
19: ; preds = %13, %17
%20 = phi i8* [ %14, %17 ], [ null, %13 ]
ret i8* %20
}