#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 */
int /*<<< orphan*/ EX_USAGE;
int /*<<< orphan*/ PrintHelp();
short atoi(char *);
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *, char *, ...);
int /*<<< orphan*/ strcpy(char *, char *);
short GetSuffixMaxLength(char *strArg) {
  char str[10 + 1];
  short num;
  strcpy(str, strArg);
  num = atoi(str);
  if (num < 1) {
    printf("%s: Invalid length specified\n", strArg);
    PrintHelp();
    exit(EX_USAGE);
  }
  if (num > 10) {
    printf("%s: Length cannot exceed %d\n", strArg, 10);
    PrintHelp();
    exit(EX_USAGE);
  }
  return num;
}


x86 assembly (clang, -O0):
<GetSuffixMaxLength>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
lea    -0x13(%rbp),%rdi
mov    -0x8(%rbp),%rsi
call   1030 <strcpy@plt>
lea    -0x13(%rbp),%rdi
call   1050 <atoi@plt>
mov    %ax,-0x16(%rbp)
movswl -0x16(%rbp),%eax
cmp    $0x1,%eax
jge    11aa <GetSuffixMaxLength+0x5a>
mov    -0x8(%rbp),%rsi
lea    0xe72(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    $0x0,%al
call   1070 <PrintHelp@plt>
mov    0x2e45(%rip),%rax
mov    (%rax),%edi
call   1060 <exit@plt>
movswl -0x16(%rbp),%eax
cmp    $0xa,%eax
jle    11e3 <GetSuffixMaxLength+0x93>
mov    -0x8(%rbp),%rsi
lea    0xe5c(%rip),%rdi
mov    $0xa,%edx
mov    $0x0,%al
call   1040 <printf@plt>
mov    $0x0,%al
call   1070 <PrintHelp@plt>
mov    0x2e0c(%rip),%rax
mov    (%rax),%edi
call   1060 <exit@plt>
movswl -0x16(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<GetSuffixMaxLength>:
push   %r14
push   %rbx
sub    $0x18,%rsp
mov    %rdi,%r14
lea    0xd(%rsp),%rbx
mov    %rbx,%rdi
mov    %r14,%rsi
call   1030 <strcpy@plt>
mov    %rbx,%rdi
call   1050 <atoi@plt>
test   %ax,%ax
jle    1185 <GetSuffixMaxLength+0x35>
cmp    $0xb,%ax
jae    1198 <GetSuffixMaxLength+0x48>
add    $0x18,%rsp
pop    %rbx
pop    %r14
ret
lea    0xe74(%rip),%rdi
mov    %r14,%rsi
xor    %eax,%eax
call   1040 <printf@plt>
jmp    11ae <GetSuffixMaxLength+0x5e>
lea    0xe7f(%rip),%rdi
mov    %r14,%rsi
mov    $0xa,%edx
xor    %eax,%eax
call   1040 <printf@plt>
xor    %eax,%eax
call   1070 <PrintHelp@plt>
mov    0x2e2c(%rip),%rax
mov    (%rax),%edi
call   1060 <exit@plt>

LLVM IR (-O0):
@.str = [30 x i8] c"%s: Invalid length specified\0A\00"
@EX_USAGE = global i32 0
@.str.1 = [29 x i8] c"%s: Length cannot exceed %d\0A\00"
define signext i16 @GetSuffixMaxLength(i8* %0) {
%2 = alloca i8*
%3 = alloca [11 x i8]
%4 = alloca i16
store i8* %0, i8** %2
%5 = getelementptr inbounds [11 x i8], [11 x i8]* %3, i64 0, i64 0
%6 = load i8*, i8** %2
%7 = call i32 @strcpy(i8* %5, i8* %6)
%8 = getelementptr inbounds [11 x i8], [11 x i8]* %3, i64 0, i64 0
%9 = call signext i16 @atoi(i8* %8)
store i16 %9, i16* %4
%10 = load i16, i16* %4
%11 = sext i16 %10 to i32
%12 = icmp slt i32 %11, 1
br i1 %12, label %13, label %19
13: ; preds = %1
%14 = load i8*, i8** %2
%15 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str, i64 0, i64 0), i8* %14)
%16 = call i32 (...) @PrintHelp()
%17 = load i32, i32* @EX_USAGE
%18 = call i32 @exit(i32 %17)
unreachable
19: ; preds = %1
%20 = load i16, i16* %4
%21 = sext i16 %20 to i32
%22 = icmp sgt i32 %21, 10
br i1 %22, label %23, label %29
23: ; preds = %19
%24 = load i8*, i8** %2
%25 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.1, i64 0, i64 0), i8* %24, i32 10)
%26 = call i32 (...) @PrintHelp()
%27 = load i32, i32* @EX_USAGE
%28 = call i32 @exit(i32 %27)
unreachable
29: ; preds = %19
%30 = load i16, i16* %4
ret i16 %30
}

LLVM IR (-O2):
@.str = [30 x i8] c"%s: Invalid length specified\0A\00"
@EX_USAGE = global i32 0
@.str.1 = [29 x i8] c"%s: Length cannot exceed %d\0A\00"
define signext i16 @GetSuffixMaxLength(i8* %0) {
%2 = alloca [11 x i8]
%3 = getelementptr inbounds [11 x i8], [11 x i8]* %2, i64 0, i64 0
%4 = call i32 @strcpy(i8* %3, i8* %0)
%5 = call signext i16 @atoi(i8* %3)
%6 = icmp slt i16 %5, 1
br i1 %6, label %7, label %12
7: ; preds = %1
%8 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str, i64 0, i64 0), i8* %0)
%9 = call i32 (...) @PrintHelp()
%10 = load i32, i32* @EX_USAGE
%11 = call i32 @exit(i32 %10)
unreachable
12: ; preds = %1
%13 = icmp ugt i16 %5, 10
br i1 %13, label %14, label %19
14: ; preds = %12
%15 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.1, i64 0, i64 0), i8* %0, i32 10)
%16 = call i32 (...) @PrintHelp()
%17 = load i32, i32* @EX_USAGE
%18 = call i32 @exit(i32 %17)
unreachable
19: ; preds = %12
ret i16 %5
}