#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 */
int my_getnbr_add(char *, int, int, int);
int my_getnbr_parse(char *, int *, int *, int *);
int my_getnbr(char *str) {
  int sign;
  int nb_start;
  int nb_end;
  int n;
  int l;
  if (str[0] == '\0') {
    return (0);
  }
  sign = 1;
  nb_start = -1;
  nb_end = -1;
  l = my_getnbr_parse(str, &nb_start, &nb_end, &sign);
  if (nb_start != -1 && nb_end == -1) {
    nb_end = l;
  }
  if (nb_end - nb_start > 10) {
    return (0);
  }
  n = my_getnbr_add(str, nb_start, nb_end, sign);
  return (n);
}


x86 assembly (clang, -O0):
<my_getnbr>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
jne    1148 <my_getnbr+0x28>
movl   $0x0,-0x4(%rbp)
jmp    11c5 <my_getnbr+0xa5>
movl   $0x1,-0x14(%rbp)
movl   $0xffffffff,-0x18(%rbp)
movl   $0xffffffff,-0x1c(%rbp)
mov    -0x10(%rbp),%rdi
lea    -0x18(%rbp),%rsi
lea    -0x1c(%rbp),%rdx
lea    -0x14(%rbp),%rcx
call   1040 <my_getnbr_parse@plt>
mov    %eax,-0x24(%rbp)
cmpl   $0xffffffff,-0x18(%rbp)
je     118f <my_getnbr+0x6f>
cmpl   $0xffffffff,-0x1c(%rbp)
jne    118f <my_getnbr+0x6f>
mov    -0x24(%rbp),%eax
mov    %eax,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
sub    -0x18(%rbp),%eax
cmp    $0xa,%eax
jle    11aa <my_getnbr+0x8a>
movl   $0x0,-0x4(%rbp)
jmp    11c5 <my_getnbr+0xa5>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%esi
mov    -0x1c(%rbp),%edx
mov    -0x14(%rbp),%ecx
call   1030 <my_getnbr_add@plt>
mov    %eax,-0x20(%rbp)
mov    -0x20(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<my_getnbr>:
push   %rbp
push   %rbx
sub    $0x18,%rsp
xor    %ebp,%ebp
cmpb   $0x0,(%rdi)
je     118b <my_getnbr+0x6b>
mov    %rdi,%rbx
movl   $0x1,0x14(%rsp)
movl   $0xffffffff,0x10(%rsp)
ff
movl   $0xffffffff,0xc(%rsp)
ff
lea    0x10(%rsp),%rsi
lea    0xc(%rsp),%rdx
lea    0x14(%rsp),%rcx
call   1040 <my_getnbr_parse@plt>
mov    0x10(%rsp),%esi
mov    0xc(%rsp),%edx
cmp    $0xffffffff,%esi
je     1174 <my_getnbr+0x54>
cmp    $0xffffffff,%edx
jne    1174 <my_getnbr+0x54>
mov    %eax,0xc(%rsp)
mov    %eax,%edx
mov    %edx,%eax
sub    %esi,%eax
cmp    $0xa,%eax
jg     118b <my_getnbr+0x6b>
mov    0x14(%rsp),%ecx
mov    %rbx,%rdi
call   1030 <my_getnbr_add@plt>
mov    %eax,%ebp
mov    %ebp,%eax
add    $0x18,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
define i32 @my_getnbr(i8* %0) {
%2 = alloca i32
%3 = alloca i8*
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
store i8* %0, i8** %3
%9 = load i8*, i8** %3
%10 = getelementptr inbounds i8, i8* %9, i64 0
%11 = load i8, i8* %10
%12 = sext i8 %11 to i32
%13 = icmp eq i32 %12, 0
br i1 %13, label %14, label %15
14: ; preds = %1
store i32 0, i32* %2
br label %38
15: ; preds = %1
store i32 1, i32* %4
store i32 -1, i32* %5
store i32 -1, i32* %6
%16 = load i8*, i8** %3
%17 = call i32 @my_getnbr_parse(i8* %16, i32* %5, i32* %6, i32* %4)
store i32 %17, i32* %8
%18 = load i32, i32* %5
%19 = icmp ne i32 %18, -1
br i1 %19, label %20, label %25
20: ; preds = %15
%21 = load i32, i32* %6
%22 = icmp eq i32 %21, -1
br i1 %22, label %23, label %25
23: ; preds = %20
%24 = load i32, i32* %8
store i32 %24, i32* %6
br label %25
25: ; preds = %23, %20, %15
%26 = load i32, i32* %6
%27 = load i32, i32* %5
%28 = sub nsw i32 %26, %27
%29 = icmp sgt i32 %28, 10
br i1 %29, label %30, label %31
30: ; preds = %25
store i32 0, i32* %2
br label %38
31: ; preds = %25
%32 = load i8*, i8** %3
%33 = load i32, i32* %5
%34 = load i32, i32* %6
%35 = load i32, i32* %4
%36 = call i32 @my_getnbr_add(i8* %32, i32 %33, i32 %34, i32 %35)
store i32 %36, i32* %7
%37 = load i32, i32* %7
store i32 %37, i32* %2
br label %38
38: ; preds = %31, %30, %14
%39 = load i32, i32* %2
ret i32 %39
}

LLVM IR (-O2):
define i32 @my_getnbr(i8* %0) {
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = bitcast i32* %2 to i8*
%6 = bitcast i32* %3 to i8*
%7 = bitcast i32* %4 to i8*
%8 = load i8, i8* %0
%9 = icmp eq i8 %8, 0
br i1 %9, label %25, label %10
10: ; preds = %1
store i32 1, i32* %2
store i32 -1, i32* %3
store i32 -1, i32* %4
%11 = call i32 @my_getnbr_parse(i8* %0, i32* %3, i32* %4, i32* %2)
%12 = load i32, i32* %3
%13 = icmp ne i32 %12, -1
%14 = load i32, i32* %4
%15 = icmp eq i32 %14, -1
%16 = select i1 %13, i1 %15, i1 false
br i1 %16, label %17, label %18
17: ; preds = %10
store i32 %11, i32* %4
br label %18
18: ; preds = %17, %10
%19 = phi i32 [ %11, %17 ], [ %14, %10 ]
%20 = sub nsw i32 %19, %12
%21 = icmp sgt i32 %20, 10
br i1 %21, label %25, label %22
22: ; preds = %18
%23 = load i32, i32* %2
%24 = call i32 @my_getnbr_add(i8* %0, i32 %12, i32 %19, i32 %23)
br label %25
25: ; preds = %18, %1, %22
%26 = phi i32 [ %24, %22 ], [ 0, %1 ], [ 0, %18 ]
ret i32 %26
}