#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 sscanf(char const *, char *, int *, int *);
int beholddb_decode_version(const char *version, int *pmajor, int *pminor) {
  if (!version) {
    *pmajor = -1;
    *pminor = 0;
    return 0;
  }
  if (2 == sscanf(version, "%d.%d", pmajor, pminor))
    return 0;
  return -1;
}


x86 assembly (clang, -O0):
<beholddb_decode_version>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    114f <beholddb_decode_version+0x3f>
mov    -0x18(%rbp),%rax
movl   $0xffffffff,(%rax)
mov    -0x20(%rbp),%rax
movl   $0x0,(%rax)
movl   $0x0,-0x4(%rbp)
jmp    1189 <beholddb_decode_version+0x79>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rdx
mov    -0x20(%rbp),%rcx
lea    0xe9e(%rip),%rsi
call   1030 <sscanf@plt>
mov    %eax,%ecx
mov    $0x2,%eax
cmp    %ecx,%eax
jne    1182 <beholddb_decode_version+0x72>
movl   $0x0,-0x4(%rbp)
jmp    1189 <beholddb_decode_version+0x79>
movl   $0xffffffff,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<beholddb_decode_version>:
push   %rax
mov    %rdx,%rcx
mov    %rsi,%rdx
test   %rdi,%rdi
je     1136 <beholddb_decode_version+0x26>
lea    0xedd(%rip),%rsi
call   1030 <sscanf@plt>
mov    %eax,%ecx
xor    %eax,%eax
cmp    $0x2,%ecx
setne  %al
neg    %eax
pop    %rcx
ret
movl   $0xffffffff,(%rdx)
movl   $0x0,(%rcx)
xor    %eax,%eax
pop    %rcx
ret

LLVM IR (-O0):
@.str = [6 x i8] c"%d.%d\00"
define i32 @beholddb_decode_version(i8* %0, i32* %1, i32* %2) {
%4 = alloca i32
%5 = alloca i8*
%6 = alloca i32*
%7 = alloca i32*
store i8* %0, i8** %5
store i32* %1, i32** %6
store i32* %2, i32** %7
%8 = load i8*, i8** %5
%9 = icmp ne i8* %8, null
br i1 %9, label %13, label %10
10: ; preds = %3
%11 = load i32*, i32** %6
store i32 -1, i32* %11
%12 = load i32*, i32** %7
store i32 0, i32* %12
store i32 0, i32* %4
br label %21
13: ; preds = %3
%14 = load i8*, i8** %5
%15 = load i32*, i32** %6
%16 = load i32*, i32** %7
%17 = call i32 @sscanf(i8* %14, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i32* %15, i32* %16)
%18 = icmp eq i32 2, %17
br i1 %18, label %19, label %20
19: ; preds = %13
store i32 0, i32* %4
br label %21
20: ; preds = %13
store i32 -1, i32* %4
br label %21
21: ; preds = %20, %19, %10
%22 = load i32, i32* %4
ret i32 %22
}

LLVM IR (-O2):
@.str = [6 x i8] c"%d.%d\00"
define i32 @beholddb_decode_version(i8* %0, i32* %1, i32* %2) {
%4 = icmp eq i8* %0, null
br i1 %4, label %5, label %6
5: ; preds = %3
store i32 -1, i32* %1
store i32 0, i32* %2
br label %10
6: ; preds = %3
%7 = tail call i32 @sscanf(i8* %0, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i32* %1, i32* %2)
%8 = icmp ne i32 %7, 2
%9 = sext i1 %8 to i32
br label %10
10: ; preds = %6, %5
%11 = phi i32 [ 0, %5 ], [ %9, %6 ]
ret i32 %11
}