#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 */
scalar_t__ alpha(int /*<<< orphan*/);
scalar_t__ an(int /*<<< orphan*/);
int /*<<< orphan*/ blanks();
int /*<<< orphan*/ ch();
char gch();
int symname(char *sname) {
  int k;
  blanks();
  if (alpha(ch()) == 0)
    return (*sname = 0);
  k = 0;
  while (an(ch())) {
    sname[k] = gch();
    if (k < 126)
      ++k;
  }
  sname[k] = 0;
  return 1;
}


x86 assembly (clang, -O0):
<symname>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    $0x0,%al
call   1050 <blanks@plt>
mov    $0x0,%al
call   1030 <ch@plt>
mov    %eax,%edi
call   1040 <alpha@plt>
cmp    $0x0,%rax
jne    118e <symname+0x3e>
mov    -0x10(%rbp),%rax
movb   $0x0,(%rax)
movl   $0x0,-0x4(%rbp)
jmp    11ec <symname+0x9c>
movl   $0x0,-0x14(%rbp)
mov    $0x0,%al
call   1030 <ch@plt>
mov    %eax,%edi
call   1070 <an@plt>
cmp    $0x0,%rax
je     11d9 <symname+0x89>
mov    $0x0,%al
call   1060 <gch@plt>
mov    %al,%dl
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    %dl,(%rax,%rcx,1)
cmpl   $0x7e,-0x14(%rbp)
jge    11d4 <symname+0x84>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1195 <symname+0x45>
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
movb   $0x0,(%rax,%rcx,1)
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<symname>:
push   %rbp
push   %rbx
push   %rax
mov    %rdi,%rbx
xor    %ebp,%ebp
xor    %eax,%eax
call   1050 <blanks@plt>
xor    %eax,%eax
call   1030 <ch@plt>
mov    %eax,%edi
call   1040 <alpha@plt>
test   %rax,%rax
je     11bf <symname+0x6f>
xor    %ebp,%ebp
xor    %eax,%eax
call   1030 <ch@plt>
mov    %eax,%edi
call   1070 <an@plt>
test   %rax,%rax
je     11b7 <symname+0x67>
xor    %ebp,%ebp
nopl   0x0(%rax)
xor    %eax,%eax
call   1060 <gch@plt>
mov    %ebp,%ecx
mov    %al,(%rbx,%rcx,1)
cmp    $0x7e,%ebp
adc    $0x0,%ebp
xor    %eax,%eax
call   1030 <ch@plt>
mov    %eax,%edi
call   1070 <an@plt>
test   %rax,%rax
jne    1190 <symname+0x40>
mov    %ebp,%ebp
add    %rbp,%rbx
mov    $0x1,%ebp
movb   $0x0,(%rbx)
mov    %ebp,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
define i32 @symname(i8* %0) {
%2 = alloca i32
%3 = alloca i8*
%4 = alloca i32
store i8* %0, i8** %3
%5 = call i32 (...) @blanks()
%6 = call i32 (...) @ch()
%7 = call i64 @alpha(i32 %6)
%8 = icmp eq i64 %7, 0
br i1 %8, label %9, label %11
9: ; preds = %1
%10 = load i8*, i8** %3
store i8 0, i8* %10
store i32 0, i32* %2
br label %33
11: ; preds = %1
store i32 0, i32* %4
br label %12
12: ; preds = %27, %11
%13 = call i32 (...) @ch()
%14 = call i64 @an(i32 %13)
%15 = icmp ne i64 %14, 0
br i1 %15, label %16, label %28
16: ; preds = %12
%17 = call signext i8 (...) @gch()
%18 = load i8*, i8** %3
%19 = load i32, i32* %4
%20 = sext i32 %19 to i64
%21 = getelementptr inbounds i8, i8* %18, i64 %20
store i8 %17, i8* %21
%22 = load i32, i32* %4
%23 = icmp slt i32 %22, 126
br i1 %23, label %24, label %27
24: ; preds = %16
%25 = load i32, i32* %4
%26 = add nsw i32 %25, 1
store i32 %26, i32* %4
br label %27
27: ; preds = %24, %16
br label %12
28: ; preds = %12
%29 = load i8*, i8** %3
%30 = load i32, i32* %4
%31 = sext i32 %30 to i64
%32 = getelementptr inbounds i8, i8* %29, i64 %31
store i8 0, i8* %32
store i32 1, i32* %2
br label %33
33: ; preds = %28, %9
%34 = load i32, i32* %2
ret i32 %34
}

LLVM IR (-O2):
define i32 @symname(i8* nocapture writeonly %0) {
%2 = tail call i32 (...) @blanks()
%3 = tail call i32 (...) @ch()
%4 = tail call i64 @alpha(i32 %3)
%5 = icmp eq i64 %4, 0
br i1 %5, label %26, label %6
6: ; preds = %1
%7 = tail call i32 (...) @ch()
%8 = tail call i64 @an(i32 %7)
%9 = icmp eq i64 %8, 0
br i1 %9, label %23, label %10
10: ; preds = %6, %10
%11 = phi i32 [ %17, %10 ], [ 0, %6 ]
%12 = tail call signext i8 (...) @gch()
%13 = zext i32 %11 to i64
%14 = getelementptr inbounds i8, i8* %0, i64 %13
store i8 %12, i8* %14
%15 = icmp ult i32 %11, 126
%16 = zext i1 %15 to i32
%17 = add nuw nsw i32 %11, %16
%18 = tail call i32 (...) @ch()
%19 = tail call i64 @an(i32 %18)
%20 = icmp eq i64 %19, 0
br i1 %20, label %21, label %10
21: ; preds = %10
%22 = zext i32 %17 to i64
br label %23
23: ; preds = %21, %6
%24 = phi i64 [ 0, %6 ], [ %22, %21 ]
%25 = getelementptr inbounds i8, i8* %0, i64 %24
br label %26
26: ; preds = %1, %23
%27 = phi i8* [ %25, %23 ], [ %0, %1 ]
%28 = phi i32 [ 1, %23 ], [ 0, %1 ]
store i8 0, i8* %27
ret i32 %28
}