#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 /*<<< orphan*/ addtonb(char, char, char, int *, int *);
int /*<<< orphan*/ isNeg(char, char, int *);
int my_strlen(char *);
int /*<<< orphan*/ stopIfLetter(char, int *, int *);
int my_getnbr(char *str) {
  int nb;
  int is_neg;
  int i;
  int dec;
  dec = 1;
  i = my_strlen(str) - 1;
  is_neg = 0;
  nb = 0;
  while (i > -1) {
    stopIfLetter(str[i], &nb, &dec);
    isNeg(str[i], str[i + 1], &is_neg);
    addtonb(str[i], str[i - 1], str[i - 2], &nb, &dec);
    --i;
  }
  if (is_neg)
    nb *= -1;
  return (nb);
}


x86 assembly (clang, -O0):
<my_getnbr>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
movl   $0x1,-0x18(%rbp)
mov    -0x8(%rbp),%rdi
call   1030 <my_strlen@plt>
sub    $0x1,%eax
mov    %eax,-0x14(%rbp)
movl   $0x0,-0x10(%rbp)
movl   $0x0,-0xc(%rbp)
cmpl   $0xffffffff,-0x14(%rbp)
jle    120e <my_getnbr+0xce>
mov    -0x8(%rbp),%rax
movslq -0x14(%rbp),%rcx
lea    -0xc(%rbp),%rsi
lea    -0x18(%rbp),%rdx
movsbl (%rax,%rcx,1),%edi
call   1060 <stopIfLetter@plt>
mov    -0x8(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,1),%sil
mov    -0x8(%rbp),%rax
mov    -0x14(%rbp),%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
lea    -0x10(%rbp),%rdx
movsbl %sil,%edi
movsbl (%rax,%rcx,1),%esi
call   1050 <isNeg@plt>
mov    -0x8(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,1),%dil
mov    -0x8(%rbp),%rax
mov    -0x14(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
mov    (%rax,%rcx,1),%sil
mov    -0x8(%rbp),%rax
mov    -0x14(%rbp),%ecx
sub    $0x2,%ecx
movslq %ecx,%rdx
lea    -0xc(%rbp),%rcx
lea    -0x18(%rbp),%r8
movsbl %dil,%edi
movsbl %sil,%esi
movsbl (%rax,%rdx,1),%edx
call   1040 <addtonb@plt>
mov    -0x14(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x14(%rbp)
jmp    1170 <my_getnbr+0x30>
cmpl   $0x0,-0x10(%rbp)
je     121f <my_getnbr+0xdf>
imul   $0xffffffff,-0xc(%rbp),%eax
mov    %eax,-0xc(%rbp)
mov    -0xc(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<my_getnbr>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x10,%rsp
mov    %rdi,%r13
movl   $0x1,0xc(%rsp)
call   1030 <my_strlen@plt>
movl   $0x0,0x8(%rsp)
movl   $0x0,0x4(%rsp)
test   %eax,%eax
jle    11eb <my_getnbr+0xab>
mov    %eax,%ebx
add    $0x1,%rbx
lea    0x4(%rsp),%r14
lea    0xc(%rsp),%r15
lea    0x8(%rsp),%r12
cs nopw 0x0(%rax,%rax,1)
movsbl -0x2(%r13,%rbx,1),%edi
mov    %r14,%rsi
mov    %r15,%rdx
call   1060 <stopIfLetter@plt>
movsbl -0x2(%r13,%rbx,1),%edi
movsbl -0x1(%r13,%rbx,1),%esi
mov    %r12,%rdx
call   1050 <isNeg@plt>
movsbl -0x2(%r13,%rbx,1),%edi
movsbl -0x3(%r13,%rbx,1),%esi
movsbl -0x4(%r13,%rbx,1),%edx
mov    %r14,%rcx
mov    %r15,%r8
call   1040 <addtonb@plt>
add    $0xffffffffffffffff,%rbx
cmp    $0x1,%rbx
ja     1190 <my_getnbr+0x50>
cmpl   $0x0,0x8(%rsp)
je     11eb <my_getnbr+0xab>
xor    %eax,%eax
sub    0x4(%rsp),%eax
jmp    11ef <my_getnbr+0xaf>
mov    0x4(%rsp),%eax
add    $0x10,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define i32 @my_getnbr(i8* %0) {
%2 = alloca i8*
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
store i8* %0, i8** %2
store i32 1, i32* %6
%7 = load i8*, i8** %2
%8 = call i32 @my_strlen(i8* %7)
%9 = sub nsw i32 %8, 1
store i32 %9, i32* %5
store i32 0, i32* %4
store i32 0, i32* %3
br label %10
10: ; preds = %13, %1
%11 = load i32, i32* %5
%12 = icmp sgt i32 %11, -1
br i1 %12, label %13, label %52
13: ; preds = %10
%14 = load i8*, i8** %2
%15 = load i32, i32* %5
%16 = sext i32 %15 to i64
%17 = getelementptr inbounds i8, i8* %14, i64 %16
%18 = load i8, i8* %17
%19 = call i32 @stopIfLetter(i8 signext %18, i32* %3, i32* %6)
%20 = load i8*, i8** %2
%21 = load i32, i32* %5
%22 = sext i32 %21 to i64
%23 = getelementptr inbounds i8, i8* %20, i64 %22
%24 = load i8, i8* %23
%25 = load i8*, i8** %2
%26 = load i32, i32* %5
%27 = add nsw i32 %26, 1
%28 = sext i32 %27 to i64
%29 = getelementptr inbounds i8, i8* %25, i64 %28
%30 = load i8, i8* %29
%31 = call i32 @isNeg(i8 signext %24, i8 signext %30, i32* %4)
%32 = load i8*, i8** %2
%33 = load i32, i32* %5
%34 = sext i32 %33 to i64
%35 = getelementptr inbounds i8, i8* %32, i64 %34
%36 = load i8, i8* %35
%37 = load i8*, i8** %2
%38 = load i32, i32* %5
%39 = sub nsw i32 %38, 1
%40 = sext i32 %39 to i64
%41 = getelementptr inbounds i8, i8* %37, i64 %40
%42 = load i8, i8* %41
%43 = load i8*, i8** %2
%44 = load i32, i32* %5
%45 = sub nsw i32 %44, 2
%46 = sext i32 %45 to i64
%47 = getelementptr inbounds i8, i8* %43, i64 %46
%48 = load i8, i8* %47
%49 = call i32 @addtonb(i8 signext %36, i8 signext %42, i8 signext %48, i32* %3, i32* %6)
%50 = load i32, i32* %5
%51 = add nsw i32 %50, -1
store i32 %51, i32* %5
br label %10
52: ; preds = %10
%53 = load i32, i32* %4
%54 = icmp ne i32 %53, 0
br i1 %54, label %55, label %58
55: ; preds = %52
%56 = load i32, i32* %3
%57 = mul nsw i32 %56, -1
store i32 %57, i32* %3
br label %58
58: ; preds = %55, %52
%59 = load i32, i32* %3
ret i32 %59
}

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*
store i32 1, i32* %4
%8 = tail call i32 @my_strlen(i8* %0)
store i32 0, i32* %3
store i32 0, i32* %2
%9 = icmp sgt i32 %8, 0
br i1 %9, label %10, label %34
10: ; preds = %1
%11 = zext i32 %8 to i64
br label %12
12: ; preds = %10, %12
%13 = phi i64 [ %11, %10 ], [ %14, %12 ]
%14 = add nsw i64 %13, -1
%15 = getelementptr inbounds i8, i8* %0, i64 %14
%16 = load i8, i8* %15
%17 = call i32 @stopIfLetter(i8 signext %16, i32* %2, i32* %4)
%18 = load i8, i8* %15
%19 = getelementptr inbounds i8, i8* %0, i64 %13
%20 = load i8, i8* %19
%21 = call i32 @isNeg(i8 signext %18, i8 signext %20, i32* %3)
%22 = load i8, i8* %15
%23 = add nsw i64 %13, -2
%24 = getelementptr inbounds i8, i8* %0, i64 %23
%25 = load i8, i8* %24
%26 = add nsw i64 %13, -3
%27 = getelementptr inbounds i8, i8* %0, i64 %26
%28 = load i8, i8* %27
%29 = call i32 @addtonb(i8 signext %22, i8 signext %25, i8 signext %28, i32* %2, i32* %4)
%30 = icmp ugt i64 %13, 1
br i1 %30, label %12, label %31
31: ; preds = %12
%32 = load i32, i32* %3
%33 = icmp eq i32 %32, 0
br i1 %33, label %34, label %36
34: ; preds = %1, %31
%35 = load i32, i32* %2
br label %39
36: ; preds = %31
%37 = load i32, i32* %2
%38 = sub nsw i32 0, %37
br label %39
39: ; preds = %34, %36
%40 = phi i32 [ %35, %34 ], [ %38, %36 ]
ret i32 %40
}