#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*/ ftp_i_char_is_number(char);
scalar_t__ strtol(char *, int /*<<< orphan*/ *, int);
int ftp_i_input_sign(char *signal) {
  char s[4] = {*signal, *(signal + 1), *(signal + 2), '\0'};
  for (int i = 0; i < 3; i++) {
    if (!ftp_i_char_is_number(s[i]))
      return 1000;
  }
  return (int)strtol(s, NULL, 10);
}


x86 assembly (clang, -O0):
<ftp_i_input_sign>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rax
mov    (%rax),%al
mov    %al,-0x14(%rbp)
mov    -0x10(%rbp),%rax
mov    0x1(%rax),%al
mov    %al,-0x13(%rbp)
mov    -0x10(%rbp),%rax
mov    0x2(%rax),%al
mov    %al,-0x12(%rbp)
movb   $0x0,-0x11(%rbp)
movl   $0x0,-0x18(%rbp)
cmpl   $0x3,-0x18(%rbp)
jge    1194 <ftp_i_input_sign+0x74>
movslq -0x18(%rbp),%rax
movsbl -0x14(%rbp,%rax,1),%edi
call   1030 <ftp_i_char_is_number@plt>
cmp    $0x0,%eax
jne    1181 <ftp_i_input_sign+0x61>
movl   $0x3e8,-0x4(%rbp)
jmp    11a9 <ftp_i_input_sign+0x89>
jmp    1186 <ftp_i_input_sign+0x66>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    1154 <ftp_i_input_sign+0x34>
lea    -0x14(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%esi
mov    $0xa,%edx
call   1040 <strtol@plt>
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ftp_i_input_sign>:
push   %rbp
push   %r14
push   %rbx
sub    $0x10,%rsp
movsbl (%rdi),%eax
mov    %al,0xc(%rsp)
mov    0x1(%rdi),%bl
mov    %bl,0xd(%rsp)
mov    0x2(%rdi),%bpl
mov    %bpl,0xe(%rsp)
movb   $0x0,0xf(%rsp)
mov    %eax,%edi
call   1030 <ftp_i_char_is_number@plt>
mov    $0x3e8,%r14d
test   %eax,%eax
je     1182 <ftp_i_input_sign+0x62>
movsbl %bl,%edi
call   1030 <ftp_i_char_is_number@plt>
test   %eax,%eax
je     1182 <ftp_i_input_sign+0x62>
movsbl %bpl,%edi
call   1030 <ftp_i_char_is_number@plt>
test   %eax,%eax
je     1182 <ftp_i_input_sign+0x62>
lea    0xc(%rsp),%rdi
xor    %esi,%esi
mov    $0xa,%edx
call   1040 <strtol@plt>
mov    %rax,%r14
mov    %r14d,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

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

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