#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 */
char *BASM_PP_EmitCharString(char *, char *);
char *BASM_PP_EmitString(char *, char *);
char *BASM_PP_PrintName(char *, char *);
scalar_t__ BASM_Parse_OpChar(char);
int /*<<< orphan*/ sprintf(char *, char *, char *);
int /*<<< orphan*/ strcmp(char *, char *);
int /*<<< orphan*/ strlen(char *);
char *BASM_PP_PrintToken(char *t, char *s, int ty) {
  if (ty == 1) {
    t = BASM_PP_PrintName(t, s);
    return (t);
  }
  if (ty == 2) {
    t = BASM_PP_PrintName(t, s);
    return (t);
  }
  if (ty == 3) {
    t = BASM_PP_EmitString(t, s);
    return (t);
  }
  if (ty == 4) {
    t = BASM_PP_EmitCharString(t, s);
    return (t);
  }
  if (!strcmp(s, ";")) {
    *t++ = ';';
    *t++ = ' ';
    *t = 0;
    return (t);
  }
  if (BASM_Parse_OpChar(*s) && BASM_Parse_OpChar(*(t - 1)))
    *t++ = ' ';
  sprintf(t, "%s", s);
  t += strlen(t);
  return (t);
}


x86 assembly (clang, -O0):
<BASM_PP_PrintToken>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %edx,-0x1c(%rbp)
cmpl   $0x1,-0x1c(%rbp)
jne    11ab <BASM_PP_PrintToken+0x3b>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1060 <BASM_PP_PrintName@plt>
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x8(%rbp)
jmp    12e8 <BASM_PP_PrintToken+0x178>
cmpl   $0x2,-0x1c(%rbp)
jne    11d3 <BASM_PP_PrintToken+0x63>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1060 <BASM_PP_PrintName@plt>
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x8(%rbp)
jmp    12e8 <BASM_PP_PrintToken+0x178>
cmpl   $0x3,-0x1c(%rbp)
jne    11fb <BASM_PP_PrintToken+0x8b>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1030 <BASM_PP_EmitString@plt>
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x8(%rbp)
jmp    12e8 <BASM_PP_PrintToken+0x178>
cmpl   $0x4,-0x1c(%rbp)
jne    1223 <BASM_PP_PrintToken+0xb3>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1070 <BASM_PP_EmitCharString@plt>
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x8(%rbp)
jmp    12e8 <BASM_PP_PrintToken+0x178>
mov    -0x18(%rbp),%rdi
lea    0xdd2(%rip),%rsi
call   1050 <strcmp@plt>
cmp    $0x0,%eax
jne    1274 <BASM_PP_PrintToken+0x104>
mov    -0x10(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x10(%rbp)
movb   $0x3b,(%rax)
mov    -0x10(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x10(%rbp)
movb   $0x20,(%rax)
mov    -0x10(%rbp),%rax
movb   $0x0,(%rax)
mov    -0x10(%rbp),%rax
mov    %rax,-0x8(%rbp)
jmp    12e8 <BASM_PP_PrintToken+0x178>
mov    -0x18(%rbp),%rax
movsbl (%rax),%edi
call   1080 <BASM_Parse_OpChar@plt>
cmp    $0x0,%rax
je     12b3 <BASM_PP_PrintToken+0x143>
mov    -0x10(%rbp),%rax
movsbl -0x1(%rax),%edi
call   1080 <BASM_Parse_OpChar@plt>
cmp    $0x0,%rax
je     12b3 <BASM_PP_PrintToken+0x143>
mov    -0x10(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x10(%rbp)
movb   $0x20,(%rax)
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rdx
lea    0xd40(%rip),%rsi
call   1090 <sprintf@plt>
mov    -0x10(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,%ecx
mov    -0x10(%rbp),%rax
movslq %ecx,%rcx
add    %rcx,%rax
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<BASM_PP_PrintToken>:
push   %r14
push   %rbx
push   %rax
mov    %rsi,%r14
mov    %rdi,%rbx
add    $0xffffffff,%edx
cmp    $0x3,%edx
ja     11a4 <BASM_PP_PrintToken+0x34>
lea    0xe77(%rip),%rax
movslq (%rax,%rdx,4),%rcx
add    %rax,%rcx
jmp    *%rcx
mov    %rbx,%rdi
mov    %r14,%rsi
add    $0x8,%rsp
pop    %rbx
pop    %r14
jmp    1070 <BASM_PP_PrintName@plt>
lea    0xe65(%rip),%rsi
mov    %r14,%rdi
call   1060 <strcmp@plt>
test   %eax,%eax
je     1218 <BASM_PP_PrintToken+0xa8>
movsbl (%r14),%edi
call   1090 <BASM_Parse_OpChar@plt>
test   %rax,%rax
je     11da <BASM_PP_PrintToken+0x6a>
movsbl -0x1(%rbx),%edi
call   1090 <BASM_Parse_OpChar@plt>
test   %rax,%rax
je     11da <BASM_PP_PrintToken+0x6a>
movb   $0x20,(%rbx)
add    $0x1,%rbx
mov    %rbx,%rdi
mov    %r14,%rsi
call   1040 <strcpy@plt>
mov    %rbx,%rdi
call   1050 <strlen@plt>
cltq
add    %rbx,%rax
jmp    1228 <BASM_PP_PrintToken+0xb8>
mov    %rbx,%rdi
mov    %r14,%rsi
add    $0x8,%rsp
pop    %rbx
pop    %r14
jmp    1030 <BASM_PP_EmitString@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
add    $0x8,%rsp
pop    %rbx
pop    %r14
jmp    1080 <BASM_PP_EmitCharString@plt>
movw   $0x203b,(%rbx)
movb   $0x0,0x2(%rbx)
add    $0x2,%rbx
mov    %rbx,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [2 x i8] c";\00"
@.str.1 = [3 x i8] c"%s\00"
define i8* @BASM_PP_PrintToken(i8* %0, i8* %1, i32 %2) {
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca i32
store i8* %0, i8** %5
store i8* %1, i8** %6
store i32 %2, i32* %7
%8 = load i32, i32* %7
%9 = icmp eq i32 %8, 1
br i1 %9, label %10, label %15
10: ; preds = %3
%11 = load i8*, i8** %5
%12 = load i8*, i8** %6
%13 = call i8* @BASM_PP_PrintName(i8* %11, i8* %12)
store i8* %13, i8** %5
%14 = load i8*, i8** %5
store i8* %14, i8** %4
br label %74
15: ; preds = %3
%16 = load i32, i32* %7
%17 = icmp eq i32 %16, 2
br i1 %17, label %18, label %23
18: ; preds = %15
%19 = load i8*, i8** %5
%20 = load i8*, i8** %6
%21 = call i8* @BASM_PP_PrintName(i8* %19, i8* %20)
store i8* %21, i8** %5
%22 = load i8*, i8** %5
store i8* %22, i8** %4
br label %74
23: ; preds = %15
%24 = load i32, i32* %7
%25 = icmp eq i32 %24, 3
br i1 %25, label %26, label %31
26: ; preds = %23
%27 = load i8*, i8** %5
%28 = load i8*, i8** %6
%29 = call i8* @BASM_PP_EmitString(i8* %27, i8* %28)
store i8* %29, i8** %5
%30 = load i8*, i8** %5
store i8* %30, i8** %4
br label %74
31: ; preds = %23
%32 = load i32, i32* %7
%33 = icmp eq i32 %32, 4
br i1 %33, label %34, label %39
34: ; preds = %31
%35 = load i8*, i8** %5
%36 = load i8*, i8** %6
%37 = call i8* @BASM_PP_EmitCharString(i8* %35, i8* %36)
store i8* %37, i8** %5
%38 = load i8*, i8** %5
store i8* %38, i8** %4
br label %74
39: ; preds = %31
%40 = load i8*, i8** %6
%41 = call i32 @strcmp(i8* %40, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%42 = icmp ne i32 %41, 0
br i1 %42, label %50, label %43
43: ; preds = %39
%44 = load i8*, i8** %5
%45 = getelementptr inbounds i8, i8* %44, i32 1
store i8* %45, i8** %5
store i8 59, i8* %44
%46 = load i8*, i8** %5
%47 = getelementptr inbounds i8, i8* %46, i32 1
store i8* %47, i8** %5
store i8 32, i8* %46
%48 = load i8*, i8** %5
store i8 0, i8* %48
%49 = load i8*, i8** %5
store i8* %49, i8** %4
br label %74
50: ; preds = %39
%51 = load i8*, i8** %6
%52 = load i8, i8* %51
%53 = call i64 @BASM_Parse_OpChar(i8 signext %52)
%54 = icmp ne i64 %53, 0
br i1 %54, label %55, label %64
55: ; preds = %50
%56 = load i8*, i8** %5
%57 = getelementptr inbounds i8, i8* %56, i64 -1
%58 = load i8, i8* %57
%59 = call i64 @BASM_Parse_OpChar(i8 signext %58)
%60 = icmp ne i64 %59, 0
br i1 %60, label %61, label %64
61: ; preds = %55
%62 = load i8*, i8** %5
%63 = getelementptr inbounds i8, i8* %62, i32 1
store i8* %63, i8** %5
store i8 32, i8* %62
br label %64
64: ; preds = %61, %55, %50
%65 = load i8*, i8** %5
%66 = load i8*, i8** %6
%67 = call i32 @sprintf(i8* %65, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %66)
%68 = load i8*, i8** %5
%69 = call i32 @strlen(i8* %68)
%70 = load i8*, i8** %5
%71 = sext i32 %69 to i64
%72 = getelementptr inbounds i8, i8* %70, i64 %71
store i8* %72, i8** %5
%73 = load i8*, i8** %5
store i8* %73, i8** %4
br label %74
74: ; preds = %64, %43, %34, %26, %18, %10
%75 = load i8*, i8** %4
ret i8* %75
}

LLVM IR (-O2):
@.str = [2 x i8] c";\00"
define i8* @BASM_PP_PrintToken(i8* %0, i8* %1, i32 %2) {
switch i32 %2, label %12 [
i32 1, label %4
i32 2, label %6
i32 3, label %8
i32 4, label %10
]
4: ; preds = %3
%5 = tail call i8* @BASM_PP_PrintName(i8* %0, i8* %1)
br label %35
6: ; preds = %3
%7 = tail call i8* @BASM_PP_PrintName(i8* %0, i8* %1)
br label %35
8: ; preds = %3
%9 = tail call i8* @BASM_PP_EmitString(i8* %0, i8* %1)
br label %35
10: ; preds = %3
%11 = tail call i8* @BASM_PP_EmitCharString(i8* %0, i8* %1)
br label %35
12: ; preds = %3
%13 = tail call i32 @strcmp(i8* dereferenceable(1) %1, i8* dereferenceable(2) getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%14 = icmp eq i32 %13, 0
br i1 %14, label %15, label %18
15: ; preds = %12
%16 = getelementptr inbounds i8, i8* %0, i64 1
store i8 59, i8* %0
%17 = getelementptr inbounds i8, i8* %0, i64 2
store i8 32, i8* %16
store i8 0, i8* %17
br label %35
18: ; preds = %12
%19 = load i8, i8* %1
%20 = tail call i64 @BASM_Parse_OpChar(i8 signext %19)
%21 = icmp eq i64 %20, 0
br i1 %21, label %29, label %22
22: ; preds = %18
%23 = getelementptr inbounds i8, i8* %0, i64 -1
%24 = load i8, i8* %23
%25 = tail call i64 @BASM_Parse_OpChar(i8 signext %24)
%26 = icmp eq i64 %25, 0
br i1 %26, label %29, label %27
27: ; preds = %22
%28 = getelementptr inbounds i8, i8* %0, i64 1
store i8 32, i8* %0
br label %29
29: ; preds = %27, %22, %18
%30 = phi i8* [ %28, %27 ], [ %0, %22 ], [ %0, %18 ]
%31 = tail call i8* @strcpy(i8* dereferenceable(1) %30, i8* %1)
%32 = tail call i32 @strlen(i8* %30)
%33 = sext i32 %32 to i64
%34 = getelementptr inbounds i8, i8* %30, i64 %33
br label %35
35: ; preds = %29, %15, %10, %8, %6, %4
%36 = phi i8* [ %5, %4 ], [ %7, %6 ], [ %9, %8 ], [ %11, %10 ], [ %34, %29 ], [ %17, %15 ]
ret i8* %36
}