#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 atoi(char const *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char const *);
int /*<<< orphan*/ stderr;
size_t strlen(char const *);
int /*<<< orphan*/ strncmp(char const *, char const *, size_t);
int /*<<< orphan*/ usage(int /*<<< orphan*/, int);
int get_int_option(const char *str, const char *name, int *num) {
  size_t namelen = strlen(name);
  if (!strncmp(str, name, namelen)) {
    *num = atoi(str + namelen);
    if (*num == 0 && str[namelen] != '0') {
      fprintf(stderr, "\nBad numeric option value: %s\n\n", str);
      usage(stderr, 1);
    }
    return 1;
  }
  return 0;
}


x86 assembly (clang, -O0):
<get_int_option>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    -0x18(%rbp),%rdi
call   1040 <strlen@plt>
mov    %rax,-0x28(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    -0x28(%rbp),%rdx
call   1030 <strncmp@plt>
cmp    $0x0,%eax
jne    11fa <get_int_option+0xaa>
mov    -0x10(%rbp),%rdi
add    -0x28(%rbp),%rdi
call   1070 <atoi@plt>
mov    %eax,%ecx
mov    -0x20(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x20(%rbp),%rax
cmpl   $0x0,(%rax)
jne    11ee <get_int_option+0x9e>
mov    -0x10(%rbp),%rax
mov    -0x28(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x30,%eax
je     11ee <get_int_option+0x9e>
mov    0x2e17(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rdx
lea    0xe2a(%rip),%rsi
call   1050 <fprintf@plt>
mov    0x2dfe(%rip),%rax
mov    (%rax),%edi
mov    $0x1,%esi
call   1060 <usage@plt>
movl   $0x1,-0x4(%rbp)
jmp    1201 <get_int_option+0xb1>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_int_option>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %rdx,%r14
mov    %rsi,%rbp
mov    %rdi,%r15
mov    %rsi,%rdi
call   1040 <strlen@plt>
mov    %rax,%rbx
mov    %r15,%rdi
mov    %rbp,%rsi
mov    %rax,%rdx
call   1030 <strncmp@plt>
xor    %ebp,%ebp
test   %eax,%eax
jne    11c4 <get_int_option+0x74>
add    %r15,%rbx
mov    %rbx,%rdi
call   1070 <atoi@plt>
mov    %eax,(%r14)
mov    $0x1,%ebp
test   %eax,%eax
jne    11c4 <get_int_option+0x74>
cmpb   $0x30,(%rbx)
je     11c4 <get_int_option+0x74>
mov    0x2e3e(%rip),%rbx
mov    (%rbx),%edi
lea    0xe55(%rip),%rsi
mov    %r15,%rdx
call   1050 <fprintf@plt>
mov    (%rbx),%edi
mov    $0x1,%ebp
mov    $0x1,%esi
call   1060 <usage@plt>
mov    %ebp,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@stderr = global i32 0
@.str = [32 x i8] c"\0ABad numeric option value: %s\0A\0A\00"
define i32 @get_int_option(i8* %0, i8* %1, i32* %2) {
%4 = alloca i32
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca i32*
%8 = alloca i64
store i8* %0, i8** %5
store i8* %1, i8** %6
store i32* %2, i32** %7
%9 = load i8*, i8** %6
%10 = call i64 @strlen(i8* %9)
store i64 %10, i64* %8
%11 = load i8*, i8** %5
%12 = load i8*, i8** %6
%13 = load i64, i64* %8
%14 = call i32 @strncmp(i8* %11, i8* %12, i64 %13)
%15 = icmp ne i32 %14, 0
br i1 %15, label %39, label %16
16: ; preds = %3
%17 = load i8*, i8** %5
%18 = load i64, i64* %8
%19 = getelementptr inbounds i8, i8* %17, i64 %18
%20 = call i32 @atoi(i8* %19)
%21 = load i32*, i32** %7
store i32 %20, i32* %21
%22 = load i32*, i32** %7
%23 = load i32, i32* %22
%24 = icmp eq i32 %23, 0
br i1 %24, label %25, label %38
25: ; preds = %16
%26 = load i8*, i8** %5
%27 = load i64, i64* %8
%28 = getelementptr inbounds i8, i8* %26, i64 %27
%29 = load i8, i8* %28
%30 = sext i8 %29 to i32
%31 = icmp ne i32 %30, 48
br i1 %31, label %32, label %38
32: ; preds = %25
%33 = load i32, i32* @stderr
%34 = load i8*, i8** %5
%35 = call i32 @fprintf(i32 %33, i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str, i64 0, i64 0), i8* %34)
%36 = load i32, i32* @stderr
%37 = call i32 @usage(i32 %36, i32 1)
br label %38
38: ; preds = %32, %25, %16
store i32 1, i32* %4
br label %40
39: ; preds = %3
store i32 0, i32* %4
br label %40
40: ; preds = %39, %38
%41 = load i32, i32* %4
ret i32 %41
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [32 x i8] c"\0ABad numeric option value: %s\0A\0A\00"
define i32 @get_int_option(i8* %0, i8* nocapture %1, i32* nocapture writeonly %2) {
%4 = tail call i64 @strlen(i8* dereferenceable(1) %1)
%5 = tail call i32 @strncmp(i8* %0, i8* %1, i64 %4)
%6 = icmp eq i32 %5, 0
br i1 %6, label %7, label %19
7: ; preds = %3
%8 = getelementptr inbounds i8, i8* %0, i64 %4
%9 = tail call i32 @atoi(i8* %8)
store i32 %9, i32* %2
%10 = icmp eq i32 %9, 0
br i1 %10, label %11, label %19
11: ; preds = %7
%12 = load i8, i8* %8
%13 = icmp eq i8 %12, 48
br i1 %13, label %19, label %14
14: ; preds = %11
%15 = load i32, i32* @stderr
%16 = tail call i32 @fprintf(i32 %15, i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str, i64 0, i64 0), i8* %0)
%17 = load i32, i32* @stderr
%18 = tail call i32 @usage(i32 %17, i32 1)
br label %19
19: ; preds = %3, %7, %11, %14
%20 = phi i32 [ 1, %14 ], [ 1, %11 ], [ 1, %7 ], [ 0, %3 ]
ret i32 %20
}