#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__ csc_isdelim(char *, char);
long strtol(char *, char **, int /*<<< orphan*/);
long csc_strbival_long(char *s, char *delim, long *opt) {
  char *next, defdlm[] = " ";
  long val;
  val = strtol(s, &next, 0);
  if (delim == NULL) {
    delim = defdlm;
  }
  while (*next && csc_isdelim(delim, *next))
    next++;
  if (opt) {
    *opt = strtol(next, NULL, 0);
  }
  return val;
}


x86 assembly (clang, -O0):
<csc_strbival_long>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    0xec5(%rip),%ax
mov    %ax,-0x22(%rbp)
mov    -0x8(%rbp),%rdi
lea    -0x20(%rbp),%rsi
xor    %edx,%edx
call   1030 <strtol@plt>
mov    %rax,-0x30(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    1165 <csc_strbival_long+0x45>
lea    -0x22(%rbp),%rax
mov    %rax,-0x10(%rbp)
jmp    116a <csc_strbival_long+0x4a>
mov    -0x20(%rbp),%rax
movsbl (%rax),%ecx
xor    %eax,%eax
cmp    $0x0,%ecx
mov    %al,-0x31(%rbp)
je     1199 <csc_strbival_long+0x79>
mov    -0x10(%rbp),%rdi
mov    -0x20(%rbp),%rax
movsbl (%rax),%esi
call   1040 <csc_isdelim@plt>
cmp    $0x0,%rax
setne  %al
mov    %al,-0x31(%rbp)
mov    -0x31(%rbp),%al
test   $0x1,%al
jne    11a9 <csc_strbival_long+0x89>
jmp    11ba <csc_strbival_long+0x9a>
mov    -0x20(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x20(%rbp)
jmp    116a <csc_strbival_long+0x4a>
cmpq   $0x0,-0x18(%rbp)
je     11de <csc_strbival_long+0xbe>
mov    -0x20(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%esi
xor    %edx,%edx
call   1030 <strtol@plt>
mov    %rax,%rcx
mov    -0x18(%rbp),%rax
mov    %rcx,(%rax)
mov    -0x30(%rbp),%rax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<csc_strbival_long>:
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %rdx,%r15
mov    %rsi,%rbx
movw   $0x20,0xe(%rsp)
lea    0x10(%rsp),%rsi
xor    %edx,%edx
call   1030 <strtol@plt>
test   %rbx,%rbx
lea    0xe(%rsp),%r12
cmovne %rbx,%r12
mov    %rax,%r14
mov    0x10(%rsp),%rbx
mov    (%rbx),%al
test   %al,%al
je     117c <csc_strbival_long+0x5c>
xchg   %ax,%ax
movsbl %al,%esi
mov    %r12,%rdi
call   1040 <csc_isdelim@plt>
test   %rax,%rax
je     117c <csc_strbival_long+0x5c>
movzbl 0x1(%rbx),%eax
add    $0x1,%rbx
test   %al,%al
jne    1160 <csc_strbival_long+0x40>
mov    %rbx,0x10(%rsp)
test   %r15,%r15
je     1195 <csc_strbival_long+0x75>
mov    %rbx,%rdi
xor    %esi,%esi
xor    %edx,%edx
call   1030 <strtol@plt>
mov    %rax,(%r15)
mov    %r14,%rax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@__const.csc_strbival_long.defdlm = [2 x i8] c" \00"
define i64 @csc_strbival_long(i8* %0, i8* %1, i64* %2) {
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i64*
%7 = alloca i8*
%8 = alloca [2 x i8]
%9 = alloca i64
store i8* %0, i8** %4
store i8* %1, i8** %5
store i64* %2, i64** %6
%10 = bitcast [2 x i8]* %8 to i8*
%11 = load i8*, i8** %4
%12 = call i64 @strtol(i8* %11, i8** %7, i32 0)
store i64 %12, i64* %9
%13 = load i8*, i8** %5
%14 = icmp eq i8* %13, null
br i1 %14, label %15, label %17
15: ; preds = %3
%16 = getelementptr inbounds [2 x i8], [2 x i8]* %8, i64 0, i64 0
store i8* %16, i8** %5
br label %17
17: ; preds = %15, %3
br label %18
18: ; preds = %31, %17
%19 = load i8*, i8** %7
%20 = load i8, i8* %19
%21 = sext i8 %20 to i32
%22 = icmp ne i32 %21, 0
br i1 %22, label %23, label %29
23: ; preds = %18
%24 = load i8*, i8** %5
%25 = load i8*, i8** %7
%26 = load i8, i8* %25
%27 = call i64 @csc_isdelim(i8* %24, i8 signext %26)
%28 = icmp ne i64 %27, 0
br label %29
29: ; preds = %23, %18
%30 = phi i1 [ false, %18 ], [ %28, %23 ]
br i1 %30, label %31, label %34
31: ; preds = %29
%32 = load i8*, i8** %7
%33 = getelementptr inbounds i8, i8* %32, i32 1
store i8* %33, i8** %7
br label %18
34: ; preds = %29
%35 = load i64*, i64** %6
%36 = icmp ne i64* %35, null
br i1 %36, label %37, label %41
37: ; preds = %34
%38 = load i8*, i8** %7
%39 = call i64 @strtol(i8* %38, i8** null, i32 0)
%40 = load i64*, i64** %6
store i64 %39, i64* %40
br label %41
41: ; preds = %37, %34
%42 = load i64, i64* %9
ret i64 %42
}

LLVM IR (-O2):
define i64 @csc_strbival_long(i8* %0, i8* %1, i64* writeonly %2) {
%4 = alloca i8*
%5 = alloca i16
%6 = bitcast i8** %4 to i8*
%7 = bitcast i16* %5 to i8*
store i16 32, i16* %5
%8 = call i64 @strtol(i8* %0, i8** %4, i32 0)
%9 = icmp eq i8* %1, null
%10 = select i1 %9, i8* %7, i8* %1
%11 = load i8*, i8** %4
%12 = load i8, i8* %11
%13 = icmp eq i8 %12, 0
br i1 %13, label %23, label %14
14: ; preds = %3, %19
%15 = phi i8 [ %21, %19 ], [ %12, %3 ]
%16 = phi i8* [ %20, %19 ], [ %11, %3 ]
%17 = call i64 @csc_isdelim(i8* %10, i8 signext %15)
%18 = icmp eq i64 %17, 0
br i1 %18, label %23, label %19
19: ; preds = %14
%20 = getelementptr inbounds i8, i8* %16, i64 1
%21 = load i8, i8* %20
%22 = icmp eq i8 %21, 0
br i1 %22, label %23, label %14
23: ; preds = %14, %19, %3
%24 = phi i8* [ %11, %3 ], [ %20, %19 ], [ %16, %14 ]
store i8* %24, i8** %4
%25 = icmp eq i64* %2, null
br i1 %25, label %28, label %26
26: ; preds = %23
%27 = call i64 @strtol(i8* nocapture %24, i8** null, i32 0)
store i64 %27, i64* %2
br label %28
28: ; preds = %26, %23
ret i64 %8
}