#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 EOF;
int /*<<< orphan*/ error(char, char *);
char getch();
int /*<<< orphan*/ getword(char *, int);
int /*<<< orphan*/ install(char *, char *);
int /*<<< orphan*/ isalpha(int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ skipblanks();
scalar_t__ strcmp(char *, char *);
int /*<<< orphan*/ undef(char *);
void getdef(void) {
  char def[100] = "";
  char dir[100] = "";
  char name[100] = "";
  int i;
  skipblanks();
  if (!isalpha(getword(dir, 100)))
    error(dir[0], "getdef: expecting a directive after '#'--got '%s'");
  else if (strcmp(dir, "define") == 0) {
    skipblanks();
    if (!isalpha(getword(name, 100)))
      error(name[0], "getdef: non-alpha name expected");
    else {
      skipblanks();
      for (i = 0; i < 100 - 1; i++)
        if ((def[i] = getch()) == EOF || def[i] == '\n')
          break;
      def[i] = '\0';
      if (i <= 0)
        error('\n', "getdef; incomplete define");
      else
        (void)install(name, def);
    }
  } else if (strcmp(dir, "undef") == 0) {
    skipblanks();
    if (!isalpha(getword(name, 100)))
      error(name[0], "getdef: non-alpha in undef");
    else
      undef(name);
  } else if (strcmp(dir, "include") == 0) {
    printf("#include");
  } else
    error(dir[0], "getdef: expecting a directive after #");
}


x86 assembly (clang, -O0):
<getdef>:
push   %rbp
mov    %rsp,%rbp
sub    $0x160,%rsp
lea    -0x70(%rbp),%rdi
xor    %esi,%esi
mov    $0x64,%edx
call   1050 <memset@plt>
lea    -0xe0(%rbp),%rdi
xor    %esi,%esi
mov    $0x64,%edx
call   1050 <memset@plt>
lea    -0x150(%rbp),%rdi
xor    %esi,%esi
mov    $0x64,%edx
call   1050 <memset@plt>
mov    $0x0,%al
call   1090 <skipblanks@plt>
lea    -0xe0(%rbp),%rdi
mov    $0x64,%esi
call   1080 <getword@plt>
mov    %eax,%edi
call   10a0 <isalpha@plt>
cmp    $0x0,%eax
jne    1221 <getdef+0x81>
lea    0xdf0(%rip),%rsi
movsbl -0xe0(%rbp),%edi
call   10c0 <error@plt>
jmp    13fd <getdef+0x25d>
lea    -0xe0(%rbp),%rdi
lea    0xe36(%rip),%rsi
call   1070 <strcmp@plt>
cmp    $0x0,%rax
jne    133f <getdef+0x19f>
mov    $0x0,%al
call   1090 <skipblanks@plt>
lea    -0x150(%rbp),%rdi
mov    $0x64,%esi
call   1080 <getword@plt>
mov    %eax,%edi
call   10a0 <isalpha@plt>
cmp    $0x0,%eax
jne    127e <getdef+0xde>
lea    0xdc5(%rip),%rsi
movsbl -0x150(%rbp),%edi
call   10c0 <error@plt>
jmp    133a <getdef+0x19a>
mov    $0x0,%al
call   1090 <skipblanks@plt>
movl   $0x0,-0x154(%rbp)
cmpl   $0x63,-0x154(%rbp)
jge    12f6 <getdef+0x156>
mov    $0x0,%al
call   10b0 <getch@plt>
movslq -0x154(%rbp),%rcx
mov    %al,-0x70(%rbp,%rcx,1)
movsbl %al,%eax
mov    0x2d30(%rip),%rcx
movsbl (%rcx),%ecx
cmp    %ecx,%eax
je     12d8 <getdef+0x138>
movslq -0x154(%rbp),%rax
movsbl -0x70(%rbp,%rax,1),%eax
cmp    $0xa,%eax
jne    12dd <getdef+0x13d>
jmp    12f6 <getdef+0x156>
jmp    12e2 <getdef+0x142>
mov    -0x154(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x154(%rbp)
jmp    128f <getdef+0xef>
movslq -0x154(%rbp),%rax
movb   $0x0,-0x70(%rbp,%rax,1)
cmpl   $0x0,-0x154(%rbp)
jg     1325 <getdef+0x185>
mov    $0xa,%edi
lea    0xd37(%rip),%rsi
call   10c0 <error@plt>
jmp    1335 <getdef+0x195>
lea    -0x150(%rbp),%rdi
lea    -0x70(%rbp),%rsi
call   1060 <install@plt>
jmp    133a <getdef+0x19a>
jmp    13f8 <getdef+0x258>
lea    -0xe0(%rbp),%rdi
lea    0xd34(%rip),%rsi
call   1070 <strcmp@plt>
cmp    $0x0,%rax
jne    13ad <getdef+0x20d>
mov    $0x0,%al
call   1090 <skipblanks@plt>
lea    -0x150(%rbp),%rdi
mov    $0x64,%esi
call   1080 <getword@plt>
mov    %eax,%edi
call   10a0 <isalpha@plt>
cmp    $0x0,%eax
jne    139c <getdef+0x1fc>
lea    0xce1(%rip),%rsi
movsbl -0x150(%rbp),%edi
call   10c0 <error@plt>
jmp    13a8 <getdef+0x208>
lea    -0x150(%rbp),%rdi
call   1030 <undef@plt>
jmp    13f3 <getdef+0x253>
lea    -0xe0(%rbp),%rdi
lea    0xccd(%rip),%rsi
call   1070 <strcmp@plt>
cmp    $0x0,%rax
jne    13db <getdef+0x23b>
lea    0xcb6(%rip),%rdi
call   1040 <printf@plt>
jmp    13ee <getdef+0x24e>
lea    0xcae(%rip),%rsi
movsbl -0xe0(%rbp),%edi
call   10c0 <error@plt>
jmp    13f3 <getdef+0x253>
jmp    13f8 <getdef+0x258>
jmp    13fd <getdef+0x25d>
add    $0x160,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<getdef>:
push   %r14
push   %rbx
sub    $0x148,%rsp
xorps  %xmm0,%xmm0
movaps %xmm0,0x130(%rsp)
movaps %xmm0,0x120(%rsp)
movaps %xmm0,0x110(%rsp)
movaps %xmm0,0x100(%rsp)
movaps %xmm0,0xf0(%rsp)
movaps %xmm0,0xe0(%rsp)
movl   $0x0,0x140(%rsp)
movaps %xmm0,0xc0(%rsp)
movaps %xmm0,0xb0(%rsp)
movaps %xmm0,0xa0(%rsp)
movaps %xmm0,0x90(%rsp)
movaps %xmm0,0x80(%rsp)
movaps %xmm0,0x70(%rsp)
movl   $0x0,0xd0(%rsp)
movaps %xmm0,0x50(%rsp)
movaps %xmm0,0x40(%rsp)
movaps %xmm0,0x30(%rsp)
movaps %xmm0,0x20(%rsp)
movaps %xmm0,0x10(%rsp)
movaps %xmm0,(%rsp)
movl   $0x0,0x60(%rsp)
xor    %eax,%eax
call   1080 <skipblanks@plt>
lea    0x70(%rsp),%rdi
mov    $0x64,%esi
call   1070 <getword@plt>
mov    %eax,%edi
call   1090 <isalpha@plt>
test   %eax,%eax
je     12ae <getdef+0x11e>
lea    0xe08(%rip),%rsi
lea    0x70(%rsp),%rdi
call   1060 <strcmp@plt>
test   %rax,%rax
je     12ca <getdef+0x13a>
lea    0xe0e(%rip),%rsi
lea    0x70(%rsp),%rdi
call   1060 <strcmp@plt>
test   %rax,%rax
je     132b <getdef+0x19b>
lea    0xdfb(%rip),%rsi
lea    0x70(%rsp),%rdi
call   1060 <strcmp@plt>
test   %rax,%rax
je     1357 <getdef+0x1c7>
movsbl 0x70(%rsp),%edi
lea    0xde4(%rip),%rsi
jmp    12ba <getdef+0x12a>
movsbl 0x70(%rsp),%edi
lea    0xd46(%rip),%rsi
call   10b0 <error@plt>
add    $0x148,%rsp
pop    %rbx
pop    %r14
ret
xor    %eax,%eax
call   1080 <skipblanks@plt>
mov    %rsp,%rdi
mov    $0x64,%esi
call   1070 <getword@plt>
mov    %eax,%edi
call   1090 <isalpha@plt>
test   %eax,%eax
je     1368 <getdef+0x1d8>
xor    %eax,%eax
call   1080 <skipblanks@plt>
mov    0x2ced(%rip),%r14
xor    %ebx,%ebx
nopl   (%rax)
xor    %eax,%eax
call   10a0 <getch@plt>
mov    %al,0xe0(%rsp,%rbx,1)
cmp    $0xa,%al
je     1378 <getdef+0x1e8>
cmp    (%r14),%al
je     1378 <getdef+0x1e8>
add    $0x1,%rbx
cmp    $0x63,%rbx
jne    1300 <getdef+0x170>
movb   $0x0,0x143(%rsp)
jmp    1384 <getdef+0x1f4>
xor    %eax,%eax
call   1080 <skipblanks@plt>
mov    %rsp,%rdi
mov    $0x64,%esi
call   1070 <getword@plt>
mov    %eax,%edi
call   1090 <isalpha@plt>
test   %eax,%eax
je     1399 <getdef+0x209>
mov    %rsp,%rdi
call   1030 <undef@plt>
jmp    12bf <getdef+0x12f>
lea    0xd29(%rip),%rdi
call   1040 <printf@plt>
jmp    12bf <getdef+0x12f>
movsbl (%rsp),%edi
lea    0xcbf(%rip),%rsi
jmp    12ba <getdef+0x12a>
movb   $0x0,0xe0(%rsp,%rbx,1)
test   %ebx,%ebx
je     13a9 <getdef+0x219>
mov    %rsp,%rdi
lea    0xe0(%rsp),%rsi
call   1050 <install@plt>
jmp    12bf <getdef+0x12f>
movsbl (%rsp),%edi
lea    0xcc8(%rip),%rsi
jmp    12ba <getdef+0x12a>
lea    0xca2(%rip),%rsi
mov    $0xa,%edi
jmp    12ba <getdef+0x12a>

LLVM IR (-O0):
@.str = [50 x i8] c"getdef: expecting a directive after '#'--got '%s'\00"
@.str.1 = [7 x i8] c"define\00"
@.str.2 = [32 x i8] c"getdef: non-alpha name expected\00"
@EOF = global i8 0
@.str.3 = [26 x i8] c"getdef; incomplete define\00"
@.str.4 = [6 x i8] c"undef\00"
@.str.5 = [27 x i8] c"getdef: non-alpha in undef\00"
@.str.6 = [8 x i8] c"include\00"
@.str.7 = [9 x i8] c"#include\00"
@.str.8 = [38 x i8] c"getdef: expecting a directive after #\00"
define void @getdef() {
%1 = alloca [100 x i8]
%2 = alloca [100 x i8]
%3 = alloca [100 x i8]
%4 = alloca i32
%5 = bitcast [100 x i8]* %1 to i8*
%6 = bitcast [100 x i8]* %2 to i8*
%7 = bitcast [100 x i8]* %3 to i8*
%8 = call i32 (...) @skipblanks()
%9 = getelementptr inbounds [100 x i8], [100 x i8]* %2, i64 0, i64 0
%10 = call i32 @getword(i8* %9, i32 100)
%11 = call i32 @isalpha(i32 %10)
%12 = icmp ne i32 %11, 0
br i1 %12, label %17, label %13
13: ; preds = %0
%14 = getelementptr inbounds [100 x i8], [100 x i8]* %2, i64 0, i64 0
%15 = load i8, i8* %14
%16 = call i32 @error(i8 signext %15, i8* getelementptr inbounds ([50 x i8], [50 x i8]* @.str, i64 0, i64 0))
br label %102
17: ; preds = %0
%18 = getelementptr inbounds [100 x i8], [100 x i8]* %2, i64 0, i64 0
%19 = call i64 @strcmp(i8* %18, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0))
%20 = icmp eq i64 %19, 0
br i1 %20, label %21, label %71
21: ; preds = %17
%22 = call i32 (...) @skipblanks()
%23 = getelementptr inbounds [100 x i8], [100 x i8]* %3, i64 0, i64 0
%24 = call i32 @getword(i8* %23, i32 100)
%25 = call i32 @isalpha(i32 %24)
%26 = icmp ne i32 %25, 0
br i1 %26, label %31, label %27
27: ; preds = %21
%28 = getelementptr inbounds [100 x i8], [100 x i8]* %3, i64 0, i64 0
%29 = load i8, i8* %28
%30 = call i32 @error(i8 signext %29, i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.2, i64 0, i64 0))
br label %70
31: ; preds = %21
%32 = call i32 (...) @skipblanks()
store i32 0, i32* %4
br label %33
33: ; preds = %54, %31
%34 = load i32, i32* %4
%35 = icmp slt i32 %34, 99
br i1 %35, label %36, label %57
36: ; preds = %33
%37 = call signext i8 (...) @getch()
%38 = load i32, i32* %4
%39 = sext i32 %38 to i64
%40 = getelementptr inbounds [100 x i8], [100 x i8]* %1, i64 0, i64 %39
store i8 %37, i8* %40
%41 = sext i8 %37 to i32
%42 = load i8, i8* @EOF
%43 = sext i8 %42 to i32
%44 = icmp eq i32 %41, %43
br i1 %44, label %52, label %45
45: ; preds = %36
%46 = load i32, i32* %4
%47 = sext i32 %46 to i64
%48 = getelementptr inbounds [100 x i8], [100 x i8]* %1, i64 0, i64 %47
%49 = load i8, i8* %48
%50 = sext i8 %49 to i32
%51 = icmp eq i32 %50, 10
br i1 %51, label %52, label %53
52: ; preds = %45, %36
br label %57
53: ; preds = %45
br label %54
54: ; preds = %53
%55 = load i32, i32* %4
%56 = add nsw i32 %55, 1
store i32 %56, i32* %4
br label %33
57: ; preds = %52, %33
%58 = load i32, i32* %4
%59 = sext i32 %58 to i64
%60 = getelementptr inbounds [100 x i8], [100 x i8]* %1, i64 0, i64 %59
store i8 0, i8* %60
%61 = load i32, i32* %4
%62 = icmp sle i32 %61, 0
br i1 %62, label %63, label %65
63: ; preds = %57
%64 = call i32 @error(i8 signext 10, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.3, i64 0, i64 0))
br label %69
65: ; preds = %57
%66 = getelementptr inbounds [100 x i8], [100 x i8]* %3, i64 0, i64 0
%67 = getelementptr inbounds [100 x i8], [100 x i8]* %1, i64 0, i64 0
%68 = call i32 @install(i8* %66, i8* %67)
br label %69
69: ; preds = %65, %63
br label %70
70: ; preds = %69, %27
br label %101
71: ; preds = %17
%72 = getelementptr inbounds [100 x i8], [100 x i8]* %2, i64 0, i64 0
%73 = call i64 @strcmp(i8* %72, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0))
%74 = icmp eq i64 %73, 0
br i1 %74, label %75, label %89
75: ; preds = %71
%76 = call i32 (...) @skipblanks()
%77 = getelementptr inbounds [100 x i8], [100 x i8]* %3, i64 0, i64 0
%78 = call i32 @getword(i8* %77, i32 100)
%79 = call i32 @isalpha(i32 %78)
%80 = icmp ne i32 %79, 0
br i1 %80, label %85, label %81
81: ; preds = %75
%82 = getelementptr inbounds [100 x i8], [100 x i8]* %3, i64 0, i64 0
%83 = load i8, i8* %82
%84 = call i32 @error(i8 signext %83, i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.5, i64 0, i64 0))
br label %88
85: ; preds = %75
%86 = getelementptr inbounds [100 x i8], [100 x i8]* %3, i64 0, i64 0
%87 = call i32 @undef(i8* %86)
br label %88
88: ; preds = %85, %81
br label %100
89: ; preds = %71
%90 = getelementptr inbounds [100 x i8], [100 x i8]* %2, i64 0, i64 0
%91 = call i64 @strcmp(i8* %90, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.6, i64 0, i64 0))
%92 = icmp eq i64 %91, 0
br i1 %92, label %93, label %95
93: ; preds = %89
%94 = call i32 @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.7, i64 0, i64 0))
br label %99
95: ; preds = %89
%96 = getelementptr inbounds [100 x i8], [100 x i8]* %2, i64 0, i64 0
%97 = load i8, i8* %96
%98 = call i32 @error(i8 signext %97, i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.8, i64 0, i64 0))
br label %99
99: ; preds = %95, %93
br label %100
100: ; preds = %99, %88
br label %101
101: ; preds = %100, %70
br label %102
102: ; preds = %101, %13
ret void
}

LLVM IR (-O2):
@.str = [50 x i8] c"getdef: expecting a directive after '#'--got '%s'\00"
@.str.1 = [7 x i8] c"define\00"
@.str.2 = [32 x i8] c"getdef: non-alpha name expected\00"
@EOF = global i8 0
@.str.3 = [26 x i8] c"getdef; incomplete define\00"
@.str.4 = [6 x i8] c"undef\00"
@.str.5 = [27 x i8] c"getdef: non-alpha in undef\00"
@.str.6 = [8 x i8] c"include\00"
@.str.7 = [9 x i8] c"#include\00"
@.str.8 = [38 x i8] c"getdef: expecting a directive after #\00"
define void @getdef() {
%1 = alloca [100 x i8]
%2 = alloca [100 x i8]
%3 = alloca [100 x i8]
%4 = getelementptr inbounds [100 x i8], [100 x i8]* %1, i64 0, i64 0
%5 = getelementptr inbounds [100 x i8], [100 x i8]* %2, i64 0, i64 0
%6 = getelementptr inbounds [100 x i8], [100 x i8]* %3, i64 0, i64 0
%7 = tail call i32 (...) @skipblanks()
%8 = call i32 @getword(i8* %5, i32 100)
%9 = call i32 @isalpha(i32 %8)
%10 = icmp eq i32 %9, 0
br i1 %10, label %11, label %14
11: ; preds = %0
%12 = load i8, i8* %5
%13 = call i32 @error(i8 signext %12, i8* getelementptr inbounds ([50 x i8], [50 x i8]* @.str, i64 0, i64 0))
br label %70
14: ; preds = %0
%15 = call i64 @strcmp(i8* %5, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0))
%16 = icmp eq i64 %15, 0
br i1 %16, label %17, label %49
17: ; preds = %14
%18 = call i32 (...) @skipblanks()
%19 = call i32 @getword(i8* %6, i32 100)
%20 = call i32 @isalpha(i32 %19)
%21 = icmp eq i32 %20, 0
br i1 %21, label %22, label %25
22: ; preds = %17
%23 = load i8, i8* %6
%24 = call i32 @error(i8 signext %23, i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.2, i64 0, i64 0))
br label %70
25: ; preds = %17
%26 = call i32 (...) @skipblanks()
br label %29
27: ; preds = %37
%28 = getelementptr inbounds [100 x i8], [100 x i8]* %1, i64 0, i64 99
store i8 0, i8* %28
br label %47
29: ; preds = %25, %37
%30 = phi i64 [ 0, %25 ], [ %38, %37 ]
%31 = call signext i8 (...) @getch()
%32 = getelementptr inbounds [100 x i8], [100 x i8]* %1, i64 0, i64 %30
store i8 %31, i8* %32
%33 = load i8, i8* @EOF
%34 = icmp eq i8 %31, %33
%35 = icmp eq i8 %31, 10
%36 = or i1 %35, %34
br i1 %36, label %40, label %37
37: ; preds = %29
%38 = add nuw nsw i64 %30, 1
%39 = icmp eq i64 %38, 99
br i1 %39, label %27, label %29
40: ; preds = %29
%41 = trunc i64 %30 to i32
%42 = and i64 %30, 4294967295
%43 = getelementptr inbounds [100 x i8], [100 x i8]* %1, i64 0, i64 %42
store i8 0, i8* %43
%44 = icmp eq i32 %41, 0
br i1 %44, label %45, label %47
45: ; preds = %40
%46 = call i32 @error(i8 signext 10, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.3, i64 0, i64 0))
br label %70
47: ; preds = %27, %40
%48 = call i32 @install(i8* %6, i8* %4)
br label %70
49: ; preds = %14
%50 = call i64 @strcmp(i8* %5, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0))
%51 = icmp eq i64 %50, 0
br i1 %51, label %52, label %62
52: ; preds = %49
%53 = call i32 (...) @skipblanks()
%54 = call i32 @getword(i8* %6, i32 100)
%55 = call i32 @isalpha(i32 %54)
%56 = icmp eq i32 %55, 0
br i1 %56, label %57, label %60
57: ; preds = %52
%58 = load i8, i8* %6
%59 = call i32 @error(i8 signext %58, i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.5, i64 0, i64 0))
br label %70
60: ; preds = %52
%61 = call i32 @undef(i8* %6)
br label %70
62: ; preds = %49
%63 = call i64 @strcmp(i8* %5, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.6, i64 0, i64 0))
%64 = icmp eq i64 %63, 0
br i1 %64, label %65, label %67
65: ; preds = %62
%66 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @.str.7, i64 0, i64 0))
br label %70
67: ; preds = %62
%68 = load i8, i8* %5
%69 = call i32 @error(i8 signext %68, i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.8, i64 0, i64 0))
br label %70
70: ; preds = %45, %47, %22, %65, %67, %57, %60, %11
ret void
}