#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__ get_integer(int *, char *, int /*<<< orphan*/);
scalar_t__ get_rate(unsigned int *, char *);
char *strchr(char *, char);
int get_rate_and_cell(unsigned *rate, int *cell_log, char *str) {
  char *slash = strchr(str, '/');
  if (slash)
    *slash = 0;
  if (get_rate(rate, str))
    return -1;
  if (slash) {
    int cell;
    int i;
    if (get_integer(&cell, slash + 1, 0))
      return -1;
    *slash = '/';
    for (i = 0; i < 32; i++) {
      if ((1 << i) == cell) {
        *cell_log = i;
        return 0;
      }
    }
    return -1;
  }
  return 0;
}


x86 assembly (clang, -O0):
<get_rate_and_cell>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    -0x20(%rbp),%rdi
mov    $0x2f,%esi
call   1050 <strchr@plt>
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
je     1168 <get_rate_and_cell+0x38>
mov    -0x28(%rbp),%rax
movb   $0x0,(%rax)
mov    -0x10(%rbp),%rdi
mov    -0x20(%rbp),%rsi
call   1030 <get_rate@plt>
cmp    $0x0,%rax
je     118b <get_rate_and_cell+0x5b>
movl   $0xffffffff,-0x4(%rbp)
jmp    1225 <get_rate_and_cell+0xf5>
cmpq   $0x0,-0x28(%rbp)
je     121e <get_rate_and_cell+0xee>
mov    -0x28(%rbp),%rsi
add    $0x1,%rsi
lea    -0x2c(%rbp),%rdi
xor    %edx,%edx
call   1040 <get_integer@plt>
cmp    $0x0,%rax
je     11bf <get_rate_and_cell+0x8f>
movl   $0xffffffff,-0x4(%rbp)
jmp    1225 <get_rate_and_cell+0xf5>
mov    -0x28(%rbp),%rax
movb   $0x2f,(%rax)
movl   $0x0,-0x30(%rbp)
cmpl   $0x20,-0x30(%rbp)
jge    1212 <get_rate_and_cell+0xe2>
mov    -0x30(%rbp),%ecx
mov    $0x1,%eax
shl    %cl,%eax
cmp    -0x2c(%rbp),%eax
jne    11ff <get_rate_and_cell+0xcf>
mov    -0x30(%rbp),%ecx
mov    -0x18(%rbp),%rax
mov    %ecx,(%rax)
movl   $0x0,-0x4(%rbp)
jmp    1225 <get_rate_and_cell+0xf5>
jmp    1204 <get_rate_and_cell+0xd4>
mov    -0x30(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x30(%rbp)
jmp    11cd <get_rate_and_cell+0x9d>
movl   $0xffffffff,-0x4(%rbp)
jmp    1225 <get_rate_and_cell+0xf5>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_rate_and_cell>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    %rdx,%rbx
mov    %rsi,%r14
mov    %rdi,%r12
mov    %rdx,%rdi
mov    $0x2f,%esi
call   1050 <strchr@plt>
mov    %rax,%r15
test   %rax,%rax
je     115a <get_rate_and_cell+0x2a>
movb   $0x0,(%r15)
mov    %r12,%rdi
mov    %rbx,%rsi
call   1030 <get_rate@plt>
mov    %rax,%rcx
xor    %eax,%eax
test   %rcx,%rcx
setne  %al
neg    %eax
test   %rcx,%rcx
jne    147e <get_rate_and_cell+0x34e>
test   %r15,%r15
je     147e <get_rate_and_cell+0x34e>
mov    %r15,%rsi
add    $0x1,%rsi
lea    0x4(%rsp),%rdi
xor    %ebx,%ebx
xor    %edx,%edx
call   1040 <get_integer@plt>
mov    %rax,%rcx
mov    $0xffffffff,%eax
test   %rcx,%rcx
jne    147e <get_rate_and_cell+0x34e>
movb   $0x2f,(%r15)
mov    0x4(%rsp),%ecx
cmp    $0x7fff,%ecx
jg     11e5 <get_rate_and_cell+0xb5>
cmp    $0x7f,%ecx
jg     1227 <get_rate_and_cell+0xf7>
lea    -0x1(%rcx),%edx
cmp    $0x3f,%edx
ja     13f1 <get_rate_and_cell+0x2c1>
lea    0xe2e(%rip),%rcx
movslq (%rcx,%rdx,4),%rdx
add    %rcx,%rdx
jmp    *%rdx
mov    $0x1,%ebx
jmp    1479 <get_rate_and_cell+0x349>
cmp    $0x7fffff,%ecx
jg     1261 <get_rate_and_cell+0x131>
cmp    $0x7ffff,%ecx
jg     129b <get_rate_and_cell+0x16b>
cmp    $0x1ffff,%ecx
jg     1325 <get_rate_and_cell+0x1f5>
cmp    $0x8000,%ecx
je     1427 <get_rate_and_cell+0x2f7>
cmp    $0x10000,%ecx
jne    147e <get_rate_and_cell+0x34e>
mov    $0x10,%ebx
jmp    1479 <get_rate_and_cell+0x349>
cmp    $0x7ff,%ecx
jg     12c9 <get_rate_and_cell+0x199>
cmp    $0x1ff,%ecx
jg     1347 <get_rate_and_cell+0x217>
cmp    $0x80,%ecx
je     142e <get_rate_and_cell+0x2fe>
cmp    $0x100,%ecx
jne    147e <get_rate_and_cell+0x34e>
mov    $0x8,%ebx
jmp    1479 <get_rate_and_cell+0x349>
cmp    $0x7ffffff,%ecx
jg     12f7 <get_rate_and_cell+0x1c7>
cmp    $0x1ffffff,%ecx
jg     1369 <get_rate_and_cell+0x239>
cmp    $0x800000,%ecx
je     1435 <get_rate_and_cell+0x305>
cmp    $0x1000000,%ecx
jne    147e <get_rate_and_cell+0x34e>
mov    $0x18,%ebx
jmp    1479 <get_rate_and_cell+0x349>
cmp    $0x1fffff,%ecx
jg     138b <get_rate_and_cell+0x25b>
cmp    $0x80000,%ecx
je     143c <get_rate_and_cell+0x30c>
cmp    $0x100000,%ecx
jne    147e <get_rate_and_cell+0x34e>
mov    $0x14,%ebx
jmp    1479 <get_rate_and_cell+0x349>
cmp    $0x1fff,%ecx
jg     13ad <get_rate_and_cell+0x27d>
cmp    $0x800,%ecx
je     1443 <get_rate_and_cell+0x313>
cmp    $0x1000,%ecx
jne    147e <get_rate_and_cell+0x34e>
mov    $0xc,%ebx
jmp    1479 <get_rate_and_cell+0x349>
cmp    $0x1fffffff,%ecx
jg     13cf <get_rate_and_cell+0x29f>
cmp    $0x8000000,%ecx
je     144a <get_rate_and_cell+0x31a>
cmp    $0x10000000,%ecx
jne    147e <get_rate_and_cell+0x34e>
mov    $0x1c,%ebx
jmp    1479 <get_rate_and_cell+0x349>
cmp    $0x20000,%ecx
je     1451 <get_rate_and_cell+0x321>
cmp    $0x40000,%ecx
jne    147e <get_rate_and_cell+0x34e>
mov    $0x12,%ebx
jmp    1479 <get_rate_and_cell+0x349>
cmp    $0x200,%ecx
je     1458 <get_rate_and_cell+0x328>
cmp    $0x400,%ecx
jne    147e <get_rate_and_cell+0x34e>
mov    $0xa,%ebx
jmp    1479 <get_rate_and_cell+0x349>
cmp    $0x2000000,%ecx
je     145f <get_rate_and_cell+0x32f>
cmp    $0x4000000,%ecx
jne    147e <get_rate_and_cell+0x34e>
mov    $0x1a,%ebx
jmp    1479 <get_rate_and_cell+0x349>
cmp    $0x200000,%ecx
je     1466 <get_rate_and_cell+0x336>
cmp    $0x400000,%ecx
jne    147e <get_rate_and_cell+0x34e>
mov    $0x16,%ebx
jmp    1479 <get_rate_and_cell+0x349>
cmp    $0x2000,%ecx
je     146d <get_rate_and_cell+0x33d>
cmp    $0x4000,%ecx
jne    147e <get_rate_and_cell+0x34e>
mov    $0xe,%ebx
jmp    1479 <get_rate_and_cell+0x349>
cmp    $0x20000000,%ecx
je     1474 <get_rate_and_cell+0x344>
cmp    $0x40000000,%ecx
jne    147e <get_rate_and_cell+0x34e>
mov    $0x1e,%ebx
jmp    1479 <get_rate_and_cell+0x349>
cmp    $0x80000000,%ecx
jne    147e <get_rate_and_cell+0x34e>
mov    $0x1f,%ebx
jmp    1479 <get_rate_and_cell+0x349>
mov    $0x2,%ebx
jmp    1479 <get_rate_and_cell+0x349>
mov    $0x3,%ebx
jmp    1479 <get_rate_and_cell+0x349>
mov    $0x4,%ebx
jmp    1479 <get_rate_and_cell+0x349>
mov    $0x5,%ebx
jmp    1479 <get_rate_and_cell+0x349>
mov    $0x6,%ebx
jmp    1479 <get_rate_and_cell+0x349>
mov    $0xf,%ebx
jmp    1479 <get_rate_and_cell+0x349>
mov    $0x7,%ebx
jmp    1479 <get_rate_and_cell+0x349>
mov    $0x17,%ebx
jmp    1479 <get_rate_and_cell+0x349>
mov    $0x13,%ebx
jmp    1479 <get_rate_and_cell+0x349>
mov    $0xb,%ebx
jmp    1479 <get_rate_and_cell+0x349>
mov    $0x1b,%ebx
jmp    1479 <get_rate_and_cell+0x349>
mov    $0x11,%ebx
jmp    1479 <get_rate_and_cell+0x349>
mov    $0x9,%ebx
jmp    1479 <get_rate_and_cell+0x349>
mov    $0x19,%ebx
jmp    1479 <get_rate_and_cell+0x349>
mov    $0x15,%ebx
jmp    1479 <get_rate_and_cell+0x349>
mov    $0xd,%ebx
jmp    1479 <get_rate_and_cell+0x349>
mov    $0x1d,%ebx
mov    %ebx,(%r14)
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define i32 @get_rate_and_cell(i32* %0, i32* %1, i8* %2) {
%4 = alloca i32
%5 = alloca i32*
%6 = alloca i32*
%7 = alloca i8*
%8 = alloca i8*
%9 = alloca i32
%10 = alloca i32
store i32* %0, i32** %5
store i32* %1, i32** %6
store i8* %2, i8** %7
%11 = load i8*, i8** %7
%12 = call i8* @strchr(i8* %11, i8 signext 47)
store i8* %12, i8** %8
%13 = load i8*, i8** %8
%14 = icmp ne i8* %13, null
br i1 %14, label %15, label %17
15: ; preds = %3
%16 = load i8*, i8** %8
store i8 0, i8* %16
br label %17
17: ; preds = %15, %3
%18 = load i32*, i32** %5
%19 = load i8*, i8** %7
%20 = call i64 @get_rate(i32* %18, i8* %19)
%21 = icmp ne i64 %20, 0
br i1 %21, label %22, label %23
22: ; preds = %17
store i32 -1, i32* %4
br label %51
23: ; preds = %17
%24 = load i8*, i8** %8
%25 = icmp ne i8* %24, null
br i1 %25, label %26, label %50
26: ; preds = %23
%27 = load i8*, i8** %8
%28 = getelementptr inbounds i8, i8* %27, i64 1
%29 = call i64 @get_integer(i32* %9, i8* %28, i32 0)
%30 = icmp ne i64 %29, 0
br i1 %30, label %31, label %32
31: ; preds = %26
store i32 -1, i32* %4
br label %51
32: ; preds = %26
%33 = load i8*, i8** %8
store i8 47, i8* %33
store i32 0, i32* %10
br label %34
34: ; preds = %46, %32
%35 = load i32, i32* %10
%36 = icmp slt i32 %35, 32
br i1 %36, label %37, label %49
37: ; preds = %34
%38 = load i32, i32* %10
%39 = shl i32 1, %38
%40 = load i32, i32* %9
%41 = icmp eq i32 %39, %40
br i1 %41, label %42, label %45
42: ; preds = %37
%43 = load i32, i32* %10
%44 = load i32*, i32** %6
store i32 %43, i32* %44
store i32 0, i32* %4
br label %51
45: ; preds = %37
br label %46
46: ; preds = %45
%47 = load i32, i32* %10
%48 = add nsw i32 %47, 1
store i32 %48, i32* %10
br label %34
49: ; preds = %34
store i32 -1, i32* %4
br label %51
50: ; preds = %23
store i32 0, i32* %4
br label %51
51: ; preds = %50, %49, %42, %31, %22
%52 = load i32, i32* %4
ret i32 %52
}

LLVM IR (-O2):
define i32 @get_rate_and_cell(i32* %0, i32* nocapture writeonly %1, i8* %2) {
%4 = alloca i32
%5 = tail call i8* @strchr(i8* dereferenceable(1) %2, i8 signext 47)
%6 = icmp eq i8* %5, null
br i1 %6, label %8, label %7
7: ; preds = %3
store i8 0, i8* %5
br label %8
8: ; preds = %7, %3
%9 = tail call i64 @get_rate(i32* %0, i8* %2)
%10 = icmp ne i64 %9, 0
%11 = select i1 %10, i1 true, i1 %6
%12 = sext i1 %10 to i32
br i1 %11, label %55, label %13
13: ; preds = %8
%14 = bitcast i32* %4 to i8*
%15 = getelementptr inbounds i8, i8* %5, i64 1
%16 = call i64 @get_integer(i32* %4, i8* %15, i32 0)
%17 = icmp eq i64 %16, 0
br i1 %17, label %18, label %53
18: ; preds = %13
store i8 47, i8* %5
%19 = load i32, i32* %4
switch i32 %19, label %53 [
i32 1, label %51
i32 2, label %20
i32 4, label %21
i32 8, label %22
i32 16, label %23
i32 32, label %24
i32 64, label %25
i32 128, label %26
i32 256, label %27
i32 512, label %28
i32 1024, label %29
i32 2048, label %30
i32 4096, label %31
i32 8192, label %32
i32 16384, label %33
i32 32768, label %34
i32 65536, label %35
i32 131072, label %36
i32 262144, label %37
i32 524288, label %38
i32 1048576, label %39
i32 2097152, label %40
i32 4194304, label %41
i32 8388608, label %42
i32 16777216, label %43
i32 33554432, label %44
i32 67108864, label %45
i32 134217728, label %46
i32 268435456, label %47
i32 536870912, label %48
i32 1073741824, label %49
i32 -2147483648, label %50
]
20: ; preds = %18
br label %51
21: ; preds = %18
br label %51
22: ; preds = %18
br label %51
23: ; preds = %18
br label %51
24: ; preds = %18
br label %51
25: ; preds = %18
br label %51
26: ; preds = %18
br label %51
27: ; preds = %18
br label %51
28: ; preds = %18
br label %51
29: ; preds = %18
br label %51
30: ; preds = %18
br label %51
31: ; preds = %18
br label %51
32: ; preds = %18
br label %51
33: ; preds = %18
br label %51
34: ; preds = %18
br label %51
35: ; preds = %18
br label %51
36: ; preds = %18
br label %51
37: ; preds = %18
br label %51
38: ; preds = %18
br label %51
39: ; preds = %18
br label %51
40: ; preds = %18
br label %51
41: ; preds = %18
br label %51
42: ; preds = %18
br label %51
43: ; preds = %18
br label %51
44: ; preds = %18
br label %51
45: ; preds = %18
br label %51
46: ; preds = %18
br label %51
47: ; preds = %18
br label %51
48: ; preds = %18
br label %51
49: ; preds = %18
br label %51
50: ; preds = %18
br label %51
51: ; preds = %18, %50, %49, %48, %47, %46, %45, %44, %43, %42, %41, %40, %39, %38, %37, %36, %35, %34, %33, %32, %31, %30, %29, %28, %27, %26, %25, %24, %23, %22, %21, %20
%52 = phi i32 [ 0, %18 ], [ 1, %20 ], [ 2, %21 ], [ 3, %22 ], [ 4, %23 ], [ 5, %24 ], [ 6, %25 ], [ 7, %26 ], [ 8, %27 ], [ 9, %28 ], [ 10, %29 ], [ 11, %30 ], [ 12, %31 ], [ 13, %32 ], [ 14, %33 ], [ 15, %34 ], [ 16, %35 ], [ 17, %36 ], [ 18, %37 ], [ 19, %38 ], [ 20, %39 ], [ 21, %40 ], [ 22, %41 ], [ 23, %42 ], [ 24, %43 ], [ 25, %44 ], [ 26, %45 ], [ 27, %46 ], [ 28, %47 ], [ 29, %48 ], [ 30, %49 ], [ 31, %50 ]
store i32 %52, i32* %1
br label %53
53: ; preds = %18, %13, %51
%54 = phi i32 [ 0, %51 ], [ -1, %13 ], [ -1, %18 ]
br label %55
55: ; preds = %8, %53
%56 = phi i32 [ %54, %53 ], [ %12, %8 ]
ret i32 %56
}