#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*/ Usage(char *);
int /*<<< orphan*/ sprintf(char *, char *, char *);
scalar_t__ strtol(char *, char **, int /*<<< orphan*/);
int optionValue(char **argv, int *num) {
  int next = *num + 1;
  char *src = argv[next];
  char *tmp = 0;
  int result = 0;
  if (src != 0) {
    result = (int)strtol(src, &tmp, 0);
    if (tmp == 0 || *tmp != 0)
      src = 0;
  }
  if (src == 0) {
    char temp[80];
    sprintf(temp, "Expected a numeric-parameter for %.20s", argv[*num]);
    Usage(temp);
  }
  *num = next;
  return result;
}


x86 assembly (clang, -O0):
<optionValue>:
push   %rbp
mov    %rsp,%rbp
sub    $0x80,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x10(%rbp),%rax
mov    (%rax),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
mov    -0x8(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
mov    %rax,-0x20(%rbp)
movq   $0x0,-0x28(%rbp)
movl   $0x0,-0x2c(%rbp)
cmpq   $0x0,-0x20(%rbp)
je     11b3 <optionValue+0x83>
mov    -0x20(%rbp),%rdi
lea    -0x28(%rbp),%rsi
xor    %edx,%edx
call   1040 <strtol@plt>
mov    %eax,-0x2c(%rbp)
cmpq   $0x0,-0x28(%rbp)
je     11a6 <optionValue+0x76>
mov    -0x28(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
je     11ae <optionValue+0x7e>
movq   $0x0,-0x20(%rbp)
jmp    11b3 <optionValue+0x83>
cmpq   $0x0,-0x20(%rbp)
jne    11e6 <optionValue+0xb6>
lea    -0x80(%rbp),%rdi
mov    -0x8(%rbp),%rax
mov    -0x10(%rbp),%rcx
movslq (%rcx),%rcx
mov    (%rax,%rcx,8),%rdx
lea    0xe28(%rip),%rsi
call   1050 <sprintf@plt>
lea    -0x80(%rbp),%rdi
call   1030 <Usage@plt>
mov    -0x14(%rbp),%ecx
mov    -0x10(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x2c(%rbp),%eax
add    $0x80,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<optionValue>:
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x68,%rsp
mov    %rsi,%r12
mov    %rdi,%r14
movslq (%rsi),%rbx
mov    0x8(%rdi,%rbx,8),%rdi
add    $0x1,%rbx
movq   $0x0,0x8(%rsp)
test   %rdi,%rdi
je     117b <optionValue+0x4b>
lea    0x8(%rsp),%rsi
xor    %edx,%edx
call   1040 <strtol@plt>
mov    %rax,%r15
mov    0x8(%rsp),%rax
test   %rax,%rax
je     117e <optionValue+0x4e>
cmpb   $0x0,(%rax)
jne    117e <optionValue+0x4e>
jmp    11a2 <optionValue+0x72>
xor    %r15d,%r15d
movslq (%r12),%rax
mov    (%r14,%rax,8),%rdx
lea    0xe73(%rip),%rsi
lea    0x10(%rsp),%r14
mov    %r14,%rdi
call   1050 <sprintf@plt>
mov    %r14,%rdi
call   1030 <Usage@plt>
mov    %ebx,(%r12)
mov    %r15d,%eax
add    $0x68,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [39 x i8] c"Expected a numeric-parameter for %.20s\00"
define i32 @optionValue(i8** %0, i32* %1) {
%3 = alloca i8**
%4 = alloca i32*
%5 = alloca i32
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca i32
%9 = alloca [80 x i8]
store i8** %0, i8*** %3
store i32* %1, i32** %4
%10 = load i32*, i32** %4
%11 = load i32, i32* %10
%12 = add nsw i32 %11, 1
store i32 %12, i32* %5
%13 = load i8**, i8*** %3
%14 = load i32, i32* %5
%15 = sext i32 %14 to i64
%16 = getelementptr inbounds i8*, i8** %13, i64 %15
%17 = load i8*, i8** %16
store i8* %17, i8** %6
store i8* null, i8** %7
store i32 0, i32* %8
%18 = load i8*, i8** %6
%19 = icmp ne i8* %18, null
br i1 %19, label %20, label %33
20: ; preds = %2
%21 = load i8*, i8** %6
%22 = call i64 @strtol(i8* %21, i8** %7, i32 0)
%23 = trunc i64 %22 to i32
store i32 %23, i32* %8
%24 = load i8*, i8** %7
%25 = icmp eq i8* %24, null
br i1 %25, label %31, label %26
26: ; preds = %20
%27 = load i8*, i8** %7
%28 = load i8, i8* %27
%29 = sext i8 %28 to i32
%30 = icmp ne i32 %29, 0
br i1 %30, label %31, label %32
31: ; preds = %26, %20
store i8* null, i8** %6
br label %32
32: ; preds = %31, %26
br label %33
33: ; preds = %32, %2
%34 = load i8*, i8** %6
%35 = icmp eq i8* %34, null
br i1 %35, label %36, label %47
36: ; preds = %33
%37 = getelementptr inbounds [80 x i8], [80 x i8]* %9, i64 0, i64 0
%38 = load i8**, i8*** %3
%39 = load i32*, i32** %4
%40 = load i32, i32* %39
%41 = sext i32 %40 to i64
%42 = getelementptr inbounds i8*, i8** %38, i64 %41
%43 = load i8*, i8** %42
%44 = call i32 @sprintf(i8* %37, i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str, i64 0, i64 0), i8* %43)
%45 = getelementptr inbounds [80 x i8], [80 x i8]* %9, i64 0, i64 0
%46 = call i32 @Usage(i8* %45)
br label %47
47: ; preds = %36, %33
%48 = load i32, i32* %5
%49 = load i32*, i32** %4
store i32 %48, i32* %49
%50 = load i32, i32* %8
ret i32 %50
}

LLVM IR (-O2):
@.str = [39 x i8] c"Expected a numeric-parameter for %.20s\00"
define i32 @optionValue(i8** nocapture %0, i32* nocapture %1) {
%3 = alloca i8*
%4 = alloca [80 x i8]
%5 = load i32, i32* %1
%6 = add nsw i32 %5, 1
%7 = sext i32 %6 to i64
%8 = getelementptr inbounds i8*, i8** %0, i64 %7
%9 = load i8*, i8** %8
%10 = bitcast i8** %3 to i8*
store i8* null, i8** %3
%11 = icmp eq i8* %9, null
br i1 %11, label %20, label %12
12: ; preds = %2
%13 = call i64 @strtol(i8* %9, i8** %3, i32 0)
%14 = trunc i64 %13 to i32
%15 = load i8*, i8** %3
%16 = icmp eq i8* %15, null
br i1 %16, label %20, label %17
17: ; preds = %12
%18 = load i8, i8* %15
%19 = icmp eq i8 %18, 0
br i1 %19, label %29, label %20
20: ; preds = %12, %17, %2
%21 = phi i32 [ 0, %2 ], [ %14, %17 ], [ %14, %12 ]
%22 = getelementptr inbounds [80 x i8], [80 x i8]* %4, i64 0, i64 0
%23 = load i32, i32* %1
%24 = sext i32 %23 to i64
%25 = getelementptr inbounds i8*, i8** %0, i64 %24
%26 = load i8*, i8** %25
%27 = call i32 @sprintf(i8* %22, i8* dereferenceable(1) getelementptr inbounds ([39 x i8], [39 x i8]* @.str, i64 0, i64 0), i8* %26)
%28 = call i32 @Usage(i8* %22)
br label %29
29: ; preds = %17, %20
%30 = phi i32 [ %21, %20 ], [ %14, %17 ]
store i32 %6, i32* %1
ret i32 %30
}