#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_3(const char *value, void *res, size_t len) {
  const char *start = value;
  char *end;
  int converted[3];
  int i;
  if (len < sizeof(converted))
    return 0;
  for (i = 0; i < 3; 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_3>:
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   $0xc,-0x20(%rbp)
jae    1154 <convert_strtoint_3+0x34>
movq   $0x0,-0x8(%rbp)
jmp    11ce <convert_strtoint_3+0xae>
movl   $0x0,-0x40(%rbp)
cmpl   $0x3,-0x40(%rbp)
jge    1197 <convert_strtoint_3+0x77>
mov    -0x28(%rbp),%rdi
lea    -0x30(%rbp),%rsi
mov    $0xa,%edx
call   1030 <strtol@plt>
mov    %eax,%ecx
movslq -0x40(%rbp),%rax
mov    %ecx,-0x3c(%rbp,%rax,4)
mov    -0x30(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    -0x40(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x40(%rbp)
jmp    115b <convert_strtoint_3+0x3b>
mov    -0x30(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
je     11b4 <convert_strtoint_3+0x94>
movq   $0x0,-0x8(%rbp)
jmp    11ce <convert_strtoint_3+0xae>
mov    -0x18(%rbp),%rdi
lea    -0x3c(%rbp),%rsi
mov    $0xc,%edx
call   1040 <memcpy@plt>
movq   $0xc,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<convert_strtoint_3>:
push   %r14
push   %rbx
sub    $0x18,%rsp
cmp    $0xc,%rdx
jb     1177 <convert_strtoint_3+0x57>
mov    %rsi,%r14
mov    %rsp,%rbx
mov    %rbx,%rsi
mov    $0xa,%edx
call   1030 <strtol@plt>
mov    %eax,0xc(%rsp)
mov    (%rsp),%rdi
mov    %rbx,%rsi
mov    $0xa,%edx
call   1030 <strtol@plt>
mov    %eax,0x10(%rsp)
mov    (%rsp),%rdi
mov    %rbx,%rsi
mov    $0xa,%edx
call   1030 <strtol@plt>
mov    %eax,0x14(%rsp)
mov    (%rsp),%rax
cmpb   $0x0,(%rax)
je     117b <convert_strtoint_3+0x5b>
xor    %eax,%eax
jmp    1192 <convert_strtoint_3+0x72>
lea    0xc(%rsp),%rsi
mov    %r14,%rdi
mov    $0xc,%edx
call   1040 <memcpy@plt>
mov    $0xc,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
define i64 @convert_strtoint_3(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 [3 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, 12
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, 3
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 [3 x i32], [3 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 [3 x i32], [3 x i32]* %10, i64 0, i64 0
%39 = call i32 @memcpy(i8* %37, i32* %38, i32 12)
store i64 12, 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_3(i8* %0, i8* %1, i64 %2) {
%4 = alloca i8*
%5 = alloca [3 x i32]
%6 = bitcast i8** %4 to i8*
%7 = bitcast [3 x i32]* %5 to i8*
%8 = icmp ult i64 %2, 12
br i1 %8, label %23, label %9
9: ; preds = %3
%10 = call i32 @strtol(i8* %0, i8** %4, i32 10)
%11 = getelementptr inbounds [3 x i32], [3 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 [3 x i32], [3 x i32]* %5, i64 0, i64 1
store i32 %13, i32* %14
%15 = load i8*, i8** %4
%16 = call i32 @strtol(i8* %15, i8** %4, i32 10)
%17 = getelementptr inbounds [3 x i32], [3 x i32]* %5, i64 0, i64 2
store i32 %16, i32* %17
%18 = load i8*, i8** %4
%19 = load i8, i8* %18
%20 = icmp eq i8 %19, 0
br i1 %20, label %21, label %23
21: ; preds = %9
%22 = call i32 @memcpy(i8* %1, i32* %11, i32 12)
br label %23
23: ; preds = %9, %3, %21
%24 = phi i64 [ 12, %21 ], [ 0, %3 ], [ 0, %9 ]
ret i64 %24
}