#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 errno;
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *);
int /*<<< orphan*/ kill(int, int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *, char *, char *);
int /*<<< orphan*/ snprintf(char *, int, char *, char *);
int sscanf(char *, char *, int *);
int /*<<< orphan*/ stderr;
scalar_t__ strchr(char *, char);
int /*<<< orphan*/ strcmp(char *, char *);
char *strerror(int);
char *strrchr(char *, char);
char *strsignal(int);
int main(int argc, char **argv) {
  int i;
  char *p;
  char tbuf[100];
  if (strchr(argv[0], '/'))
    argv[0] = strrchr(argv[0], '/') + 1;
  if (argc != 2) {
    fprintf(stderr, "Usage: %s <number>\n", argv[0]);
    return 1;
  }
  if (sscanf(argv[1], "%d", &i) != 1) {
    fprintf(stderr, "Bad decimal number \"%s\"\n", argv[1]);
    return 1;
  }
  if (!strcmp(argv[0], "strerror"))
    p = strerror(i);
  else if (!strcmp(argv[0], "strsignal"))
    p = strsignal(i);
  else if (!strcmp(argv[0], "kill0")) {
    errno = 0;
    kill(i, 0);
    snprintf(tbuf, sizeof tbuf, "%s", strerror(errno));
    p = tbuf;
  } else {
    fprintf(
        stderr,
        "%s must be invoked as \"strerror\" or \"strsignal\" or \"kill0\"\n",
        argv[0]);
    return 1;
  }
  printf("%s returned %s\n", argv[0], p);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0xa0,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
mov    $0x2f,%esi
call   1030 <strchr@plt>
cmp    $0x0,%rax
je     11f3 <main+0x53>
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
mov    $0x2f,%esi
call   1060 <strrchr@plt>
mov    %rax,%rcx
add    $0x1,%rcx
mov    -0x10(%rbp),%rax
mov    %rcx,(%rax)
cmpl   $0x2,-0x8(%rbp)
je     1225 <main+0x85>
mov    0x2ddc(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    (%rax),%rdx
lea    0xdec(%rip),%rsi
call   1080 <fprintf@plt>
movl   $0x1,-0x4(%rbp)
jmp    1393 <main+0x1f3>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xde0(%rip),%rsi
lea    -0x14(%rbp),%rdx
call   10a0 <sscanf@plt>
cmp    $0x1,%eax
je     126f <main+0xcf>
mov    0x2d93(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdx
lea    0xdb9(%rip),%rsi
call   1080 <fprintf@plt>
movl   $0x1,-0x4(%rbp)
jmp    1393 <main+0x1f3>
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
lea    0xdb3(%rip),%rsi
call   1070 <strcmp@plt>
cmp    $0x0,%eax
jne    129c <main+0xfc>
mov    -0x14(%rbp),%edi
call   10c0 <strerror@plt>
mov    %rax,-0x20(%rbp)
jmp    1375 <main+0x1d5>
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
lea    0xd8f(%rip),%rsi
call   1070 <strcmp@plt>
cmp    $0x0,%eax
jne    12c9 <main+0x129>
mov    -0x14(%rbp),%edi
call   10b0 <strsignal@plt>
mov    %rax,-0x20(%rbp)
jmp    1370 <main+0x1d0>
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
lea    0xd6c(%rip),%rsi
call   1070 <strcmp@plt>
cmp    $0x0,%eax
jne    1343 <main+0x1a3>
mov    0x2cec(%rip),%rax
movl   $0x0,(%rax)
mov    -0x14(%rbp),%edi
xor    %esi,%esi
call   1090 <kill@plt>
lea    -0x90(%rbp),%rax
mov    %rax,-0x98(%rbp)
mov    0x2cc7(%rip),%rax
mov    (%rax),%edi
call   10c0 <strerror@plt>
mov    -0x98(%rbp),%rdi
mov    %rax,%rcx
mov    $0x64,%esi
lea    0xd1b(%rip),%rdx
call   1050 <snprintf@plt>
lea    -0x90(%rbp),%rax
mov    %rax,-0x20(%rbp)
jmp    136b <main+0x1cb>
mov    0x2c96(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    (%rax),%rdx
lea    0xcf2(%rip),%rsi
call   1080 <fprintf@plt>
movl   $0x1,-0x4(%rbp)
jmp    1393 <main+0x1f3>
jmp    1370 <main+0x1d0>
jmp    1375 <main+0x1d5>
mov    -0x10(%rbp),%rax
mov    (%rax),%rsi
mov    -0x20(%rbp),%rdx
lea    0xd01(%rip),%rdi
call   1040 <printf@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0xa0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r14
push   %rbx
sub    $0x80,%rsp
mov    %rsi,%rbx
mov    %edi,%ebp
mov    (%rsi),%rdi
mov    $0x2f,%esi
call   1030 <strchr@plt>
test   %rax,%rax
je     11d6 <main+0x36>
mov    (%rbx),%rdi
mov    $0x2f,%esi
call   1060 <strrchr@plt>
add    $0x1,%rax
mov    %rax,(%rbx)
cmp    $0x2,%ebp
jne    1246 <main+0xa6>
mov    0x8(%rbx),%rdi
lea    0xe2e(%rip),%rsi
lea    0xc(%rsp),%rdx
call   10a0 <sscanf@plt>
cmp    $0x1,%eax
jne    125b <main+0xbb>
mov    (%rbx),%r14
lea    0xe31(%rip),%rsi
mov    %r14,%rdi
call   1070 <strcmp@plt>
test   %eax,%eax
je     1285 <main+0xe5>
lea    0xe27(%rip),%rsi
mov    %r14,%rdi
call   1070 <strcmp@plt>
test   %eax,%eax
je     1293 <main+0xf3>
lea    0xe1e(%rip),%rsi
mov    %r14,%rdi
call   1070 <strcmp@plt>
test   %eax,%eax
je     12a1 <main+0x101>
mov    0x2da8(%rip),%rax
mov    (%rax),%edi
lea    0xe0b(%rip),%rsi
mov    %r14,%rdx
jmp    126f <main+0xcf>
mov    0x2d93(%rip),%rax
mov    (%rax),%edi
mov    (%rbx),%rdx
lea    0xda7(%rip),%rsi
jmp    126f <main+0xcf>
mov    0x2d7e(%rip),%rax
mov    (%rax),%edi
mov    0x8(%rbx),%rdx
lea    0xda8(%rip),%rsi
call   1080 <fprintf@plt>
mov    $0x1,%eax
add    $0x80,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret
mov    0xc(%rsp),%edi
call   10c0 <strerror@plt>
mov    %rax,%r14
jmp    12de <main+0x13e>
mov    0xc(%rsp),%edi
call   10b0 <strsignal@plt>
mov    %rax,%r14
jmp    12de <main+0x13e>
lea    0x10(%rsp),%r14
mov    0x2d2b(%rip),%rbp
movl   $0x0,0x0(%rbp)
mov    0xc(%rsp),%edi
xor    %esi,%esi
call   1090 <kill@plt>
mov    0x0(%rbp),%edi
call   10c0 <strerror@plt>
lea    0xd7b(%rip),%rdx
mov    %r14,%rdi
mov    $0x64,%esi
mov    %rax,%rcx
call   1050 <snprintf@plt>
mov    (%rbx),%rsi
lea    0xda0(%rip),%rdi
mov    %r14,%rdx
call   1040 <printf@plt>
xor    %eax,%eax
jmp    1279 <main+0xd9>

LLVM IR (-O0):
@stderr = global i32 0
@.str = [20 x i8] c"Usage: %s <number>\0A\00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [25 x i8] c"Bad decimal number \22%s\22\0A\00"
@.str.3 = [9 x i8] c"strerror\00"
@.str.4 = [10 x i8] c"strsignal\00"
@.str.5 = [6 x i8] c"kill0\00"
@errno = global i32 0
@.str.6 = [3 x i8] c"%s\00"
@.str.7 = [60 x i8] c"%s must be invoked as \22strerror\22 or \22strsignal\22 or \22kill0\22\0A\00"
@.str.8 = [16 x i8] c"%s returned %s\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i8*
%8 = alloca [100 x i8]
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%9 = load i8**, i8*** %5
%10 = getelementptr inbounds i8*, i8** %9, i64 0
%11 = load i8*, i8** %10
%12 = call i64 @strchr(i8* %11, i8 signext 47)
%13 = icmp ne i64 %12, 0
br i1 %13, label %14, label %22
14: ; preds = %2
%15 = load i8**, i8*** %5
%16 = getelementptr inbounds i8*, i8** %15, i64 0
%17 = load i8*, i8** %16
%18 = call i8* @strrchr(i8* %17, i8 signext 47)
%19 = getelementptr inbounds i8, i8* %18, i64 1
%20 = load i8**, i8*** %5
%21 = getelementptr inbounds i8*, i8** %20, i64 0
store i8* %19, i8** %21
br label %22
22: ; preds = %14, %2
%23 = load i32, i32* %4
%24 = icmp ne i32 %23, 2
br i1 %24, label %25, label %31
25: ; preds = %22
%26 = load i32, i32* @stderr
%27 = load i8**, i8*** %5
%28 = getelementptr inbounds i8*, i8** %27, i64 0
%29 = load i8*, i8** %28
%30 = call i32 @fprintf(i32 %26, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0), i8* %29)
store i32 1, i32* %3
br label %89
31: ; preds = %22
%32 = load i8**, i8*** %5
%33 = getelementptr inbounds i8*, i8** %32, i64 1
%34 = load i8*, i8** %33
%35 = call i32 @sscanf(i8* %34, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %6)
%36 = icmp ne i32 %35, 1
br i1 %36, label %37, label %43
37: ; preds = %31
%38 = load i32, i32* @stderr
%39 = load i8**, i8*** %5
%40 = getelementptr inbounds i8*, i8** %39, i64 1
%41 = load i8*, i8** %40
%42 = call i32 @fprintf(i32 %38, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.2, i64 0, i64 0), i8* %41)
store i32 1, i32* %3
br label %89
43: ; preds = %31
%44 = load i8**, i8*** %5
%45 = getelementptr inbounds i8*, i8** %44, i64 0
%46 = load i8*, i8** %45
%47 = call i32 @strcmp(i8* %46, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.3, i64 0, i64 0))
%48 = icmp ne i32 %47, 0
br i1 %48, label %52, label %49
49: ; preds = %43
%50 = load i32, i32* %6
%51 = call i8* @strerror(i32 %50)
store i8* %51, i8** %7
br label %83
52: ; preds = %43
%53 = load i8**, i8*** %5
%54 = getelementptr inbounds i8*, i8** %53, i64 0
%55 = load i8*, i8** %54
%56 = call i32 @strcmp(i8* %55, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.4, i64 0, i64 0))
%57 = icmp ne i32 %56, 0
br i1 %57, label %61, label %58
58: ; preds = %52
%59 = load i32, i32* %6
%60 = call i8* @strsignal(i32 %59)
store i8* %60, i8** %7
br label %82
61: ; preds = %52
%62 = load i8**, i8*** %5
%63 = getelementptr inbounds i8*, i8** %62, i64 0
%64 = load i8*, i8** %63
%65 = call i32 @strcmp(i8* %64, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.5, i64 0, i64 0))
%66 = icmp ne i32 %65, 0
br i1 %66, label %75, label %67
67: ; preds = %61
store i32 0, i32* @errno
%68 = load i32, i32* %6
%69 = call i32 @kill(i32 %68, i32 0)
%70 = getelementptr inbounds [100 x i8], [100 x i8]* %8, i64 0, i64 0
%71 = load i32, i32* @errno
%72 = call i8* @strerror(i32 %71)
%73 = call i32 @snprintf(i8* %70, i32 100, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.6, i64 0, i64 0), i8* %72)
%74 = getelementptr inbounds [100 x i8], [100 x i8]* %8, i64 0, i64 0
store i8* %74, i8** %7
br label %81
75: ; preds = %61
%76 = load i32, i32* @stderr
%77 = load i8**, i8*** %5
%78 = getelementptr inbounds i8*, i8** %77, i64 0
%79 = load i8*, i8** %78
%80 = call i32 @fprintf(i32 %76, i8* getelementptr inbounds ([60 x i8], [60 x i8]* @.str.7, i64 0, i64 0), i8* %79)
store i32 1, i32* %3
br label %89
81: ; preds = %67
br label %82
82: ; preds = %81, %58
br label %83
83: ; preds = %82, %49
%84 = load i8**, i8*** %5
%85 = getelementptr inbounds i8*, i8** %84, i64 0
%86 = load i8*, i8** %85
%87 = load i8*, i8** %7
%88 = call i32 @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.8, i64 0, i64 0), i8* %86, i8* %87)
store i32 0, i32* %3
br label %89
89: ; preds = %83, %75, %37, %25
%90 = load i32, i32* %3
ret i32 %90
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [20 x i8] c"Usage: %s <number>\0A\00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [25 x i8] c"Bad decimal number \22%s\22\0A\00"
@.str.3 = [9 x i8] c"strerror\00"
@.str.4 = [10 x i8] c"strsignal\00"
@.str.5 = [6 x i8] c"kill0\00"
@errno = global i32 0
@.str.6 = [3 x i8] c"%s\00"
@.str.7 = [60 x i8] c"%s must be invoked as \22strerror\22 or \22strsignal\22 or \22kill0\22\0A\00"
@.str.8 = [16 x i8] c"%s returned %s\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca i32
%4 = alloca [100 x i8]
%5 = bitcast i32* %3 to i8*
%6 = getelementptr inbounds [100 x i8], [100 x i8]* %4, i64 0, i64 0
%7 = load i8*, i8** %1
%8 = tail call i64 @strchr(i8* %7, i8 signext 47)
%9 = icmp eq i64 %8, 0
br i1 %9, label %14, label %10
10: ; preds = %2
%11 = load i8*, i8** %1
%12 = tail call i8* @strrchr(i8* dereferenceable(1) %11, i8 signext 47)
%13 = getelementptr inbounds i8, i8* %12, i64 1
store i8* %13, i8** %1
br label %14
14: ; preds = %10, %2
%15 = icmp eq i32 %0, 2
br i1 %15, label %20, label %16
16: ; preds = %14
%17 = load i32, i32* @stderr
%18 = load i8*, i8** %1
%19 = tail call i32 @fprintf(i32 %17, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0), i8* %18)
br label %58
20: ; preds = %14
%21 = getelementptr inbounds i8*, i8** %1, i64 1
%22 = load i8*, i8** %21
%23 = call i32 @sscanf(i8* %22, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %3)
%24 = icmp eq i32 %23, 1
br i1 %24, label %29, label %25
25: ; preds = %20
%26 = load i32, i32* @stderr
%27 = load i8*, i8** %21
%28 = call i32 @fprintf(i32 %26, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.2, i64 0, i64 0), i8* %27)
br label %58
29: ; preds = %20
%30 = load i8*, i8** %1
%31 = call i32 @strcmp(i8* dereferenceable(1) %30, i8* dereferenceable(9) getelementptr inbounds ([9 x i8], [9 x i8]* @.str.3, i64 0, i64 0))
%32 = icmp eq i32 %31, 0
br i1 %32, label %33, label %36
33: ; preds = %29
%34 = load i32, i32* %3
%35 = call i8* @strerror(i32 %34)
br label %54
36: ; preds = %29
%37 = call i32 @strcmp(i8* dereferenceable(1) %30, i8* dereferenceable(10) getelementptr inbounds ([10 x i8], [10 x i8]* @.str.4, i64 0, i64 0))
%38 = icmp eq i32 %37, 0
br i1 %38, label %39, label %42
39: ; preds = %36
%40 = load i32, i32* %3
%41 = call i8* @strsignal(i32 %40)
br label %54
42: ; preds = %36
%43 = call i32 @strcmp(i8* dereferenceable(1) %30, i8* dereferenceable(6) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.5, i64 0, i64 0))
%44 = icmp eq i32 %43, 0
br i1 %44, label %45, label %51
45: ; preds = %42
store i32 0, i32* @errno
%46 = load i32, i32* %3
%47 = call i32 @kill(i32 %46, i32 0)
%48 = load i32, i32* @errno
%49 = call i8* @strerror(i32 %48)
%50 = call i32 @snprintf(i8* %6, i32 100, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.6, i64 0, i64 0), i8* %49)
br label %54
51: ; preds = %42
%52 = load i32, i32* @stderr
%53 = call i32 @fprintf(i32 %52, i8* getelementptr inbounds ([60 x i8], [60 x i8]* @.str.7, i64 0, i64 0), i8* %30)
br label %58
54: ; preds = %39, %45, %33
%55 = phi i8* [ %6, %45 ], [ %41, %39 ], [ %35, %33 ]
%56 = load i8*, i8** %1
%57 = call i32 @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.8, i64 0, i64 0), i8* %56, i8* %55)
br label %58
58: ; preds = %54, %51, %25, %16
%59 = phi i32 [ 1, %16 ], [ 1, %25 ], [ 1, %51 ], [ 0, %54 ]
ret i32 %59
}