#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 *);
int /*<<< orphan*/ free(char *);
char *strchr(char *, char);
char *strdup(char const *);
char tolower(char);
void parse_label_dimensions(const char *str, int *width, int *height) {
  int w = 0, h = 0;
  char *ptr, *tmp;
  if ((tmp = strdup(str)) == NULL)
    return;
  ptr = tmp;
  while ((*ptr = tolower(*ptr)) != '\0')
    ptr++;
  if ((ptr = strchr(tmp, 'x')) != NULL) {
    *ptr = '\0';
    ptr++;
  }
  w = atoi(tmp);
  if (ptr)
    h = atoi(ptr);
  if (w)
    *width = w;
  if (h)
    *height = h;
  free(tmp);
}


x86 assembly (clang, -O0):
<parse_label_dimensions>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
movl   $0x0,-0x20(%rbp)
mov    -0x8(%rbp),%rdi
call   1070 <strdup@plt>
mov    %rax,-0x30(%rbp)
cmp    $0x0,%rax
jne    118e <parse_label_dimensions+0x3e>
jmp    1246 <parse_label_dimensions+0xf6>
mov    -0x30(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rax
movsbl (%rax),%edi
call   1050 <tolower@plt>
mov    -0x28(%rbp),%rcx
mov    %al,(%rcx)
movsbl %al,%eax
cmp    $0x0,%eax
je     11c5 <parse_label_dimensions+0x75>
mov    -0x28(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x28(%rbp)
jmp    1196 <parse_label_dimensions+0x46>
mov    -0x30(%rbp),%rdi
mov    $0x78,%esi
call   1040 <strchr@plt>
mov    %rax,-0x28(%rbp)
cmp    $0x0,%rax
je     11f4 <parse_label_dimensions+0xa4>
mov    -0x28(%rbp),%rax
movb   $0x0,(%rax)
mov    -0x28(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x28(%rbp)
mov    -0x30(%rbp),%rdi
call   1060 <atoi@plt>
mov    %eax,-0x1c(%rbp)
cmpq   $0x0,-0x28(%rbp)
je     1217 <parse_label_dimensions+0xc7>
mov    -0x28(%rbp),%rdi
call   1060 <atoi@plt>
mov    %eax,-0x20(%rbp)
cmpl   $0x0,-0x1c(%rbp)
je     122a <parse_label_dimensions+0xda>
mov    -0x1c(%rbp),%ecx
mov    -0x10(%rbp),%rax
mov    %ecx,(%rax)
cmpl   $0x0,-0x20(%rbp)
je     123d <parse_label_dimensions+0xed>
mov    -0x20(%rbp),%ecx
mov    -0x18(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x30(%rbp),%rdi
call   1030 <free@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<parse_label_dimensions>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rdx,%r14
mov    %rsi,%r15
call   1070 <strdup@plt>
test   %rax,%rax
je     11e6 <parse_label_dimensions+0x96>
mov    %rax,%r13
mov    %rax,%rbx
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
movsbl (%rbx),%edi
call   1050 <tolower@plt>
mov    %al,(%rbx)
add    $0x1,%rbx
test   %al,%al
jne    1180 <parse_label_dimensions+0x30>
mov    %r13,%rdi
mov    $0x78,%esi
call   1040 <strchr@plt>
test   %rax,%rax
je     11f5 <parse_label_dimensions+0xa5>
mov    %rax,%rbp
movb   $0x0,(%rax)
add    $0x1,%rbp
mov    %r13,%rdi
call   1060 <atoi@plt>
mov    %eax,%r12d
mov    %rbp,%rdi
call   1060 <atoi@plt>
test   %r12d,%r12d
je     11c9 <parse_label_dimensions+0x79>
mov    %r12d,(%r15)
test   %eax,%eax
je     11d0 <parse_label_dimensions+0x80>
mov    %eax,(%r14)
mov    %r13,%rdi
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <free@plt>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    %r13,%rdi
call   1060 <atoi@plt>
mov    %eax,%r12d
xor    %eax,%eax
test   %r12d,%r12d
jne    11c6 <parse_label_dimensions+0x76>
jmp    11c9 <parse_label_dimensions+0x79>

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

LLVM IR (-O2):
define void @parse_label_dimensions(i8* nocapture %0, i32* nocapture writeonly %1, i32* nocapture writeonly %2) {
%4 = tail call i8* @strdup(i8* %0)
%5 = icmp eq i8* %4, null
br i1 %5, label %31, label %6
6: ; preds = %3, %6
%7 = phi i8* [ %11, %6 ], [ %4, %3 ]
%8 = load i8, i8* %7
%9 = tail call signext i8 @tolower(i8 signext %8)
store i8 %9, i8* %7
%10 = icmp eq i8 %9, 0
%11 = getelementptr inbounds i8, i8* %7, i64 1
br i1 %10, label %12, label %6
12: ; preds = %6
%13 = tail call i8* @strchr(i8* %4, i8 signext 120)
%14 = icmp eq i8* %13, null
br i1 %14, label %15, label %17
15: ; preds = %12
%16 = tail call i32 @atoi(i8* %4)
br label %21
17: ; preds = %12
store i8 0, i8* %13
%18 = getelementptr inbounds i8, i8* %13, i64 1
%19 = tail call i32 @atoi(i8* %4)
%20 = tail call i32 @atoi(i8* %18)
br label %21
21: ; preds = %15, %17
%22 = phi i32 [ %19, %17 ], [ %16, %15 ]
%23 = phi i32 [ %20, %17 ], [ 0, %15 ]
%24 = icmp eq i32 %22, 0
br i1 %24, label %26, label %25
25: ; preds = %21
store i32 %22, i32* %1
br label %26
26: ; preds = %25, %21
%27 = icmp eq i32 %23, 0
br i1 %27, label %29, label %28
28: ; preds = %26
store i32 %23, i32* %2
br label %29
29: ; preds = %28, %26
%30 = tail call i32 @free(i8* %4)
br label %31
31: ; preds = %3, %29
ret void
}