#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 */
long atol(char *);
scalar_t__ is_number(char *);
long get_tail_length(int argc, char *argv[]) {
  if (argc > 1 && argv[1][0] == '-' && is_number(argv[1]))
    return -atol(argv[1]);
  else
    return 10L;
}


x86 assembly (clang, -O0):
<get_tail_length>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0xc(%rbp)
mov    %rsi,-0x18(%rbp)
cmpl   $0x1,-0xc(%rbp)
jle    1182 <get_tail_length+0x62>
mov    -0x18(%rbp),%rax
mov    0x8(%rax),%rax
movsbl (%rax),%eax
cmp    $0x2d,%eax
jne    1182 <get_tail_length+0x62>
mov    -0x18(%rbp),%rax
mov    0x8(%rax),%rdi
call   1030 <is_number@plt>
cmp    $0x0,%rax
je     1182 <get_tail_length+0x62>
mov    -0x18(%rbp),%rax
mov    0x8(%rax),%rdi
call   1040 <atol@plt>
mov    %rax,%rcx
xor    %eax,%eax
sub    %rcx,%rax
mov    %rax,-0x8(%rbp)
jmp    118a <get_tail_length+0x6a>
movq   $0xa,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_tail_length>:
push   %r14
push   %rbx
push   %rax
mov    $0xa,%ebx
cmp    $0x2,%edi
jl     1153 <get_tail_length+0x33>
mov    %rsi,%r14
mov    0x8(%rsi),%rdi
cmpb   $0x2d,(%rdi)
jne    1153 <get_tail_length+0x33>
call   1030 <is_number@plt>
test   %rax,%rax
je     1153 <get_tail_length+0x33>
mov    0x8(%r14),%rdi
call   1040 <atol@plt>
mov    %rax,%rbx
neg    %rbx
mov    %rbx,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

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

LLVM IR (-O2):
define i64 @get_tail_length(i32 %0, i8** nocapture %1) {
%3 = icmp sgt i32 %0, 1
br i1 %3, label %4, label %16
4: ; preds = %2
%5 = getelementptr inbounds i8*, i8** %1, i64 1
%6 = load i8*, i8** %5
%7 = load i8, i8* %6
%8 = icmp eq i8 %7, 45
br i1 %8, label %9, label %16
9: ; preds = %4
%10 = tail call i64 @is_number(i8* %6)
%11 = icmp eq i64 %10, 0
br i1 %11, label %16, label %12
12: ; preds = %9
%13 = load i8*, i8** %5
%14 = tail call i64 @atol(i8* %13)
%15 = sub nsw i64 0, %14
br label %16
16: ; preds = %2, %4, %9, %12
%17 = phi i64 [ %15, %12 ], [ 10, %9 ], [ 10, %4 ], [ 10, %2 ]
ret i64 %17
}