#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 */
typedef int /*<<< orphan*/ line;

/* Variables and functions */
scalar_t__ fgets(char *, int, int /*<<< orphan*/);
int /*<<< orphan*/ print_dirs(char *);
int /*<<< orphan*/ stdin;
int /*<<< orphan*/ strcmp(char *, char *);
char *strtok(char *, char *);
int main(int argc, char **argv) {
  char line[1024];
  while (fgets(line, sizeof(line), stdin)) {
    char *cmd, *p1 = NULL;
    cmd = strtok(line, " \t\r\n");
    if (!cmd || *cmd == '#')
      continue;
    p1 = strtok(NULL, " \t\r\n");
    if (!strcmp("dirs", cmd) && p1)
      print_dirs(p1);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x420,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    -0x410(%rbp),%rdi
mov    0x2e81(%rip),%rax
mov    (%rax),%edx
mov    $0x400,%esi
call   1030 <fgets@plt>
cmp    $0x0,%rax
je     121a <main+0xda>
movq   $0x0,-0x420(%rbp)
lea    -0x410(%rbp),%rdi
lea    0xe6a(%rip),%rsi
call   1060 <strtok@plt>
mov    %rax,-0x418(%rbp)
cmpq   $0x0,-0x418(%rbp)
je     11c3 <main+0x83>
mov    -0x418(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x23,%eax
jne    11c8 <main+0x88>
jmp    1159 <main+0x19>
xor    %eax,%eax
mov    %eax,%edi
lea    0xe2d(%rip),%rsi
call   1060 <strtok@plt>
mov    %rax,-0x420(%rbp)
mov    -0x418(%rbp),%rsi
lea    0xe18(%rip),%rdi
call   1040 <strcmp@plt>
cmp    $0x0,%eax
jne    1215 <main+0xd5>
cmpq   $0x0,-0x420(%rbp)
je     1215 <main+0xd5>
mov    -0x420(%rbp),%rdi
call   1050 <print_dirs@plt>
jmp    1159 <main+0x19>
xor    %eax,%eax
add    $0x420,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x408,%rsp
mov    0x2e90(%rip),%rbp
mov    0x0(%rbp),%edx
mov    %rsp,%rdi
mov    $0x400,%esi
call   1030 <fgets@plt>
test   %rax,%rax
je     11d8 <main+0x98>
lea    0xe8c(%rip),%r14
mov    %rsp,%r12
lea    0xe87(%rip),%r15
jmp    1195 <main+0x55>
mov    0x0(%rbp),%edx
mov    %r12,%rdi
mov    $0x400,%esi
call   1030 <fgets@plt>
test   %rax,%rax
je     11d8 <main+0x98>
mov    %r12,%rdi
mov    %r14,%rsi
call   1060 <strtok@plt>
test   %rax,%rax
je     1180 <main+0x40>
mov    %rax,%rbx
cmpb   $0x23,(%rax)
je     1180 <main+0x40>
xor    %edi,%edi
mov    %r14,%rsi
call   1060 <strtok@plt>
mov    %rax,%r13
mov    %r15,%rdi
mov    %rbx,%rsi
call   1040 <strcmp@plt>
test   %eax,%eax
jne    1180 <main+0x40>
test   %r13,%r13
je     1180 <main+0x40>
mov    %r13,%rdi
call   1050 <print_dirs@plt>
jmp    1180 <main+0x40>
xor    %eax,%eax
add    $0x408,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@stdin = global i32 0
@.str = [5 x i8] c" \09\0D\0A\00"
@.str.1 = [5 x i8] c"dirs\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca [1024 x i8]
%7 = alloca i8*
%8 = alloca i8*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
br label %9
9: ; preds = %36, %24, %2
%10 = getelementptr inbounds [1024 x i8], [1024 x i8]* %6, i64 0, i64 0
%11 = load i32, i32* @stdin
%12 = call i64 @fgets(i8* %10, i32 1024, i32 %11)
%13 = icmp ne i64 %12, 0
br i1 %13, label %14, label %37
14: ; preds = %9
store i8* null, i8** %8
%15 = getelementptr inbounds [1024 x i8], [1024 x i8]* %6, i64 0, i64 0
%16 = call i8* @strtok(i8* %15, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
store i8* %16, i8** %7
%17 = load i8*, i8** %7
%18 = icmp ne i8* %17, null
br i1 %18, label %19, label %24
19: ; preds = %14
%20 = load i8*, i8** %7
%21 = load i8, i8* %20
%22 = sext i8 %21 to i32
%23 = icmp eq i32 %22, 35
br i1 %23, label %24, label %25
24: ; preds = %19, %14
br label %9
25: ; preds = %19
%26 = call i8* @strtok(i8* null, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
store i8* %26, i8** %8
%27 = load i8*, i8** %7
%28 = call i32 @strcmp(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i8* %27)
%29 = icmp ne i32 %28, 0
br i1 %29, label %36, label %30
30: ; preds = %25
%31 = load i8*, i8** %8
%32 = icmp ne i8* %31, null
br i1 %32, label %33, label %36
33: ; preds = %30
%34 = load i8*, i8** %8
%35 = call i32 @print_dirs(i8* %34)
br label %36
36: ; preds = %33, %30, %25
br label %9
37: ; preds = %9
ret i32 0
}

LLVM IR (-O2):
@stdin = global i32 0
@.str = [5 x i8] c" \09\0D\0A\00"
@.str.1 = [5 x i8] c"dirs\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca [1024 x i8]
%4 = getelementptr inbounds [1024 x i8], [1024 x i8]* %3, i64 0, i64 0
%5 = load i32, i32* @stdin
%6 = call i64 @fgets(i8* %4, i32 1024, i32 %5)
%7 = icmp eq i64 %6, 0
br i1 %7, label %26, label %8
8: ; preds = %2, %22
%9 = call i8* @strtok(i8* %4, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
%10 = icmp eq i8* %9, null
br i1 %10, label %22, label %11
11: ; preds = %8
%12 = load i8, i8* %9
%13 = icmp eq i8 %12, 35
br i1 %13, label %22, label %14
14: ; preds = %11
%15 = call i8* @strtok(i8* null, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
%16 = call i32 @strcmp(i8* dereferenceable(5) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i8* %9)
%17 = icmp eq i32 %16, 0
%18 = icmp ne i8* %15, null
%19 = select i1 %17, i1 %18, i1 false
br i1 %19, label %20, label %22
20: ; preds = %14
%21 = call i32 @print_dirs(i8* %15)
br label %22
22: ; preds = %14, %20, %8, %11
%23 = load i32, i32* @stdin
%24 = call i64 @fgets(i8* %4, i32 1024, i32 %23)
%25 = icmp eq i64 %24, 0
br i1 %25, label %26, label %8
26: ; preds = %22, %2
ret i32 0
}