#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__ EINVAL;
scalar_t__ ERANGE;
int /*<<< orphan*/ EXIT_FAILURE;
long INT_MAX;
int /*<<< orphan*/ err(int /*<<< orphan*/, char *, char const *);
scalar_t__ errno;
long strtol(char const *, char **, int);
int get_rotation(const char *arg) {
  long rot;
  char *endp;
  errno = 0;
  rot = strtol(arg, &endp, 10);
  if (errno == 0 && (arg[0] == '\0' || *endp != '\0'))
    errno = EINVAL;
  if (errno == 0 && (rot < 0 || rot > INT_MAX))
    errno = ERANGE;
  if (errno)
    err(EXIT_FAILURE, "Bad rotation value `%s'", arg);
  return (int)rot;
}


x86 assembly (clang, -O0):
<get_rotation>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    0x2e9d(%rip),%rax
movq   $0x0,(%rax)
mov    -0x8(%rbp),%rdi
lea    -0x18(%rbp),%rsi
mov    $0xa,%edx
call   1030 <strtol@plt>
mov    %rax,-0x10(%rbp)
mov    0x2e79(%rip),%rax
cmpq   $0x0,(%rax)
jne    1195 <get_rotation+0x75>
mov    -0x8(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
je     1181 <get_rotation+0x61>
mov    -0x18(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
je     1195 <get_rotation+0x75>
mov    0x2e38(%rip),%rax
mov    (%rax),%rcx
mov    0x2e3e(%rip),%rax
mov    %rcx,(%rax)
mov    0x2e34(%rip),%rax
cmpq   $0x0,(%rax)
jne    11d9 <get_rotation+0xb9>
cmpq   $0x0,-0x10(%rbp)
jl     11c5 <get_rotation+0xa5>
mov    -0x10(%rbp),%rax
mov    0x2e2c(%rip),%rcx
cmp    (%rcx),%rax
jle    11d9 <get_rotation+0xb9>
mov    0x2e14(%rip),%rax
mov    (%rax),%rcx
mov    0x2dfa(%rip),%rax
mov    %rcx,(%rax)
mov    0x2df0(%rip),%rax
cmpq   $0x0,(%rax)
je     1203 <get_rotation+0xe3>
mov    0x2dd7(%rip),%rax
mov    (%rax),%edi
mov    -0x8(%rbp),%rdx
lea    0xe02(%rip),%rsi
call   1040 <err@plt>
mov    -0x10(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_rotation>:
push   %r15
push   %r14
push   %rbx
sub    $0x10,%rsp
mov    %rdi,%rbx
mov    0x2e9d(%rip),%r15
movq   $0x0,(%r15)
lea    0x8(%rsp),%rsi
mov    $0xa,%edx
call   1030 <strtol@plt>
mov    %rax,%r14
cmpq   $0x0,(%r15)
jne    1196 <get_rotation+0x76>
cmpb   $0x0,(%rbx)
je     1161 <get_rotation+0x41>
mov    0x8(%rsp),%rax
cmpb   $0x0,(%rax)
je     1173 <get_rotation+0x53>
mov    0x2e58(%rip),%rax
mov    (%rax),%rax
mov    %rax,(%r15)
test   %rax,%rax
jne    1196 <get_rotation+0x76>
test   %r14,%r14
js     1184 <get_rotation+0x64>
mov    0x2e69(%rip),%rax
cmp    (%rax),%r14
jle    11ae <get_rotation+0x8e>
mov    0x2e55(%rip),%rax
mov    (%rax),%rax
mov    %rax,(%r15)
test   %rax,%rax
je     11ae <get_rotation+0x8e>
mov    0x2e2b(%rip),%rax
mov    (%rax),%edi
lea    0xe5a(%rip),%rsi
mov    %rbx,%rdx
call   1040 <err@plt>
mov    %r14d,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@errno = global i64 0
@EINVAL = global i64 0
@INT_MAX = global i64 0
@ERANGE = global i64 0
@EXIT_FAILURE = global i32 0
@.str = [24 x i8] c"Bad rotation value `%s'\00"
define i32 @get_rotation(i8* %0) {
%2 = alloca i8*
%3 = alloca i64
%4 = alloca i8*
store i8* %0, i8** %2
store i64 0, i64* @errno
%5 = load i8*, i8** %2
%6 = call i64 @strtol(i8* %5, i8** %4, i32 10)
store i64 %6, i64* %3
%7 = load i64, i64* @errno
%8 = icmp eq i64 %7, 0
br i1 %8, label %9, label %22
9: ; preds = %1
%10 = load i8*, i8** %2
%11 = getelementptr inbounds i8, i8* %10, i64 0
%12 = load i8, i8* %11
%13 = sext i8 %12 to i32
%14 = icmp eq i32 %13, 0
br i1 %14, label %20, label %15
15: ; preds = %9
%16 = load i8*, i8** %4
%17 = load i8, i8* %16
%18 = sext i8 %17 to i32
%19 = icmp ne i32 %18, 0
br i1 %19, label %20, label %22
20: ; preds = %15, %9
%21 = load i64, i64* @EINVAL
store i64 %21, i64* @errno
br label %22
22: ; preds = %20, %15, %1
%23 = load i64, i64* @errno
%24 = icmp eq i64 %23, 0
br i1 %24, label %25, label %34
25: ; preds = %22
%26 = load i64, i64* %3
%27 = icmp slt i64 %26, 0
br i1 %27, label %32, label %28
28: ; preds = %25
%29 = load i64, i64* %3
%30 = load i64, i64* @INT_MAX
%31 = icmp sgt i64 %29, %30
br i1 %31, label %32, label %34
32: ; preds = %28, %25
%33 = load i64, i64* @ERANGE
store i64 %33, i64* @errno
br label %34
34: ; preds = %32, %28, %22
%35 = load i64, i64* @errno
%36 = icmp ne i64 %35, 0
br i1 %36, label %37, label %41
37: ; preds = %34
%38 = load i32, i32* @EXIT_FAILURE
%39 = load i8*, i8** %2
%40 = call i32 @err(i32 %38, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0), i8* %39)
br label %41
41: ; preds = %37, %34
%42 = load i64, i64* %3
%43 = trunc i64 %42 to i32
ret i32 %43
}

LLVM IR (-O2):
@errno = global i64 0
@EINVAL = global i64 0
@INT_MAX = global i64 0
@ERANGE = global i64 0
@EXIT_FAILURE = global i32 0
@.str = [24 x i8] c"Bad rotation value `%s'\00"
define i32 @get_rotation(i8* %0) {
%2 = alloca i8*
%3 = bitcast i8** %2 to i8*
store i64 0, i64* @errno
%4 = call i64 @strtol(i8* %0, i8** %2, i32 10)
%5 = load i64, i64* @errno
%6 = icmp eq i64 %5, 0
br i1 %6, label %7, label %25
7: ; preds = %1
%8 = load i8, i8* %0
%9 = icmp eq i8 %8, 0
br i1 %9, label %14, label %10
10: ; preds = %7
%11 = load i8*, i8** %2
%12 = load i8, i8* %11
%13 = icmp eq i8 %12, 0
br i1 %13, label %17, label %14
14: ; preds = %7, %10
%15 = load i64, i64* @EINVAL
store i64 %15, i64* @errno
%16 = icmp eq i64 %15, 0
br i1 %16, label %17, label %25
17: ; preds = %10, %14
%18 = icmp slt i64 %4, 0
%19 = load i64, i64* @INT_MAX
%20 = icmp sgt i64 %4, %19
%21 = select i1 %18, i1 true, i1 %20
br i1 %21, label %22, label %28
22: ; preds = %17
%23 = load i64, i64* @ERANGE
store i64 %23, i64* @errno
%24 = icmp eq i64 %23, 0
br i1 %24, label %28, label %25
25: ; preds = %14, %1, %22
%26 = load i32, i32* @EXIT_FAILURE
%27 = tail call i32 @err(i32 %26, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0), i8* %0)
br label %28
28: ; preds = %17, %25, %22
%29 = trunc i64 %4 to i32
ret i32 %29
}