#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;
char *get_string();
long strtol(char *, int /*<<< orphan*/ *, int /*<<< orphan*/);
signed char get_Boolean(void) {
  char *text;
  signed long input;
  text = get_string();
  if (text == NULL)
    return -1;
  input = strtol(text, NULL, 0);
  if (errno == ERANGE) {
    errno = 0;
    return -1;
  }
  if (input != 0)
    return 1;
  return (text[0] & 1);
}


x86 assembly (clang, -O0):
<get_Boolean>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    $0x0,%al
call   1030 <get_string@plt>
mov    %rax,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    1147 <get_Boolean+0x27>
movb   $0xff,-0x1(%rbp)
jmp    11ac <get_Boolean+0x8c>
mov    -0x10(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%esi
xor    %edx,%edx
call   1040 <strtol@plt>
mov    %rax,-0x18(%rbp)
mov    0x2e77(%rip),%rax
mov    (%rax),%rax
mov    0x2e7d(%rip),%rcx
cmp    (%rcx),%rax
jne    118b <get_Boolean+0x6b>
mov    0x2e5d(%rip),%rax
movq   $0x0,(%rax)
movb   $0xff,-0x1(%rbp)
jmp    11ac <get_Boolean+0x8c>
cmpq   $0x0,-0x18(%rbp)
je     119f <get_Boolean+0x7f>
movb   $0x1,-0x1(%rbp)
jmp    11ac <get_Boolean+0x8c>
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
and    $0x1,%eax
mov    %al,-0x1(%rbp)
movsbl -0x1(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_Boolean>:
push   %rbp
push   %rbx
push   %rax
xor    %eax,%eax
call   1030 <get_string@plt>
mov    $0xff,%bpl
test   %rax,%rax
je     116f <get_Boolean+0x4f>
mov    %rax,%rbx
mov    %rax,%rdi
xor    %esi,%esi
xor    %edx,%edx
call   1040 <strtol@plt>
mov    0x2e90(%rip),%rcx
mov    (%rcx),%rdx
mov    0x2e96(%rip),%rsi
cmp    (%rsi),%rdx
jne    1160 <get_Boolean+0x40>
movq   $0x0,(%rcx)
jmp    116f <get_Boolean+0x4f>
mov    $0x1,%bpl
test   %rax,%rax
jne    116f <get_Boolean+0x4f>
mov    (%rbx),%bpl
and    $0x1,%bpl
mov    %ebp,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@errno = global i64 0
@ERANGE = global i64 0
define signext i8 @get_Boolean() {
%1 = alloca i8
%2 = alloca i8*
%3 = alloca i64
%4 = call i8* (...) @get_string()
store i8* %4, i8** %2
%5 = load i8*, i8** %2
%6 = icmp eq i8* %5, null
br i1 %6, label %7, label %8
7: ; preds = %0
store i8 -1, i8* %1
br label %26
8: ; preds = %0
%9 = load i8*, i8** %2
%10 = call i64 @strtol(i8* %9, i32* null, i32 0)
store i64 %10, i64* %3
%11 = load i64, i64* @errno
%12 = load i64, i64* @ERANGE
%13 = icmp eq i64 %11, %12
br i1 %13, label %14, label %15
14: ; preds = %8
store i64 0, i64* @errno
store i8 -1, i8* %1
br label %26
15: ; preds = %8
%16 = load i64, i64* %3
%17 = icmp ne i64 %16, 0
br i1 %17, label %18, label %19
18: ; preds = %15
store i8 1, i8* %1
br label %26
19: ; preds = %15
%20 = load i8*, i8** %2
%21 = getelementptr inbounds i8, i8* %20, i64 0
%22 = load i8, i8* %21
%23 = sext i8 %22 to i32
%24 = and i32 %23, 1
%25 = trunc i32 %24 to i8
store i8 %25, i8* %1
br label %26
26: ; preds = %19, %18, %14, %7
%27 = load i8, i8* %1
ret i8 %27
}

LLVM IR (-O2):
@errno = global i64 0
@ERANGE = global i64 0
define signext i8 @get_Boolean() {
%1 = tail call i8* (...) @get_string()
%2 = icmp eq i8* %1, null
br i1 %2, label %14, label %3
3: ; preds = %0
%4 = tail call i64 @strtol(i8* nocapture %1, i32* null, i32 0)
%5 = load i64, i64* @errno
%6 = load i64, i64* @ERANGE
%7 = icmp eq i64 %5, %6
br i1 %7, label %8, label %9
8: ; preds = %3
store i64 0, i64* @errno
br label %14
9: ; preds = %3
%10 = icmp eq i64 %4, 0
br i1 %10, label %11, label %14
11: ; preds = %9
%12 = load i8, i8* %1
%13 = and i8 %12, 1
br label %14
14: ; preds = %9, %0, %11, %8
%15 = phi i8 [ -1, %8 ], [ %13, %11 ], [ -1, %0 ], [ 1, %9 ]
ret i8 %15
}