#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*/ fprintf(int /*<<< orphan*/, char *, char const *, ...);
int /*<<< orphan*/ stderr;
long strtol(char const *, char **, int);
int main(int argc, const char *argv[]) {
  if (argc < 2) {
    return 0;
  }
  const char *program = argv[0];
  const char *arg = argv[1];
  char *end = NULL;
  long status = strtol(arg, &end, 10);
  if (end == arg || *end != '\0') {
    fprintf(stderr, "%s: warning: invalid status code: `%s`\n", program, arg);
  }
  if (status < 0) {
    fprintf(stderr,
            "%s: warning: status should be positive. Instead got: `%ld`\n",
            program, status);
  } else if (status > 0xFF) {
    fprintf(stderr, "%s: warning: status too large: `%ld`\n", program, status);
  }
  return status & 0xFF;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x2,-0x8(%rbp)
jge    114c <main+0x2c>
movl   $0x0,-0x4(%rbp)
jmp    122c <main+0x10c>
mov    -0x10(%rbp),%rax
mov    (%rax),%rax
mov    %rax,-0x18(%rbp)
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rax
mov    %rax,-0x20(%rbp)
movq   $0x0,-0x28(%rbp)
mov    -0x20(%rbp),%rdi
lea    -0x28(%rbp),%rsi
mov    $0xa,%edx
call   1040 <strtol@plt>
mov    %rax,-0x30(%rbp)
mov    -0x28(%rbp),%rax
cmp    -0x20(%rbp),%rax
je     119f <main+0x7f>
mov    -0x28(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
je     11be <main+0x9e>
mov    0x2e3a(%rip),%rax
mov    (%rax),%edi
mov    -0x18(%rbp),%rdx
mov    -0x20(%rbp),%rcx
lea    0xe49(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
cmpq   $0x0,-0x30(%rbp)
jge    11ed <main+0xcd>
mov    0x2e10(%rip),%rax
mov    (%rax),%edi
mov    -0x18(%rbp),%rdx
mov    -0x30(%rbp),%rcx
lea    0xe47(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
jmp    121f <main+0xff>
cmpq   $0xff,-0x30(%rbp)
jle    121a <main+0xfa>
mov    0x2dde(%rip),%rax
mov    (%rax),%edi
mov    -0x18(%rbp),%rdx
mov    -0x30(%rbp),%rcx
lea    0xe51(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
jmp    121f <main+0xff>
mov    -0x30(%rbp),%rax
and    $0xff,%rax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
xor    %eax,%eax
cmp    $0x2,%edi
jl     11c6 <main+0xa6>
push   %r15
push   %r14
push   %rbx
sub    $0x10,%rsp
mov    (%rsi),%r14
mov    0x8(%rsi),%rbx
movq   $0x0,0x8(%rsp)
lea    0x8(%rsp),%rsi
mov    %rbx,%rdi
mov    $0xa,%edx
call   1040 <strtol@plt>
mov    %rax,%r15
mov    0x8(%rsp),%rax
cmp    %rbx,%rax
je     1168 <main+0x48>
cmpb   $0x0,(%rax)
je     1185 <main+0x65>
mov    0x2e71(%rip),%rax
mov    (%rax),%edi
lea    0xe88(%rip),%rsi
mov    %r14,%rdx
mov    %rbx,%rcx
xor    %eax,%eax
call   1030 <fprintf@plt>
test   %r15,%r15
js     119c <main+0x7c>
cmp    $0x100,%r15
jb     11b9 <main+0x99>
lea    0xeca(%rip),%rsi
jmp    11a3 <main+0x83>
lea    0xe85(%rip),%rsi
mov    0x2e36(%rip),%rax
mov    (%rax),%edi
mov    %r14,%rdx
mov    %r15,%rcx
xor    %eax,%eax
call   1030 <fprintf@plt>
movzbl %r15b,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@stderr = global i32 0
@.str = [40 x i8] c"%s: warning: invalid status code: `%s`\0A\00"
@.str.1 = [60 x i8] c"%s: warning: status should be positive. Instead got: `%ld`\0A\00"
@.str.2 = [38 x i8] c"%s: warning: status too large: `%ld`\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca i8*
%9 = alloca i64
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%10 = load i32, i32* %4
%11 = icmp slt i32 %10, 2
br i1 %11, label %12, label %13
12: ; preds = %2
store i32 0, i32* %3
br label %56
13: ; preds = %2
%14 = load i8**, i8*** %5
%15 = getelementptr inbounds i8*, i8** %14, i64 0
%16 = load i8*, i8** %15
store i8* %16, i8** %6
%17 = load i8**, i8*** %5
%18 = getelementptr inbounds i8*, i8** %17, i64 1
%19 = load i8*, i8** %18
store i8* %19, i8** %7
store i8* null, i8** %8
%20 = load i8*, i8** %7
%21 = call i64 @strtol(i8* %20, i8** %8, i32 10)
store i64 %21, i64* %9
%22 = load i8*, i8** %8
%23 = load i8*, i8** %7
%24 = icmp eq i8* %22, %23
br i1 %24, label %30, label %25
25: ; preds = %13
%26 = load i8*, i8** %8
%27 = load i8, i8* %26
%28 = sext i8 %27 to i32
%29 = icmp ne i32 %28, 0
br i1 %29, label %30, label %35
30: ; preds = %25, %13
%31 = load i32, i32* @stderr
%32 = load i8*, i8** %6
%33 = load i8*, i8** %7
%34 = call i32 (i32, i8*, i8*, ...) @fprintf(i32 %31, i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str, i64 0, i64 0), i8* %32, i8* %33)
br label %35
35: ; preds = %30, %25
%36 = load i64, i64* %9
%37 = icmp slt i64 %36, 0
br i1 %37, label %38, label %43
38: ; preds = %35
%39 = load i32, i32* @stderr
%40 = load i8*, i8** %6
%41 = load i64, i64* %9
%42 = call i32 (i32, i8*, i8*, ...) @fprintf(i32 %39, i8* getelementptr inbounds ([60 x i8], [60 x i8]* @.str.1, i64 0, i64 0), i8* %40, i64 %41)
br label %52
43: ; preds = %35
%44 = load i64, i64* %9
%45 = icmp sgt i64 %44, 255
br i1 %45, label %46, label %51
46: ; preds = %43
%47 = load i32, i32* @stderr
%48 = load i8*, i8** %6
%49 = load i64, i64* %9
%50 = call i32 (i32, i8*, i8*, ...) @fprintf(i32 %47, i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.2, i64 0, i64 0), i8* %48, i64 %49)
br label %51
51: ; preds = %46, %43
br label %52
52: ; preds = %51, %38
%53 = load i64, i64* %9
%54 = and i64 %53, 255
%55 = trunc i64 %54 to i32
store i32 %55, i32* %3
br label %56
56: ; preds = %52, %12
%57 = load i32, i32* %3
ret i32 %57
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [40 x i8] c"%s: warning: invalid status code: `%s`\0A\00"
@.str.1 = [60 x i8] c"%s: warning: status should be positive. Instead got: `%ld`\0A\00"
@.str.2 = [38 x i8] c"%s: warning: status too large: `%ld`\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca i8*
%4 = icmp slt i32 %0, 2
br i1 %4, label %30, label %5
5: ; preds = %2
%6 = load i8*, i8** %1
%7 = getelementptr inbounds i8*, i8** %1, i64 1
%8 = load i8*, i8** %7
%9 = bitcast i8** %3 to i8*
store i8* null, i8** %3
%10 = call i64 @strtol(i8* %8, i8** %3, i32 10)
%11 = load i8*, i8** %3
%12 = icmp eq i8* %11, %8
br i1 %12, label %16, label %13
13: ; preds = %5
%14 = load i8, i8* %11
%15 = icmp eq i8 %14, 0
br i1 %15, label %19, label %16
16: ; preds = %13, %5
%17 = load i32, i32* @stderr
%18 = tail call i32 (i32, i8*, i8*, ...) @fprintf(i32 %17, i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str, i64 0, i64 0), i8* %6, i8* %8)
br label %19
19: ; preds = %16, %13
%20 = icmp slt i64 %10, 0
br i1 %20, label %23, label %21
21: ; preds = %19
%22 = icmp ugt i64 %10, 255
br i1 %22, label %23, label %27
23: ; preds = %21, %19
%24 = phi i8* [ getelementptr inbounds ([60 x i8], [60 x i8]* @.str.1, i64 0, i64 0), %19 ], [ getelementptr inbounds ([38 x i8], [38 x i8]* @.str.2, i64 0, i64 0), %21 ]
%25 = load i32, i32* @stderr
%26 = tail call i32 (i32, i8*, i8*, ...) @fprintf(i32 %25, i8* %24, i8* %6, i64 %10)
br label %27
27: ; preds = %23, %21
%28 = trunc i64 %10 to i32
%29 = and i32 %28, 255
br label %30
30: ; preds = %2, %27
%31 = phi i32 [ %29, %27 ], [ 0, %2 ]
ret i32 %31
}