#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_string_to_int(char *, int);
int my_getnbr(char *str) {
  int nb;
  int begin;
  if (str == NULL)
    return (0);
  if (str[0] == '-')
    begin = 1;
  else
    begin = 0;
  nb = my_string_to_int(str, begin);
  if (str[0] == '-')
    nb *= -1;
  return (nb);
}


x86 assembly (clang, -O0):
<my_getnbr>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    1133 <my_getnbr+0x23>
movl   $0x0,-0x4(%rbp)
jmp    1182 <my_getnbr+0x72>
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x2d,%eax
jne    114f <my_getnbr+0x3f>
movl   $0x1,-0x18(%rbp)
jmp    1156 <my_getnbr+0x46>
movl   $0x0,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%esi
call   1030 <my_string_to_int@plt>
mov    %eax,-0x14(%rbp)
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x2d,%eax
jne    117c <my_getnbr+0x6c>
imul   $0xffffffff,-0x14(%rbp),%eax
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<my_getnbr>:
test   %rdi,%rdi
je     1133 <my_getnbr+0x23>
push   %rbx
mov    %rdi,%rbx
xor    %esi,%esi
cmpb   $0x2d,(%rdi)
sete   %sil
call   1030 <my_string_to_int@plt>
mov    %eax,%ecx
neg    %eax
cmpb   $0x2d,(%rbx)
cmovne %ecx,%eax
pop    %rbx
ret
xor    %eax,%eax
ret

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

LLVM IR (-O2):
define i32 @my_getnbr(i8* %0) {
%2 = icmp eq i8* %0, null
br i1 %2, label %12, label %3
3: ; preds = %1
%4 = load i8, i8* %0
%5 = icmp eq i8 %4, 45
%6 = zext i1 %5 to i32
%7 = tail call i32 @my_string_to_int(i8* %0, i32 %6)
%8 = load i8, i8* %0
%9 = icmp eq i8 %8, 45
%10 = sub nsw i32 0, %7
%11 = select i1 %9, i32 %10, i32 %7
br label %12
12: ; preds = %1, %3
%13 = phi i32 [ %11, %3 ], [ 0, %1 ]
ret i32 %13
}