#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*/ exit(int);
int /*<<< orphan*/ strlen(char *);
char *strtok(char *, char *);
unsigned long long strtoll(char *, char **, int /*<<< orphan*/);
unsigned argconfig_parse_comma_sep_array_long(char *string,
                                              unsigned long long *val,
                                              unsigned max_length) {
  unsigned ret = 0;
  char *tmp;
  char *p;
  if (!string || !strlen(string))
    return 0;
  tmp = strtok(string, ",");
  if (tmp == NULL)
    return 0;
  val[ret] = strtoll(tmp, &p, 0);
  if (*p != 0)
    exit(1);
  ret++;
  while (1) {
    tmp = strtok(NULL, ",");
    if (tmp == NULL)
      return ret;
    if (ret >= max_length)
      exit(1);
    val[ret] = strtoll(tmp, &p, 0);
    if (*p != 0)
      exit(1);
    ret++;
  }
}


x86 assembly (clang, -O0):
<argconfig_parse_comma_sep_array_long>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %edx,-0x1c(%rbp)
movl   $0x0,-0x20(%rbp)
cmpq   $0x0,-0x10(%rbp)
je     1177 <argconfig_parse_comma_sep_array_long+0x37>
mov    -0x10(%rbp),%rdi
call   1030 <strlen@plt>
cmp    $0x0,%eax
jne    1183 <argconfig_parse_comma_sep_array_long+0x43>
movl   $0x0,-0x4(%rbp)
jmp    1273 <argconfig_parse_comma_sep_array_long+0x133>
mov    -0x10(%rbp),%rdi
lea    0xe72(%rip),%rsi
call   1050 <strtok@plt>
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
jne    11ae <argconfig_parse_comma_sep_array_long+0x6e>
movl   $0x0,-0x4(%rbp)
jmp    1273 <argconfig_parse_comma_sep_array_long+0x133>
mov    -0x28(%rbp),%rdi
lea    -0x30(%rbp),%rsi
xor    %edx,%edx
call   1040 <strtoll@plt>
mov    %rax,%rdx
mov    -0x18(%rbp),%rax
mov    -0x20(%rbp),%ecx
mov    %rdx,(%rax,%rcx,8)
mov    -0x30(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
je     11e5 <argconfig_parse_comma_sep_array_long+0xa5>
mov    $0x1,%edi
call   1060 <exit@plt>
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
xor    %eax,%eax
mov    %eax,%edi
lea    0xe07(%rip),%rsi
call   1050 <strtok@plt>
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
jne    1218 <argconfig_parse_comma_sep_array_long+0xd8>
mov    -0x20(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    1273 <argconfig_parse_comma_sep_array_long+0x133>
mov    -0x20(%rbp),%eax
cmp    -0x1c(%rbp),%eax
jb     122e <argconfig_parse_comma_sep_array_long+0xee>
mov    $0x1,%edi
call   1060 <exit@plt>
mov    -0x28(%rbp),%rdi
lea    -0x30(%rbp),%rsi
xor    %edx,%edx
call   1040 <strtoll@plt>
mov    %rax,%rdx
mov    -0x18(%rbp),%rax
mov    -0x20(%rbp),%ecx
mov    %rdx,(%rax,%rcx,8)
mov    -0x30(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
je     1265 <argconfig_parse_comma_sep_array_long+0x125>
mov    $0x1,%edi
call   1060 <exit@plt>
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    11ee <argconfig_parse_comma_sep_array_long+0xae>
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<argconfig_parse_comma_sep_array_long>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x10,%rsp
xor    %ebx,%ebx
test   %rdi,%rdi
je     121a <argconfig_parse_comma_sep_array_long+0xda>
mov    %edx,%r15d
mov    %rsi,%r14
mov    %rdi,%rbp
call   1030 <strlen@plt>
test   %eax,%eax
je     121a <argconfig_parse_comma_sep_array_long+0xda>
lea    0xe8c(%rip),%rsi
mov    %rbp,%rdi
call   1050 <strtok@plt>
test   %rax,%rax
je     121a <argconfig_parse_comma_sep_array_long+0xda>
lea    0x8(%rsp),%rsi
mov    %rax,%rdi
xor    %edx,%edx
call   1040 <strtoll@plt>
mov    %rax,(%r14)
mov    0x8(%rsp),%rax
cmpb   $0x0,(%rax)
jne    1229 <argconfig_parse_comma_sep_array_long+0xe9>
lea    0xe54(%rip),%rsi
xor    %edi,%edi
call   1050 <strtok@plt>
test   %rax,%rax
je     1215 <argconfig_parse_comma_sep_array_long+0xd5>
cmp    $0x2,%r15d
mov    $0x1,%ebp
cmovae %r15d,%ebp
mov    $0x1,%ebx
lea    0x8(%rsp),%r15
lea    0xe2a(%rip),%r12
cs nopw 0x0(%rax,%rax,1)
cmp    %rbx,%rbp
je     1229 <argconfig_parse_comma_sep_array_long+0xe9>
mov    %rax,%rdi
mov    %r15,%rsi
xor    %edx,%edx
call   1040 <strtoll@plt>
mov    %rax,(%r14,%rbx,8)
mov    0x8(%rsp),%rax
cmpb   $0x0,(%rax)
jne    1229 <argconfig_parse_comma_sep_array_long+0xe9>
add    $0x1,%rbx
xor    %edi,%edi
mov    %r12,%rsi
call   1050 <strtok@plt>
test   %rax,%rax
jne    11e0 <argconfig_parse_comma_sep_array_long+0xa0>
jmp    121a <argconfig_parse_comma_sep_array_long+0xda>
mov    $0x1,%ebx
mov    %ebx,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret
mov    $0x1,%edi
call   1060 <exit@plt>

LLVM IR (-O0):
@.str = [2 x i8] c",\00"
define i32 @argconfig_parse_comma_sep_array_long(i8* %0, i64* %1, i32 %2) {
%4 = alloca i32
%5 = alloca i8*
%6 = alloca i64*
%7 = alloca i32
%8 = alloca i32
%9 = alloca i8*
%10 = alloca i8*
store i8* %0, i8** %5
store i64* %1, i64** %6
store i32 %2, i32* %7
store i32 0, i32* %8
%11 = load i8*, i8** %5
%12 = icmp ne i8* %11, null
br i1 %12, label %13, label %17
13: ; preds = %3
%14 = load i8*, i8** %5
%15 = call i32 @strlen(i8* %14)
%16 = icmp ne i32 %15, 0
br i1 %16, label %18, label %17
17: ; preds = %13, %3
store i32 0, i32* %4
br label %68
18: ; preds = %13
%19 = load i8*, i8** %5
%20 = call i8* @strtok(i8* %19, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i8* %20, i8** %9
%21 = load i8*, i8** %9
%22 = icmp eq i8* %21, null
br i1 %22, label %23, label %24
23: ; preds = %18
store i32 0, i32* %4
br label %68
24: ; preds = %18
%25 = load i8*, i8** %9
%26 = call i64 @strtoll(i8* %25, i8** %10, i32 0)
%27 = load i64*, i64** %6
%28 = load i32, i32* %8
%29 = zext i32 %28 to i64
%30 = getelementptr inbounds i64, i64* %27, i64 %29
store i64 %26, i64* %30
%31 = load i8*, i8** %10
%32 = load i8, i8* %31
%33 = sext i8 %32 to i32
%34 = icmp ne i32 %33, 0
br i1 %34, label %35, label %37
35: ; preds = %24
%36 = call i32 @exit(i32 1)
unreachable
37: ; preds = %24
%38 = load i32, i32* %8
%39 = add i32 %38, 1
store i32 %39, i32* %8
br label %40
40: ; preds = %37, %65
%41 = call i8* @strtok(i8* null, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i8* %41, i8** %9
%42 = load i8*, i8** %9
%43 = icmp eq i8* %42, null
br i1 %43, label %44, label %46
44: ; preds = %40
%45 = load i32, i32* %8
store i32 %45, i32* %4
br label %68
46: ; preds = %40
%47 = load i32, i32* %8
%48 = load i32, i32* %7
%49 = icmp uge i32 %47, %48
br i1 %49, label %50, label %52
50: ; preds = %46
%51 = call i32 @exit(i32 1)
unreachable
52: ; preds = %46
%53 = load i8*, i8** %9
%54 = call i64 @strtoll(i8* %53, i8** %10, i32 0)
%55 = load i64*, i64** %6
%56 = load i32, i32* %8
%57 = zext i32 %56 to i64
%58 = getelementptr inbounds i64, i64* %55, i64 %57
store i64 %54, i64* %58
%59 = load i8*, i8** %10
%60 = load i8, i8* %59
%61 = sext i8 %60 to i32
%62 = icmp ne i32 %61, 0
br i1 %62, label %63, label %65
63: ; preds = %52
%64 = call i32 @exit(i32 1)
unreachable
65: ; preds = %52
%66 = load i32, i32* %8
%67 = add i32 %66, 1
store i32 %67, i32* %8
br label %40
68: ; preds = %44, %23, %17
%69 = load i32, i32* %4
ret i32 %69
}

LLVM IR (-O2):
@.str = [2 x i8] c",\00"
define i32 @argconfig_parse_comma_sep_array_long(i8* %0, i64* nocapture writeonly %1, i32 %2) {
%4 = alloca i8*
%5 = bitcast i8** %4 to i8*
%6 = icmp eq i8* %0, null
br i1 %6, label %46, label %7
7: ; preds = %3
%8 = tail call i32 @strlen(i8* %0)
%9 = icmp eq i32 %8, 0
br i1 %9, label %46, label %10
10: ; preds = %7
%11 = tail call i8* @strtok(i8* %0, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%12 = icmp eq i8* %11, null
br i1 %12, label %46, label %13
13: ; preds = %10
%14 = call i64 @strtoll(i8* %11, i8** %4, i32 0)
store i64 %14, i64* %1
%15 = load i8*, i8** %4
%16 = load i8, i8* %15
%17 = icmp eq i8 %16, 0
br i1 %17, label %18, label %24
18: ; preds = %13
%19 = tail call i8* @strtok(i8* null, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%20 = icmp eq i8* %19, null
br i1 %20, label %46, label %21
21: ; preds = %18
%22 = call i32 @llvm.umax.i32(i32 %2, i32 1)
%23 = zext i32 %22 to i64
br label %26
24: ; preds = %13
%25 = tail call i32 @exit(i32 1)
unreachable
26: ; preds = %21, %40
%27 = phi i64 [ 1, %21 ], [ %41, %40 ]
%28 = phi i8* [ %19, %21 ], [ %42, %40 ]
%29 = icmp eq i64 %27, %23
br i1 %29, label %30, label %32
30: ; preds = %26
%31 = tail call i32 @exit(i32 1)
unreachable
32: ; preds = %26
%33 = call i64 @strtoll(i8* %28, i8** %4, i32 0)
%34 = getelementptr inbounds i64, i64* %1, i64 %27
store i64 %33, i64* %34
%35 = load i8*, i8** %4
%36 = load i8, i8* %35
%37 = icmp eq i8 %36, 0
br i1 %37, label %40, label %38
38: ; preds = %32
%39 = tail call i32 @exit(i32 1)
unreachable
40: ; preds = %32
%41 = add nuw nsw i64 %27, 1
%42 = tail call i8* @strtok(i8* null, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%43 = icmp eq i8* %42, null
br i1 %43, label %44, label %26
44: ; preds = %40
%45 = trunc i64 %41 to i32
br label %46
46: ; preds = %44, %18, %10, %3, %7
%47 = phi i32 [ 0, %7 ], [ 0, %3 ], [ 0, %10 ], [ 1, %18 ], [ %45, %44 ]
ret i32 %47
}