#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 */
long LONG_MAX;
long LONG_MIN;
long UINT_MAX;
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, long);
int /*<<< orphan*/ fputs(char *, int /*<<< orphan*/);
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ stderr;
long strtol(char *, int /*<<< orphan*/ *, int);
int set_tape_length(char *length) {
  long int temp_length = strtol(length, NULL, 10);
  if (temp_length > 0 && temp_length <= UINT_MAX)
    return temp_length;
  else {
    if (temp_length == LONG_MIN || temp_length == LONG_MAX)
      perror("");
    fputs("Invalid input for tape-length. It must be a number between 1 and ",
          stderr);
    fprintf(stderr, "%u\n", UINT_MAX);
    exit(-1);
  }
}


x86 assembly (clang, -O0):
<set_tape_length>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%esi
mov    $0xa,%edx
call   1050 <strtol@plt>
mov    %rax,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
jle    119b <set_tape_length+0x4b>
mov    -0x10(%rbp),%rax
mov    0x2e60(%rip),%rcx
cmp    (%rcx),%rax
jg     119b <set_tape_length+0x4b>
mov    -0x10(%rbp),%rax
add    $0x10,%rsp
pop    %rbp
ret
mov    -0x10(%rbp),%rax
mov    0x2e3a(%rip),%rcx
cmp    (%rcx),%rax
je     11c3 <set_tape_length+0x73>
mov    -0x10(%rbp),%rax
mov    0x2e0e(%rip),%rcx
cmp    (%rcx),%rax
jne    11cf <set_tape_length+0x7f>
lea    0xe7b(%rip),%rdi
call   1060 <perror@plt>
mov    0x2dfa(%rip),%rax
mov    (%rax),%esi
lea    0xe21(%rip),%rdi
call   1030 <fputs@plt>
mov    0x2de5(%rip),%rax
mov    (%rax),%edi
mov    0x2df4(%rip),%rax
mov    (%rax),%rdx
lea    0xe44(%rip),%rsi
call   1040 <fprintf@plt>
mov    $0xffffffff,%edi
call   1070 <exit@plt>

x86 assembly (clang, -O2):
<set_tape_length>:
push   %r14
push   %rbx
push   %rax
xor    %esi,%esi
mov    $0xa,%edx
call   1050 <strtol@plt>
mov    0x2e81(%rip),%rbx
test   %rax,%rax
jle    1179 <set_tape_length+0x29>
cmp    (%rbx),%rax
jg     1179 <set_tape_length+0x29>
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret
mov    0x2e60(%rip),%rcx
cmp    (%rcx),%rax
je     1191 <set_tape_length+0x41>
mov    0x2e3c(%rip),%rcx
cmp    (%rcx),%rax
jne    119d <set_tape_length+0x4d>
lea    0xead(%rip),%rdi
call   1060 <perror@plt>
mov    0x2e2c(%rip),%r14
mov    (%r14),%esi
lea    0xe52(%rip),%rdi
call   1030 <fputs@plt>
mov    (%r14),%edi
mov    (%rbx),%rdx
lea    0xe82(%rip),%rsi
call   1040 <fprintf@plt>
mov    $0xffffffff,%edi
call   1070 <exit@plt>

LLVM IR (-O0):
@UINT_MAX = global i64 0
@LONG_MIN = global i64 0
@LONG_MAX = global i64 0
@.str = [1 x i8] zeroinitializer
@.str.1 = [66 x i8] c"Invalid input for tape-length. It must be a number between 1 and \00"
@stderr = global i32 0
@.str.2 = [4 x i8] c"%u\0A\00"
define i32 @set_tape_length(i8* %0) {
%2 = alloca i8*
%3 = alloca i64
store i8* %0, i8** %2
%4 = load i8*, i8** %2
%5 = call i64 @strtol(i8* %4, i32* null, i32 10)
store i64 %5, i64* %3
%6 = load i64, i64* %3
%7 = icmp sgt i64 %6, 0
br i1 %7, label %8, label %15
8: ; preds = %1
%9 = load i64, i64* %3
%10 = load i64, i64* @UINT_MAX
%11 = icmp sle i64 %9, %10
br i1 %11, label %12, label %15
12: ; preds = %8
%13 = load i64, i64* %3
%14 = trunc i64 %13 to i32
ret i32 %14
15: ; preds = %8, %1
%16 = load i64, i64* %3
%17 = load i64, i64* @LONG_MIN
%18 = icmp eq i64 %16, %17
br i1 %18, label %23, label %19
19: ; preds = %15
%20 = load i64, i64* %3
%21 = load i64, i64* @LONG_MAX
%22 = icmp eq i64 %20, %21
br i1 %22, label %23, label %25
23: ; preds = %19, %15
%24 = call i32 @perror(i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str, i64 0, i64 0))
br label %25
25: ; preds = %23, %19
%26 = load i32, i32* @stderr
%27 = call i32 @fputs(i8* getelementptr inbounds ([66 x i8], [66 x i8]* @.str.1, i64 0, i64 0), i32 %26)
%28 = load i32, i32* @stderr
%29 = load i64, i64* @UINT_MAX
%30 = call i32 @fprintf(i32 %28, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i64 %29)
%31 = call i32 @exit(i32 -1)
unreachable
}

LLVM IR (-O2):
@UINT_MAX = global i64 0
@LONG_MIN = global i64 0
@LONG_MAX = global i64 0
@.str = [1 x i8] zeroinitializer
@.str.1 = [66 x i8] c"Invalid input for tape-length. It must be a number between 1 and \00"
@stderr = global i32 0
@.str.2 = [4 x i8] c"%u\0A\00"
define i32 @set_tape_length(i8* nocapture %0) {
%2 = tail call i64 @strtol(i8* nocapture %0, i32* null, i32 10)
%3 = icmp slt i64 %2, 1
%4 = load i64, i64* @UINT_MAX
%5 = icmp sgt i64 %2, %4
%6 = select i1 %3, i1 true, i1 %5
br i1 %6, label %9, label %7
7: ; preds = %1
%8 = trunc i64 %2 to i32
ret i32 %8
9: ; preds = %1
%10 = load i64, i64* @LONG_MIN
%11 = icmp eq i64 %2, %10
%12 = load i64, i64* @LONG_MAX
%13 = icmp eq i64 %2, %12
%14 = select i1 %11, i1 true, i1 %13
br i1 %14, label %15, label %17
15: ; preds = %9
%16 = tail call i32 @perror(i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str, i64 0, i64 0))
br label %17
17: ; preds = %9, %15
%18 = load i32, i32* @stderr
%19 = tail call i32 @fputs(i8* getelementptr inbounds ([66 x i8], [66 x i8]* @.str.1, i64 0, i64 0), i32 %18)
%20 = load i32, i32* @stderr
%21 = load i64, i64* @UINT_MAX
%22 = tail call i32 @fprintf(i32 %20, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i64 %21)
%23 = tail call i32 @exit(i32 -1)
unreachable
}