#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 abbrevToID(char *);
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *);
char *idToName(int);
int nameToID(char *);
int /*<<< orphan*/ printf(char *, char *, ...);
int /*<<< orphan*/ stderr;
int strlen(char *);
int main(int argc, char **argv) {
  int id;
  if (argc < 2) {
    fprintf(stderr, "Usage %s Place (name or abbrev)\n", argv[0]);
    exit(1);
  }
  if (strlen(argv[1]) > 2) {
    id = nameToID(argv[1]);
    if (id != -1)
      printf("%s has ID %d\n", argv[1], id);
  } else {
    id = abbrevToID(argv[1]);
    if (id != -1)
      printf("%s is %s (%d)\n", argv[1], idToName(id), id);
  }
  if (id == -1)
    printf("Invalid place '%s'\n", argv[1]);
  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)
cmpl   $0x2,-0x8(%rbp)
jge    11b6 <main+0x46>
mov    0x2e49(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    (%rax),%rdx
lea    0xe59(%rip),%rsi
call   1060 <fprintf@plt>
mov    $0x1,%edi
call   1090 <exit@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1040 <strlen@plt>
cmp    $0x2,%eax
jle    1204 <main+0x94>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1070 <nameToID@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0xffffffff,-0x14(%rbp)
je     11ff <main+0x8f>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rsi
mov    -0x14(%rbp),%edx
lea    0xe29(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
jmp    124f <main+0xdf>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1080 <abbrevToID@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0xffffffff,-0x14(%rbp)
je     124a <main+0xda>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rax
mov    %rax,-0x20(%rbp)
mov    -0x14(%rbp),%edi
call   1030 <idToName@plt>
mov    -0x20(%rbp),%rsi
mov    %rax,%rdx
mov    -0x14(%rbp),%ecx
lea    0xdec(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
jmp    124f <main+0xdf>
cmpl   $0xffffffff,-0x14(%rbp)
jne    126f <main+0xff>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rsi
lea    0xdd6(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %rbx
push   %rax
mov    %rsi,%rbx
cmp    $0x1,%edi
jle    11f7 <main+0x87>
mov    0x8(%rbx),%rdi
call   1040 <strlen@plt>
mov    0x8(%rbx),%rdi
cmp    $0x3,%eax
jl     11ad <main+0x3d>
call   1070 <nameToID@plt>
cmp    $0xffffffff,%eax
je     11dc <main+0x6c>
mov    0x8(%rbx),%rsi
lea    0xe7f(%rip),%rdi
mov    %eax,%edx
xor    %eax,%eax
call   1050 <printf@plt>
jmp    11ee <main+0x7e>
call   1080 <abbrevToID@plt>
cmp    $0xffffffff,%eax
je     11dc <main+0x6c>
mov    %eax,%ebp
mov    0x8(%rbx),%rbx
mov    %eax,%edi
call   1030 <idToName@plt>
lea    0xe64(%rip),%rdi
mov    %rbx,%rsi
mov    %rax,%rdx
mov    %ebp,%ecx
xor    %eax,%eax
call   1050 <printf@plt>
jmp    11ee <main+0x7e>
mov    0x8(%rbx),%rsi
lea    0xe57(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret
mov    0x2de2(%rip),%rax
mov    (%rax),%edi
mov    (%rbx),%rdx
lea    0xdf6(%rip),%rsi
call   1060 <fprintf@plt>
mov    $0x1,%edi
call   1090 <exit@plt>

LLVM IR (-O0):
@stderr = global i32 0
@.str = [33 x i8] c"Usage %s Place (name or abbrev)\0A\00"
@.str.1 = [14 x i8] c"%s has ID %d\0A\00"
@.str.2 = [15 x i8] c"%s is %s (%d)\0A\00"
@.str.3 = [20 x i8] c"Invalid place '%s'\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%7 = load i32, i32* %4
%8 = icmp slt i32 %7, 2
br i1 %8, label %9, label %16
9: ; preds = %2
%10 = load i32, i32* @stderr
%11 = load i8**, i8*** %5
%12 = getelementptr inbounds i8*, i8** %11, i64 0
%13 = load i8*, i8** %12
%14 = call i32 @fprintf(i32 %10, i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str, i64 0, i64 0), i8* %13)
%15 = call i32 @exit(i32 1)
unreachable
16: ; preds = %2
%17 = load i8**, i8*** %5
%18 = getelementptr inbounds i8*, i8** %17, i64 1
%19 = load i8*, i8** %18
%20 = call i32 @strlen(i8* %19)
%21 = icmp sgt i32 %20, 2
br i1 %21, label %22, label %36
22: ; preds = %16
%23 = load i8**, i8*** %5
%24 = getelementptr inbounds i8*, i8** %23, i64 1
%25 = load i8*, i8** %24
%26 = call i32 @nameToID(i8* %25)
store i32 %26, i32* %6
%27 = load i32, i32* %6
%28 = icmp ne i32 %27, -1
br i1 %28, label %29, label %35
29: ; preds = %22
%30 = load i8**, i8*** %5
%31 = getelementptr inbounds i8*, i8** %30, i64 1
%32 = load i8*, i8** %31
%33 = load i32, i32* %6
%34 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0), i8* %32, i32 %33)
br label %35
35: ; preds = %29, %22
br label %52
36: ; preds = %16
%37 = load i8**, i8*** %5
%38 = getelementptr inbounds i8*, i8** %37, i64 1
%39 = load i8*, i8** %38
%40 = call i32 @abbrevToID(i8* %39)
store i32 %40, i32* %6
%41 = load i32, i32* %6
%42 = icmp ne i32 %41, -1
br i1 %42, label %43, label %51
43: ; preds = %36
%44 = load i8**, i8*** %5
%45 = getelementptr inbounds i8*, i8** %44, i64 1
%46 = load i8*, i8** %45
%47 = load i32, i32* %6
%48 = call i8* @idToName(i32 %47)
%49 = load i32, i32* %6
%50 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.2, i64 0, i64 0), i8* %46, i8* %48, i32 %49)
br label %51
51: ; preds = %43, %36
br label %52
52: ; preds = %51, %35
%53 = load i32, i32* %6
%54 = icmp eq i32 %53, -1
br i1 %54, label %55, label %60
55: ; preds = %52
%56 = load i8**, i8*** %5
%57 = getelementptr inbounds i8*, i8** %56, i64 1
%58 = load i8*, i8** %57
%59 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.3, i64 0, i64 0), i8* %58)
br label %60
60: ; preds = %55, %52
ret i32 0
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [33 x i8] c"Usage %s Place (name or abbrev)\0A\00"
@.str.1 = [14 x i8] c"%s has ID %d\0A\00"
@.str.2 = [15 x i8] c"%s is %s (%d)\0A\00"
@.str.3 = [20 x i8] c"Invalid place '%s'\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = icmp slt i32 %0, 2
br i1 %3, label %4, label %9
4: ; preds = %2
%5 = load i32, i32* @stderr
%6 = load i8*, i8** %1
%7 = tail call i32 @fprintf(i32 %5, i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str, i64 0, i64 0), i8* %6)
%8 = tail call i32 @exit(i32 1)
unreachable
9: ; preds = %2
%10 = getelementptr inbounds i8*, i8** %1, i64 1
%11 = load i8*, i8** %10
%12 = tail call i32 @strlen(i8* %11)
%13 = icmp sgt i32 %12, 2
%14 = load i8*, i8** %10
br i1 %13, label %15, label %21
15: ; preds = %9
%16 = tail call i32 @nameToID(i8* %14)
%17 = icmp eq i32 %16, -1
br i1 %17, label %28, label %18
18: ; preds = %15
%19 = load i8*, i8** %10
%20 = tail call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0), i8* %19, i32 %16)
br label %31
21: ; preds = %9
%22 = tail call i32 @abbrevToID(i8* %14)
%23 = icmp eq i32 %22, -1
br i1 %23, label %28, label %24
24: ; preds = %21
%25 = load i8*, i8** %10
%26 = tail call i8* @idToName(i32 %22)
%27 = tail call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.2, i64 0, i64 0), i8* %25, i8* %26, i32 %22)
br label %31
28: ; preds = %15, %21
%29 = load i8*, i8** %10
%30 = tail call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.3, i64 0, i64 0), i8* %29)
br label %31
31: ; preds = %18, %24, %28
ret i32 0
}