#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 *);
scalar_t__ isdigit(char);
int parsenum(char **cpp) {
  char *cp = *cpp, c;
  int num = 0;
  if (**cpp == '-')
    (*cpp)++;
  while (isdigit(**cpp))
    (*cpp)++;
  c = **cpp;
  **cpp = '\0';
  num = atoi(cp);
  **cpp = c;
  return num;
}


x86 assembly (clang, -O0):
<parsenum>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rax
mov    (%rax),%rax
mov    %rax,-0x10(%rbp)
movl   $0x0,-0x18(%rbp)
mov    -0x8(%rbp),%rax
mov    (%rax),%rax
movsbl (%rax),%eax
cmp    $0x2d,%eax
jne    115f <parsenum+0x3f>
mov    -0x8(%rbp),%rax
mov    (%rax),%rcx
add    $0x1,%rcx
mov    %rcx,(%rax)
jmp    1164 <parsenum+0x44>
mov    -0x8(%rbp),%rax
mov    (%rax),%rax
movsbl (%rax),%edi
call   1030 <isdigit@plt>
cmp    $0x0,%rax
je     1190 <parsenum+0x70>
mov    -0x8(%rbp),%rax
mov    (%rax),%rcx
add    $0x1,%rcx
mov    %rcx,(%rax)
jmp    1164 <parsenum+0x44>
mov    -0x8(%rbp),%rax
mov    (%rax),%rax
mov    (%rax),%al
mov    %al,-0x11(%rbp)
mov    -0x8(%rbp),%rax
mov    (%rax),%rax
movb   $0x0,(%rax)
mov    -0x10(%rbp),%rdi
call   1040 <atoi@plt>
mov    %eax,-0x18(%rbp)
mov    -0x11(%rbp),%cl
mov    -0x8(%rbp),%rax
mov    (%rax),%rax
mov    %cl,(%rax)
mov    -0x18(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<parsenum>:
push   %rbp
push   %r14
push   %rbx
mov    %rdi,%rbx
mov    (%rdi),%r14
mov    (%r14),%al
cmp    $0x2d,%al
jne    113c <parsenum+0x1c>
lea    0x1(%r14),%rax
mov    %rax,(%rbx)
mov    0x1(%r14),%al
movsbl %al,%edi
nop
call   1030 <isdigit@plt>
test   %rax,%rax
je     115a <parsenum+0x3a>
mov    (%rbx),%rax
lea    0x1(%rax),%rcx
mov    %rcx,(%rbx)
movsbl 0x1(%rax),%edi
jmp    1140 <parsenum+0x20>
mov    (%rbx),%rax
mov    (%rax),%bpl
movb   $0x0,(%rax)
mov    %r14,%rdi
call   1040 <atoi@plt>
mov    (%rbx),%rcx
mov    %bpl,(%rcx)
pop    %rbx
pop    %r14
pop    %rbp
ret

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

LLVM IR (-O2):
define i32 @parsenum(i8** nocapture %0) {
%2 = load i8*, i8** %0
%3 = load i8, i8* %2
%4 = icmp eq i8 %3, 45
br i1 %4, label %5, label %8
5: ; preds = %1
%6 = getelementptr inbounds i8, i8* %2, i64 1
store i8* %6, i8** %0
%7 = load i8, i8* %6
br label %8
8: ; preds = %5, %1
%9 = phi i8 [ %7, %5 ], [ %3, %1 ]
%10 = tail call i64 @isdigit(i8 signext %9)
%11 = icmp eq i64 %10, 0
br i1 %11, label %18, label %12
12: ; preds = %8, %12
%13 = load i8*, i8** %0
%14 = getelementptr inbounds i8, i8* %13, i64 1
store i8* %14, i8** %0
%15 = load i8, i8* %14
%16 = tail call i64 @isdigit(i8 signext %15)
%17 = icmp eq i64 %16, 0
br i1 %17, label %18, label %12
18: ; preds = %12, %8
%19 = load i8*, i8** %0
%20 = load i8, i8* %19
store i8 0, i8* %19
%21 = tail call i32 @atoi(i8* %2)
%22 = load i8*, i8** %0
store i8 %20, i8* %22
ret i32 %21
}