#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*/ die(char *, char const *, int /*<<< orphan*/);
scalar_t__ errno;
unsigned int parse_uint(char const *, unsigned int, unsigned int);
int /*<<< orphan*/ strerror(scalar_t__);
unsigned int parse_segment_index(const char *str, unsigned int min,
                                 unsigned int max, const char *fail_msg) {
  unsigned int ret = parse_uint(str, min, max);
  if (errno)
    die("%s: %s", fail_msg, strerror(errno));
  return ret;
}


x86 assembly (clang, -O0):
<parse_segment_index>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
mov    %rcx,-0x18(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%esi
mov    -0x10(%rbp),%edx
call   1050 <parse_uint@plt>
mov    %eax,-0x1c(%rbp)
mov    0x2e81(%rip),%rax
cmpq   $0x0,(%rax)
je     1192 <parse_segment_index+0x62>
mov    -0x18(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    0x2e68(%rip),%rax
mov    (%rax),%rdi
call   1040 <strerror@plt>
mov    -0x28(%rbp),%rsi
mov    %eax,%edx
lea    0xe73(%rip),%rdi
call   1030 <die@plt>
mov    -0x1c(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<parse_segment_index>:
push   %rbp
push   %rbx
push   %rax
mov    %rcx,%rbx
call   1050 <parse_uint@plt>
mov    %eax,%ebp
mov    0x2e9c(%rip),%rax
mov    (%rax),%rdi
test   %rdi,%rdi
je     1162 <parse_segment_index+0x32>
call   1040 <strerror@plt>
lea    0xea8(%rip),%rdi
mov    %rbx,%rsi
mov    %eax,%edx
call   1030 <die@plt>
mov    %ebp,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@errno = global i64 0
@.str = [7 x i8] c"%s: %s\00"
define i32 @parse_segment_index(i8* %0, i32 %1, i32 %2, i8* %3) {
%5 = alloca i8*
%6 = alloca i32
%7 = alloca i32
%8 = alloca i8*
%9 = alloca i32
store i8* %0, i8** %5
store i32 %1, i32* %6
store i32 %2, i32* %7
store i8* %3, i8** %8
%10 = load i8*, i8** %5
%11 = load i32, i32* %6
%12 = load i32, i32* %7
%13 = call i32 @parse_uint(i8* %10, i32 %11, i32 %12)
store i32 %13, i32* %9
%14 = load i64, i64* @errno
%15 = icmp ne i64 %14, 0
br i1 %15, label %16, label %21
16: ; preds = %4
%17 = load i8*, i8** %8
%18 = load i64, i64* @errno
%19 = call i32 @strerror(i64 %18)
%20 = call i32 @die(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i8* %17, i32 %19)
br label %21
21: ; preds = %16, %4
%22 = load i32, i32* %9
ret i32 %22
}

LLVM IR (-O2):
@errno = global i64 0
@.str = [7 x i8] c"%s: %s\00"
define i32 @parse_segment_index(i8* %0, i32 %1, i32 %2, i8* %3) {
%5 = tail call i32 @parse_uint(i8* %0, i32 %1, i32 %2)
%6 = load i64, i64* @errno
%7 = icmp eq i64 %6, 0
br i1 %7, label %11, label %8
8: ; preds = %4
%9 = tail call i32 @strerror(i64 %6)
%10 = tail call i32 @die(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i8* %3, i32 %9)
br label %11
11: ; preds = %8, %4
ret i32 %5
}