#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 /*<<< orphan*/ diagnostics(int, char *, ...);
char getRawTexChar();
char getTexChar();
int /*<<< orphan*/ isalpha(int);
char *my_strdup(char *);
int /*<<< orphan*/ ungetTexChar(char);
char *getSimpleCommand(void) {
  char buffer[128];
  int size;
  buffer[0] = getTexChar();
  if (buffer[0] != '\\')
    return NULL;
  buffer[1] = getTexChar();
  for (size = 2; size < 127; size++) {
    buffer[size] = getRawTexChar();
    if (!isalpha((int)buffer[size])) {
      ungetTexChar(buffer[size]);
      break;
    }
  }
  buffer[size] = '\0';
  if (size == 127) {
    diagnostics(1, "Misplaced brace.");
    diagnostics(0, "Cannot find close brace in 127 characters");
  }
  diagnostics(5, "getSimpleCommand result <%s>", buffer);
  return my_strdup(buffer);
}


x86 assembly (clang, -O0):
<getSimpleCommand>:
push   %rbp
mov    %rsp,%rbp
sub    $0xa0,%rsp
mov    $0x0,%al
call   1040 <getTexChar@plt>
mov    %al,-0x90(%rbp)
movsbl -0x90(%rbp),%eax
cmp    $0x5c,%eax
je     1195 <getSimpleCommand+0x35>
movq   $0x0,-0x8(%rbp)
jmp    1288 <getSimpleCommand+0x128>
mov    $0x0,%al
call   1040 <getTexChar@plt>
mov    %al,-0x8f(%rbp)
movl   $0x2,-0x94(%rbp)
cmpl   $0x7f,-0x94(%rbp)
jge    121f <getSimpleCommand+0xbf>
mov    $0x0,%al
call   1050 <getRawTexChar@plt>
mov    %al,%cl
movslq -0x94(%rbp),%rax
mov    %cl,-0x90(%rbp,%rax,1)
movslq -0x94(%rbp),%rax
movsbl -0x90(%rbp,%rax,1),%edi
ff
call   1070 <isalpha@plt>
cmp    $0x0,%eax
jne    1206 <getSimpleCommand+0xa6>
movslq -0x94(%rbp),%rax
movsbl -0x90(%rbp,%rax,1),%edi
ff
call   1030 <ungetTexChar@plt>
jmp    121f <getSimpleCommand+0xbf>
jmp    120b <getSimpleCommand+0xab>
mov    -0x94(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x94(%rbp)
jmp    11ac <getSimpleCommand+0x4c>
movslq -0x94(%rbp),%rax
movb   $0x0,-0x90(%rbp,%rax,1)
cmpl   $0x7f,-0x94(%rbp)
jne    125e <getSimpleCommand+0xfe>
mov    $0x1,%edi
lea    0xdb9(%rip),%rsi
mov    $0x0,%al
call   1060 <diagnostics@plt>
xor    %edi,%edi
lea    0xdba(%rip),%rsi
mov    $0x0,%al
call   1060 <diagnostics@plt>
lea    -0x90(%rbp),%rdx
mov    $0x5,%edi
lea    0xdca(%rip),%rsi
mov    $0x0,%al
call   1060 <diagnostics@plt>
lea    -0x90(%rbp),%rdi
call   1080 <my_strdup@plt>
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0xa0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<getSimpleCommand>:
push   %rbp
push   %rbx
sub    $0x88,%rsp
xor    %ebx,%ebx
xor    %eax,%eax
call   1040 <getTexChar@plt>
mov    %al,(%rsp)
cmp    $0x5c,%al
jne    120b <getSimpleCommand+0xab>
xor    %eax,%eax
call   1040 <getTexChar@plt>
mov    %al,0x1(%rsp)
mov    $0x2,%ebx
nopl   (%rax)
xor    %eax,%eax
call   1050 <getRawTexChar@plt>
mov    %al,(%rsp,%rbx,1)
movsbl %al,%ebp
mov    %ebp,%edi
call   1070 <isalpha@plt>
test   %eax,%eax
je     11dc <getSimpleCommand+0x7c>
add    $0x1,%rbx
cmp    $0x7f,%rbx
jne    1190 <getSimpleCommand+0x30>
movb   $0x0,0x7f(%rsp)
lea    0xe42(%rip),%rsi
mov    $0x1,%edi
xor    %eax,%eax
call   1060 <diagnostics@plt>
lea    0xe40(%rip),%rsi
xor    %edi,%edi
xor    %eax,%eax
call   1060 <diagnostics@plt>
jmp    11e7 <getSimpleCommand+0x87>
mov    %ebp,%edi
call   1030 <ungetTexChar@plt>
movb   $0x0,(%rsp,%rbx,1)
lea    0xe4d(%rip),%rsi
mov    %rsp,%rbx
mov    $0x5,%edi
mov    %rbx,%rdx
xor    %eax,%eax
call   1060 <diagnostics@plt>
mov    %rbx,%rdi
call   1080 <my_strdup@plt>
mov    %rax,%rbx
mov    %rbx,%rax
add    $0x88,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@.str = [17 x i8] c"Misplaced brace.\00"
@.str.1 = [42 x i8] c"Cannot find close brace in 127 characters\00"
@.str.2 = [29 x i8] c"getSimpleCommand result <%s>\00"
define i8* @getSimpleCommand() {
%1 = alloca i8*
%2 = alloca [128 x i8]
%3 = alloca i32
%4 = call signext i8 (...) @getTexChar()
%5 = getelementptr inbounds [128 x i8], [128 x i8]* %2, i64 0, i64 0
store i8 %4, i8* %5
%6 = getelementptr inbounds [128 x i8], [128 x i8]* %2, i64 0, i64 0
%7 = load i8, i8* %6
%8 = sext i8 %7 to i32
%9 = icmp ne i32 %8, 92
br i1 %9, label %10, label %11
10: ; preds = %0
store i8* null, i8** %1
br label %53
11: ; preds = %0
%12 = call signext i8 (...) @getTexChar()
%13 = getelementptr inbounds [128 x i8], [128 x i8]* %2, i64 0, i64 1
store i8 %12, i8* %13
store i32 2, i32* %3
br label %14
14: ; preds = %36, %11
%15 = load i32, i32* %3
%16 = icmp slt i32 %15, 127
br i1 %16, label %17, label %39
17: ; preds = %14
%18 = call signext i8 (...) @getRawTexChar()
%19 = load i32, i32* %3
%20 = sext i32 %19 to i64
%21 = getelementptr inbounds [128 x i8], [128 x i8]* %2, i64 0, i64 %20
store i8 %18, i8* %21
%22 = load i32, i32* %3
%23 = sext i32 %22 to i64
%24 = getelementptr inbounds [128 x i8], [128 x i8]* %2, i64 0, i64 %23
%25 = load i8, i8* %24
%26 = sext i8 %25 to i32
%27 = call i32 @isalpha(i32 %26)
%28 = icmp ne i32 %27, 0
br i1 %28, label %35, label %29
29: ; preds = %17
%30 = load i32, i32* %3
%31 = sext i32 %30 to i64
%32 = getelementptr inbounds [128 x i8], [128 x i8]* %2, i64 0, i64 %31
%33 = load i8, i8* %32
%34 = call i32 @ungetTexChar(i8 signext %33)
br label %39
35: ; preds = %17
br label %36
36: ; preds = %35
%37 = load i32, i32* %3
%38 = add nsw i32 %37, 1
store i32 %38, i32* %3
br label %14
39: ; preds = %29, %14
%40 = load i32, i32* %3
%41 = sext i32 %40 to i64
%42 = getelementptr inbounds [128 x i8], [128 x i8]* %2, i64 0, i64 %41
store i8 0, i8* %42
%43 = load i32, i32* %3
%44 = icmp eq i32 %43, 127
br i1 %44, label %45, label %48
45: ; preds = %39
%46 = call i32 (i32, i8*, ...) @diagnostics(i32 1, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0))
%47 = call i32 (i32, i8*, ...) @diagnostics(i32 0, i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str.1, i64 0, i64 0))
br label %48
48: ; preds = %45, %39
%49 = getelementptr inbounds [128 x i8], [128 x i8]* %2, i64 0, i64 0
%50 = call i32 (i32, i8*, ...) @diagnostics(i32 5, i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.2, i64 0, i64 0), i8* %49)
%51 = getelementptr inbounds [128 x i8], [128 x i8]* %2, i64 0, i64 0
%52 = call i8* @my_strdup(i8* %51)
store i8* %52, i8** %1
br label %53
53: ; preds = %48, %10
%54 = load i8*, i8** %1
ret i8* %54
}

LLVM IR (-O2):
@.str = [17 x i8] c"Misplaced brace.\00"
@.str.1 = [42 x i8] c"Cannot find close brace in 127 characters\00"
@.str.2 = [29 x i8] c"getSimpleCommand result <%s>\00"
define i8* @getSimpleCommand() {
%1 = alloca [128 x i8]
%2 = getelementptr inbounds [128 x i8], [128 x i8]* %1, i64 0, i64 0
%3 = tail call signext i8 (...) @getTexChar()
store i8 %3, i8* %2
%4 = icmp eq i8 %3, 92
br i1 %4, label %5, label %29
5: ; preds = %0
%6 = tail call signext i8 (...) @getTexChar()
%7 = getelementptr inbounds [128 x i8], [128 x i8]* %1, i64 0, i64 1
store i8 %6, i8* %7
br label %8
8: ; preds = %5, %19
%9 = phi i64 [ 2, %5 ], [ %20, %19 ]
%10 = tail call signext i8 (...) @getRawTexChar()
%11 = getelementptr inbounds [128 x i8], [128 x i8]* %1, i64 0, i64 %9
store i8 %10, i8* %11
%12 = sext i8 %10 to i32
%13 = tail call i32 @isalpha(i32 %12)
%14 = icmp eq i32 %13, 0
br i1 %14, label %15, label %19
15: ; preds = %8
%16 = tail call i32 @ungetTexChar(i8 signext %10)
%17 = and i64 %9, 4294967295
%18 = getelementptr inbounds [128 x i8], [128 x i8]* %1, i64 0, i64 %17
store i8 0, i8* %18
br label %26
19: ; preds = %8
%20 = add nuw nsw i64 %9, 1
%21 = icmp eq i64 %20, 127
br i1 %21, label %22, label %8
22: ; preds = %19
%23 = getelementptr inbounds [128 x i8], [128 x i8]* %1, i64 0, i64 127
store i8 0, i8* %23
%24 = tail call i32 (i32, i8*, ...) @diagnostics(i32 1, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0))
%25 = tail call i32 (i32, i8*, ...) @diagnostics(i32 0, i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str.1, i64 0, i64 0))
br label %26
26: ; preds = %15, %22
%27 = call i32 (i32, i8*, ...) @diagnostics(i32 5, i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.2, i64 0, i64 0), i8* %2)
%28 = call i8* @my_strdup(i8* %2)
br label %29
29: ; preds = %0, %26
%30 = phi i8* [ %28, %26 ], [ null, %0 ]
ret i8* %30
}