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

/* Variables and functions */
scalar_t__ ispunct(char);
int /*<<< orphan*/ lex(char *);
int /*<<< orphan*/ memset(char *, int /*<<< orphan*/, int);
int /*<<< orphan*/ parse(char *, char *);
void lex_punct(char *str) {
  char token[20];
  char *toktype;
  int i = 0;
  while (ispunct(*str) && *str != '\0' && i < 20) {
    token[i] = *str;
    i++;
    str++;
  }
  token[i] = '\0';
  toktype = "Punct";
  parse(token, toktype);
  memset(&token[0], 0, sizeof(token));
  lex(str);
}


x86 assembly (clang, -O0):
<lex_punct>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
movl   $0x0,-0x2c(%rbp)
mov    -0x8(%rbp),%rax
movsbl (%rax),%edi
call   1050 <ispunct@plt>
mov    %rax,%rcx
xor    %eax,%eax
cmp    $0x0,%rcx
mov    %al,-0x2d(%rbp)
je     1190 <lex_punct+0x50>
mov    -0x8(%rbp),%rax
movsbl (%rax),%ecx
xor    %eax,%eax
cmp    $0x0,%ecx
mov    %al,-0x2d(%rbp)
je     1190 <lex_punct+0x50>
cmpl   $0x14,-0x2c(%rbp)
setl   %al
mov    %al,-0x2d(%rbp)
mov    -0x2d(%rbp),%al
test   $0x1,%al
jne    11a0 <lex_punct+0x60>
jmp    11c8 <lex_punct+0x88>
mov    -0x8(%rbp),%rax
mov    (%rax),%cl
movslq -0x2c(%rbp),%rax
mov    %cl,-0x20(%rbp,%rax,1)
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
mov    -0x8(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x8(%rbp)
jmp    1153 <lex_punct+0x13>
movslq -0x2c(%rbp),%rax
movb   $0x0,-0x20(%rbp,%rax,1)
lea    0xe28(%rip),%rax
mov    %rax,-0x28(%rbp)
lea    -0x20(%rbp),%rdi
mov    -0x28(%rbp),%rsi
call   1060 <parse@plt>
lea    -0x20(%rbp),%rdi
xor    %esi,%esi
mov    $0x14,%edx
call   1040 <memset@plt>
mov    -0x8(%rbp),%rdi
call   1030 <lex@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<lex_punct>:
push   %r15
push   %r14
push   %rbx
sub    $0x20,%rsp
mov    %rdi,%r15
movsbl (%rdi),%edi
call   1050 <ispunct@plt>
xor    %ebx,%ebx
test   %rax,%rax
je     1189 <lex_punct+0x49>
nopl   0x0(%rax,%rax,1)
movzbl (%r15,%rbx,1),%eax
test   %al,%al
je     1186 <lex_punct+0x46>
cmp    $0x13,%rbx
ja     1186 <lex_punct+0x46>
mov    %al,(%rsp,%rbx,1)
movsbl 0x1(%r15,%rbx,1),%edi
add    $0x1,%rbx
call   1050 <ispunct@plt>
test   %rax,%rax
jne    1160 <lex_punct+0x20>
add    %rbx,%r15
movb   $0x0,(%rsp,%rbx,1)
lea    0xe6c(%rip),%rsi
mov    %rsp,%r14
mov    %r14,%rdi
call   1060 <parse@plt>
mov    %r14,%rdi
xor    %esi,%esi
mov    $0x14,%edx
call   1040 <memset@plt>
mov    %r15,%rdi
call   1030 <lex@plt>
add    $0x20,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [6 x i8] c"Punct\00"
define void @lex_punct(i8* %0) {
%2 = alloca i8*
%3 = alloca [20 x i8]
%4 = alloca i8*
%5 = alloca i32
store i8* %0, i8** %2
store i32 0, i32* %5
br label %6
6: ; preds = %21, %1
%7 = load i8*, i8** %2
%8 = load i8, i8* %7
%9 = call i64 @ispunct(i8 signext %8)
%10 = icmp ne i64 %9, 0
br i1 %10, label %11, label %19
11: ; preds = %6
%12 = load i8*, i8** %2
%13 = load i8, i8* %12
%14 = sext i8 %13 to i32
%15 = icmp ne i32 %14, 0
br i1 %15, label %16, label %19
16: ; preds = %11
%17 = load i32, i32* %5
%18 = icmp slt i32 %17, 20
br label %19
19: ; preds = %16, %11, %6
%20 = phi i1 [ false, %11 ], [ false, %6 ], [ %18, %16 ]
br i1 %20, label %21, label %31
21: ; preds = %19
%22 = load i8*, i8** %2
%23 = load i8, i8* %22
%24 = load i32, i32* %5
%25 = sext i32 %24 to i64
%26 = getelementptr inbounds [20 x i8], [20 x i8]* %3, i64 0, i64 %25
store i8 %23, i8* %26
%27 = load i32, i32* %5
%28 = add nsw i32 %27, 1
store i32 %28, i32* %5
%29 = load i8*, i8** %2
%30 = getelementptr inbounds i8, i8* %29, i32 1
store i8* %30, i8** %2
br label %6
31: ; preds = %19
%32 = load i32, i32* %5
%33 = sext i32 %32 to i64
%34 = getelementptr inbounds [20 x i8], [20 x i8]* %3, i64 0, i64 %33
store i8 0, i8* %34
store i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i8** %4
%35 = getelementptr inbounds [20 x i8], [20 x i8]* %3, i64 0, i64 0
%36 = load i8*, i8** %4
%37 = call i32 @parse(i8* %35, i8* %36)
%38 = getelementptr inbounds [20 x i8], [20 x i8]* %3, i64 0, i64 0
%39 = call i32 @memset(i8* %38, i32 0, i32 20)
%40 = load i8*, i8** %2
%41 = call i32 @lex(i8* %40)
ret void
}

LLVM IR (-O2):
@.str = [6 x i8] c"Punct\00"
define void @lex_punct(i8* %0) {
%2 = alloca [20 x i8]
%3 = getelementptr inbounds [20 x i8], [20 x i8]* %2, i64 0, i64 0
%4 = load i8, i8* %0
%5 = tail call i64 @ispunct(i8 signext %4)
%6 = icmp eq i64 %5, 0
br i1 %6, label %21, label %7
7: ; preds = %1, %14
%8 = phi i64 [ %16, %14 ], [ 0, %1 ]
%9 = phi i8* [ %17, %14 ], [ %0, %1 ]
%10 = load i8, i8* %9
%11 = icmp ne i8 %10, 0
%12 = icmp ult i64 %8, 20
%13 = select i1 %11, i1 %12, i1 false
br i1 %13, label %14, label %21
14: ; preds = %7
%15 = getelementptr inbounds [20 x i8], [20 x i8]* %2, i64 0, i64 %8
store i8 %10, i8* %15
%16 = add nuw nsw i64 %8, 1
%17 = getelementptr inbounds i8, i8* %9, i64 1
%18 = load i8, i8* %17
%19 = tail call i64 @ispunct(i8 signext %18)
%20 = icmp eq i64 %19, 0
br i1 %20, label %21, label %7
21: ; preds = %7, %14, %1
%22 = phi i8* [ %0, %1 ], [ %9, %7 ], [ %17, %14 ]
%23 = phi i64 [ 0, %1 ], [ %8, %7 ], [ %16, %14 ]
%24 = getelementptr inbounds [20 x i8], [20 x i8]* %2, i64 0, i64 %23
store i8 0, i8* %24
%25 = call i32 @parse(i8* %3, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0))
%26 = call i32 @memset(i8* %3, i32 0, i32 20)
%27 = call i32 @lex(i8* %22)
ret void
}