blob: 2f50e37ee017a3012d5f243387ec09ecb3652901 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
|
/* { dg-do compile } */
/* { dg-options "-O2" } */
int
php_filter_parse_int (char const *str, unsigned int str_len, long *ret)
{
long ctx_value;
int sign;
int digit;
char const *end;
int tmp;
char const *tmp___0;
char const *tmp___1;
sign = 0;
digit = 0;
end = str + str_len;
switch ((int) *str)
{
case 45:
sign = 1;
case 43:
str++;
default:;
break;
}
if ((unsigned long) str < (unsigned long) end)
{
if ((int const) *str >= 49)
{
if ((int const) *str <= 57)
{
if (sign)
{
tmp = -1;
}
else
{
tmp = 1;
}
tmp___0 = str;
str++;
ctx_value = (long) (tmp * (int) ((int const) *tmp___0 - 48));
}
else
{
return (-1);
}
}
else
{
return (-1);
}
}
else
{
return (-1);
}
if (end - str > 19)
{
return (-1);
}
while ((unsigned long) str < (unsigned long) end)
{
if ((int const) *str >= 48)
{
if ((int const) *str <= 57)
{
tmp___1 = str;
str++;
digit = (int) ((int const) *tmp___1 - 48);
if (!sign)
{
if (ctx_value <=
(9223372036854775807L - (long) digit) / 10L)
{
ctx_value = ctx_value * 10L + (long) digit;
}
else
{
goto _L;
}
}
else
{
_L:
if (sign)
{
if (ctx_value >=
((-0x7FFFFFFFFFFFFFFF - 1) + (long) digit) / 10L)
{
ctx_value = ctx_value * 10L - (long) digit;
}
else
{
return (-1);
}
}
else
{
return (-1);
}
}
}
else
{
return (-1);
}
}
else
{
return (-1);
}
}
*ret = ctx_value;
return (1);
}
/* { dg-final { scan-assembler-not "idiv" } } */
|