#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 */
int atoi(char *);
char *strchr(char *, char);
void parse_version(char *string, int *version, int *update) {
  char *ptr = strchr(string, '.');
  if (ptr)
    ptr[0] = 0;
  *version = atoi(string);
  if (ptr) {
    ptr++;
    *update = atoi(ptr);
    if (*update < 10 && ptr[0] != '0')
      *update *= 10;
    ptr--;
    ptr[0] = '.';
  } else
    *update = 0;
}


x86 assembly (clang, -O0):
<parse_version>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    -0x8(%rbp),%rdi
mov    $0x2e,%esi
call   1030 <strchr@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
je     1158 <parse_version+0x38>
mov    -0x20(%rbp),%rax
movb   $0x0,(%rax)
mov    -0x8(%rbp),%rdi
call   1040 <atoi@plt>
mov    %eax,%ecx
mov    -0x10(%rbp),%rax
mov    %ecx,(%rax)
cmpq   $0x0,-0x20(%rbp)
je     11cf <parse_version+0xaf>
mov    -0x20(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rdi
call   1040 <atoi@plt>
mov    %eax,%ecx
mov    -0x18(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x18(%rbp),%rax
cmpl   $0xa,(%rax)
jge    11b7 <parse_version+0x97>
mov    -0x20(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x30,%eax
je     11b7 <parse_version+0x97>
mov    -0x18(%rbp),%rax
imul   $0xa,(%rax),%ecx
mov    %ecx,(%rax)
mov    -0x20(%rbp),%rax
add    $0xffffffffffffffff,%rax
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rax
movb   $0x2e,(%rax)
jmp    11d9 <parse_version+0xb9>
mov    -0x18(%rbp),%rax
movl   $0x0,(%rax)
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<parse_version>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    %rdx,%r14
mov    %rsi,%r15
mov    %rdi,%rbx
mov    $0x2e,%esi
call   1030 <strchr@plt>
test   %rax,%rax
je     117c <parse_version+0x5c>
mov    %rax,%r12
movb   $0x0,(%rax)
mov    %rbx,%rdi
call   1040 <atoi@plt>
mov    %eax,(%r15)
mov    %r12,%rbx
add    $0x1,%rbx
mov    %rbx,%rdi
call   1040 <atoi@plt>
mov    %eax,(%r14)
cmp    $0x9,%eax
jg     1175 <parse_version+0x55>
cmpb   $0x30,(%rbx)
je     1175 <parse_version+0x55>
add    %eax,%eax
lea    (%rax,%rax,4),%eax
mov    %eax,(%r14)
movb   $0x2e,(%r12)
jmp    118e <parse_version+0x6e>
mov    %rbx,%rdi
call   1040 <atoi@plt>
mov    %eax,(%r15)
movl   $0x0,(%r14)
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define void @parse_version(i8* %0, i32* %1, i32* %2) {
%4 = alloca i8*
%5 = alloca i32*
%6 = alloca i32*
%7 = alloca i8*
store i8* %0, i8** %4
store i32* %1, i32** %5
store i32* %2, i32** %6
%8 = load i8*, i8** %4
%9 = call i8* @strchr(i8* %8, i8 signext 46)
store i8* %9, i8** %7
%10 = load i8*, i8** %7
%11 = icmp ne i8* %10, null
br i1 %11, label %12, label %15
12: ; preds = %3
%13 = load i8*, i8** %7
%14 = getelementptr inbounds i8, i8* %13, i64 0
store i8 0, i8* %14
br label %15
15: ; preds = %12, %3
%16 = load i8*, i8** %4
%17 = call i32 @atoi(i8* %16)
%18 = load i32*, i32** %5
store i32 %17, i32* %18
%19 = load i8*, i8** %7
%20 = icmp ne i8* %19, null
br i1 %20, label %21, label %45
21: ; preds = %15
%22 = load i8*, i8** %7
%23 = getelementptr inbounds i8, i8* %22, i32 1
store i8* %23, i8** %7
%24 = load i8*, i8** %7
%25 = call i32 @atoi(i8* %24)
%26 = load i32*, i32** %6
store i32 %25, i32* %26
%27 = load i32*, i32** %6
%28 = load i32, i32* %27
%29 = icmp slt i32 %28, 10
br i1 %29, label %30, label %40
30: ; preds = %21
%31 = load i8*, i8** %7
%32 = getelementptr inbounds i8, i8* %31, i64 0
%33 = load i8, i8* %32
%34 = sext i8 %33 to i32
%35 = icmp ne i32 %34, 48
br i1 %35, label %36, label %40
36: ; preds = %30
%37 = load i32*, i32** %6
%38 = load i32, i32* %37
%39 = mul nsw i32 %38, 10
store i32 %39, i32* %37
br label %40
40: ; preds = %36, %30, %21
%41 = load i8*, i8** %7
%42 = getelementptr inbounds i8, i8* %41, i32 -1
store i8* %42, i8** %7
%43 = load i8*, i8** %7
%44 = getelementptr inbounds i8, i8* %43, i64 0
store i8 46, i8* %44
br label %47
45: ; preds = %15
%46 = load i32*, i32** %6
store i32 0, i32* %46
br label %47
47: ; preds = %45, %40
ret void
}

LLVM IR (-O2):
define void @parse_version(i8* %0, i32* nocapture writeonly %1, i32* nocapture writeonly %2) {
%4 = tail call i8* @strchr(i8* dereferenceable(1) %0, i8 signext 46)
%5 = icmp eq i8* %4, null
br i1 %5, label %17, label %6
6: ; preds = %3
store i8 0, i8* %4
%7 = tail call i32 @atoi(i8* %0)
store i32 %7, i32* %1
%8 = getelementptr inbounds i8, i8* %4, i64 1
%9 = tail call i32 @atoi(i8* %8)
store i32 %9, i32* %2
%10 = icmp slt i32 %9, 10
br i1 %10, label %11, label %16
11: ; preds = %6
%12 = load i8, i8* %8
%13 = icmp eq i8 %12, 48
br i1 %13, label %16, label %14
14: ; preds = %11
%15 = mul nsw i32 %9, 10
store i32 %15, i32* %2
br label %16
16: ; preds = %14, %11, %6
store i8 46, i8* %4
br label %19
17: ; preds = %3
%18 = tail call i32 @atoi(i8* %0)
store i32 %18, i32* %1
store i32 0, i32* %2
br label %19
19: ; preds = %17, %16
ret void
}