#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 atol(char *);
int /*<<< orphan*/ die(char *, char *, ...);
scalar_t__ pit_arg_is_option(char **);
int pit_arg_number(char **arg, char *required) {
  int number = 0;
  if (required && (!*arg || pit_arg_is_option(arg))) {
    die("missing %s", required);
  }
  if (*arg) {
    number = atol(*arg);
    if (number == 0 && **arg != '0' && required) {
      die("invalid %s value: %s", required, *arg);
    }
  }
  return number;
}


x86 assembly (clang, -O0):
<pit_arg_number>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
cmpq   $0x0,-0x10(%rbp)
je     1185 <pit_arg_number+0x55>
mov    -0x8(%rbp),%rax
cmpq   $0x0,(%rax)
je     1173 <pit_arg_number+0x43>
mov    -0x8(%rbp),%rdi
call   1030 <pit_arg_is_option@plt>
cmp    $0x0,%rax
je     1185 <pit_arg_number+0x55>
mov    -0x10(%rbp),%rsi
lea    0xe82(%rip),%rdi
mov    $0x0,%al
call   1050 <die@plt>
mov    -0x8(%rbp),%rax
cmpq   $0x0,(%rax)
je     11e8 <pit_arg_number+0xb8>
mov    -0x8(%rbp),%rax
mov    (%rax),%rdi
call   1040 <atol@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0x0,-0x14(%rbp)
jne    11e3 <pit_arg_number+0xb3>
mov    -0x8(%rbp),%rax
mov    (%rax),%rax
movsbl (%rax),%eax
cmp    $0x30,%eax
je     11e3 <pit_arg_number+0xb3>
cmpq   $0x0,-0x10(%rbp)
je     11e3 <pit_arg_number+0xb3>
mov    -0x10(%rbp),%rsi
mov    -0x8(%rbp),%rax
mov    (%rax),%rdx
lea    0xe2f(%rip),%rdi
mov    $0x0,%al
call   1050 <die@plt>
jmp    11e8 <pit_arg_number+0xb8>
mov    -0x14(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<pit_arg_number>:
push   %rbp
push   %r14
push   %rbx
mov    %rsi,%r14
mov    %rdi,%rbx
test   %rsi,%rsi
je     1163 <pit_arg_number+0x33>
cmpq   $0x0,(%rbx)
je     1152 <pit_arg_number+0x22>
mov    %rbx,%rdi
call   1030 <pit_arg_is_option@plt>
test   %rax,%rax
je     1163 <pit_arg_number+0x33>
lea    0xea7(%rip),%rdi
mov    %r14,%rsi
xor    %eax,%eax
call   1050 <die@plt>
mov    (%rbx),%rbx
test   %rbx,%rbx
je     11a0 <pit_arg_number+0x70>
mov    %rbx,%rdi
call   1040 <atol@plt>
mov    %eax,%ebp
test   %eax,%eax
jne    11a2 <pit_arg_number+0x72>
test   %r14,%r14
je     11a0 <pit_arg_number+0x70>
cmpb   $0x30,(%rbx)
mov    $0x0,%ebp
je     11a2 <pit_arg_number+0x72>
lea    0xe7c(%rip),%rdi
xor    %ebp,%ebp
mov    %r14,%rsi
mov    %rbx,%rdx
xor    %eax,%eax
call   1050 <die@plt>
jmp    11a2 <pit_arg_number+0x72>
xor    %ebp,%ebp
mov    %ebp,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@.str = [11 x i8] c"missing %s\00"
@.str.1 = [21 x i8] c"invalid %s value: %s\00"
define i32 @pit_arg_number(i8** %0, i8* %1) {
%3 = alloca i8**
%4 = alloca i8*
%5 = alloca i32
store i8** %0, i8*** %3
store i8* %1, i8** %4
store i32 0, i32* %5
%6 = load i8*, i8** %4
%7 = icmp ne i8* %6, null
br i1 %7, label %8, label %19
8: ; preds = %2
%9 = load i8**, i8*** %3
%10 = load i8*, i8** %9
%11 = icmp ne i8* %10, null
br i1 %11, label %12, label %16
12: ; preds = %8
%13 = load i8**, i8*** %3
%14 = call i64 @pit_arg_is_option(i8** %13)
%15 = icmp ne i64 %14, 0
br i1 %15, label %16, label %19
16: ; preds = %12, %8
%17 = load i8*, i8** %4
%18 = call i32 (i8*, i8*, ...) @die(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i8* %17)
br label %19
19: ; preds = %16, %12, %2
%20 = load i8**, i8*** %3
%21 = load i8*, i8** %20
%22 = icmp ne i8* %21, null
br i1 %22, label %23, label %44
23: ; preds = %19
%24 = load i8**, i8*** %3
%25 = load i8*, i8** %24
%26 = call i32 @atol(i8* %25)
store i32 %26, i32* %5
%27 = load i32, i32* %5
%28 = icmp eq i32 %27, 0
br i1 %28, label %29, label %43
29: ; preds = %23
%30 = load i8**, i8*** %3
%31 = load i8*, i8** %30
%32 = load i8, i8* %31
%33 = sext i8 %32 to i32
%34 = icmp ne i32 %33, 48
br i1 %34, label %35, label %43
35: ; preds = %29
%36 = load i8*, i8** %4
%37 = icmp ne i8* %36, null
br i1 %37, label %38, label %43
38: ; preds = %35
%39 = load i8*, i8** %4
%40 = load i8**, i8*** %3
%41 = load i8*, i8** %40
%42 = call i32 (i8*, i8*, ...) @die(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.1, i64 0, i64 0), i8* %39, i8* %41)
br label %43
43: ; preds = %38, %35, %29, %23
br label %44
44: ; preds = %43, %19
%45 = load i32, i32* %5
ret i32 %45
}

LLVM IR (-O2):
@.str = [11 x i8] c"missing %s\00"
@.str.1 = [21 x i8] c"invalid %s value: %s\00"
define i32 @pit_arg_number(i8** %0, i8* %1) {
%3 = icmp ne i8* %1, null
br i1 %3, label %4, label %12
4: ; preds = %2
%5 = load i8*, i8** %0
%6 = icmp eq i8* %5, null
br i1 %6, label %10, label %7
7: ; preds = %4
%8 = tail call i64 @pit_arg_is_option(i8** %0)
%9 = icmp eq i64 %8, 0
br i1 %9, label %12, label %10
10: ; preds = %7, %4
%11 = tail call i32 (i8*, i8*, ...) @die(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i8* %1)
br label %12
12: ; preds = %10, %7, %2
%13 = load i8*, i8** %0
%14 = icmp eq i8* %13, null
br i1 %14, label %24, label %15
15: ; preds = %12
%16 = tail call i32 @atol(i8* %13)
%17 = icmp eq i32 %16, 0
br i1 %17, label %18, label %24
18: ; preds = %15
%19 = load i8, i8* %13
%20 = icmp ne i8 %19, 48
%21 = and i1 %3, %20
br i1 %21, label %22, label %24
22: ; preds = %18
%23 = tail call i32 (i8*, i8*, ...) @die(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.1, i64 0, i64 0), i8* %1, i8* %13)
br label %24
24: ; preds = %15, %18, %22, %12
%25 = phi i32 [ 0, %22 ], [ 0, %18 ], [ %16, %15 ], [ 0, %12 ]
ret i32 %25
}