#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 */
size_t count_digits(unsigned char const *, int, size_t);
int parse_number(unsigned char const *, int, int);
size_t dt_parse_iso_zone_basic(const char *str, size_t len, int *op) {
  const unsigned char *p;
  int o, h, m, sign;
  size_t n;
  if (len < 1)
    return 0;
  p = (const unsigned char *)str;
  switch (*p) {
  case 'Z':
    o = 0;
    n = 1;
    goto zulu;
  case '+':
    sign = 1;
    break;
  case '-':
    sign = -1;
    break;
  default:
    return 0;
  }
  if (len < 3)
    return 0;
  n = count_digits(p, 1, len);
  m = 0;
  switch (n) {
  case 2:
    h = parse_number(p, 1, 2);
    n = 3;
    break;
  case 4:
    h = parse_number(p, 1, 2);
    m = parse_number(p, 3, 2);
    n = 5;
    break;
  default:
    return 0;
  }
  if (h > 23 || m > 59)
    return 0;
  o = sign * (h * 60 + m);
zulu:
  if (op)
    *op = o;
  return n;
}


x86 assembly (clang, -O0):
<dt_parse_iso_zone_basic>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
cmpq   $0x1,-0x18(%rbp)
jae    114c <dt_parse_iso_zone_basic+0x2c>
movq   $0x0,-0x8(%rbp)
jmp    12dc <dt_parse_iso_zone_basic+0x1bc>
mov    -0x10(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rax
movzbl (%rax),%eax
mov    %eax,-0x44(%rbp)
sub    $0x2b,%eax
je     11a2 <dt_parse_iso_zone_basic+0x82>
jmp    116c <dt_parse_iso_zone_basic+0x4c>
mov    -0x44(%rbp),%eax
sub    $0x2d,%eax
je     11ae <dt_parse_iso_zone_basic+0x8e>
jmp    117d <dt_parse_iso_zone_basic+0x5d>
mov    -0x44(%rbp),%eax
sub    $0x5a,%eax
jne    11ba <dt_parse_iso_zone_basic+0x9a>
jmp    118e <dt_parse_iso_zone_basic+0x6e>
movl   $0x0,-0x2c(%rbp)
movq   $0x1,-0x40(%rbp)
jmp    12c0 <dt_parse_iso_zone_basic+0x1a0>
movl   $0x1,-0x38(%rbp)
jmp    11c7 <dt_parse_iso_zone_basic+0xa7>
movl   $0xffffffff,-0x38(%rbp)
jmp    11c7 <dt_parse_iso_zone_basic+0xa7>
movq   $0x0,-0x8(%rbp)
jmp    12dc <dt_parse_iso_zone_basic+0x1bc>
cmpq   $0x3,-0x18(%rbp)
jae    11df <dt_parse_iso_zone_basic+0xbf>
movq   $0x0,-0x8(%rbp)
jmp    12dc <dt_parse_iso_zone_basic+0x1bc>
mov    -0x28(%rbp),%rdi
mov    -0x18(%rbp),%rdx
mov    $0x1,%esi
call   1030 <count_digits@plt>
mov    %rax,-0x40(%rbp)
movl   $0x0,-0x34(%rbp)
mov    -0x40(%rbp),%rax
mov    %rax,-0x50(%rbp)
sub    $0x2,%rax
je     1226 <dt_parse_iso_zone_basic+0x106>
jmp    1213 <dt_parse_iso_zone_basic+0xf3>
mov    -0x50(%rbp),%rax
sub    $0x4,%rax
je     1249 <dt_parse_iso_zone_basic+0x129>
jmp    1282 <dt_parse_iso_zone_basic+0x162>
mov    -0x28(%rbp),%rdi
mov    $0x1,%esi
mov    $0x2,%edx
call   1040 <parse_number@plt>
mov    %eax,-0x30(%rbp)
movq   $0x3,-0x40(%rbp)
jmp    128f <dt_parse_iso_zone_basic+0x16f>
mov    -0x28(%rbp),%rdi
mov    $0x1,%esi
mov    $0x2,%edx
call   1040 <parse_number@plt>
mov    %eax,-0x30(%rbp)
mov    -0x28(%rbp),%rdi
mov    $0x3,%esi
mov    $0x2,%edx
call   1040 <parse_number@plt>
mov    %eax,-0x34(%rbp)
movq   $0x5,-0x40(%rbp)
jmp    128f <dt_parse_iso_zone_basic+0x16f>
movq   $0x0,-0x8(%rbp)
jmp    12dc <dt_parse_iso_zone_basic+0x1bc>
cmpl   $0x17,-0x30(%rbp)
jg     12a3 <dt_parse_iso_zone_basic+0x183>
cmpl   $0x3b,-0x34(%rbp)
jle    12b0 <dt_parse_iso_zone_basic+0x190>
movq   $0x0,-0x8(%rbp)
jmp    12dc <dt_parse_iso_zone_basic+0x1bc>
mov    -0x38(%rbp),%eax
imul   $0x3c,-0x30(%rbp),%ecx
add    -0x34(%rbp),%ecx
imul   %ecx,%eax
mov    %eax,-0x2c(%rbp)
cmpq   $0x0,-0x20(%rbp)
je     12d4 <dt_parse_iso_zone_basic+0x1b4>
mov    -0x2c(%rbp),%ecx
mov    -0x20(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x40(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<dt_parse_iso_zone_basic>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
xor    %eax,%eax
test   %rsi,%rsi
je     11ac <dt_parse_iso_zone_basic+0x8c>
mov    %rdx,%r14
mov    %rsi,%rdx
mov    %rdi,%rbx
mov    (%rdi),%cl
cmp    $0x2b,%cl
je     1156 <dt_parse_iso_zone_basic+0x36>
cmp    $0x5a,%cl
je     119c <dt_parse_iso_zone_basic+0x7c>
cmp    $0x2d,%cl
jne    11ac <dt_parse_iso_zone_basic+0x8c>
mov    $0xffffffff,%r15d
cmp    $0x3,%rdx
jb     1198 <dt_parse_iso_zone_basic+0x78>
jmp    1162 <dt_parse_iso_zone_basic+0x42>
mov    $0x1,%r15d
cmp    $0x3,%rdx
jb     1198 <dt_parse_iso_zone_basic+0x78>
mov    %rbx,%rdi
mov    $0x1,%esi
call   1030 <count_digits@plt>
cmp    $0x4,%rax
je     11b7 <dt_parse_iso_zone_basic+0x97>
cmp    $0x2,%rax
jne    1198 <dt_parse_iso_zone_basic+0x78>
mov    %rbx,%rdi
mov    $0x1,%esi
mov    $0x2,%edx
call   1040 <parse_number@plt>
mov    %eax,%ebp
mov    $0x3,%edx
xor    %ecx,%ecx
jmp    11e4 <dt_parse_iso_zone_basic+0xc4>
xor    %eax,%eax
jmp    11ac <dt_parse_iso_zone_basic+0x8c>
mov    $0x1,%edx
test   %r14,%r14
je     11a9 <dt_parse_iso_zone_basic+0x89>
mov    %eax,(%r14)
mov    %rdx,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret
mov    %rbx,%rdi
mov    $0x1,%esi
mov    $0x2,%edx
call   1040 <parse_number@plt>
mov    %eax,%ebp
mov    %rbx,%rdi
mov    $0x3,%esi
mov    $0x2,%edx
call   1040 <parse_number@plt>
mov    %eax,%ecx
mov    $0x5,%edx
xor    %eax,%eax
cmp    $0x17,%ebp
jg     11ac <dt_parse_iso_zone_basic+0x8c>
cmp    $0x3b,%ecx
jg     11ac <dt_parse_iso_zone_basic+0x8c>
imul   $0x3c,%ebp,%eax
add    %ecx,%eax
imul   %r15d,%eax
test   %r14,%r14
jne    11a6 <dt_parse_iso_zone_basic+0x86>
jmp    11a9 <dt_parse_iso_zone_basic+0x89>

LLVM IR (-O0):
define i64 @dt_parse_iso_zone_basic(i8* %0, i64 %1, i32* %2) {
%4 = alloca i64
%5 = alloca i8*
%6 = alloca i64
%7 = alloca i32*
%8 = alloca i8*
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32
%13 = alloca i64
store i8* %0, i8** %5
store i64 %1, i64* %6
store i32* %2, i32** %7
%14 = load i64, i64* %6
%15 = icmp ult i64 %14, 1
br i1 %15, label %16, label %17
16: ; preds = %3
store i64 0, i64* %4
br label %66
17: ; preds = %3
%18 = load i8*, i8** %5
store i8* %18, i8** %8
%19 = load i8*, i8** %8
%20 = load i8, i8* %19
%21 = zext i8 %20 to i32
switch i32 %21, label %25 [
i32 90, label %22
i32 43, label %23
i32 45, label %24
]
22: ; preds = %17
store i32 0, i32* %9
store i64 1, i64* %13
br label %58
23: ; preds = %17
store i32 1, i32* %12
br label %26
24: ; preds = %17
store i32 -1, i32* %12
br label %26
25: ; preds = %17
store i64 0, i64* %4
br label %66
26: ; preds = %24, %23
%27 = load i64, i64* %6
%28 = icmp ult i64 %27, 3
br i1 %28, label %29, label %30
29: ; preds = %26
store i64 0, i64* %4
br label %66
30: ; preds = %26
%31 = load i8*, i8** %8
%32 = load i64, i64* %6
%33 = call i64 @count_digits(i8* %31, i32 1, i64 %32)
store i64 %33, i64* %13
store i32 0, i32* %11
%34 = load i64, i64* %13
switch i64 %34, label %43 [
i64 2, label %35
i64 4, label %38
]
35: ; preds = %30
%36 = load i8*, i8** %8
%37 = call i32 @parse_number(i8* %36, i32 1, i32 2)
store i32 %37, i32* %10
store i64 3, i64* %13
br label %44
38: ; preds = %30
%39 = load i8*, i8** %8
%40 = call i32 @parse_number(i8* %39, i32 1, i32 2)
store i32 %40, i32* %10
%41 = load i8*, i8** %8
%42 = call i32 @parse_number(i8* %41, i32 3, i32 2)
store i32 %42, i32* %11
store i64 5, i64* %13
br label %44
43: ; preds = %30
store i64 0, i64* %4
br label %66
44: ; preds = %38, %35
%45 = load i32, i32* %10
%46 = icmp sgt i32 %45, 23
br i1 %46, label %50, label %47
47: ; preds = %44
%48 = load i32, i32* %11
%49 = icmp sgt i32 %48, 59
br i1 %49, label %50, label %51
50: ; preds = %47, %44
store i64 0, i64* %4
br label %66
51: ; preds = %47
%52 = load i32, i32* %12
%53 = load i32, i32* %10
%54 = mul nsw i32 %53, 60
%55 = load i32, i32* %11
%56 = add nsw i32 %54, %55
%57 = mul nsw i32 %52, %56
store i32 %57, i32* %9
br label %58
58: ; preds = %51, %22
%59 = load i32*, i32** %7
%60 = icmp ne i32* %59, null
br i1 %60, label %61, label %64
61: ; preds = %58
%62 = load i32, i32* %9
%63 = load i32*, i32** %7
store i32 %62, i32* %63
br label %64
64: ; preds = %61, %58
%65 = load i64, i64* %13
store i64 %65, i64* %4
br label %66
66: ; preds = %64, %50, %43, %29, %25, %16
%67 = load i64, i64* %4
ret i64 %67
}

LLVM IR (-O2):
define i64 @dt_parse_iso_zone_basic(i8* %0, i64 %1, i32* writeonly %2) {
%4 = icmp eq i64 %1, 0
br i1 %4, label %34, label %5
5: ; preds = %3
%6 = load i8, i8* %0
switch i8 %6, label %34 [
i8 90, label %29
i8 43, label %8
i8 45, label %7
]
7: ; preds = %5
br label %8
8: ; preds = %5, %7
%9 = phi i32 [ -1, %7 ], [ 1, %5 ]
%10 = icmp ult i64 %1, 3
br i1 %10, label %34, label %11
11: ; preds = %8
%12 = tail call i64 @count_digits(i8* %0, i32 1, i64 %1)
switch i64 %12, label %34 [
i64 2, label %13
i64 4, label %15
]
13: ; preds = %11
%14 = tail call i32 @parse_number(i8* %0, i32 1, i32 2)
br label %18
15: ; preds = %11
%16 = tail call i32 @parse_number(i8* %0, i32 1, i32 2)
%17 = tail call i32 @parse_number(i8* %0, i32 3, i32 2)
br label %18
18: ; preds = %15, %13
%19 = phi i32 [ %16, %15 ], [ %14, %13 ]
%20 = phi i32 [ %17, %15 ], [ 0, %13 ]
%21 = phi i64 [ 5, %15 ], [ 3, %13 ]
%22 = icmp sgt i32 %19, 23
%23 = icmp sgt i32 %20, 59
%24 = select i1 %22, i1 true, i1 %23
br i1 %24, label %34, label %25
25: ; preds = %18
%26 = mul nsw i32 %19, 60
%27 = add nsw i32 %26, %20
%28 = mul nsw i32 %27, %9
br label %29
29: ; preds = %5, %25
%30 = phi i32 [ %28, %25 ], [ 0, %5 ]
%31 = phi i64 [ %21, %25 ], [ 1, %5 ]
%32 = icmp eq i32* %2, null
br i1 %32, label %34, label %33
33: ; preds = %29
store i32 %30, i32* %2
br label %34
34: ; preds = %29, %33, %18, %11, %8, %5, %3
%35 = phi i64 [ 0, %3 ], [ 0, %5 ], [ 0, %8 ], [ 0, %11 ], [ 0, %18 ], [ %31, %33 ], [ %31, %29 ]
ret i64 %35
}