#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*/ strcpy(char *, char *);
unsigned int strlen(char *);
int getNumber(char s[]) {
  int semn = 1, x = 0;
  if (s[0] == '-') {
    semn = -1;
    strcpy(s, s + 1);
  }
  for (unsigned i = 0; i < strlen(s); i++)
    x = x * 10 + (s[i] - '0');
  x = x * semn;
  return x;
}


x86 assembly (clang, -O0):
<getNumber>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
movl   $0x1,-0xc(%rbp)
movl   $0x0,-0x10(%rbp)
mov    -0x8(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x2d,%eax
jne    1162 <getNumber+0x42>
movl   $0xffffffff,-0xc(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x8(%rbp),%rsi
add    $0x1,%rsi
call   1030 <strcpy@plt>
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%eax
mov    %eax,-0x18(%rbp)
mov    -0x8(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,%ecx
mov    -0x18(%rbp),%eax
cmp    %ecx,%eax
jae    11aa <getNumber+0x8a>
imul   $0xa,-0x10(%rbp),%eax
mov    -0x8(%rbp),%rcx
mov    -0x14(%rbp),%edx
movsbl (%rcx,%rdx,1),%ecx
sub    $0x30,%ecx
add    %ecx,%eax
mov    %eax,-0x10(%rbp)
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1169 <getNumber+0x49>
mov    -0x10(%rbp),%eax
imul   -0xc(%rbp),%eax
mov    %eax,-0x10(%rbp)
mov    -0x10(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<getNumber>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %rdi,%r14
mov    $0x1,%r15d
cmpb   $0x2d,(%rdi)
jne    1147 <getNumber+0x27>
lea    0x1(%r14),%rsi
mov    %r14,%rdi
call   1030 <strcpy@plt>
mov    $0xffffffff,%r15d
mov    %r14,%rdi
call   1040 <strlen@plt>
test   %eax,%eax
je     1183 <getNumber+0x63>
xor    %ebp,%ebp
xor    %ebx,%ebx
nopw   0x0(%rax,%rax,1)
lea    (%rbx,%rbx,4),%eax
movsbl (%r14,%rbp,1),%ecx
lea    (%rcx,%rax,2),%ebx
add    $0xffffffd0,%ebx
add    $0x1,%rbp
mov    %r14,%rdi
call   1040 <strlen@plt>
mov    %eax,%eax
cmp    %rax,%rbp
jb     1160 <getNumber+0x40>
jmp    1185 <getNumber+0x65>
xor    %ebx,%ebx
imul   %r15d,%ebx
mov    %ebx,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
define i32 @getNumber(i8* %0) {
%2 = load i8, i8* %0
%3 = icmp eq i8 %2, 45
br i1 %3, label %4, label %7
4: ; preds = %1
%5 = getelementptr inbounds i8, i8* %0, i64 1
%6 = tail call i32 @strcpy(i8* %0, i8* %5)
br label %7
7: ; preds = %4, %1
%8 = phi i32 [ -1, %4 ], [ 1, %1 ]
%9 = tail call i32 @strlen(i8* %0)
%10 = icmp eq i32 %9, 0
br i1 %10, label %11, label %14
11: ; preds = %14, %7
%12 = phi i32 [ 0, %7 ], [ %22, %14 ]
%13 = mul nsw i32 %12, %8
ret i32 %13
14: ; preds = %7, %14
%15 = phi i64 [ %23, %14 ], [ 0, %7 ]
%16 = phi i32 [ %22, %14 ], [ 0, %7 ]
%17 = mul nsw i32 %16, 10
%18 = getelementptr inbounds i8, i8* %0, i64 %15
%19 = load i8, i8* %18
%20 = sext i8 %19 to i32
%21 = add i32 %17, -48
%22 = add i32 %21, %20
%23 = add nuw nsw i64 %15, 1
%24 = tail call i32 @strlen(i8* %0)
%25 = zext i32 %24 to i64
%26 = icmp ult i64 %23, %25
br i1 %26, label %14, label %11
}