#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 */
unsigned long ULONG_MAX;
unsigned long errno;
int /*<<< orphan*/ printf(char *, char *, ...);
char *strerror(unsigned long);
unsigned long strtoul(char *, int /*<<< orphan*/ *, int /*<<< orphan*/);
int main(int argc, char **argv) {
  unsigned long err = 0;
  if (argc != 2) {
    printf("Usage: ./%s errno\n", argv[0]);
    return 1;
  }
  err = strtoul(argv[1], NULL, 0);
  if (err == ULONG_MAX) {
    printf("strtoul failed: %s\n", strerror(errno));
    return 1;
  }
  printf("%s represents: %s\n", argv[0], strerror(err));
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movq   $0x0,-0x18(%rbp)
cmpl   $0x2,-0x8(%rbp)
je     1179 <main+0x49>
mov    -0x10(%rbp),%rax
mov    (%rax),%rsi
lea    0xe9a(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    1200 <main+0xd0>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
xor    %eax,%eax
mov    %eax,%esi
xor    %edx,%edx
call   1040 <strtoul@plt>
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rax
mov    0x2e35(%rip),%rcx
cmp    (%rcx),%rax
jne    11d0 <main+0xa0>
mov    0x2e35(%rip),%rax
mov    (%rax),%rdi
call   1050 <strerror@plt>
mov    %rax,%rsi
lea    0xe56(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    1200 <main+0xd0>
mov    -0x10(%rbp),%rax
mov    (%rax),%rax
mov    %rax,-0x20(%rbp)
mov    -0x18(%rbp),%rdi
call   1050 <strerror@plt>
mov    -0x20(%rbp),%rsi
mov    %rax,%rdx
lea    0xe35(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
push   %rax
mov    %rsi,%rbx
cmp    $0x2,%edi
jne    1173 <main+0x43>
mov    0x8(%rbx),%rdi
xor    %r14d,%r14d
xor    %esi,%esi
xor    %edx,%edx
call   1040 <strtoul@plt>
mov    0x2e7d(%rip),%rcx
cmp    (%rcx),%rax
jne    118c <main+0x5c>
mov    0x2e81(%rip),%rax
mov    (%rax),%rdi
call   1050 <strerror@plt>
lea    0xea5(%rip),%rdi
mov    %rax,%rsi
jmp    117d <main+0x4d>
mov    (%rbx),%rsi
lea    0xe83(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
mov    $0x1,%r14d
jmp    11ab <main+0x7b>
mov    (%rbx),%rbx
mov    %rax,%rdi
call   1050 <strerror@plt>
lea    0xe89(%rip),%rdi
mov    %rbx,%rsi
mov    %rax,%rdx
xor    %eax,%eax
call   1030 <printf@plt>
mov    %r14d,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [19 x i8] c"Usage: ./%s errno\0A\00"
@ULONG_MAX = global i64 0
@.str.1 = [20 x i8] c"strtoul failed: %s\0A\00"
@errno = global i64 0
@.str.2 = [19 x i8] c"%s represents: %s\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i64
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i64 0, i64* %6
%7 = load i32, i32* %4
%8 = icmp ne i32 %7, 2
br i1 %8, label %9, label %14
9: ; preds = %2
%10 = load i8**, i8*** %5
%11 = getelementptr inbounds i8*, i8** %10, i64 0
%12 = load i8*, i8** %11
%13 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0), i8* %12)
store i32 1, i32* %3
br label %33
14: ; preds = %2
%15 = load i8**, i8*** %5
%16 = getelementptr inbounds i8*, i8** %15, i64 1
%17 = load i8*, i8** %16
%18 = call i64 @strtoul(i8* %17, i32* null, i32 0)
store i64 %18, i64* %6
%19 = load i64, i64* %6
%20 = load i64, i64* @ULONG_MAX
%21 = icmp eq i64 %19, %20
br i1 %21, label %22, label %26
22: ; preds = %14
%23 = load i64, i64* @errno
%24 = call i8* @strerror(i64 %23)
%25 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.1, i64 0, i64 0), i8* %24)
store i32 1, i32* %3
br label %33
26: ; preds = %14
%27 = load i8**, i8*** %5
%28 = getelementptr inbounds i8*, i8** %27, i64 0
%29 = load i8*, i8** %28
%30 = load i64, i64* %6
%31 = call i8* @strerror(i64 %30)
%32 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.2, i64 0, i64 0), i8* %29, i8* %31)
store i32 0, i32* %3
br label %33
33: ; preds = %26, %22, %9
%34 = load i32, i32* %3
ret i32 %34
}

LLVM IR (-O2):
@.str = [19 x i8] c"Usage: ./%s errno\0A\00"
@ULONG_MAX = global i64 0
@.str.1 = [20 x i8] c"strtoul failed: %s\0A\00"
@errno = global i64 0
@.str.2 = [19 x i8] c"%s represents: %s\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = icmp eq i32 %0, 2
br i1 %3, label %7, label %4
4: ; preds = %2
%5 = load i8*, i8** %1
%6 = tail call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0), i8* %5)
br label %21
7: ; preds = %2
%8 = getelementptr inbounds i8*, i8** %1, i64 1
%9 = load i8*, i8** %8
%10 = tail call i64 @strtoul(i8* nocapture %9, i32* null, i32 0)
%11 = load i64, i64* @ULONG_MAX
%12 = icmp eq i64 %10, %11
br i1 %12, label %13, label %17
13: ; preds = %7
%14 = load i64, i64* @errno
%15 = tail call i8* @strerror(i64 %14)
%16 = tail call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.1, i64 0, i64 0), i8* %15)
br label %21
17: ; preds = %7
%18 = load i8*, i8** %1
%19 = tail call i8* @strerror(i64 %10)
%20 = tail call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.2, i64 0, i64 0), i8* %18, i8* %19)
br label %21
21: ; preds = %17, %13, %4
%22 = phi i32 [ 1, %4 ], [ 1, %13 ], [ 0, %17 ]
ret i32 %22
}