#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*/ revert_string(char *, int /*<<< orphan*/, int);
char *strchr(char *, char);
int strlen(char *);
void revert_I_am_a_student(char *string) {
  char *current, *space;
  revert_string(string, 0, strlen(string) - 1);
  current = string;
  do {
    space = strchr(current, ' ');
    if (space) {
      revert_string(current, 0, space - current - 1);
      current = space + 1;
    } else {
      break;
    }
  } while (*current != '\0');
}


x86 assembly (clang, -O0):
<revert_I_am_a_student>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x8(%rbp),%rdi
call   1030 <strlen@plt>
mov    -0x20(%rbp),%rdi
mov    %eax,%edx
sub    $0x1,%edx
xor    %esi,%esi
call   1050 <revert_string@plt>
mov    -0x8(%rbp),%rax
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
mov    $0x20,%esi
call   1040 <strchr@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
je     11af <revert_I_am_a_student+0x7f>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rax
mov    -0x10(%rbp),%rcx
sub    %rcx,%rax
sub    $0x1,%rax
mov    %eax,%edx
xor    %esi,%esi
call   1050 <revert_string@plt>
mov    -0x18(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x10(%rbp)
jmp    11b4 <revert_I_am_a_student+0x84>
jmp    11c9 <revert_I_am_a_student+0x99>
jmp    11b9 <revert_I_am_a_student+0x89>
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
jne    1165 <revert_I_am_a_student+0x35>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<revert_I_am_a_student>:
push   %r14
push   %rbx
push   %rax
mov    %rdi,%rbx
call   1030 <strlen@plt>
lea    -0x1(%rax),%edx
mov    %rbx,%rdi
xor    %esi,%esi
call   1050 <revert_string@plt>
nopl   0x0(%rax)
mov    %rbx,%rdi
mov    $0x20,%esi
call   1040 <strchr@plt>
test   %rax,%rax
je     1184 <revert_I_am_a_student+0x54>
mov    %rax,%r14
mov    %ebx,%edx
not    %edx
add    %r14d,%edx
mov    %rbx,%rdi
xor    %esi,%esi
call   1050 <revert_string@plt>
mov    %r14,%rbx
add    $0x1,%rbx
cmpb   $0x0,0x1(%r14)
jne    1150 <revert_I_am_a_student+0x20>
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
define void @revert_I_am_a_student(i8* %0) {
%2 = alloca i8*
%3 = alloca i8*
%4 = alloca i8*
store i8* %0, i8** %2
%5 = load i8*, i8** %2
%6 = load i8*, i8** %2
%7 = call i32 @strlen(i8* %6)
%8 = sub nsw i32 %7, 1
%9 = call i32 @revert_string(i8* %5, i32 0, i32 %8)
%10 = load i8*, i8** %2
store i8* %10, i8** %3
br label %11
11: ; preds = %30, %1
%12 = load i8*, i8** %3
%13 = call i8* @strchr(i8* %12, i8 signext 32)
store i8* %13, i8** %4
%14 = load i8*, i8** %4
%15 = icmp ne i8* %14, null
br i1 %15, label %16, label %28
16: ; preds = %11
%17 = load i8*, i8** %3
%18 = load i8*, i8** %4
%19 = load i8*, i8** %3
%20 = ptrtoint i8* %18 to i64
%21 = ptrtoint i8* %19 to i64
%22 = sub i64 %20, %21
%23 = sub nsw i64 %22, 1
%24 = trunc i64 %23 to i32
%25 = call i32 @revert_string(i8* %17, i32 0, i32 %24)
%26 = load i8*, i8** %4
%27 = getelementptr inbounds i8, i8* %26, i64 1
store i8* %27, i8** %3
br label %29
28: ; preds = %11
br label %35
29: ; preds = %16
br label %30
30: ; preds = %29
%31 = load i8*, i8** %3
%32 = load i8, i8* %31
%33 = sext i8 %32 to i32
%34 = icmp ne i32 %33, 0
br i1 %34, label %11, label %35
35: ; preds = %30, %28
ret void
}

LLVM IR (-O2):
define void @revert_I_am_a_student(i8* %0) {
%2 = tail call i32 @strlen(i8* %0)
%3 = add nsw i32 %2, -1
%4 = tail call i32 @revert_string(i8* %0, i32 0, i32 %3)
br label %5
5: ; preds = %9, %1
%6 = phi i8* [ %0, %1 ], [ %16, %9 ]
%7 = tail call i8* @strchr(i8* dereferenceable(1) %6, i8 signext 32)
%8 = icmp eq i8* %7, null
br i1 %8, label %19, label %9
9: ; preds = %5
%10 = ptrtoint i8* %7 to i64
%11 = ptrtoint i8* %6 to i64
%12 = xor i64 %11, -1
%13 = add i64 %10, %12
%14 = trunc i64 %13 to i32
%15 = tail call i32 @revert_string(i8* %6, i32 0, i32 %14)
%16 = getelementptr inbounds i8, i8* %7, i64 1
%17 = load i8, i8* %16
%18 = icmp eq i8 %17, 0
br i1 %18, label %19, label %5
19: ; preds = %5, %9
ret void
}