#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__ my_isblank(char);
int /*<<< orphan*/ printf(char *, char *);
char *sskip(char *);
char *next_word(char *w, size_t wsize, char *s) {
  size_t i;
  s = sskip(s);
  for (i = 0; i < wsize - 1; i++) {
    if (s[i] == 0 || my_isblank(s[i]))
      break;
    w[i] = s[i];
  }
  w[i] = 0;
  if (s[i] != 0 && !my_isblank(s[i]))
    printf("warning: '%s' truncated\n", w);
  return s + i;
}


x86 assembly (clang, -O0):
<next_word>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
call   1050 <sskip@plt>
mov    %rax,-0x18(%rbp)
movq   $0x0,-0x20(%rbp)
mov    -0x20(%rbp),%rax
mov    -0x10(%rbp),%rcx
sub    $0x1,%rcx
cmp    %rcx,%rax
jae    11ca <next_word+0x9a>
mov    -0x18(%rbp),%rax
mov    -0x20(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x0,%eax
je     119e <next_word+0x6e>
mov    -0x18(%rbp),%rax
mov    -0x20(%rbp),%rcx
movsbl (%rax,%rcx,1),%edi
call   1040 <my_isblank@plt>
cmp    $0x0,%rax
je     11a3 <next_word+0x73>
jmp    11ca <next_word+0x9a>
mov    -0x18(%rbp),%rax
mov    -0x20(%rbp),%rcx
mov    (%rax,%rcx,1),%dl
mov    -0x8(%rbp),%rax
mov    -0x20(%rbp),%rcx
mov    %dl,(%rax,%rcx,1)
mov    -0x20(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x20(%rbp)
jmp    1159 <next_word+0x29>
mov    -0x8(%rbp),%rax
mov    -0x20(%rbp),%rcx
movb   $0x0,(%rax,%rcx,1)
mov    -0x18(%rbp),%rax
mov    -0x20(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x0,%eax
je     1216 <next_word+0xe6>
mov    -0x18(%rbp),%rax
mov    -0x20(%rbp),%rcx
movsbl (%rax,%rcx,1),%edi
call   1040 <my_isblank@plt>
cmp    $0x0,%rax
jne    1216 <next_word+0xe6>
mov    -0x8(%rbp),%rsi
lea    0xdef(%rip),%rdi
call   1030 <printf@plt>
mov    -0x18(%rbp),%rax
add    -0x20(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<next_word>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
mov    %rsi,%r12
mov    %rdi,%r15
mov    %rdx,%rdi
call   1050 <sskip@plt>
mov    %rax,%r14
mov    %rax,%r13
xor    %ebx,%ebx
add    $0xffffffffffffffff,%r12
je     118d <next_word+0x5d>
cs nopw 0x0(%rax,%rax,1)
nop
movzbl 0x0(%r13,%rbx,1),%eax
test   %al,%al
je     118d <next_word+0x5d>
movsbl %al,%edi
call   1040 <my_isblank@plt>
test   %rax,%rax
jne    118d <next_word+0x5d>
movzbl 0x0(%r13,%rbx,1),%eax
mov    %al,(%r15,%rbx,1)
add    $0x1,%rbx
cmp    %rbx,%r12
jne    1160 <next_word+0x30>
mov    %r12,%rbx
movb   $0x0,(%r15,%rbx,1)
add    %rbx,%r14
mov    0x0(%r13,%rbx,1),%al
test   %al,%al
je     11ba <next_word+0x8a>
movsbl %al,%edi
call   1040 <my_isblank@plt>
test   %rax,%rax
jne    11ba <next_word+0x8a>
lea    0xe4e(%rip),%rdi
mov    %r15,%rsi
call   1030 <printf@plt>
mov    %r14,%rax
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [25 x i8] c"warning: '%s' truncated\0A\00"
define i8* @next_word(i8* %0, i64 %1, i8* %2) {
%4 = alloca i8*
%5 = alloca i64
%6 = alloca i8*
%7 = alloca i64
store i8* %0, i8** %4
store i64 %1, i64* %5
store i8* %2, i8** %6
%8 = load i8*, i8** %6
%9 = call i8* @sskip(i8* %8)
store i8* %9, i8** %6
store i64 0, i64* %7
br label %10
10: ; preds = %38, %3
%11 = load i64, i64* %7
%12 = load i64, i64* %5
%13 = sub i64 %12, 1
%14 = icmp ult i64 %11, %13
br i1 %14, label %15, label %41
15: ; preds = %10
%16 = load i8*, i8** %6
%17 = load i64, i64* %7
%18 = getelementptr inbounds i8, i8* %16, i64 %17
%19 = load i8, i8* %18
%20 = sext i8 %19 to i32
%21 = icmp eq i32 %20, 0
br i1 %21, label %29, label %22
22: ; preds = %15
%23 = load i8*, i8** %6
%24 = load i64, i64* %7
%25 = getelementptr inbounds i8, i8* %23, i64 %24
%26 = load i8, i8* %25
%27 = call i64 @my_isblank(i8 signext %26)
%28 = icmp ne i64 %27, 0
br i1 %28, label %29, label %30
29: ; preds = %22, %15
br label %41
30: ; preds = %22
%31 = load i8*, i8** %6
%32 = load i64, i64* %7
%33 = getelementptr inbounds i8, i8* %31, i64 %32
%34 = load i8, i8* %33
%35 = load i8*, i8** %4
%36 = load i64, i64* %7
%37 = getelementptr inbounds i8, i8* %35, i64 %36
store i8 %34, i8* %37
br label %38
38: ; preds = %30
%39 = load i64, i64* %7
%40 = add i64 %39, 1
store i64 %40, i64* %7
br label %10
41: ; preds = %29, %10
%42 = load i8*, i8** %4
%43 = load i64, i64* %7
%44 = getelementptr inbounds i8, i8* %42, i64 %43
store i8 0, i8* %44
%45 = load i8*, i8** %6
%46 = load i64, i64* %7
%47 = getelementptr inbounds i8, i8* %45, i64 %46
%48 = load i8, i8* %47
%49 = sext i8 %48 to i32
%50 = icmp ne i32 %49, 0
br i1 %50, label %51, label %61
51: ; preds = %41
%52 = load i8*, i8** %6
%53 = load i64, i64* %7
%54 = getelementptr inbounds i8, i8* %52, i64 %53
%55 = load i8, i8* %54
%56 = call i64 @my_isblank(i8 signext %55)
%57 = icmp ne i64 %56, 0
br i1 %57, label %61, label %58
58: ; preds = %51
%59 = load i8*, i8** %4
%60 = call i32 @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0), i8* %59)
br label %61
61: ; preds = %58, %51, %41
%62 = load i8*, i8** %6
%63 = load i64, i64* %7
%64 = getelementptr inbounds i8, i8* %62, i64 %63
ret i8* %64
}

LLVM IR (-O2):
@.str = [25 x i8] c"warning: '%s' truncated\0A\00"
define i8* @next_word(i8* %0, i64 %1, i8* %2) {
%4 = tail call i8* @sskip(i8* %2)
%5 = add i64 %1, -1
%6 = icmp eq i64 %5, 0
br i1 %6, label %20, label %7
7: ; preds = %3, %15
%8 = phi i64 [ %18, %15 ], [ 0, %3 ]
%9 = getelementptr inbounds i8, i8* %4, i64 %8
%10 = load i8, i8* %9
%11 = icmp eq i8 %10, 0
br i1 %11, label %20, label %12
12: ; preds = %7
%13 = tail call i64 @my_isblank(i8 signext %10)
%14 = icmp eq i64 %13, 0
br i1 %14, label %15, label %20
15: ; preds = %12
%16 = load i8, i8* %9
%17 = getelementptr inbounds i8, i8* %0, i64 %8
store i8 %16, i8* %17
%18 = add nuw i64 %8, 1
%19 = icmp eq i64 %18, %5
br i1 %19, label %20, label %7
20: ; preds = %15, %12, %7, %3
%21 = phi i64 [ 0, %3 ], [ %8, %7 ], [ %8, %12 ], [ %5, %15 ]
%22 = getelementptr inbounds i8, i8* %0, i64 %21
store i8 0, i8* %22
%23 = getelementptr inbounds i8, i8* %4, i64 %21
%24 = load i8, i8* %23
%25 = icmp eq i8 %24, 0
br i1 %25, label %31, label %26
26: ; preds = %20
%27 = tail call i64 @my_isblank(i8 signext %24)
%28 = icmp eq i64 %27, 0
br i1 %28, label %29, label %31
29: ; preds = %26
%30 = tail call i32 @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0), i8* %0)
br label %31
31: ; preds = %29, %26, %20
ret i8* %23
}