#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 *, ...);
void toNextChar(char *c, int *index) {
  printf("toNextChar\n");
  int i;
  i = *index;
  do {
    *index = ++i;
  } while (c[i] == ' ');
  printf("next index: %d\n", *index);
  *index = i - 1;
}


x86 assembly (clang, -O0):
<toNextChar>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    0xed9(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x10(%rbp),%rax
mov    (%rax),%eax
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%ecx
add    $0x1,%ecx
mov    %ecx,-0x14(%rbp)
mov    -0x10(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x8(%rbp),%rax
movslq -0x14(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x20,%eax
je     1137 <toNextChar+0x27>
mov    -0x10(%rbp),%rax
mov    (%rax),%esi
lea    0xea4(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x14(%rbp),%ecx
sub    $0x1,%ecx
mov    -0x10(%rbp),%rax
mov    %ecx,(%rax)
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<toNextChar>:
push   %rbp
push   %r14
push   %rbx
mov    %rsi,%rbx
mov    %rdi,%r14
lea    0xedf(%rip),%rdi
call   1030 <puts@plt>
movslq (%rbx),%rsi
lea    (%rsi,%r14,1),%rax
add    $0x1,%rax
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
add    $0x1,%esi
mov    %esi,(%rbx)
cmpb   $0x20,(%rax)
lea    0x1(%rax),%rax
je     1150 <toNextChar+0x30>
lea    -0x1(%rsi),%ebp
lea    0xe98(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %ebp,(%rbx)
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@.str = [12 x i8] c"toNextChar\0A\00"
@.str.1 = [16 x i8] c"next index: %d\0A\00"
define void @toNextChar(i8* %0, i32* %1) {
%3 = alloca i8*
%4 = alloca i32*
%5 = alloca i32
store i8* %0, i8** %3
store i32* %1, i32** %4
%6 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0))
%7 = load i32*, i32** %4
%8 = load i32, i32* %7
store i32 %8, i32* %5
br label %9
9: ; preds = %13, %2
%10 = load i32, i32* %5
%11 = add nsw i32 %10, 1
store i32 %11, i32* %5
%12 = load i32*, i32** %4
store i32 %11, i32* %12
br label %13
13: ; preds = %9
%14 = load i8*, i8** %3
%15 = load i32, i32* %5
%16 = sext i32 %15 to i64
%17 = getelementptr inbounds i8, i8* %14, i64 %16
%18 = load i8, i8* %17
%19 = sext i8 %18 to i32
%20 = icmp eq i32 %19, 32
br i1 %20, label %9, label %21
21: ; preds = %13
%22 = load i32*, i32** %4
%23 = load i32, i32* %22
%24 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.1, i64 0, i64 0), i32 %23)
%25 = load i32, i32* %5
%26 = sub nsw i32 %25, 1
%27 = load i32*, i32** %4
store i32 %26, i32* %27
ret void
}

LLVM IR (-O2):
@.str.1 = [16 x i8] c"next index: %d\0A\00"
@str = [11 x i8] c"toNextChar\00"
define void @toNextChar(i8* nocapture %0, i32* nocapture %1) {
%3 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @str, i64 0, i64 0))
%4 = load i32, i32* %1
%5 = sext i32 %4 to i64
br label %6
6: ; preds = %6, %2
%7 = phi i64 [ %8, %6 ], [ %5, %2 ]
%8 = add nsw i64 %7, 1
%9 = trunc i64 %8 to i32
store i32 %9, i32* %1
%10 = getelementptr inbounds i8, i8* %0, i64 %8
%11 = load i8, i8* %10
%12 = icmp eq i8 %11, 32
br i1 %12, label %6, label %13
13: ; preds = %6
%14 = trunc i64 %8 to i32
%15 = trunc i64 %7 to i32
%16 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @.str.1, i64 0, i64 0), i32 %14)
store i32 %15, i32* %1
ret void
}