#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 /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ sscanf(char *, char *, int *);
int strlen(char *);
int get2val(char *s, int *a, int *b) {
  if (strlen(s) != 6) {
    printf("Error: Parameter must be 'xxxyyy' (decimal)!\n");
    return (0);
  }
  if (!sscanf(s + 3, "%d", b))
    return (0);
  *(s + 3) = 0;
  if (!sscanf(s, "%d", a))
    return (0);
  return (1);
}


x86 assembly (clang, -O0):
<get2val>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <strlen@plt>
cmp    $0x6,%eax
je     116e <get2val+0x3e>
lea    0xea3(%rip),%rdi
call   1040 <printf@plt>
movl   $0x0,-0x4(%rbp)
jmp    11d3 <get2val+0xa3>
mov    -0x10(%rbp),%rdi
add    $0x3,%rdi
mov    -0x20(%rbp),%rdx
lea    0xead(%rip),%rsi
call   1050 <sscanf@plt>
cmp    $0x0,%eax
jne    119b <get2val+0x6b>
movl   $0x0,-0x4(%rbp)
jmp    11d3 <get2val+0xa3>
mov    -0x10(%rbp),%rax
movb   $0x0,0x3(%rax)
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rdx
lea    0xe7c(%rip),%rsi
call   1050 <sscanf@plt>
cmp    $0x0,%eax
jne    11cc <get2val+0x9c>
movl   $0x0,-0x4(%rbp)
jmp    11d3 <get2val+0xa3>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get2val>:
push   %r15
push   %r14
push   %rbx
mov    %rdx,%r15
mov    %rsi,%r14
mov    %rdi,%rbx
call   1040 <strlen@plt>
cmp    $0x6,%eax
jne    1180 <get2val+0x50>
lea    0x3(%rbx),%rdi
lea    0xead(%rip),%rsi
mov    %r15,%rdx
call   1050 <sscanf@plt>
test   %eax,%eax
je     118c <get2val+0x5c>
movb   $0x0,0x3(%rbx)
lea    0xe96(%rip),%rsi
mov    %rbx,%rdi
mov    %r14,%rdx
call   1050 <sscanf@plt>
mov    %eax,%ecx
xor    %eax,%eax
test   %ecx,%ecx
setne  %al
jmp    118e <get2val+0x5e>
lea    0xe7c(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [46 x i8] c"Error: Parameter must be 'xxxyyy' (decimal)!\0A\00"
@.str.1 = [3 x i8] c"%d\00"
define i32 @get2val(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 = call i32 @strlen(i8* %8)
%10 = icmp ne i32 %9, 6
br i1 %10, label %11, label %13
11: ; preds = %3
%12 = call i32 @printf(i8* getelementptr inbounds ([46 x i8], [46 x i8]* @.str, i64 0, i64 0))
store i32 0, i32* %4
br label %29
13: ; preds = %3
%14 = load i8*, i8** %5
%15 = getelementptr inbounds i8, i8* %14, i64 3
%16 = load i32*, i32** %7
%17 = call i32 @sscanf(i8* %15, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %16)
%18 = icmp ne i32 %17, 0
br i1 %18, label %20, label %19
19: ; preds = %13
store i32 0, i32* %4
br label %29
20: ; preds = %13
%21 = load i8*, i8** %5
%22 = getelementptr inbounds i8, i8* %21, i64 3
store i8 0, i8* %22
%23 = load i8*, i8** %5
%24 = load i32*, i32** %6
%25 = call i32 @sscanf(i8* %23, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %24)
%26 = icmp ne i32 %25, 0
br i1 %26, label %28, label %27
27: ; preds = %20
store i32 0, i32* %4
br label %29
28: ; preds = %20
store i32 1, i32* %4
br label %29
29: ; preds = %28, %27, %19, %11
%30 = load i32, i32* %4
ret i32 %30
}

LLVM IR (-O2):
@.str.1 = [3 x i8] c"%d\00"
@str = [45 x i8] c"Error: Parameter must be 'xxxyyy' (decimal)!\00"
define i32 @get2val(i8* %0, i32* %1, i32* %2) {
%4 = tail call i32 @strlen(i8* %0)
%5 = icmp eq i32 %4, 6
br i1 %5, label %8, label %6
6: ; preds = %3
%7 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([45 x i8], [45 x i8]* @str, i64 0, i64 0))
br label %16
8: ; preds = %3
%9 = getelementptr inbounds i8, i8* %0, i64 3
%10 = tail call i32 @sscanf(i8* %9, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %2)
%11 = icmp eq i32 %10, 0
br i1 %11, label %16, label %12
12: ; preds = %8
store i8 0, i8* %9
%13 = tail call i32 @sscanf(i8* %0, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %1)
%14 = icmp ne i32 %13, 0
%15 = zext i1 %14 to i32
br label %16
16: ; preds = %12, %8, %6
%17 = phi i32 [ 0, %6 ], [ 0, %8 ], [ %15, %12 ]
ret i32 %17
}