#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 atoi(char *);
int strlen(char *);
int dtoi(char data[]) {
  int i, off = 0;
  char datas[11];
  for (i = 0; i < strlen(data); i++) {
    if (data[i] != '-') {
      datas[off] = data[i];
      off++;
    }
  }
  datas[off] = '\0';
  return atoi(datas);
}


x86 assembly (clang, -O0):
<dtoi>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
movl   $0x0,-0x10(%rbp)
movl   $0x0,-0xc(%rbp)
mov    -0xc(%rbp),%eax
mov    %eax,-0x20(%rbp)
mov    -0x8(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,%ecx
mov    -0x20(%rbp),%eax
cmp    %ecx,%eax
jge    119a <dtoi+0x7a>
mov    -0x8(%rbp),%rax
movslq -0xc(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x2d,%eax
je     1187 <dtoi+0x67>
mov    -0x8(%rbp),%rax
movslq -0xc(%rbp),%rcx
mov    (%rax,%rcx,1),%cl
movslq -0x10(%rbp),%rax
mov    %cl,-0x1b(%rbp,%rax,1)
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    118c <dtoi+0x6c>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    113a <dtoi+0x1a>
movslq -0x10(%rbp),%rax
movb   $0x0,-0x1b(%rbp,%rax,1)
lea    -0x1b(%rbp),%rdi
call   1040 <atoi@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<dtoi>:
push   %r15
push   %r14
push   %rbx
sub    $0x10,%rsp
mov    %rdi,%r14
call   1030 <strlen@plt>
test   %eax,%eax
jle    116a <dtoi+0x4a>
xor    %ebx,%ebx
xor    %r15d,%r15d
jmp    1153 <dtoi+0x33>
nopl   0x0(%rax)
add    $0x1,%rbx
mov    %r14,%rdi
call   1030 <strlen@plt>
cltq
cmp    %rax,%rbx
jge    116d <dtoi+0x4d>
movzbl (%r14,%rbx,1),%eax
cmp    $0x2d,%al
je     1140 <dtoi+0x20>
movslq %r15d,%r15
mov    %al,0x5(%rsp,%r15,1)
add    $0x1,%r15d
jmp    1140 <dtoi+0x20>
xor    %r15d,%r15d
movslq %r15d,%rax
movb   $0x0,0x5(%rsp,%rax,1)
lea    0x5(%rsp),%rdi
call   1040 <atoi@plt>
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

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

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