#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*/ printf(char *, char *);
void test2(char *data) {
  char tok2[20];
  int i = 0;
  while (*data != '\0') {
    data++;
    if (*data == '\'') {
      data++;
      while (*data != '\'') {
        tok2[i] = *data;
        data++;
        i++;
      }
      break;
    }
  }
  tok2[i] = '\0';
  printf("Token: %s \n", tok2);
}


x86 assembly (clang, -O0):
<test2>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
movl   $0x0,-0x24(%rbp)
mov    -0x8(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
je     119d <test2+0x8d>
mov    -0x8(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x27,%eax
jne    1198 <test2+0x88>
mov    -0x8(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x27,%eax
je     1193 <test2+0x83>
mov    -0x8(%rbp),%rax
mov    (%rax),%cl
movslq -0x24(%rbp),%rax
mov    %cl,-0x20(%rbp,%rax,1)
mov    -0x8(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x8(%rbp)
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    115b <test2+0x4b>
jmp    119d <test2+0x8d>
jmp    1123 <test2+0x13>
movslq -0x24(%rbp),%rax
movb   $0x0,-0x20(%rbp,%rax,1)
lea    -0x20(%rbp),%rsi
lea    0xe4f(%rip),%rdi
call   1030 <printf@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<test2>:
sub    $0x18,%rsp
mov    (%rdi),%cl
add    $0x1,%rdi
xor    %eax,%eax
nopl   0x0(%rax)
test   %cl,%cl
je     1152 <test2+0x42>
movzbl (%rdi),%ecx
add    $0x1,%rdi
cmp    $0x27,%cl
jne    1120 <test2+0x10>
mov    (%rdi),%al
cmp    $0x27,%al
jne    113a <test2+0x2a>
xor    %eax,%eax
jmp    1152 <test2+0x42>
xor    %ecx,%ecx
nopl   0x0(%rax)
mov    %al,(%rsp,%rcx,1)
movzbl 0x1(%rdi,%rcx,1),%eax
add    $0x1,%rcx
cmp    $0x27,%al
jne    1140 <test2+0x30>
mov    %ecx,%eax
movb   $0x0,(%rsp,%rax,1)
lea    0xea3(%rip),%rdi
mov    %rsp,%rsi
call   1030 <printf@plt>
add    $0x18,%rsp
ret

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

LLVM IR (-O2):
@.str = [12 x i8] c"Token: %s \0A\00"
define void @test2(i8* nocapture %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
br label %5
5: ; preds = %9, %1
%6 = phi i8 [ %11, %9 ], [ %4, %1 ]
%7 = phi i8* [ %10, %9 ], [ %0, %1 ]
%8 = icmp eq i8 %6, 0
br i1 %8, label %28, label %9
9: ; preds = %5
%10 = getelementptr inbounds i8, i8* %7, i64 1
%11 = load i8, i8* %10
%12 = icmp eq i8 %11, 39
br i1 %12, label %13, label %5
13: ; preds = %9
%14 = getelementptr inbounds i8, i8* %7, i64 2
%15 = load i8, i8* %14
%16 = icmp eq i8 %15, 39
br i1 %16, label %28, label %17
17: ; preds = %13, %17
%18 = phi i64 [ %23, %17 ], [ 0, %13 ]
%19 = phi i8 [ %24, %17 ], [ %15, %13 ]
%20 = phi i8* [ %22, %17 ], [ %14, %13 ]
%21 = getelementptr inbounds [20 x i8], [20 x i8]* %2, i64 0, i64 %18
store i8 %19, i8* %21
%22 = getelementptr inbounds i8, i8* %20, i64 1
%23 = add nuw i64 %18, 1
%24 = load i8, i8* %22
%25 = icmp eq i8 %24, 39
br i1 %25, label %26, label %17
26: ; preds = %17
%27 = and i64 %23, 4294967295
br label %28
28: ; preds = %5, %26, %13
%29 = phi i64 [ 0, %13 ], [ %27, %26 ], [ 0, %5 ]
%30 = getelementptr inbounds [20 x i8], [20 x i8]* %2, i64 0, i64 %29
store i8 0, i8* %30
%31 = call i32 @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i8* %3)
ret void
}