#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*/ EX_USAGE;
int /*<<< orphan*/ errx(int /*<<< orphan*/, char *, char const *);
long strtol(char const *, char **, int /*<<< orphan*/);
size_t get_positive(const char *s, const char *err_mess, int fussyP) {
  char *t;
  long result = strtol(s, &t, 0);
  if (*t) {
    if (fussyP)
      goto Lose;
    else
      return 0;
  }
  if (result <= 0) {
  Lose:
    errx(EX_USAGE, "%s", err_mess);
  }
  return (size_t)result;
}


x86 assembly (clang, -O0):
<get_positive>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %edx,-0x1c(%rbp)
mov    -0x10(%rbp),%rdi
lea    -0x28(%rbp),%rsi
xor    %edx,%edx
call   1040 <strtol@plt>
mov    %rax,-0x30(%rbp)
mov    -0x28(%rbp),%rax
cmpb   $0x0,(%rax)
je     116f <get_positive+0x4f>
cmpl   $0x0,-0x1c(%rbp)
je     1162 <get_positive+0x42>
jmp    117f <get_positive+0x5f>
movq   $0x0,-0x8(%rbp)
jmp    11a0 <get_positive+0x80>
cmpq   $0x0,-0x30(%rbp)
jg     1198 <get_positive+0x78>
jmp    117f <get_positive+0x5f>
mov    0x2e62(%rip),%rax
mov    (%rax),%edi
mov    -0x18(%rbp),%rdx
lea    0xe6d(%rip),%rsi
call   1030 <errx@plt>
mov    -0x30(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_positive>:
push   %rbp
push   %r14
push   %rbx
sub    $0x10,%rsp
mov    %edx,%ebp
mov    %rsi,%r14
lea    0x8(%rsp),%rsi
xor    %edx,%edx
call   1040 <strtol@plt>
mov    %rax,%rbx
mov    0x8(%rsp),%rax
cmpb   $0x0,(%rax)
je     114e <get_positive+0x2e>
test   %ebp,%ebp
jne    1153 <get_positive+0x33>
xor    %ebx,%ebx
jmp    116b <get_positive+0x4b>
test   %rbx,%rbx
jg     116b <get_positive+0x4b>
mov    0x2e8e(%rip),%rax
mov    (%rax),%edi
lea    0xe9d(%rip),%rsi
mov    %r14,%rdx
call   1030 <errx@plt>
mov    %rbx,%rax
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@EX_USAGE = global i32 0
@.str = [3 x i8] c"%s\00"
define i64 @get_positive(i8* %0, i8* %1, i32 %2) {
%4 = alloca i64
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca i32
%8 = alloca i8*
%9 = alloca i64
store i8* %0, i8** %5
store i8* %1, i8** %6
store i32 %2, i32* %7
%10 = load i8*, i8** %5
%11 = call i64 @strtol(i8* %10, i8** %8, i32 0)
store i64 %11, i64* %9
%12 = load i8*, i8** %8
%13 = load i8, i8* %12
%14 = icmp ne i8 %13, 0
br i1 %14, label %15, label %20
15: ; preds = %3
%16 = load i32, i32* %7
%17 = icmp ne i32 %16, 0
br i1 %17, label %18, label %19
18: ; preds = %15
br label %24
19: ; preds = %15
store i64 0, i64* %4
br label %30
20: ; preds = %3
%21 = load i64, i64* %9
%22 = icmp sle i64 %21, 0
br i1 %22, label %23, label %28
23: ; preds = %20
br label %24
24: ; preds = %23, %18
%25 = load i32, i32* @EX_USAGE
%26 = load i8*, i8** %6
%27 = call i32 @errx(i32 %25, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %26)
br label %28
28: ; preds = %24, %20
%29 = load i64, i64* %9
store i64 %29, i64* %4
br label %30
30: ; preds = %28, %19
%31 = load i64, i64* %4
ret i64 %31
}

LLVM IR (-O2):
@EX_USAGE = global i32 0
@.str = [3 x i8] c"%s\00"
define i64 @get_positive(i8* %0, i8* %1, i32 %2) {
%4 = alloca i8*
%5 = bitcast i8** %4 to i8*
%6 = call i64 @strtol(i8* %0, i8** %4, i32 0)
%7 = load i8*, i8** %4
%8 = load i8, i8* %7
%9 = icmp eq i8 %8, 0
br i1 %9, label %12, label %10
10: ; preds = %3
%11 = icmp eq i32 %2, 0
br i1 %11, label %17, label %14
12: ; preds = %3
%13 = icmp slt i64 %6, 1
br i1 %13, label %14, label %17
14: ; preds = %12, %10
%15 = load i32, i32* @EX_USAGE
%16 = tail call i32 @errx(i32 %15, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %1)
br label %17
17: ; preds = %12, %14, %10
%18 = phi i64 [ 0, %10 ], [ %6, %14 ], [ %6, %12 ]
ret i64 %18
}