#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 */
unsigned int fiolSReadUInt(char const *, unsigned int *);
unsigned int fiolSReadInt(const char *src, signed int *dst) {
  unsigned int length = 0;
  switch (src[0]) {
  case '-':
    length = fiolSReadUInt(src + 1, (unsigned int *)dst) + 1;
    (*dst) *= -1;
    break;
  case '+':
    length = fiolSReadUInt(src + 1, (unsigned int *)dst) + 1;
    break;
  default:
    length = fiolSReadUInt(src, (unsigned int *)dst);
    break;
  }
  return length;
}


x86 assembly (clang, -O0):
<fiolSReadInt>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
mov    -0x8(%rbp),%rax
movsbl (%rax),%eax
mov    %eax,-0x18(%rbp)
sub    $0x2b,%eax
je     1175 <fiolSReadInt+0x65>
jmp    113f <fiolSReadInt+0x2f>
mov    -0x18(%rbp),%eax
sub    $0x2d,%eax
jne    1191 <fiolSReadInt+0x81>
jmp    1150 <fiolSReadInt+0x40>
mov    -0x8(%rbp),%rdi
add    $0x1,%rdi
mov    -0x10(%rbp),%rsi
call   1030 <fiolSReadUInt@plt>
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
mov    -0x10(%rbp),%rax
imul   $0xffffffff,(%rax),%ecx
mov    %ecx,(%rax)
jmp    11a1 <fiolSReadInt+0x91>
mov    -0x8(%rbp),%rdi
add    $0x1,%rdi
mov    -0x10(%rbp),%rsi
call   1030 <fiolSReadUInt@plt>
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    11a1 <fiolSReadInt+0x91>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1030 <fiolSReadUInt@plt>
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<fiolSReadInt>:
push   %rbx
mov    %rsi,%rbx
movsbl (%rdi),%eax
cmp    $0x2b,%eax
je     1134 <fiolSReadInt+0x24>
cmp    $0x2d,%eax
jne    1145 <fiolSReadInt+0x35>
add    $0x1,%rdi
mov    %rbx,%rsi
call   1030 <fiolSReadUInt@plt>
add    $0x1,%eax
negl   (%rbx)
pop    %rbx
ret
add    $0x1,%rdi
mov    %rbx,%rsi
call   1030 <fiolSReadUInt@plt>
add    $0x1,%eax
pop    %rbx
ret
mov    %rbx,%rsi
pop    %rbx
jmp    1030 <fiolSReadUInt@plt>

LLVM IR (-O0):
define i32 @fiolSReadInt(i8* %0, i32* %1) {
%3 = alloca i8*
%4 = alloca i32*
%5 = alloca i32
store i8* %0, i8** %3
store i32* %1, i32** %4
store i32 0, i32* %5
%6 = load i8*, i8** %3
%7 = getelementptr inbounds i8, i8* %6, i64 0
%8 = load i8, i8* %7
%9 = sext i8 %8 to i32
switch i32 %9, label %25 [
i32 45, label %10
i32 43, label %19
]
10: ; preds = %2
%11 = load i8*, i8** %3
%12 = getelementptr inbounds i8, i8* %11, i64 1
%13 = load i32*, i32** %4
%14 = call i32 @fiolSReadUInt(i8* %12, i32* %13)
%15 = add i32 %14, 1
store i32 %15, i32* %5
%16 = load i32*, i32** %4
%17 = load i32, i32* %16
%18 = mul nsw i32 %17, -1
store i32 %18, i32* %16
br label %29
19: ; preds = %2
%20 = load i8*, i8** %3
%21 = getelementptr inbounds i8, i8* %20, i64 1
%22 = load i32*, i32** %4
%23 = call i32 @fiolSReadUInt(i8* %21, i32* %22)
%24 = add i32 %23, 1
store i32 %24, i32* %5
br label %29
25: ; preds = %2
%26 = load i8*, i8** %3
%27 = load i32*, i32** %4
%28 = call i32 @fiolSReadUInt(i8* %26, i32* %27)
store i32 %28, i32* %5
br label %29
29: ; preds = %25, %19, %10
%30 = load i32, i32* %5
ret i32 %30
}

LLVM IR (-O2):
define i32 @fiolSReadInt(i8* %0, i32* %1) {
%3 = load i8, i8* %0
%4 = sext i8 %3 to i32
switch i32 %4, label %15 [
i32 45, label %5
i32 43, label %11
]
5: ; preds = %2
%6 = getelementptr inbounds i8, i8* %0, i64 1
%7 = tail call i32 @fiolSReadUInt(i8* %6, i32* %1)
%8 = add i32 %7, 1
%9 = load i32, i32* %1
%10 = sub nsw i32 0, %9
store i32 %10, i32* %1
br label %17
11: ; preds = %2
%12 = getelementptr inbounds i8, i8* %0, i64 1
%13 = tail call i32 @fiolSReadUInt(i8* %12, i32* %1)
%14 = add i32 %13, 1
br label %17
15: ; preds = %2
%16 = tail call i32 @fiolSReadUInt(i8* %0, i32* %1)
br label %17
17: ; preds = %15, %11, %5
%18 = phi i32 [ %16, %15 ], [ %14, %11 ], [ %8, %5 ]
ret i32 %18
}