#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;
char *next_param(char ***);
int /*<<< orphan*/ progerr(char *, char, ...);
int /*<<< orphan*/ progerrno(char *, char, char *);
long strtol(char *, char **, int);
int get_param_number(char ***argv, char c) {
  char *badchar;
  long num;
  char *string = next_param(argv);
  if (!string)
    progerr(" '-%c' requires a positive integer.", c);
  num = strtol(string, &badchar, 10);
  if (num == LONG_MAX || num == LONG_MIN)
    progerrno("Failed to convert '-%c %s' to a number: ", c, string);
  if (*badchar)
    progerr("Invalid char '%c' found in argument to '-%c %s'", badchar[0], c,
            string);
  return (int)num;
}


x86 assembly (clang, -O0):
<get_param_number>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %sil,%al
mov    %rdi,-0x8(%rbp)
mov    %al,-0x9(%rbp)
mov    -0x8(%rbp),%rdi
call   1050 <next_param@plt>
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
jne    117c <get_param_number+0x3c>
lea    0xe8f(%rip),%rdi
movsbl -0x9(%rbp),%esi
mov    $0x0,%al
call   1030 <progerr@plt>
mov    -0x28(%rbp),%rdi
lea    -0x18(%rbp),%rsi
mov    $0xa,%edx
call   1040 <strtol@plt>
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rax
mov    0x2e3b(%rip),%rcx
cmp    (%rcx),%rax
je     11ba <get_param_number+0x7a>
mov    -0x20(%rbp),%rax
mov    0x2e37(%rip),%rcx
cmp    (%rcx),%rax
jne    11d0 <get_param_number+0x90>
mov    -0x9(%rbp),%al
mov    -0x28(%rbp),%rdx
lea    0xe5c(%rip),%rdi
movsbl %al,%esi
call   1060 <progerrno@plt>
mov    -0x18(%rbp),%rax
cmpb   $0x0,(%rax)
je     11fc <get_param_number+0xbc>
mov    -0x18(%rbp),%rax
mov    (%rax),%al
movsbl -0x9(%rbp),%edx
mov    -0x28(%rbp),%rcx
lea    0xe5b(%rip),%rdi
movsbl %al,%esi
mov    $0x0,%al
call   1030 <progerr@plt>
mov    -0x20(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_param_number>:
push   %rbp
push   %r14
push   %rbx
sub    $0x10,%rsp
mov    %esi,%ebp
call   1050 <next_param@plt>
mov    %rax,%rbx
movsbl %bpl,%r14d
test   %rax,%rax
jne    116c <get_param_number+0x2c>
lea    0xe9e(%rip),%rdi
mov    %r14d,%esi
xor    %eax,%eax
call   1030 <progerr@plt>
lea    0x8(%rsp),%rsi
mov    %rbx,%rdi
mov    $0xa,%edx
call   1040 <strtol@plt>
mov    %rax,%rbp
mov    0x2e50(%rip),%rax
cmp    (%rax),%rbp
je     1199 <get_param_number+0x59>
mov    0x2e54(%rip),%rax
cmp    (%rax),%rbp
jne    11ab <get_param_number+0x6b>
lea    0xe84(%rip),%rdi
mov    %r14d,%esi
mov    %rbx,%rdx
call   1060 <progerrno@plt>
mov    0x8(%rsp),%rax
mov    (%rax),%al
test   %al,%al
je     11cd <get_param_number+0x8d>
movsbl %al,%esi
lea    0xe8d(%rip),%rdi
mov    %r14d,%edx
mov    %rbx,%rcx
xor    %eax,%eax
call   1030 <progerr@plt>
mov    %ebp,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@.str = [36 x i8] c" '-%c' requires a positive integer.\00"
@LONG_MAX = global i64 0
@LONG_MIN = global i64 0
@.str.1 = [41 x i8] c"Failed to convert '-%c %s' to a number: \00"
@.str.2 = [48 x i8] c"Invalid char '%c' found in argument to '-%c %s'\00"
define i32 @get_param_number(i8*** %0, i8 signext %1) {
%3 = alloca i8***
%4 = alloca i8
%5 = alloca i8*
%6 = alloca i64
%7 = alloca i8*
store i8*** %0, i8**** %3
store i8 %1, i8* %4
%8 = load i8***, i8**** %3
%9 = call i8* @next_param(i8*** %8)
store i8* %9, i8** %7
%10 = load i8*, i8** %7
%11 = icmp ne i8* %10, null
br i1 %11, label %15, label %12
12: ; preds = %2
%13 = load i8, i8* %4
%14 = call i32 (i8*, i8, ...) @progerr(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str, i64 0, i64 0), i8 signext %13)
br label %15
15: ; preds = %12, %2
%16 = load i8*, i8** %7
%17 = call i64 @strtol(i8* %16, i8** %5, i32 10)
store i64 %17, i64* %6
%18 = load i64, i64* %6
%19 = load i64, i64* @LONG_MAX
%20 = icmp eq i64 %18, %19
br i1 %20, label %25, label %21
21: ; preds = %15
%22 = load i64, i64* %6
%23 = load i64, i64* @LONG_MIN
%24 = icmp eq i64 %22, %23
br i1 %24, label %25, label %29
25: ; preds = %21, %15
%26 = load i8, i8* %4
%27 = load i8*, i8** %7
%28 = call i32 @progerrno(i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str.1, i64 0, i64 0), i8 signext %26, i8* %27)
br label %29
29: ; preds = %25, %21
%30 = load i8*, i8** %5
%31 = load i8, i8* %30
%32 = icmp ne i8 %31, 0
br i1 %32, label %33, label %41
33: ; preds = %29
%34 = load i8*, i8** %5
%35 = getelementptr inbounds i8, i8* %34, i64 0
%36 = load i8, i8* %35
%37 = load i8, i8* %4
%38 = sext i8 %37 to i32
%39 = load i8*, i8** %7
%40 = call i32 (i8*, i8, ...) @progerr(i8* getelementptr inbounds ([48 x i8], [48 x i8]* @.str.2, i64 0, i64 0), i8 signext %36, i32 %38, i8* %39)
br label %41
41: ; preds = %33, %29
%42 = load i64, i64* %6
%43 = trunc i64 %42 to i32
ret i32 %43
}

LLVM IR (-O2):
@.str = [36 x i8] c" '-%c' requires a positive integer.\00"
@LONG_MAX = global i64 0
@LONG_MIN = global i64 0
@.str.1 = [41 x i8] c"Failed to convert '-%c %s' to a number: \00"
@.str.2 = [48 x i8] c"Invalid char '%c' found in argument to '-%c %s'\00"
define i32 @get_param_number(i8*** %0, i8 signext %1) {
%3 = alloca i8*
%4 = bitcast i8** %3 to i8*
%5 = tail call i8* @next_param(i8*** %0)
%6 = icmp eq i8* %5, null
br i1 %6, label %7, label %9
7: ; preds = %2
%8 = tail call i32 (i8*, i8, ...) @progerr(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str, i64 0, i64 0), i8 signext %1)
br label %9
9: ; preds = %7, %2
%10 = call i64 @strtol(i8* %5, i8** %3, i32 10)
%11 = load i64, i64* @LONG_MAX
%12 = icmp eq i64 %10, %11
%13 = load i64, i64* @LONG_MIN
%14 = icmp eq i64 %10, %13
%15 = select i1 %12, i1 true, i1 %14
br i1 %15, label %16, label %18
16: ; preds = %9
%17 = tail call i32 @progerrno(i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str.1, i64 0, i64 0), i8 signext %1, i8* %5)
br label %18
18: ; preds = %9, %16
%19 = load i8*, i8** %3
%20 = load i8, i8* %19
%21 = icmp eq i8 %20, 0
br i1 %21, label %25, label %22
22: ; preds = %18
%23 = sext i8 %1 to i32
%24 = tail call i32 (i8*, i8, ...) @progerr(i8* getelementptr inbounds ([48 x i8], [48 x i8]* @.str.2, i64 0, i64 0), i8 signext %20, i32 %23, i8* %5)
br label %25
25: ; preds = %22, %18
%26 = trunc i64 %10 to i32
ret i32 %26
}