#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 */
struct frozen {
  int dummy;
};

/* Variables and functions */
int parse_key(struct frozen *);
int parse_value(struct frozen *);
int test_and_skip(struct frozen *, char);
int parse_pair(struct frozen *f) {
  do {
    int _n = parse_key(f);
    if (_n < 0)
      return _n;
  } while (0);
  do {
    int _n = test_and_skip(f, ':');
    if (_n < 0)
      return _n;
  } while (0);
  do {
    int _n = parse_value(f);
    if (_n < 0)
      return _n;
  } while (0);
  return 0;
}


x86 assembly (clang, -O0):
<parse_pair>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
call   1050 <parse_key@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0x0,-0x14(%rbp)
jge    115d <parse_pair+0x2d>
mov    -0x14(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    11c4 <parse_pair+0x94>
jmp    1162 <parse_pair+0x32>
jmp    1167 <parse_pair+0x37>
mov    -0x10(%rbp),%rdi
mov    $0x3a,%esi
call   1040 <test_and_skip@plt>
mov    %eax,-0x18(%rbp)
cmpl   $0x0,-0x18(%rbp)
jge    118d <parse_pair+0x5d>
mov    -0x18(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    11c4 <parse_pair+0x94>
jmp    1192 <parse_pair+0x62>
jmp    1197 <parse_pair+0x67>
mov    -0x10(%rbp),%rdi
call   1030 <parse_value@plt>
mov    %eax,-0x1c(%rbp)
cmpl   $0x0,-0x1c(%rbp)
jge    11b8 <parse_pair+0x88>
mov    -0x1c(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    11c4 <parse_pair+0x94>
jmp    11bd <parse_pair+0x8d>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<parse_pair>:
push   %rbx
mov    %rdi,%rbx
call   1050 <parse_key@plt>
test   %eax,%eax
js     115d <parse_pair+0x2d>
mov    %rbx,%rdi
mov    $0x3a,%esi
call   1040 <test_and_skip@plt>
test   %eax,%eax
js     115d <parse_pair+0x2d>
mov    %rbx,%rdi
call   1030 <parse_value@plt>
mov    %eax,%ecx
sar    $0x1f,%eax
and    %ecx,%eax
pop    %rbx
ret

LLVM IR (-O0):
%struct.frozen = type { i32 }
define i32 @parse_pair(%struct.frozen* %0) {
%2 = alloca i32
%3 = alloca %struct.frozen*
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
store %struct.frozen* %0, %struct.frozen** %3
br label %7
7: ; preds = %1
%8 = load %struct.frozen*, %struct.frozen** %3
%9 = call i32 @parse_key(%struct.frozen* %8)
store i32 %9, i32* %4
%10 = load i32, i32* %4
%11 = icmp slt i32 %10, 0
br i1 %11, label %12, label %14
12: ; preds = %7
%13 = load i32, i32* %4
store i32 %13, i32* %2
br label %34
14: ; preds = %7
br label %15
15: ; preds = %14
br label %16
16: ; preds = %15
%17 = load %struct.frozen*, %struct.frozen** %3
%18 = call i32 @test_and_skip(%struct.frozen* %17, i8 signext 58)
store i32 %18, i32* %5
%19 = load i32, i32* %5
%20 = icmp slt i32 %19, 0
br i1 %20, label %21, label %23
21: ; preds = %16
%22 = load i32, i32* %5
store i32 %22, i32* %2
br label %34
23: ; preds = %16
br label %24
24: ; preds = %23
br label %25
25: ; preds = %24
%26 = load %struct.frozen*, %struct.frozen** %3
%27 = call i32 @parse_value(%struct.frozen* %26)
store i32 %27, i32* %6
%28 = load i32, i32* %6
%29 = icmp slt i32 %28, 0
br i1 %29, label %30, label %32
30: ; preds = %25
%31 = load i32, i32* %6
store i32 %31, i32* %2
br label %34
32: ; preds = %25
br label %33
33: ; preds = %32
store i32 0, i32* %2
br label %34
34: ; preds = %33, %30, %21, %12
%35 = load i32, i32* %2
ret i32 %35
}

LLVM IR (-O2):
%struct.frozen = type { i32 }
define i32 @parse_pair(%struct.frozen* %0) {
%2 = tail call i32 @parse_key(%struct.frozen* %0)
%3 = icmp sgt i32 %2, -1
br i1 %3, label %4, label %11
4: ; preds = %1
%5 = tail call i32 @test_and_skip(%struct.frozen* %0, i8 signext 58)
%6 = icmp slt i32 %5, 0
br i1 %6, label %11, label %7
7: ; preds = %4
%8 = tail call i32 @parse_value(%struct.frozen* %0)
%9 = icmp slt i32 %8, 0
%10 = select i1 %9, i32 %8, i32 0
br label %11
11: ; preds = %7, %4, %1
%12 = phi i32 [ %2, %1 ], [ %5, %4 ], [ %10, %7 ]
ret i32 %12
}