#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*/ i3_strlcpy(char *, char *, int);
int strlen(char *);
int I3_token(char type, char *string, char *oname, char *tname) {
  char code[50];
  char *p = '\0';
  switch (type) {
  default:
    code[0] = type;
    code[1] = '\0';
    return 1;
  case '$':
    i3_strlcpy(code, "$", 50);
    break;
  case ' ':
    i3_strlcpy(code, " ", 50);
    break;
  case 'N':
    i3_strlcpy(code, oname, 50);
    break;
  case 'O':
    i3_strlcpy(code, tname, 50);
    break;
  }
  p = code;
  while (*p != '\0') {
    *string = *p++;
    *++string = '\0';
  }
  return (strlen(code));
}


x86 assembly (clang, -O0):
<I3_token>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
mov    %dil,%al
mov    %al,-0x5(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
movq   $0x0,-0x68(%rbp)
movsbl -0x5(%rbp),%eax
mov    %eax,-0x6c(%rbp)
sub    $0x20,%eax
je     11ba <I3_token+0x9a>
jmp    1157 <I3_token+0x37>
mov    -0x6c(%rbp),%eax
sub    $0x24,%eax
je     11a0 <I3_token+0x80>
jmp    1168 <I3_token+0x48>
mov    -0x6c(%rbp),%eax
sub    $0x4e,%eax
je     11d4 <I3_token+0xb4>
jmp    1179 <I3_token+0x59>
mov    -0x6c(%rbp),%eax
sub    $0x4f,%eax
je     11eb <I3_token+0xcb>
jmp    118a <I3_token+0x6a>
mov    -0x5(%rbp),%al
mov    %al,-0x60(%rbp)
movb   $0x0,-0x5f(%rbp)
movl   $0x1,-0x4(%rbp)
jmp    1250 <I3_token+0x130>
lea    -0x60(%rbp),%rdi
lea    0xe55(%rip),%rsi
mov    $0x32,%edx
call   1040 <i3_strlcpy@plt>
jmp    11fd <I3_token+0xdd>
lea    -0x60(%rbp),%rdi
lea    0xe3d(%rip),%rsi
mov    $0x32,%edx
call   1040 <i3_strlcpy@plt>
jmp    11fd <I3_token+0xdd>
lea    -0x60(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    $0x32,%edx
call   1040 <i3_strlcpy@plt>
jmp    11fd <I3_token+0xdd>
lea    -0x60(%rbp),%rdi
mov    -0x20(%rbp),%rsi
mov    $0x32,%edx
call   1040 <i3_strlcpy@plt>
lea    -0x60(%rbp),%rax
mov    %rax,-0x68(%rbp)
mov    -0x68(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
je     1244 <I3_token+0x124>
mov    -0x68(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x68(%rbp)
mov    (%rax),%cl
mov    -0x10(%rbp),%rax
mov    %cl,(%rax)
mov    -0x10(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x10(%rbp)
movb   $0x0,0x1(%rax)
jmp    1205 <I3_token+0xe5>
lea    -0x60(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x70,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<I3_token>:
push   %rbx
sub    $0x40,%rsp
mov    %rsi,%rbx
mov    $0x1,%eax
cmp    $0x4d,%edi
jg     1145 <I3_token+0x25>
cmp    $0x20,%edi
je     1154 <I3_token+0x34>
cmp    $0x24,%edi
jne    119c <I3_token+0x7c>
lea    0xebd(%rip),%rdx
jmp    115b <I3_token+0x3b>
cmp    $0x4e,%edi
je     115b <I3_token+0x3b>
cmp    $0x4f,%edi
jne    119c <I3_token+0x7c>
mov    %rcx,%rdx
jmp    115b <I3_token+0x3b>
lea    0xea7(%rip),%rdx
mov    %rsp,%rdi
mov    %rdx,%rsi
mov    $0x32,%edx
call   1040 <i3_strlcpy@plt>
mov    (%rsp),%al
test   %al,%al
je     1194 <I3_token+0x74>
mov    $0x1,%ecx
nopw   0x0(%rax,%rax,1)
mov    %al,-0x1(%rbx,%rcx,1)
movb   $0x0,(%rbx,%rcx,1)
movzbl (%rsp,%rcx,1),%eax
add    $0x1,%rcx
test   %al,%al
jne    1180 <I3_token+0x60>
mov    %rsp,%rdi
call   1030 <strlen@plt>
add    $0x40,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [2 x i8] c"$\00"
@.str.1 = [2 x i8] c" \00"
define i32 @I3_token(i8 signext %0, i8* %1, i8* %2, i8* %3) {
%5 = alloca i32
%6 = alloca i8
%7 = alloca i8*
%8 = alloca i8*
%9 = alloca i8*
%10 = alloca [50 x i8]
%11 = alloca i8*
store i8 %0, i8* %6
store i8* %1, i8** %7
store i8* %2, i8** %8
store i8* %3, i8** %9
store i8* null, i8** %11
%12 = load i8, i8* %6
%13 = sext i8 %12 to i32
switch i32 %13, label %14 [
i32 36, label %18
i32 32, label %21
i32 78, label %24
i32 79, label %28
]
14: ; preds = %4
%15 = load i8, i8* %6
%16 = getelementptr inbounds [50 x i8], [50 x i8]* %10, i64 0, i64 0
store i8 %15, i8* %16
%17 = getelementptr inbounds [50 x i8], [50 x i8]* %10, i64 0, i64 1
store i8 0, i8* %17
store i32 1, i32* %5
br label %49
18: ; preds = %4
%19 = getelementptr inbounds [50 x i8], [50 x i8]* %10, i64 0, i64 0
%20 = call i32 @i3_strlcpy(i8* %19, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0), i32 50)
br label %32
21: ; preds = %4
%22 = getelementptr inbounds [50 x i8], [50 x i8]* %10, i64 0, i64 0
%23 = call i32 @i3_strlcpy(i8* %22, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0), i32 50)
br label %32
24: ; preds = %4
%25 = getelementptr inbounds [50 x i8], [50 x i8]* %10, i64 0, i64 0
%26 = load i8*, i8** %8
%27 = call i32 @i3_strlcpy(i8* %25, i8* %26, i32 50)
br label %32
28: ; preds = %4
%29 = getelementptr inbounds [50 x i8], [50 x i8]* %10, i64 0, i64 0
%30 = load i8*, i8** %9
%31 = call i32 @i3_strlcpy(i8* %29, i8* %30, i32 50)
br label %32
32: ; preds = %28, %24, %21, %18
%33 = getelementptr inbounds [50 x i8], [50 x i8]* %10, i64 0, i64 0
store i8* %33, i8** %11
br label %34
34: ; preds = %39, %32
%35 = load i8*, i8** %11
%36 = load i8, i8* %35
%37 = sext i8 %36 to i32
%38 = icmp ne i32 %37, 0
br i1 %38, label %39, label %46
39: ; preds = %34
%40 = load i8*, i8** %11
%41 = getelementptr inbounds i8, i8* %40, i32 1
store i8* %41, i8** %11
%42 = load i8, i8* %40
%43 = load i8*, i8** %7
store i8 %42, i8* %43
%44 = load i8*, i8** %7
%45 = getelementptr inbounds i8, i8* %44, i32 1
store i8* %45, i8** %7
store i8 0, i8* %45
br label %34
46: ; preds = %34
%47 = getelementptr inbounds [50 x i8], [50 x i8]* %10, i64 0, i64 0
%48 = call i32 @strlen(i8* %47)
store i32 %48, i32* %5
br label %49
49: ; preds = %46, %14
%50 = load i32, i32* %5
ret i32 %50
}

LLVM IR (-O2):
@.str = [2 x i8] c"$\00"
@.str.1 = [2 x i8] c" \00"
define i32 @I3_token(i8 signext %0, i8* nocapture writeonly %1, i8* %2, i8* %3) {
%5 = alloca [50 x i8]
%6 = getelementptr inbounds [50 x i8], [50 x i8]* %5, i64 0, i64 0
%7 = sext i8 %0 to i32
switch i32 %7, label %26 [
i32 36, label %11
i32 32, label %8
i32 78, label %9
i32 79, label %10
]
8: ; preds = %4
br label %11
9: ; preds = %4
br label %11
10: ; preds = %4
br label %11
11: ; preds = %4, %10, %9, %8
%12 = phi i8* [ %3, %10 ], [ %2, %9 ], [ getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0), %8 ], [ getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0), %4 ]
%13 = call i32 @i3_strlcpy(i8* %6, i8* %12, i32 50)
%14 = load i8, i8* %6
%15 = icmp eq i8 %14, 0
br i1 %15, label %24, label %16
16: ; preds = %11, %16
%17 = phi i8 [ %22, %16 ], [ %14, %11 ]
%18 = phi i8* [ %20, %16 ], [ %6, %11 ]
%19 = phi i8* [ %21, %16 ], [ %1, %11 ]
%20 = getelementptr inbounds i8, i8* %18, i64 1
store i8 %17, i8* %19
%21 = getelementptr inbounds i8, i8* %19, i64 1
store i8 0, i8* %21
%22 = load i8, i8* %20
%23 = icmp eq i8 %22, 0
br i1 %23, label %24, label %16
24: ; preds = %16, %11
%25 = call i32 @strlen(i8* %6)
br label %26
26: ; preds = %4, %24
%27 = phi i32 [ %25, %24 ], [ 1, %4 ]
ret i32 %27
}