#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__ myisdigit(char);
int get_color(const char *string, int *num) {
  char c1 = string[0];
  if (myisdigit(c1)) {
    char c2 = string[1];
    if (myisdigit(c2)) {
      *num = (c1 - '0') * 10 + (c2 - '0');
      return 2;
    }
    *num = c1 - '0';
    return 1;
  }
  return 0;
}


x86 assembly (clang, -O0):
<get_color>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    -0x10(%rbp),%rax
mov    (%rax),%al
mov    %al,-0x19(%rbp)
movsbl -0x19(%rbp),%edi
call   1030 <myisdigit@plt>
cmp    $0x0,%rax
je     1197 <get_color+0x87>
mov    -0x10(%rbp),%rax
mov    0x1(%rax),%al
mov    %al,-0x1a(%rbp)
movsbl -0x1a(%rbp),%edi
call   1030 <myisdigit@plt>
cmp    $0x0,%rax
je     117e <get_color+0x6e>
movsbl -0x19(%rbp),%eax
sub    $0x30,%eax
imul   $0xa,%eax,%ecx
movsbl -0x1a(%rbp),%eax
sub    $0x30,%eax
add    %eax,%ecx
mov    -0x18(%rbp),%rax
mov    %ecx,(%rax)
movl   $0x2,-0x4(%rbp)
jmp    119e <get_color+0x8e>
movsbl -0x19(%rbp),%ecx
sub    $0x30,%ecx
mov    -0x18(%rbp),%rax
mov    %ecx,(%rax)
movl   $0x1,-0x4(%rbp)
jmp    119e <get_color+0x8e>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_color>:
push   %r15
push   %r14
push   %rbx
mov    %rsi,%r14
mov    %rdi,%rbx
movsbl (%rdi),%r15d
mov    %r15d,%edi
call   1030 <myisdigit@plt>
test   %rax,%rax
je     115d <get_color+0x4d>
movsbl 0x1(%rbx),%ebx
mov    %ebx,%edi
call   1030 <myisdigit@plt>
lea    -0x30(%r15),%ecx
xor    %edx,%edx
test   %rax,%rax
lea    (%r15,%r15,4),%eax
lea    -0x210(%rbx,%rax,2),%esi
cmove  %ecx,%esi
sete   %dl
mov    $0x2,%eax
sub    %edx,%eax
mov    %esi,(%r14)
jmp    115f <get_color+0x4f>
xor    %eax,%eax
pop    %rbx
pop    %r14
pop    %r15
ret

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

LLVM IR (-O2):
define i32 @get_color(i8* nocapture %0, i32* nocapture writeonly %1) {
%3 = load i8, i8* %0
%4 = tail call i64 @myisdigit(i8 signext %3)
%5 = icmp eq i64 %4, 0
br i1 %5, label %19, label %6
6: ; preds = %2
%7 = getelementptr inbounds i8, i8* %0, i64 1
%8 = load i8, i8* %7
%9 = tail call i64 @myisdigit(i8 signext %8)
%10 = icmp eq i64 %9, 0
%11 = sext i8 %3 to i32
%12 = add nsw i32 %11, -48
%13 = mul nsw i32 %11, 10
%14 = sext i8 %8 to i32
%15 = add nsw i32 %13, -528
%16 = add nsw i32 %15, %14
%17 = select i1 %10, i32 %12, i32 %16
%18 = select i1 %10, i32 1, i32 2
store i32 %17, i32* %1
br label %19
19: ; preds = %2, %6
%20 = phi i32 [ %18, %6 ], [ 0, %2 ]
ret i32 %20
}