#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 */
scalar_t__ isspace(char);
int /*<<< orphan*/ printf(char *, char);
void first(char *str) {
  char ret;
  int toknum = 0;
  char *next = str + 1;
  char *prev = str - 1;
  while (*str != '\0') {
    if (!isspace(*str) && (isspace(*prev) || toknum == 0)) {
      toknum++;
      ret = *str;
      printf("%c \n", ret);
    }
    str++;
    next++;
    prev++;
  }
}


x86 assembly (clang, -O0):
<first>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
movl   $0x0,-0x10(%rbp)
mov    -0x8(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x18(%rbp)
mov    -0x8(%rbp),%rax
add    $0xffffffffffffffff,%rax
mov    %rax,-0x20(%rbp)
mov    -0x8(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
je     11dc <first+0xbc>
mov    -0x8(%rbp),%rax
movsbl (%rax),%edi
call   1040 <isspace@plt>
cmp    $0x0,%rax
jne    11b3 <first+0x93>
mov    -0x20(%rbp),%rax
movsbl (%rax),%edi
call   1040 <isspace@plt>
cmp    $0x0,%rax
jne    1191 <first+0x71>
cmpl   $0x0,-0x10(%rbp)
jne    11b3 <first+0x93>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
mov    -0x8(%rbp),%rax
mov    (%rax),%al
mov    %al,-0x9(%rbp)
lea    0xe56(%rip),%rdi
movsbl -0x9(%rbp),%esi
call   1030 <printf@plt>
mov    -0x8(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x8(%rbp)
mov    -0x18(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x18(%rbp)
mov    -0x20(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x20(%rbp)
jmp    114b <first+0x2b>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<first>:
push   %rbp
push   %r14
push   %rbx
mov    (%rdi),%al
test   %al,%al
je     117d <first+0x5d>
mov    %rdi,%rbx
xor    %ebp,%ebp
lea    0xeca(%rip),%r14
jmp    115c <first+0x3c>
add    $0x1,%ebp
movsbl (%rbx),%esi
mov    %r14,%rdi
call   1030 <printf@plt>
cs nopw 0x0(%rax,%rax,1)
movzbl 0x1(%rbx),%eax
add    $0x1,%rbx
test   %al,%al
je     117d <first+0x5d>
movsbl %al,%edi
call   1040 <isspace@plt>
test   %rax,%rax
jne    1150 <first+0x30>
movsbl -0x1(%rbx),%edi
call   1040 <isspace@plt>
test   %rax,%rax
jne    1138 <first+0x18>
test   %ebp,%ebp
jne    1150 <first+0x30>
jmp    1138 <first+0x18>
pop    %rbx
pop    %r14
pop    %rbp
ret

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

LLVM IR (-O2):
@.str = [5 x i8] c"%c \0A\00"
define void @first(i8* nocapture %0) {
%2 = load i8, i8* %0
%3 = icmp eq i8 %2, 0
br i1 %3, label %29, label %4
4: ; preds = %1
%5 = getelementptr inbounds i8, i8* %0, i64 -1
br label %6
6: ; preds = %4, %23
%7 = phi i8 [ %27, %23 ], [ %2, %4 ]
%8 = phi i8* [ %26, %23 ], [ %5, %4 ]
%9 = phi i32 [ %24, %23 ], [ 0, %4 ]
%10 = phi i8* [ %25, %23 ], [ %0, %4 ]
%11 = tail call i64 @isspace(i8 signext %7)
%12 = icmp eq i64 %11, 0
br i1 %12, label %13, label %23
13: ; preds = %6
%14 = load i8, i8* %8
%15 = tail call i64 @isspace(i8 signext %14)
%16 = icmp ne i64 %15, 0
%17 = icmp eq i32 %9, 0
%18 = select i1 %16, i1 true, i1 %17
br i1 %18, label %19, label %23
19: ; preds = %13
%20 = add nsw i32 %9, 1
%21 = load i8, i8* %10
%22 = tail call i32 @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i8 signext %21)
br label %23
23: ; preds = %13, %19, %6
%24 = phi i32 [ %9, %6 ], [ %20, %19 ], [ %9, %13 ]
%25 = getelementptr inbounds i8, i8* %10, i64 1
%26 = getelementptr inbounds i8, i8* %8, i64 1
%27 = load i8, i8* %25
%28 = icmp eq i8 %27, 0
br i1 %28, label %29, label %6
29: ; preds = %23, %1
ret void
}