#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 */
typedef int /*<<< orphan*/ converted;

/* Variables and functions */
int /*<<< orphan*/ memcpy(void *, int *, int);
int strtol(char const *, char **, int);
size_t convert_strtoint_2(const char *value, void *res, size_t len) {
  const char *start = value;
  char *end;
  int converted[2];
  int i;
  if (len < sizeof(converted))
    return 0;
  for (i = 0; i < 2; i++) {
    converted[i] = strtol(start, &end, 10);
    start = end;
  }
  if (*end != '\0')
    return 0;
  memcpy(res, converted, sizeof(converted));
  return sizeof(converted);
}


x86 assembly (clang, -O0):
<convert_strtoint_2>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x28(%rbp)
cmpq   $0x8,-0x20(%rbp)
jae    1154 <convert_strtoint_2+0x34>
movq   $0x0,-0x8(%rbp)
jmp    11ce <convert_strtoint_2+0xae>
movl   $0x0,-0x3c(%rbp)
cmpl   $0x2,-0x3c(%rbp)
jge    1197 <convert_strtoint_2+0x77>
mov    -0x28(%rbp),%rdi
lea    -0x30(%rbp),%rsi
mov    $0xa,%edx
call   1030 <strtol@plt>
mov    %eax,%ecx
movslq -0x3c(%rbp),%rax
mov    %ecx,-0x38(%rbp,%rax,4)
mov    -0x30(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    -0x3c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x3c(%rbp)
jmp    115b <convert_strtoint_2+0x3b>
mov    -0x30(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
je     11b4 <convert_strtoint_2+0x94>
movq   $0x0,-0x8(%rbp)
jmp    11ce <convert_strtoint_2+0xae>
mov    -0x18(%rbp),%rdi
lea    -0x38(%rbp),%rsi
mov    $0x8,%edx
call   1040 <memcpy@plt>
movq   $0x8,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<convert_strtoint_2>:
push   %r14
push   %rbx
sub    $0x18,%rsp
cmp    $0x8,%rdx
jb     1166 <convert_strtoint_2+0x46>
mov    %rsi,%rbx
lea    0x8(%rsp),%r14
mov    %r14,%rsi
mov    $0xa,%edx
call   1030 <strtol@plt>
mov    %eax,0x10(%rsp)
mov    0x8(%rsp),%rdi
mov    %r14,%rsi
mov    $0xa,%edx
call   1030 <strtol@plt>
mov    %eax,0x14(%rsp)
mov    0x8(%rsp),%rax
cmpb   $0x0,(%rax)
je     116a <convert_strtoint_2+0x4a>
xor    %eax,%eax
jmp    1181 <convert_strtoint_2+0x61>
lea    0x10(%rsp),%rsi
mov    %rbx,%rdi
mov    $0x8,%edx
call   1040 <memcpy@plt>
mov    $0x8,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
define i64 @convert_strtoint_2(i8* %0, i8* %1, i64 %2) {
%4 = alloca i64
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca i64
%8 = alloca i8*
%9 = alloca i8*
%10 = alloca [2 x i32]
%11 = alloca i32
store i8* %0, i8** %5
store i8* %1, i8** %6
store i64 %2, i64* %7
%12 = load i8*, i8** %5
store i8* %12, i8** %8
%13 = load i64, i64* %7
%14 = icmp ult i64 %13, 8
br i1 %14, label %15, label %16
15: ; preds = %3
store i64 0, i64* %4
br label %40
16: ; preds = %3
store i32 0, i32* %11
br label %17
17: ; preds = %27, %16
%18 = load i32, i32* %11
%19 = icmp slt i32 %18, 2
br i1 %19, label %20, label %30
20: ; preds = %17
%21 = load i8*, i8** %8
%22 = call i32 @strtol(i8* %21, i8** %9, i32 10)
%23 = load i32, i32* %11
%24 = sext i32 %23 to i64
%25 = getelementptr inbounds [2 x i32], [2 x i32]* %10, i64 0, i64 %24
store i32 %22, i32* %25
%26 = load i8*, i8** %9
store i8* %26, i8** %8
br label %27
27: ; preds = %20
%28 = load i32, i32* %11
%29 = add nsw i32 %28, 1
store i32 %29, i32* %11
br label %17
30: ; preds = %17
%31 = load i8*, i8** %9
%32 = load i8, i8* %31
%33 = sext i8 %32 to i32
%34 = icmp ne i32 %33, 0
br i1 %34, label %35, label %36
35: ; preds = %30
store i64 0, i64* %4
br label %40
36: ; preds = %30
%37 = load i8*, i8** %6
%38 = getelementptr inbounds [2 x i32], [2 x i32]* %10, i64 0, i64 0
%39 = call i32 @memcpy(i8* %37, i32* %38, i32 8)
store i64 8, i64* %4
br label %40
40: ; preds = %36, %35, %15
%41 = load i64, i64* %4
ret i64 %41
}

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