#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*/ FILE;

/* Variables and functions */
char fgetc(int /*<<< orphan*/ *);
int /*<<< orphan*/ lang_skipWhitespace(int /*<<< orphan*/ *);
scalar_t__ malloc(int);
int /*<<< orphan*/ ungetc(char, int /*<<< orphan*/ *);
char *lang_getVarName(FILE *lang_in) {
  lang_skipWhitespace(lang_in);
  char *name;
  name = (char *)malloc(80);
  char c;
  c = fgetc(lang_in);
  int i;
  i = -1;
  while (((c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z') || c == '_') &&
         i < 79) {
    name[++i] = c;
    c = fgetc(lang_in);
  }
  ungetc(c, lang_in);
  name[++i] = 0;
  return name;
}


x86 assembly (clang, -O0):
<lang_getVarName>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
call   1040 <lang_skipWhitespace@plt>
mov    $0x50,%edi
call   1050 <malloc@plt>
mov    %rax,-0x10(%rbp)
mov    -0x8(%rbp),%rdi
call   1030 <fgetc@plt>
mov    %al,-0x11(%rbp)
movl   $0xffffffff,-0x18(%rbp)
movsbl -0x11(%rbp),%eax
cmp    $0x61,%eax
jl     1190 <lang_getVarName+0x50>
movsbl -0x11(%rbp),%eax
cmp    $0x7a,%eax
jle    11bc <lang_getVarName+0x7c>
movsbl -0x11(%rbp),%eax
cmp    $0x41,%eax
jl     11aa <lang_getVarName+0x6a>
movsbl -0x11(%rbp),%eax
cmp    $0x5a,%eax
jle    11bc <lang_getVarName+0x7c>
movsbl -0x11(%rbp),%ecx
xor    %eax,%eax
cmp    $0x5f,%ecx
mov    %al,-0x19(%rbp)
jne    11c6 <lang_getVarName+0x86>
cmpl   $0x4f,-0x18(%rbp)
setl   %al
mov    %al,-0x19(%rbp)
mov    -0x19(%rbp),%al
test   $0x1,%al
jne    11d6 <lang_getVarName+0x96>
jmp    11fd <lang_getVarName+0xbd>
mov    -0x11(%rbp),%dl
mov    -0x10(%rbp),%rax
mov    -0x18(%rbp),%ecx
add    $0x1,%ecx
mov    %ecx,-0x18(%rbp)
movslq %ecx,%rcx
mov    %dl,(%rax,%rcx,1)
mov    -0x8(%rbp),%rdi
call   1030 <fgetc@plt>
mov    %al,-0x11(%rbp)
jmp    1176 <lang_getVarName+0x36>
mov    -0x11(%rbp),%al
mov    -0x8(%rbp),%rsi
movsbl %al,%edi
call   1060 <ungetc@plt>
mov    -0x10(%rbp),%rax
mov    -0x18(%rbp),%ecx
add    $0x1,%ecx
mov    %ecx,-0x18(%rbp)
movslq %ecx,%rcx
movb   $0x0,(%rax,%rcx,1)
mov    -0x10(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<lang_getVarName>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
mov    %rdi,%r14
call   1040 <lang_skipWhitespace@plt>
mov    $0x50,%edi
call   1050 <malloc@plt>
mov    %rax,%r15
mov    $0xffffffffffffffff,%rbx
xor    %r12d,%r12d
movabs $0x100000000,%r13
jmp    1192 <lang_getVarName+0x52>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
cmp    $0x4e,%rbx
jg     11ba <lang_getVarName+0x7a>
mov    %al,0x1(%r15,%rbx,1)
add    $0x1,%rbx
add    %r13,%r12
mov    %r14,%rdi
call   1030 <fgetc@plt>
lea    -0x61(%rax),%ecx
cmp    $0x1a,%cl
jb     1180 <lang_getVarName+0x40>
lea    -0x41(%rax),%ecx
cmp    $0x1a,%cl
setae  %cl
cmp    $0x5f,%al
setne  %dl
test   %cl,%dl
jne    11ba <lang_getVarName+0x7a>
cmp    $0x4f,%rbx
jl     1186 <lang_getVarName+0x46>
movsbl %al,%edi
mov    %r14,%rsi
call   1060 <ungetc@plt>
sar    $0x20,%r12
movb   $0x0,(%r15,%r12,1)
mov    %r15,%rax
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define i8* @lang_getVarName(i32* %0) {
%2 = alloca i32*
%3 = alloca i8*
%4 = alloca i8
%5 = alloca i32
store i32* %0, i32** %2
%6 = load i32*, i32** %2
%7 = call i32 @lang_skipWhitespace(i32* %6)
%8 = call i64 @malloc(i32 80)
%9 = inttoptr i64 %8 to i8*
store i8* %9, i8** %3
%10 = load i32*, i32** %2
%11 = call signext i8 @fgetc(i32* %10)
store i8 %11, i8* %4
store i32 -1, i32* %5
br label %12
12: ; preds = %37, %1
%13 = load i8, i8* %4
%14 = sext i8 %13 to i32
%15 = icmp sge i32 %14, 97
br i1 %15, label %16, label %20
16: ; preds = %12
%17 = load i8, i8* %4
%18 = sext i8 %17 to i32
%19 = icmp sle i32 %18, 122
br i1 %19, label %32, label %20
20: ; preds = %16, %12
%21 = load i8, i8* %4
%22 = sext i8 %21 to i32
%23 = icmp sge i32 %22, 65
br i1 %23, label %24, label %28
24: ; preds = %20
%25 = load i8, i8* %4
%26 = sext i8 %25 to i32
%27 = icmp sle i32 %26, 90
br i1 %27, label %32, label %28
28: ; preds = %24, %20
%29 = load i8, i8* %4
%30 = sext i8 %29 to i32
%31 = icmp eq i32 %30, 95
br i1 %31, label %32, label %35
32: ; preds = %28, %24, %16
%33 = load i32, i32* %5
%34 = icmp slt i32 %33, 79
br label %35
35: ; preds = %32, %28
%36 = phi i1 [ false, %28 ], [ %34, %32 ]
br i1 %36, label %37, label %46
37: ; preds = %35
%38 = load i8, i8* %4
%39 = load i8*, i8** %3
%40 = load i32, i32* %5
%41 = add nsw i32 %40, 1
store i32 %41, i32* %5
%42 = sext i32 %41 to i64
%43 = getelementptr inbounds i8, i8* %39, i64 %42
store i8 %38, i8* %43
%44 = load i32*, i32** %2
%45 = call signext i8 @fgetc(i32* %44)
store i8 %45, i8* %4
br label %12
46: ; preds = %35
%47 = load i8, i8* %4
%48 = load i32*, i32** %2
%49 = call i32 @ungetc(i8 signext %47, i32* %48)
%50 = load i8*, i8** %3
%51 = load i32, i32* %5
%52 = add nsw i32 %51, 1
store i32 %52, i32* %5
%53 = sext i32 %52 to i64
%54 = getelementptr inbounds i8, i8* %50, i64 %53
store i8 0, i8* %54
%55 = load i8*, i8** %3
ret i8* %55
}

LLVM IR (-O2):
define i8* @lang_getVarName(i32* %0) {
%2 = tail call i32 @lang_skipWhitespace(i32* %0)
%3 = tail call i64 @malloc(i32 80)
%4 = inttoptr i64 %3 to i8*
br label %5
5: ; preds = %19, %1
%6 = phi i64 [ %20, %19 ], [ -1, %1 ]
%7 = tail call signext i8 @fgetc(i32* %0)
%8 = add i8 %7, -97
%9 = icmp ult i8 %8, 26
br i1 %9, label %17, label %10
10: ; preds = %5
%11 = add i8 %7, -65
%12 = icmp ult i8 %11, 26
%13 = icmp eq i8 %7, 95
%14 = or i1 %13, %12
%15 = icmp slt i64 %6, 79
%16 = select i1 %14, i1 %15, i1 false
br i1 %16, label %19, label %22
17: ; preds = %5
%18 = icmp slt i64 %6, 79
br i1 %18, label %19, label %22
19: ; preds = %10, %17
%20 = add nsw i64 %6, 1
%21 = getelementptr inbounds i8, i8* %4, i64 %20
store i8 %7, i8* %21
br label %5
22: ; preds = %10, %17
%23 = tail call i32 @ungetc(i8 signext %7, i32* %0)
%24 = shl i64 %6, 32
%25 = add i64 %24, 4294967296
%26 = ashr exact i64 %25, 32
%27 = getelementptr inbounds i8, i8* %4, i64 %26
store i8 0, i8* %27
ret i8* %4
}