#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__ isspace(char const);
int strtoul(char const *, char **, int);
int parse_format(const char *p, int *w, int *h) {
  char *end;
  for (; isspace(*p); ++p)
    ;
  *w = strtoul(p, &end, 10);
  if (*end != 'x')
    return -1;
  p = end + 1;
  *h = strtoul(p, &end, 10);
  if (*end != '\0')
    return -1;
  return 0;
}


x86 assembly (clang, -O0):
<parse_format>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    -0x10(%rbp),%rax
movsbl (%rax),%edi
call   1030 <isspace@plt>
cmp    $0x0,%rax
je     1160 <parse_format+0x40>
jmp    114f <parse_format+0x2f>
mov    -0x10(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x10(%rbp)
jmp    1134 <parse_format+0x14>
mov    -0x10(%rbp),%rdi
lea    -0x28(%rbp),%rsi
mov    $0xa,%edx
call   1040 <strtoul@plt>
mov    %eax,%ecx
mov    -0x18(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x28(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x78,%eax
je     1196 <parse_format+0x76>
movl   $0xffffffff,-0x4(%rbp)
jmp    11df <parse_format+0xbf>
mov    -0x28(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
lea    -0x28(%rbp),%rsi
mov    $0xa,%edx
call   1040 <strtoul@plt>
mov    %eax,%ecx
mov    -0x20(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x28(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
je     11d8 <parse_format+0xb8>
movl   $0xffffffff,-0x4(%rbp)
jmp    11df <parse_format+0xbf>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<parse_format>:
push   %r15
push   %r14
push   %rbx
sub    $0x10,%rsp
mov    %rdx,%r14
mov    %rsi,%r15
mov    %rdi,%rbx
add    $0xffffffffffffffff,%rbx
cs nopw 0x0(%rax,%rax,1)
movsbl 0x1(%rbx),%edi
add    $0x1,%rbx
call   1030 <isspace@plt>
test   %rax,%rax
jne    1140 <parse_format+0x20>
lea    0x8(%rsp),%rsi
mov    %rbx,%rdi
mov    $0xa,%edx
call   1040 <strtoul@plt>
mov    %eax,(%r15)
mov    0x8(%rsp),%rdi
mov    $0xffffffff,%eax
cmpb   $0x78,(%rdi)
jne    1197 <parse_format+0x77>
add    $0x1,%rdi
lea    0x8(%rsp),%rsi
mov    $0xa,%edx
call   1040 <strtoul@plt>
mov    %eax,(%r14)
mov    0x8(%rsp),%rax
xor    %ecx,%ecx
cmp    (%rax),%cl
sbb    %eax,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

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

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