#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 scalar_t__ ptrdiff_t;

/* Variables and functions */
int atoi(char *);
char *strchr(char const *, char);
int /*<<< orphan*/ strcpy(char *, char const *);
int /*<<< orphan*/ strncpy(char *, char const *, int);
void ParseVersionFromString(int *pOutMajor, int *pOutMinor,
                            const char *strVersion) {
  const char *strDotPos = NULL;
  int iLength = 0;
  char strWorkBuff[10];
  *pOutMinor = 0;
  *pOutMajor = 0;
  strDotPos = strchr(strVersion, '.');
  if (!strDotPos)
    return;
  iLength = (int)((ptrdiff_t)strDotPos - (ptrdiff_t)strVersion);
  strncpy(strWorkBuff, strVersion, iLength);
  strWorkBuff[iLength] = '\0';
  *pOutMajor = atoi(strWorkBuff);
  strDotPos = strchr(strVersion + iLength + 1, ' ');
  if (!strDotPos) {
    strcpy(strWorkBuff, strVersion + iLength + 1);
  } else {
    int iLengthMinor = (int)((ptrdiff_t)strDotPos - (ptrdiff_t)strVersion);
    iLengthMinor = iLengthMinor - (iLength + 1);
    strncpy(strWorkBuff, strVersion + iLength + 1, iLengthMinor);
    strWorkBuff[iLengthMinor] = '\0';
  }
  *pOutMinor = atoi(strWorkBuff);
}


x86 assembly (clang, -O0):
<ParseVersionFromString>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
movq   $0x0,-0x20(%rbp)
movl   $0x0,-0x24(%rbp)
mov    -0x10(%rbp),%rax
movl   $0x0,(%rax)
mov    -0x8(%rbp),%rax
movl   $0x0,(%rax)
mov    -0x18(%rbp),%rdi
mov    $0x2e,%esi
call   1050 <strchr@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
jne    1199 <ParseVersionFromString+0x59>
jmp    1267 <ParseVersionFromString+0x127>
mov    -0x20(%rbp),%rax
mov    -0x18(%rbp),%rcx
sub    %rcx,%rax
mov    %eax,-0x24(%rbp)
lea    -0x2e(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    -0x24(%rbp),%edx
call   1030 <strncpy@plt>
movslq -0x24(%rbp),%rax
movb   $0x0,-0x2e(%rbp,%rax,1)
lea    -0x2e(%rbp),%rdi
call   1060 <atoi@plt>
mov    %eax,%ecx
mov    -0x8(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x18(%rbp),%rdi
movslq -0x24(%rbp),%rax
add    %rax,%rdi
add    $0x1,%rdi
mov    $0x20,%esi
call   1050 <strchr@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
jne    1216 <ParseVersionFromString+0xd6>
lea    -0x2e(%rbp),%rdi
mov    -0x18(%rbp),%rsi
movslq -0x24(%rbp),%rax
add    %rax,%rsi
add    $0x1,%rsi
call   1040 <strcpy@plt>
jmp    1256 <ParseVersionFromString+0x116>
mov    -0x20(%rbp),%rax
mov    -0x18(%rbp),%rcx
sub    %rcx,%rax
mov    %eax,-0x34(%rbp)
mov    -0x34(%rbp),%eax
mov    -0x24(%rbp),%ecx
add    $0x1,%ecx
sub    %ecx,%eax
mov    %eax,-0x34(%rbp)
lea    -0x2e(%rbp),%rdi
mov    -0x18(%rbp),%rsi
movslq -0x24(%rbp),%rax
add    %rax,%rsi
add    $0x1,%rsi
mov    -0x34(%rbp),%edx
call   1030 <strncpy@plt>
movslq -0x34(%rbp),%rax
movb   $0x0,-0x2e(%rbp,%rax,1)
lea    -0x2e(%rbp),%rdi
call   1060 <atoi@plt>
mov    %eax,%ecx
mov    -0x10(%rbp),%rax
mov    %ecx,(%rax)
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ParseVersionFromString>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %rdx,%r15
mov    %rsi,%r14
mov    %rdi,%r12
movl   $0x0,(%rsi)
movl   $0x0,(%rdi)
mov    %rdx,%rdi
mov    $0x2e,%esi
call   1050 <strchr@plt>
test   %rax,%rax
je     11f9 <ParseVersionFromString+0xb9>
mov    %rax,%rbx
sub    %r15,%rbx
lea    0xe(%rsp),%r13
mov    %r13,%rdi
mov    %r15,%rsi
mov    %ebx,%edx
call   1030 <strncpy@plt>
movslq %ebx,%rbp
movb   $0x0,0xe(%rsp,%rbp,1)
mov    %r13,%rdi
call   1060 <atoi@plt>
mov    %eax,(%r12)
lea    (%r15,%rbp,1),%r12
add    $0x1,%r12
mov    %r12,%rdi
mov    $0x20,%esi
call   1050 <strchr@plt>
test   %rax,%rax
je     11df <ParseVersionFromString+0x9f>
sub    %r15d,%eax
not    %ebx
add    %eax,%ebx
lea    0xe(%rsp),%rdi
mov    %r12,%rsi
mov    %ebx,%edx
call   1030 <strncpy@plt>
movslq %ebx,%rax
movb   $0x0,0xe(%rsp,%rax,1)
jmp    11ec <ParseVersionFromString+0xac>
lea    0xe(%rsp),%rdi
mov    %r12,%rsi
call   1040 <strcpy@plt>
lea    0xe(%rsp),%rdi
call   1060 <atoi@plt>
mov    %eax,(%r14)
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define void @ParseVersionFromString(i32* %0, i32* %1, i8* %2) {
%4 = alloca i32*
%5 = alloca i32*
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca i32
%9 = alloca [10 x i8]
%10 = alloca i32
store i32* %0, i32** %4
store i32* %1, i32** %5
store i8* %2, i8** %6
store i8* null, i8** %7
store i32 0, i32* %8
%11 = load i32*, i32** %5
store i32 0, i32* %11
%12 = load i32*, i32** %4
store i32 0, i32* %12
%13 = load i8*, i8** %6
%14 = call i8* @strchr(i8* %13, i8 signext 46)
store i8* %14, i8** %7
%15 = load i8*, i8** %7
%16 = icmp ne i8* %15, null
br i1 %16, label %18, label %17
17: ; preds = %3
br label %77
18: ; preds = %3
%19 = load i8*, i8** %7
%20 = ptrtoint i8* %19 to i64
%21 = load i8*, i8** %6
%22 = ptrtoint i8* %21 to i64
%23 = sub nsw i64 %20, %22
%24 = trunc i64 %23 to i32
store i32 %24, i32* %8
%25 = getelementptr inbounds [10 x i8], [10 x i8]* %9, i64 0, i64 0
%26 = load i8*, i8** %6
%27 = load i32, i32* %8
%28 = call i32 @strncpy(i8* %25, i8* %26, i32 %27)
%29 = load i32, i32* %8
%30 = sext i32 %29 to i64
%31 = getelementptr inbounds [10 x i8], [10 x i8]* %9, i64 0, i64 %30
store i8 0, i8* %31
%32 = getelementptr inbounds [10 x i8], [10 x i8]* %9, i64 0, i64 0
%33 = call i32 @atoi(i8* %32)
%34 = load i32*, i32** %4
store i32 %33, i32* %34
%35 = load i8*, i8** %6
%36 = load i32, i32* %8
%37 = sext i32 %36 to i64
%38 = getelementptr inbounds i8, i8* %35, i64 %37
%39 = getelementptr inbounds i8, i8* %38, i64 1
%40 = call i8* @strchr(i8* %39, i8 signext 32)
store i8* %40, i8** %7
%41 = load i8*, i8** %7
%42 = icmp ne i8* %41, null
br i1 %42, label %51, label %43
43: ; preds = %18
%44 = getelementptr inbounds [10 x i8], [10 x i8]* %9, i64 0, i64 0
%45 = load i8*, i8** %6
%46 = load i32, i32* %8
%47 = sext i32 %46 to i64
%48 = getelementptr inbounds i8, i8* %45, i64 %47
%49 = getelementptr inbounds i8, i8* %48, i64 1
%50 = call i32 @strcpy(i8* %44, i8* %49)
br label %73
51: ; preds = %18
%52 = load i8*, i8** %7
%53 = ptrtoint i8* %52 to i64
%54 = load i8*, i8** %6
%55 = ptrtoint i8* %54 to i64
%56 = sub nsw i64 %53, %55
%57 = trunc i64 %56 to i32
store i32 %57, i32* %10
%58 = load i32, i32* %10
%59 = load i32, i32* %8
%60 = add nsw i32 %59, 1
%61 = sub nsw i32 %58, %60
store i32 %61, i32* %10
%62 = getelementptr inbounds [10 x i8], [10 x i8]* %9, i64 0, i64 0
%63 = load i8*, i8** %6
%64 = load i32, i32* %8
%65 = sext i32 %64 to i64
%66 = getelementptr inbounds i8, i8* %63, i64 %65
%67 = getelementptr inbounds i8, i8* %66, i64 1
%68 = load i32, i32* %10
%69 = call i32 @strncpy(i8* %62, i8* %67, i32 %68)
%70 = load i32, i32* %10
%71 = sext i32 %70 to i64
%72 = getelementptr inbounds [10 x i8], [10 x i8]* %9, i64 0, i64 %71
store i8 0, i8* %72
br label %73
73: ; preds = %51, %43
%74 = getelementptr inbounds [10 x i8], [10 x i8]* %9, i64 0, i64 0
%75 = call i32 @atoi(i8* %74)
%76 = load i32*, i32** %5
store i32 %75, i32* %76
br label %77
77: ; preds = %73, %17
ret void
}

LLVM IR (-O2):
define void @ParseVersionFromString(i32* nocapture writeonly %0, i32* nocapture writeonly %1, i8* %2) {
%4 = alloca [10 x i8]
%5 = getelementptr inbounds [10 x i8], [10 x i8]* %4, i64 0, i64 0
store i32 0, i32* %1
store i32 0, i32* %0
%6 = tail call i8* @strchr(i8* dereferenceable(1) %2, i8 signext 46)
%7 = icmp eq i8* %6, null
br i1 %7, label %35, label %8
8: ; preds = %3
%9 = ptrtoint i8* %6 to i64
%10 = ptrtoint i8* %2 to i64
%11 = sub nsw i64 %9, %10
%12 = trunc i64 %11 to i32
%13 = call i32 @strncpy(i8* %5, i8* %2, i32 %12)
%14 = shl i64 %11, 32
%15 = ashr exact i64 %14, 32
%16 = getelementptr inbounds [10 x i8], [10 x i8]* %4, i64 0, i64 %15
store i8 0, i8* %16
%17 = call i32 @atoi(i8* %5)
store i32 %17, i32* %0
%18 = getelementptr inbounds i8, i8* %2, i64 %15
%19 = getelementptr inbounds i8, i8* %18, i64 1
%20 = call i8* @strchr(i8* %19, i8 signext 32)
%21 = icmp eq i8* %20, null
br i1 %21, label %22, label %24
22: ; preds = %8
%23 = call i32 @strcpy(i8* %5, i8* %19)
br label %33
24: ; preds = %8
%25 = ptrtoint i8* %20 to i64
%26 = sub nsw i64 %25, %10
%27 = trunc i64 %26 to i32
%28 = xor i32 %12, -1
%29 = add i32 %27, %28
%30 = call i32 @strncpy(i8* %5, i8* %19, i32 %29)
%31 = sext i32 %29 to i64
%32 = getelementptr inbounds [10 x i8], [10 x i8]* %4, i64 0, i64 %31
store i8 0, i8* %32
br label %33
33: ; preds = %24, %22
%34 = call i32 @atoi(i8* %5)
store i32 %34, i32* %1
br label %35
35: ; preds = %3, %33
ret void
}