#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 */
long strtol(char const *, char **, int /*<<< orphan*/);
int html_cvt_long(const char *data, int len, void *dst, void *closure) {
  if (data) {
    char *e;
    long val;
    val = strtol(data, &e, 0);
    if (data + len == e) {
      long *d = dst;
      *d = val;
      return 1;
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<html_cvt_long>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
mov    %rdx,-0x20(%rbp)
mov    %rcx,-0x28(%rbp)
cmpq   $0x0,-0x10(%rbp)
je     117e <html_cvt_long+0x6e>
mov    -0x10(%rbp),%rdi
lea    -0x30(%rbp),%rsi
xor    %edx,%edx
call   1030 <strtol@plt>
mov    %rax,-0x38(%rbp)
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
add    %rcx,%rax
cmp    -0x30(%rbp),%rax
jne    1179 <html_cvt_long+0x69>
mov    -0x20(%rbp),%rax
mov    %rax,-0x40(%rbp)
mov    -0x38(%rbp),%rcx
mov    -0x40(%rbp),%rax
mov    %rcx,(%rax)
movl   $0x1,-0x4(%rbp)
jmp    1185 <html_cvt_long+0x75>
jmp    117e <html_cvt_long+0x6e>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<html_cvt_long>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
test   %rdi,%rdi
je     1147 <html_cvt_long+0x37>
mov    %rdx,%r14
mov    %esi,%r15d
mov    %rdi,%rbx
mov    %rsp,%rsi
xor    %ebp,%ebp
xor    %edx,%edx
call   1030 <strtol@plt>
movslq %r15d,%rcx
add    %rbx,%rcx
cmp    (%rsp),%rcx
jne    1149 <html_cvt_long+0x39>
mov    %rax,(%r14)
mov    $0x1,%ebp
jmp    1149 <html_cvt_long+0x39>
xor    %ebp,%ebp
mov    %ebp,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

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

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