#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 */
scalar_t__ ERANGE;
scalar_t__ errno;
int /*<<< orphan*/ ffpmsg(char *);
int /*<<< orphan*/ strcpy(char *, char *);
int /*<<< orphan*/ strncat(char *, char *, int);
long strtol(char *, char **, int);
int ffc2ii(char *cval, long *ival, int *status) {
  char *loc, msg[81];
  if (*status > 0)
    return (*status);
  errno = 0;
  *ival = 0;
  *ival = strtol(cval, &loc, 10);
  if (*loc != '\0' && *loc != ' ')
    *status = 407;
  if (errno == ERANGE) {
    strcpy(msg, "Range Error in ffc2ii converting string to long int: ");
    strncat(msg, cval, 25);
    ffpmsg(msg);
    *status = 412;
    errno = 0;
  }
  return (*status);
}


x86 assembly (clang, -O0):
<ffc2ii>:
push   %rbp
mov    %rsp,%rbp
sub    $0x80,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    -0x20(%rbp),%rax
cmpl   $0x0,(%rax)
jle    1172 <ffc2ii+0x32>
mov    -0x20(%rbp),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    1237 <ffc2ii+0xf7>
mov    0x2e5f(%rip),%rax
movq   $0x0,(%rax)
mov    -0x18(%rbp),%rax
movq   $0x0,(%rax)
mov    -0x10(%rbp),%rdi
lea    -0x28(%rbp),%rsi
mov    $0xa,%edx
call   1060 <strtol@plt>
mov    %rax,%rcx
mov    -0x18(%rbp),%rax
mov    %rcx,(%rax)
mov    -0x28(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
je     11d1 <ffc2ii+0x91>
mov    -0x28(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x20,%eax
je     11d1 <ffc2ii+0x91>
mov    -0x20(%rbp),%rax
movl   $0x197,(%rax)
mov    0x2e00(%rip),%rax
mov    (%rax),%rax
mov    0x2e06(%rip),%rcx
cmp    (%rcx),%rax
jne    122e <ffc2ii+0xee>
lea    -0x80(%rbp),%rdi
lea    0xe0a(%rip),%rsi
call   1030 <strcpy@plt>
lea    -0x80(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    $0x19,%edx
call   1050 <strncat@plt>
lea    -0x80(%rbp),%rdi
call   1040 <ffpmsg@plt>
mov    -0x20(%rbp),%rax
movl   $0x19c,(%rax)
mov    0x2db1(%rip),%rax
movq   $0x0,(%rax)
mov    -0x20(%rbp),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x80,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ffc2ii>:
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x68,%rsp
mov    (%rdx),%eax
test   %eax,%eax
jg     11ec <ffc2ii+0xac>
mov    %rdx,%r15
mov    %rsi,%rbx
mov    %rdi,%r14
mov    0x2e73(%rip),%r12
movq   $0x0,(%r12)
movq   $0x0,(%rsi)
lea    0x8(%rsp),%rsi
mov    $0xa,%edx
call   1060 <strtol@plt>
mov    %rax,(%rbx)
mov    0x8(%rsp),%rax
testb  $0xdf,(%rax)
je     1197 <ffc2ii+0x57>
movl   $0x197,(%r15)
mov    (%r12),%rax
mov    0x2e46(%rip),%rcx
cmp    (%rcx),%rax
jne    11e9 <ffc2ii+0xa9>
lea    0xe52(%rip),%rsi
lea    0x10(%rsp),%rbx
mov    %rbx,%rdi
call   1030 <strcpy@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
mov    $0x19,%edx
call   1050 <strncat@plt>
mov    %rbx,%rdi
call   1040 <ffpmsg@plt>
movl   $0x19c,(%r15)
movq   $0x0,(%r12)
mov    $0x19c,%eax
jmp    11ec <ffc2ii+0xac>
mov    (%r15),%eax
add    $0x68,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@errno = global i64 0
@ERANGE = global i64 0
@.str = [54 x i8] c"Range Error in ffc2ii converting string to long int: \00"
define i32 @ffc2ii(i8* %0, i64* %1, i32* %2) {
%4 = alloca i32
%5 = alloca i8*
%6 = alloca i64*
%7 = alloca i32*
%8 = alloca i8*
%9 = alloca [81 x i8]
store i8* %0, i8** %5
store i64* %1, i64** %6
store i32* %2, i32** %7
%10 = load i32*, i32** %7
%11 = load i32, i32* %10
%12 = icmp sgt i32 %11, 0
br i1 %12, label %13, label %16
13: ; preds = %3
%14 = load i32*, i32** %7
%15 = load i32, i32* %14
store i32 %15, i32* %4
br label %48
16: ; preds = %3
store i64 0, i64* @errno
%17 = load i64*, i64** %6
store i64 0, i64* %17
%18 = load i8*, i8** %5
%19 = call i64 @strtol(i8* %18, i8** %8, i32 10)
%20 = load i64*, i64** %6
store i64 %19, i64* %20
%21 = load i8*, i8** %8
%22 = load i8, i8* %21
%23 = sext i8 %22 to i32
%24 = icmp ne i32 %23, 0
br i1 %24, label %25, label %32
25: ; preds = %16
%26 = load i8*, i8** %8
%27 = load i8, i8* %26
%28 = sext i8 %27 to i32
%29 = icmp ne i32 %28, 32
br i1 %29, label %30, label %32
30: ; preds = %25
%31 = load i32*, i32** %7
store i32 407, i32* %31
br label %32
32: ; preds = %30, %25, %16
%33 = load i64, i64* @errno
%34 = load i64, i64* @ERANGE
%35 = icmp eq i64 %33, %34
br i1 %35, label %36, label %45
36: ; preds = %32
%37 = getelementptr inbounds [81 x i8], [81 x i8]* %9, i64 0, i64 0
%38 = call i32 @strcpy(i8* %37, i8* getelementptr inbounds ([54 x i8], [54 x i8]* @.str, i64 0, i64 0))
%39 = getelementptr inbounds [81 x i8], [81 x i8]* %9, i64 0, i64 0
%40 = load i8*, i8** %5
%41 = call i32 @strncat(i8* %39, i8* %40, i32 25)
%42 = getelementptr inbounds [81 x i8], [81 x i8]* %9, i64 0, i64 0
%43 = call i32 @ffpmsg(i8* %42)
%44 = load i32*, i32** %7
store i32 412, i32* %44
store i64 0, i64* @errno
br label %45
45: ; preds = %36, %32
%46 = load i32*, i32** %7
%47 = load i32, i32* %46
store i32 %47, i32* %4
br label %48
48: ; preds = %45, %13
%49 = load i32, i32* %4
ret i32 %49
}

LLVM IR (-O2):
@errno = global i64 0
@ERANGE = global i64 0
@.str = [54 x i8] c"Range Error in ffc2ii converting string to long int: \00"
define i32 @ffc2ii(i8* %0, i64* nocapture writeonly %1, i32* nocapture %2) {
%4 = alloca i8*
%5 = alloca [81 x i8]
%6 = bitcast i8** %4 to i8*
%7 = getelementptr inbounds [81 x i8], [81 x i8]* %5, i64 0, i64 0
%8 = load i32, i32* %2
%9 = icmp sgt i32 %8, 0
br i1 %9, label %25, label %10
10: ; preds = %3
store i64 0, i64* @errno
store i64 0, i64* %1
%11 = call i64 @strtol(i8* %0, i8** %4, i32 10)
store i64 %11, i64* %1
%12 = load i8*, i8** %4
%13 = load i8, i8* %12
switch i8 %13, label %14 [
i8 0, label %15
i8 32, label %15
]
14: ; preds = %10
store i32 407, i32* %2
br label %15
15: ; preds = %10, %10, %14
%16 = load i64, i64* @errno
%17 = load i64, i64* @ERANGE
%18 = icmp eq i64 %16, %17
br i1 %18, label %21, label %19
19: ; preds = %15
%20 = load i32, i32* %2
br label %25
21: ; preds = %15
%22 = call i32 @strcpy(i8* %7, i8* getelementptr inbounds ([54 x i8], [54 x i8]* @.str, i64 0, i64 0))
%23 = call i32 @strncat(i8* %7, i8* %0, i32 25)
%24 = call i32 @ffpmsg(i8* %7)
store i32 412, i32* %2
store i64 0, i64* @errno
br label %25
25: ; preds = %21, %19, %3
%26 = phi i32 [ %8, %3 ], [ %20, %19 ], [ 412, %21 ]
ret i32 %26
}