#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 */
typedef int /*<<< orphan*/ uid_t;

/* Variables and functions */
scalar_t__ errno;
int /*<<< orphan*/ errx(int, char *, char const *, char const *);
int /*<<< orphan*/ strtoul(char const *, char **, int);
uid_t id(const char *name, const char *type) {
  uid_t val;
  char *ep;
  errno = 0;
  val = strtoul(name, &ep, 10);
  if (errno || *ep != '\0')
    errx(1, "%s: illegal %s name", name, type);
  return (val);
}


x86 assembly (clang, -O0):
<id>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    0x2ea9(%rip),%rax
movq   $0x0,(%rax)
mov    -0x8(%rbp),%rdi
lea    -0x20(%rbp),%rsi
mov    $0xa,%edx
call   1040 <strtoul@plt>
mov    %eax,-0x14(%rbp)
mov    0x2e86(%rip),%rax
cmpq   $0x0,(%rax)
jne    1174 <id+0x54>
mov    -0x20(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
je     118d <id+0x6d>
mov    -0x8(%rbp),%rdx
mov    -0x10(%rbp),%rcx
mov    $0x1,%edi
lea    0xe78(%rip),%rsi
call   1030 <errx@plt>
mov    -0x14(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<id>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %rsi,%r14
mov    %rdi,%rbx
mov    0x2eac(%rip),%r15
movq   $0x0,(%r15)
mov    %rsp,%rsi
mov    $0xa,%edx
call   1040 <strtoul@plt>
mov    %eax,%ebp
cmpq   $0x0,(%r15)
jne    1159 <id+0x39>
mov    (%rsp),%rax
cmpb   $0x0,(%rax)
je     1170 <id+0x50>
lea    0xea0(%rip),%rsi
mov    $0x1,%edi
mov    %rbx,%rdx
mov    %r14,%rcx
call   1030 <errx@plt>
mov    %ebp,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
@errno = global i64 0
@.str = [20 x i8] c"%s: illegal %s name\00"
define i32 @id(i8* %0, i8* %1) {
%3 = alloca i8*
%4 = bitcast i8** %3 to i8*
store i64 0, i64* @errno
%5 = call i32 @strtoul(i8* %0, i8** %3, i32 10)
%6 = load i64, i64* @errno
%7 = icmp eq i64 %6, 0
br i1 %7, label %8, label %12
8: ; preds = %2
%9 = load i8*, i8** %3
%10 = load i8, i8* %9
%11 = icmp eq i8 %10, 0
br i1 %11, label %14, label %12
12: ; preds = %8, %2
%13 = tail call i32 @errx(i32 1, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0), i8* %0, i8* %1)
br label %14
14: ; preds = %12, %8
ret i32 %5
}