#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 */
char *getvar(char const *);
int /*<<< orphan*/ stare(char const *);
scalar_t__ strcmp(char *, char *);
int /*<<< orphan*/ warnx(char *);
void look(int argc, char *argv[]) {
  const char *room = getvar("room");
  const char *d = NULL;
  if (argc > 3 || (argc == 3 && !(strcmp((argv[1]), ("at")) == 0))) {
    warnx("...I don't understand what you want to look at.");
    return;
  }
  if (argc == 3)
    d = argv[2];
  if (argc == 2)
    d = argv[1];
  if (d != NULL)
    room = getvar(d);
  if (room == NULL)
    room = d;
  if (room == NULL) {
    if (argc == 1)
      warnx("You are nowhere to see anything.");
    else
      warnx("There's nothing there to look at.");
    return;
  }
  stare(room);
}


x86 assembly (clang, -O0):
<look>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
lea    0xeaa(%rip),%rdi
call   1030 <getvar@plt>
mov    %rax,-0x18(%rbp)
movq   $0x0,-0x20(%rbp)
cmpl   $0x3,-0x4(%rbp)
jg     1199 <look+0x59>
cmpl   $0x3,-0x4(%rbp)
jne    11aa <look+0x6a>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xe7b(%rip),%rsi
call   1050 <strcmp@plt>
cmp    $0x0,%rax
je     11aa <look+0x6a>
lea    0xe68(%rip),%rdi
call   1040 <warnx@plt>
jmp    1241 <look+0x101>
cmpl   $0x3,-0x4(%rbp)
jne    11c0 <look+0x80>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rax
mov    %rax,-0x20(%rbp)
cmpl   $0x2,-0x4(%rbp)
jne    11d6 <look+0x96>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rax
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
je     11ee <look+0xae>
mov    -0x20(%rbp),%rdi
call   1030 <getvar@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    1201 <look+0xc1>
mov    -0x20(%rbp),%rax
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    1238 <look+0xf8>
cmpl   $0x1,-0x4(%rbp)
jne    1227 <look+0xe7>
lea    0xe1b(%rip),%rdi
call   1040 <warnx@plt>
jmp    1233 <look+0xf3>
lea    0xe2b(%rip),%rdi
call   1040 <warnx@plt>
jmp    1241 <look+0x101>
mov    -0x18(%rbp),%rdi
call   1060 <stare@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<look>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %rsi,%r15
mov    %edi,%ebp
lea    0xead(%rip),%rdi
call   1030 <getvar@plt>
cmp    $0x3,%ebp
jle    1173 <look+0x33>
lea    0xea4(%rip),%rdi
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
jmp    1040 <warnx@plt>
mov    %rax,%r14
cmp    $0x2,%ebp
je     119c <look+0x5c>
cmp    $0x3,%ebp
jne    11b7 <look+0x77>
mov    0x8(%r15),%rdi
lea    0xe7a(%rip),%rsi
call   1050 <strcmp@plt>
test   %rax,%rax
jne    115d <look+0x1d>
mov    $0x2,%eax
jmp    11a1 <look+0x61>
mov    $0x1,%eax
mov    (%r15,%rax,8),%rbx
test   %rbx,%rbx
je     11b7 <look+0x77>
mov    %rbx,%rdi
call   1030 <getvar@plt>
mov    %rax,%r14
jmp    11b9 <look+0x79>
xor    %ebx,%ebx
test   %r14,%r14
cmovne %r14,%rbx
test   %rbx,%rbx
je     11d7 <look+0x97>
mov    %rbx,%rdi
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
jmp    1060 <stare@plt>
cmp    $0x1,%ebp
jne    11e8 <look+0xa8>
lea    0xe55(%rip),%rdi
jmp    1164 <look+0x24>
lea    0xe6a(%rip),%rdi
jmp    1164 <look+0x24>

LLVM IR (-O0):
@.str = [5 x i8] c"room\00"
@.str.1 = [3 x i8] c"at\00"
@.str.2 = [48 x i8] c"...I don't understand what you want to look at.\00"
@.str.3 = [33 x i8] c"You are nowhere to see anything.\00"
@.str.4 = [34 x i8] c"There's nothing there to look at.\00"
define void @look(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i8**
%5 = alloca i8*
%6 = alloca i8*
store i32 %0, i32* %3
store i8** %1, i8*** %4
%7 = call i8* @getvar(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
store i8* %7, i8** %5
store i8* null, i8** %6
%8 = load i32, i32* %3
%9 = icmp sgt i32 %8, 3
br i1 %9, label %19, label %10
10: ; preds = %2
%11 = load i32, i32* %3
%12 = icmp eq i32 %11, 3
br i1 %12, label %13, label %21
13: ; preds = %10
%14 = load i8**, i8*** %4
%15 = getelementptr inbounds i8*, i8** %14, i64 1
%16 = load i8*, i8** %15
%17 = call i64 @strcmp(i8* %16, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%18 = icmp eq i64 %17, 0
br i1 %18, label %21, label %19
19: ; preds = %13, %2
%20 = call i32 @warnx(i8* getelementptr inbounds ([48 x i8], [48 x i8]* @.str.2, i64 0, i64 0))
br label %60
21: ; preds = %13, %10
%22 = load i32, i32* %3
%23 = icmp eq i32 %22, 3
br i1 %23, label %24, label %28
24: ; preds = %21
%25 = load i8**, i8*** %4
%26 = getelementptr inbounds i8*, i8** %25, i64 2
%27 = load i8*, i8** %26
store i8* %27, i8** %6
br label %28
28: ; preds = %24, %21
%29 = load i32, i32* %3
%30 = icmp eq i32 %29, 2
br i1 %30, label %31, label %35
31: ; preds = %28
%32 = load i8**, i8*** %4
%33 = getelementptr inbounds i8*, i8** %32, i64 1
%34 = load i8*, i8** %33
store i8* %34, i8** %6
br label %35
35: ; preds = %31, %28
%36 = load i8*, i8** %6
%37 = icmp ne i8* %36, null
br i1 %37, label %38, label %41
38: ; preds = %35
%39 = load i8*, i8** %6
%40 = call i8* @getvar(i8* %39)
store i8* %40, i8** %5
br label %41
41: ; preds = %38, %35
%42 = load i8*, i8** %5
%43 = icmp eq i8* %42, null
br i1 %43, label %44, label %46
44: ; preds = %41
%45 = load i8*, i8** %6
store i8* %45, i8** %5
br label %46
46: ; preds = %44, %41
%47 = load i8*, i8** %5
%48 = icmp eq i8* %47, null
br i1 %48, label %49, label %57
49: ; preds = %46
%50 = load i32, i32* %3
%51 = icmp eq i32 %50, 1
br i1 %51, label %52, label %54
52: ; preds = %49
%53 = call i32 @warnx(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.3, i64 0, i64 0))
br label %56
54: ; preds = %49
%55 = call i32 @warnx(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.4, i64 0, i64 0))
br label %56
56: ; preds = %54, %52
br label %60
57: ; preds = %46
%58 = load i8*, i8** %5
%59 = call i32 @stare(i8* %58)
br label %60
60: ; preds = %57, %56, %19
ret void
}

LLVM IR (-O2):
@.str = [5 x i8] c"room\00"
@.str.1 = [3 x i8] c"at\00"
@.str.2 = [48 x i8] c"...I don't understand what you want to look at.\00"
@.str.3 = [33 x i8] c"You are nowhere to see anything.\00"
@.str.4 = [34 x i8] c"There's nothing there to look at.\00"
define void @look(i32 %0, i8** nocapture %1) {
%3 = tail call i8* @getvar(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
%4 = icmp sgt i32 %0, 3
br i1 %4, label %11, label %5
5: ; preds = %2
switch i32 %0, label %20 [
i32 3, label %6
i32 2, label %13
]
6: ; preds = %5
%7 = getelementptr inbounds i8*, i8** %1, i64 1
%8 = load i8*, i8** %7
%9 = tail call i64 @strcmp(i8* %8, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%10 = icmp eq i64 %9, 0
br i1 %10, label %13, label %11
11: ; preds = %6, %2
%12 = tail call i32 @warnx(i8* getelementptr inbounds ([48 x i8], [48 x i8]* @.str.2, i64 0, i64 0))
br label %34
13: ; preds = %5, %6
%14 = phi i64 [ 2, %6 ], [ 1, %5 ]
%15 = getelementptr inbounds i8*, i8** %1, i64 %14
%16 = load i8*, i8** %15
%17 = icmp eq i8* %16, null
br i1 %17, label %20, label %18
18: ; preds = %13
%19 = tail call i8* @getvar(i8* %16)
br label %20
20: ; preds = %5, %18, %13
%21 = phi i8* [ %16, %18 ], [ null, %13 ], [ null, %5 ]
%22 = phi i8* [ %19, %18 ], [ %3, %13 ], [ %3, %5 ]
%23 = icmp eq i8* %22, null
%24 = select i1 %23, i8* %21, i8* %22
%25 = icmp eq i8* %24, null
br i1 %25, label %26, label %32
26: ; preds = %20
%27 = icmp eq i32 %0, 1
br i1 %27, label %28, label %30
28: ; preds = %26
%29 = tail call i32 @warnx(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.3, i64 0, i64 0))
br label %34
30: ; preds = %26
%31 = tail call i32 @warnx(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.4, i64 0, i64 0))
br label %34
32: ; preds = %20
%33 = tail call i32 @stare(i8* %24)
br label %34
34: ; preds = %28, %30, %32, %11
ret void
}