#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 */
typedef int uint8_t;

/* Variables and functions */
uint8_t parse_print_flag(const char **rem, const char *str) {
  uint8_t flag = 0;
  if (*str == ':') {
    str++;
    flag = (1 << 0);
  }
  if (*str == ':') {
    str++;
    flag = (1 << 1);
  }
  if (rem)
    *rem = str;
  return flag;
}


x86 assembly (clang, -O0):
<parse_print_flag>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x3a,%eax
jne    1136 <parse_print_flag+0x36>
mov    -0x10(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x10(%rbp)
movl   $0x1,-0x14(%rbp)
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x3a,%eax
jne    1159 <parse_print_flag+0x59>
mov    -0x10(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x10(%rbp)
movl   $0x2,-0x14(%rbp)
cmpq   $0x0,-0x8(%rbp)
je     116f <parse_print_flag+0x6f>
mov    -0x10(%rbp),%rcx
mov    -0x8(%rbp),%rax
mov    %rcx,(%rax)
mov    -0x14(%rbp),%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<parse_print_flag>:
mov    (%rsi),%al
xor    %edx,%edx
cmp    $0x3a,%al
sete   %dl
mov    (%rsi,%rdx,1),%cl
test   %rdi,%rdi
je     1122 <parse_print_flag+0x22>
add    %rdx,%rsi
xor    %edx,%edx
cmp    $0x3a,%cl
sete   %dl
add    %rsi,%rdx
mov    %rdx,(%rdi)
xor    %edx,%edx
cmp    $0x3a,%al
sete   %dl
cmp    $0x3a,%cl
mov    $0x2,%eax
cmovne %edx,%eax
ret

LLVM IR (-O0):
define i32 @parse_print_flag(i8** %0, i8* %1) {
%3 = alloca i8**
%4 = alloca i8*
%5 = alloca i32
store i8** %0, i8*** %3
store i8* %1, i8** %4
store i32 0, i32* %5
%6 = load i8*, i8** %4
%7 = load i8, i8* %6
%8 = sext i8 %7 to i32
%9 = icmp eq i32 %8, 58
br i1 %9, label %10, label %13
10: ; preds = %2
%11 = load i8*, i8** %4
%12 = getelementptr inbounds i8, i8* %11, i32 1
store i8* %12, i8** %4
store i32 1, i32* %5
br label %13
13: ; preds = %10, %2
%14 = load i8*, i8** %4
%15 = load i8, i8* %14
%16 = sext i8 %15 to i32
%17 = icmp eq i32 %16, 58
br i1 %17, label %18, label %21
18: ; preds = %13
%19 = load i8*, i8** %4
%20 = getelementptr inbounds i8, i8* %19, i32 1
store i8* %20, i8** %4
store i32 2, i32* %5
br label %21
21: ; preds = %18, %13
%22 = load i8**, i8*** %3
%23 = icmp ne i8** %22, null
br i1 %23, label %24, label %27
24: ; preds = %21
%25 = load i8*, i8** %4
%26 = load i8**, i8*** %3
store i8* %25, i8** %26
br label %27
27: ; preds = %24, %21
%28 = load i32, i32* %5
ret i32 %28
}

LLVM IR (-O2):
define i32 @parse_print_flag(i8** writeonly %0, i8* %1) {
%3 = load i8, i8* %1
%4 = icmp eq i8 %3, 58
%5 = zext i1 %4 to i64
%6 = getelementptr i8, i8* %1, i64 %5
%7 = load i8, i8* %6
%8 = icmp eq i8 %7, 58
%9 = icmp eq i8** %0, null
br i1 %9, label %13, label %10
10: ; preds = %2
%11 = zext i1 %8 to i64
%12 = getelementptr i8, i8* %6, i64 %11
store i8* %12, i8** %0
br label %13
13: ; preds = %10, %2
%14 = zext i1 %4 to i32
%15 = select i1 %8, i32 2, i32 %14
ret i32 %15
}