#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*/ alpha(int /*<<< orphan*/);
scalar_t__ alphanumeric(int /*<<< orphan*/);
int /*<<< orphan*/ blanks();
int /*<<< orphan*/ ch();
char gch();
symname(char *sname) {
  int k;
  blanks();
  if (!alpha(ch()))
    return (0);
  k = 0;
  while (alphanumeric(ch()))
    sname[k++] = gch();
  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,%eax
jne    1186 <symname+0x36>
movl   $0x0,-0x4(%rbp)
jmp    11db <symname+0x8b>
movl   $0x0,-0x14(%rbp)
mov    $0x0,%al
call   1030 <ch@plt>
mov    %eax,%edi
call   1060 <alphanumeric@plt>
cmp    $0x0,%rax
je     11c8 <symname+0x78>
mov    $0x0,%al
call   1070 <gch@plt>
mov    %al,%dl
mov    -0x10(%rbp),%rax
mov    -0x14(%rbp),%ecx
mov    %ecx,%esi
add    $0x1,%esi
mov    %esi,-0x14(%rbp)
movslq %ecx,%rcx
mov    %dl,(%rax,%rcx,1)
jmp    118d <symname+0x3d>
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   %eax,%eax
je     11bc <symname+0x6c>
xor    %ebp,%ebp
xor    %eax,%eax
call   1030 <ch@plt>
mov    %eax,%edi
call   1060 <alphanumeric@plt>
test   %rax,%rax
je     11b3 <symname+0x63>
xor    %ebp,%ebp
nopl   0x0(%rax,%rax,1)
xor    %eax,%eax
call   1070 <gch@plt>
mov    %al,(%rbx,%rbp,1)
add    $0x1,%rbp
xor    %eax,%eax
call   1030 <ch@plt>
mov    %eax,%edi
call   1060 <alphanumeric@plt>
test   %rax,%rax
jne    1190 <symname+0x40>
mov    %ebp,%ebp
movb   $0x0,(%rbx,%rbp,1)
mov    $0x1,%ebp
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 i32 @alpha(i32 %6)
%8 = icmp ne i32 %7, 0
br i1 %8, label %10, label %9
9: ; preds = %1
store i32 0, i32* %2
br label %27
10: ; preds = %1
store i32 0, i32* %4
br label %11
11: ; preds = %15, %10
%12 = call i32 (...) @ch()
%13 = call i64 @alphanumeric(i32 %12)
%14 = icmp ne i64 %13, 0
br i1 %14, label %15, label %22
15: ; preds = %11
%16 = call signext i8 (...) @gch()
%17 = load i8*, i8** %3
%18 = load i32, i32* %4
%19 = add nsw i32 %18, 1
store i32 %19, i32* %4
%20 = sext i32 %18 to i64
%21 = getelementptr inbounds i8, i8* %17, i64 %20
store i8 %16, i8* %21
br label %11
22: ; preds = %11
%23 = load i8*, i8** %3
%24 = load i32, i32* %4
%25 = sext i32 %24 to i64
%26 = getelementptr inbounds i8, i8* %23, i64 %25
store i8 0, i8* %26
store i32 1, i32* %2
br label %27
27: ; preds = %22, %9
%28 = load i32, i32* %2
ret i32 %28
}

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