#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 */
short EX_USAGE;
int /*<<< orphan*/ PrintHelp();
short atoi(char *);
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();
    return (EX_USAGE);
  }
  if (num > 10) {
    printf("%s: Length cannot exceed %d\n", strArg, 10);
    PrintHelp();
    return (EX_USAGE);
  }
  return num;
}


x86 assembly (clang, -O0):
<GetSuffixMaxLength>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
lea    -0x1b(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1030 <strcpy@plt>
lea    -0x1b(%rbp),%rdi
call   1050 <atoi@plt>
mov    %ax,-0x1e(%rbp)
movswl -0x1e(%rbp),%eax
cmp    $0x1,%eax
jge    119f <GetSuffixMaxLength+0x5f>
mov    -0x10(%rbp),%rsi
lea    0xe82(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    $0x0,%al
call   1060 <PrintHelp@plt>
mov    0x2e55(%rip),%rax
mov    (%rax),%ax
mov    %ax,-0x2(%rbp)
jmp    11e5 <GetSuffixMaxLength+0xa5>
movswl -0x1e(%rbp),%eax
cmp    $0xa,%eax
jle    11dd <GetSuffixMaxLength+0x9d>
mov    -0x10(%rbp),%rsi
lea    0xe67(%rip),%rdi
mov    $0xa,%edx
mov    $0x0,%al
call   1040 <printf@plt>
mov    $0x0,%al
call   1060 <PrintHelp@plt>
mov    0x2e17(%rip),%rax
mov    (%rax),%ax
mov    %ax,-0x2(%rbp)
jmp    11e5 <GetSuffixMaxLength+0xa5>
mov    -0x1e(%rbp),%ax
mov    %ax,-0x2(%rbp)
movswl -0x2(%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+0x45>
cmp    $0xb,%ax
jb     11a7 <GetSuffixMaxLength+0x67>
lea    0xeaa(%rip),%rdi
mov    %r14,%rsi
mov    $0xa,%edx
xor    %eax,%eax
call   1040 <printf@plt>
jmp    1196 <GetSuffixMaxLength+0x56>
lea    0xe74(%rip),%rdi
mov    %r14,%rsi
xor    %eax,%eax
call   1040 <printf@plt>
xor    %eax,%eax
call   1060 <PrintHelp@plt>
mov    0x2e44(%rip),%rax
movzwl (%rax),%eax
add    $0x18,%rsp
pop    %rbx
pop    %r14
ret

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

LLVM IR (-O2):
@.str = [30 x i8] c"%s: Invalid length specified\0A\00"
@EX_USAGE = global i16 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 %9
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)
br label %13
9: ; preds = %1
%10 = icmp ugt i16 %5, 10
br i1 %10, label %11, label %16
11: ; preds = %9
%12 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.1, i64 0, i64 0), i8* %0, i32 10)
br label %13
13: ; preds = %7, %11
%14 = call i32 (...) @PrintHelp()
%15 = load i16, i16* @EX_USAGE
br label %16
16: ; preds = %13, %9
%17 = phi i16 [ %5, %9 ], [ %15, %13 ]
ret i16 %17
}