#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 *);
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *, ...);
int /*<<< orphan*/ numeric(char *);
int /*<<< orphan*/ stderr;
int get_posval(char *name, char *val) {
  int value = atoi(val);
  if (!numeric(val)) {
    fprintf(stderr, "atoprc: %s value %s not a (positive) numeric\n", name,
            val);
    exit(1);
  }
  if (value < 0) {
    fprintf(stderr, "atoprc: %s value %d not positive\n", name, value);
    exit(1);
  }
  return value;
}


x86 assembly (clang, -O0):
<get_posval>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
call   1050 <atoi@plt>
mov    %eax,-0x14(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <numeric@plt>
cmp    $0x0,%eax
jne    1197 <get_posval+0x57>
mov    0x2e6b(%rip),%rax
mov    (%rax),%edi
mov    -0x8(%rbp),%rdx
mov    -0x10(%rbp),%rcx
lea    0xe7a(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
mov    $0x1,%edi
call   1060 <exit@plt>
cmpl   $0x0,-0x14(%rbp)
jge    11c9 <get_posval+0x89>
mov    0x2e38(%rip),%rax
mov    (%rax),%edi
mov    -0x8(%rbp),%rdx
mov    -0x14(%rbp),%ecx
lea    0xe76(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
mov    $0x1,%edi
call   1060 <exit@plt>
mov    -0x14(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_posval>:
push   %rbp
push   %r14
push   %rbx
mov    %rsi,%rbx
mov    %rdi,%r14
mov    %rsi,%rdi
call   1050 <atoi@plt>
mov    %eax,%ebp
mov    %rbx,%rdi
call   1030 <numeric@plt>
test   %eax,%eax
je     116b <get_posval+0x2b>
test   %ebp,%ebp
js     1192 <get_posval+0x52>
mov    %ebp,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret
mov    0x2e6e(%rip),%rax
mov    (%rax),%edi
lea    0xe85(%rip),%rsi
mov    %r14,%rdx
mov    %rbx,%rcx
xor    %eax,%eax
call   1040 <fprintf@plt>
mov    $0x1,%edi
call   1060 <exit@plt>
mov    0x2e47(%rip),%rax
mov    (%rax),%edi
lea    0xe8c(%rip),%rsi
mov    %r14,%rdx
mov    %ebp,%ecx
xor    %eax,%eax
call   1040 <fprintf@plt>
mov    $0x1,%edi
call   1060 <exit@plt>

LLVM IR (-O0):
@stderr = global i32 0
@.str = [46 x i8] c"atoprc: %s value %s not a (positive) numeric\0A\00"
@.str.1 = [34 x i8] c"atoprc: %s value %d not positive\0A\00"
define i32 @get_posval(i8* %0, i8* %1) {
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i32
store i8* %0, i8** %3
store i8* %1, i8** %4
%6 = load i8*, i8** %4
%7 = call i32 @atoi(i8* %6)
store i32 %7, i32* %5
%8 = load i8*, i8** %4
%9 = call i32 @numeric(i8* %8)
%10 = icmp ne i32 %9, 0
br i1 %10, label %17, label %11
11: ; preds = %2
%12 = load i32, i32* @stderr
%13 = load i8*, i8** %3
%14 = load i8*, i8** %4
%15 = call i32 (i32, i8*, i8*, ...) @fprintf(i32 %12, i8* getelementptr inbounds ([46 x i8], [46 x i8]* @.str, i64 0, i64 0), i8* %13, i8* %14)
%16 = call i32 @exit(i32 1)
unreachable
17: ; preds = %2
%18 = load i32, i32* %5
%19 = icmp slt i32 %18, 0
br i1 %19, label %20, label %26
20: ; preds = %17
%21 = load i32, i32* @stderr
%22 = load i8*, i8** %3
%23 = load i32, i32* %5
%24 = call i32 (i32, i8*, i8*, ...) @fprintf(i32 %21, i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.1, i64 0, i64 0), i8* %22, i32 %23)
%25 = call i32 @exit(i32 1)
unreachable
26: ; preds = %17
%27 = load i32, i32* %5
ret i32 %27
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [46 x i8] c"atoprc: %s value %s not a (positive) numeric\0A\00"
@.str.1 = [34 x i8] c"atoprc: %s value %d not positive\0A\00"
define i32 @get_posval(i8* %0, i8* %1) {
%3 = tail call i32 @atoi(i8* %1)
%4 = tail call i32 @numeric(i8* %1)
%5 = icmp eq i32 %4, 0
br i1 %5, label %6, label %10
6: ; preds = %2
%7 = load i32, i32* @stderr
%8 = tail call i32 (i32, i8*, i8*, ...) @fprintf(i32 %7, i8* getelementptr inbounds ([46 x i8], [46 x i8]* @.str, i64 0, i64 0), i8* %0, i8* %1)
%9 = tail call i32 @exit(i32 1)
unreachable
10: ; preds = %2
%11 = icmp slt i32 %3, 0
br i1 %11, label %12, label %16
12: ; preds = %10
%13 = load i32, i32* @stderr
%14 = tail call i32 (i32, i8*, i8*, ...) @fprintf(i32 %13, i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.1, i64 0, i64 0), i8* %0, i32 %3)
%15 = tail call i32 @exit(i32 1)
unreachable
16: ; preds = %10
ret i32 %3
}