#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 */
scalar_t__ strtoul(char *, char **, int);
void decode_version(char *buf, int *version, int *modification, int *patch) {
  *version = (int)strtoul(buf, &buf, 10);
  *modification = 0;
  *patch = 0;
  if (*buf == '.') {
    ++buf;
    *modification = (int)strtoul(buf, &buf, 10);
    if (*buf == '.') {
      ++buf;
      *patch = (int)strtoul(buf, &buf, 10);
    }
  }
  if (*buf != '\0') {
    *version = *modification = *patch = 0;
  }
}


x86 assembly (clang, -O0):
<decode_version>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    -0x8(%rbp),%rdi
lea    -0x8(%rbp),%rsi
mov    $0xa,%edx
call   1030 <strtoul@plt>
mov    %eax,%ecx
mov    -0x10(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x18(%rbp),%rax
movl   $0x0,(%rax)
mov    -0x20(%rbp),%rax
movl   $0x0,(%rax)
mov    -0x8(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x2e,%eax
jne    11c7 <decode_version+0xb7>
mov    -0x8(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
lea    -0x8(%rbp),%rsi
mov    $0xa,%edx
call   1030 <strtoul@plt>
mov    %eax,%ecx
mov    -0x18(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x8(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x2e,%eax
jne    11c2 <decode_version+0xb2>
mov    -0x8(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
lea    -0x8(%rbp),%rsi
mov    $0xa,%edx
call   1030 <strtoul@plt>
mov    %eax,%ecx
mov    -0x20(%rbp),%rax
mov    %ecx,(%rax)
jmp    11c7 <decode_version+0xb7>
mov    -0x8(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
je     11f5 <decode_version+0xe5>
mov    -0x20(%rbp),%rax
movl   $0x0,(%rax)
mov    -0x18(%rbp),%rax
movl   $0x0,(%rax)
mov    -0x10(%rbp),%rax
movl   $0x0,(%rax)
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<decode_version>:
push   %r15
push   %r14
push   %rbx
sub    $0x10,%rsp
mov    %rcx,%r15
mov    %rdx,%rbx
mov    %rsi,%r14
mov    %rdi,0x8(%rsp)
lea    0x8(%rsp),%rsi
mov    $0xa,%edx
call   1030 <strtoul@plt>
mov    %eax,(%r14)
movl   $0x0,(%rbx)
movl   $0x0,(%r15)
mov    0x8(%rsp),%rdi
mov    (%rdi),%al
cmp    $0x2e,%al
jne    1198 <decode_version+0x88>
add    $0x1,%rdi
mov    %rdi,0x8(%rsp)
lea    0x8(%rsp),%rsi
mov    $0xa,%edx
call   1030 <strtoul@plt>
mov    %eax,(%rbx)
mov    0x8(%rsp),%rdi
mov    (%rdi),%al
cmp    $0x2e,%al
jne    1198 <decode_version+0x88>
add    $0x1,%rdi
mov    %rdi,0x8(%rsp)
lea    0x8(%rsp),%rsi
mov    $0xa,%edx
call   1030 <strtoul@plt>
mov    %eax,(%r15)
mov    0x8(%rsp),%rax
mov    (%rax),%al
test   %al,%al
je     11b0 <decode_version+0xa0>
movl   $0x0,(%r15)
movl   $0x0,(%rbx)
movl   $0x0,(%r14)
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

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

LLVM IR (-O2):
define void @decode_version(i8* %0, i32* nocapture writeonly %1, i32* nocapture writeonly %2, i32* nocapture writeonly %3) {
%5 = alloca i8*
store i8* %0, i8** %5
%6 = call i64 @strtoul(i8* %0, i8** %5, i32 10)
%7 = trunc i64 %6 to i32
store i32 %7, i32* %1
store i32 0, i32* %2
store i32 0, i32* %3
%8 = load i8*, i8** %5
%9 = load i8, i8* %8
%10 = icmp eq i8 %9, 46
br i1 %10, label %11, label %24
11: ; preds = %4
%12 = getelementptr inbounds i8, i8* %8, i64 1
store i8* %12, i8** %5
%13 = call i64 @strtoul(i8* %12, i8** %5, i32 10)
%14 = trunc i64 %13 to i32
store i32 %14, i32* %2
%15 = load i8*, i8** %5
%16 = load i8, i8* %15
%17 = icmp eq i8 %16, 46
br i1 %17, label %18, label %24
18: ; preds = %11
%19 = getelementptr inbounds i8, i8* %15, i64 1
store i8* %19, i8** %5
%20 = call i64 @strtoul(i8* %19, i8** %5, i32 10)
%21 = trunc i64 %20 to i32
store i32 %21, i32* %3
%22 = load i8*, i8** %5
%23 = load i8, i8* %22
br label %24
24: ; preds = %11, %18, %4
%25 = phi i8 [ %16, %11 ], [ %23, %18 ], [ %9, %4 ]
%26 = icmp eq i8 %25, 0
br i1 %26, label %28, label %27
27: ; preds = %24
store i32 0, i32* %3
store i32 0, i32* %2
store i32 0, i32* %1
br label %28
28: ; preds = %27, %24
ret void
}