#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*/ is_digit(char const);
const char *get_sign(const char *s, int *sign, int *error) {
  *error = 0;
  *sign = 1;
  if (*s == '-') {
    *sign = -1;
    ++s;
  } else if (*s == '+') {
    *sign = +1;
    ++s;
  } else if (!is_digit(*s) && *s != '.')
    *error = 1;
  return s;
}


x86 assembly (clang, -O0):
<get_sign>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    -0x18(%rbp),%rax
movl   $0x0,(%rax)
mov    -0x10(%rbp),%rax
movl   $0x1,(%rax)
mov    -0x8(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x2d,%eax
jne    1163 <get_sign+0x53>
mov    -0x10(%rbp),%rax
movl   $0xffffffff,(%rax)
mov    -0x8(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x8(%rbp)
jmp    11c7 <get_sign+0xb7>
mov    -0x8(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x2b,%eax
jne    118e <get_sign+0x7e>
mov    -0x10(%rbp),%rax
movl   $0x1,(%rax)
mov    -0x8(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x8(%rbp)
jmp    11c2 <get_sign+0xb2>
mov    -0x8(%rbp),%rax
movsbl (%rax),%edi
call   1030 <is_digit@plt>
cmp    $0x0,%eax
jne    11bd <get_sign+0xad>
mov    -0x8(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x2e,%eax
je     11bd <get_sign+0xad>
mov    -0x18(%rbp),%rax
movl   $0x1,(%rax)
jmp    11c2 <get_sign+0xb2>
jmp    11c7 <get_sign+0xb7>
mov    -0x8(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_sign>:
push   %r14
push   %rbx
push   %rax
mov    %rdi,%rbx
movl   $0x0,(%rdx)
movl   $0x1,(%rsi)
mov    (%rdi),%al
cmp    $0x2b,%al
je     1133 <get_sign+0x23>
cmp    $0x2d,%al
jne    1139 <get_sign+0x29>
movl   $0xffffffff,(%rsi)
add    $0x1,%rbx
jmp    1154 <get_sign+0x44>
mov    %rdx,%r14
movsbl %al,%edi
call   1030 <is_digit@plt>
test   %eax,%eax
jne    1154 <get_sign+0x44>
cmpb   $0x2e,(%rbx)
je     1154 <get_sign+0x44>
movl   $0x1,(%r14)
mov    %rbx,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
define i8* @get_sign(i8* %0, i32* %1, i32* %2) {
%4 = alloca i8*
%5 = alloca i32*
%6 = alloca i32*
store i8* %0, i8** %4
store i32* %1, i32** %5
store i32* %2, i32** %6
%7 = load i32*, i32** %6
store i32 0, i32* %7
%8 = load i32*, i32** %5
store i32 1, i32* %8
%9 = load i8*, i8** %4
%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 = %3
%14 = load i32*, i32** %5
store i32 -1, i32* %14
%15 = load i8*, i8** %4
%16 = getelementptr inbounds i8, i8* %15, i32 1
store i8* %16, i8** %4
br label %40
17: ; preds = %3
%18 = load i8*, i8** %4
%19 = load i8, i8* %18
%20 = sext i8 %19 to i32
%21 = icmp eq i32 %20, 43
br i1 %21, label %22, label %26
22: ; preds = %17
%23 = load i32*, i32** %5
store i32 1, i32* %23
%24 = load i8*, i8** %4
%25 = getelementptr inbounds i8, i8* %24, i32 1
store i8* %25, i8** %4
br label %39
26: ; preds = %17
%27 = load i8*, i8** %4
%28 = load i8, i8* %27
%29 = call i32 @is_digit(i8 signext %28)
%30 = icmp ne i32 %29, 0
br i1 %30, label %38, label %31
31: ; preds = %26
%32 = load i8*, i8** %4
%33 = load i8, i8* %32
%34 = sext i8 %33 to i32
%35 = icmp ne i32 %34, 46
br i1 %35, label %36, label %38
36: ; preds = %31
%37 = load i32*, i32** %6
store i32 1, i32* %37
br label %38
38: ; preds = %36, %31, %26
br label %39
39: ; preds = %38, %22
br label %40
40: ; preds = %39, %13
%41 = load i8*, i8** %4
ret i8* %41
}

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