#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*/ fgets(char *, int, int /*<<< orphan*/);
int /*<<< orphan*/ parseSentence(char *);
int /*<<< orphan*/ printf(char *, char *, ...);
int /*<<< orphan*/ reverse(char *);
int /*<<< orphan*/ stdin;
int main(void) {
  char buffer1[] = {'t', 'h', 'i', 's', ' ', 'i', 's', ' ', 't',
                    'h', 'e', ' ', 'f', 'i', 'r', 's', 't', ' ',
                    'b', 'u', 'f', 'f', 'e', 'r', '\0'};
  char buffer2[] = "this is the second buffer";
  char buffer3[80];
  printf("\n%s", "Please enter a sentence: ");
  fgets(buffer3, 80, stdin);
  printf("\n%s %s\n%s %s\n%s %s\n", "buffer1:", buffer1, "buffer2:", buffer2,
         "buffer3:", buffer3);
  char *pBuffer = buffer3;
  printf("%s %s", "pBuffer before being incremented:", pBuffer);
  pBuffer++;
  pBuffer++;
  pBuffer++;
  printf("%s %s\n", "pBuffer after being incremented by 3 chars:", pBuffer);
  printf("%s %s\n", "buffer2 before being reversed:", buffer2);
  reverse(buffer2);
  printf("%s %s\n", "buffer2 after being reversed:", buffer2);
  printf("\n%s\n", "Your sentence tokenized: ");
  parseSentence(buffer3);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0xa0,%rsp
movl   $0x0,-0x4(%rbp)
mov    0xea7(%rip),%rax
mov    %rax,-0x20(%rbp)
mov    0xea4(%rip),%rax
mov    %rax,-0x18(%rbp)
mov    0xea1(%rip),%rax
mov    %rax,-0x10(%rbp)
mov    0xe9f(%rip),%al
mov    %al,-0x8(%rbp)
mov    0xe9d(%rip),%rax
mov    %rax,-0x40(%rbp)
mov    0xe9a(%rip),%rax
mov    %rax,-0x38(%rbp)
mov    0xe97(%rip),%rax
mov    %rax,-0x30(%rbp)
mov    0xe94(%rip),%ax
mov    %ax,-0x28(%rbp)
lea    0xe8b(%rip),%rdi
lea    0xe88(%rip),%rsi
mov    $0x0,%al
call   1050 <printf@plt>
lea    -0x90(%rbp),%rdi
mov    0x2e1d(%rip),%rax
mov    (%rax),%edx
mov    $0x50,%esi
call   1060 <fgets@plt>
lea    -0x20(%rbp),%rdx
lea    -0x40(%rbp),%r8
lea    -0x90(%rbp),%rax
lea    0xe6b(%rip),%rdi
lea    0xe78(%rip),%rsi
lea    0xe7a(%rip),%rcx
lea    0xe7c(%rip),%r9
mov    %rax,(%rsp)
mov    $0x0,%al
call   1050 <printf@plt>
lea    -0x90(%rbp),%rax
mov    %rax,-0x98(%rbp)
mov    -0x98(%rbp),%rdx
lea    0xe5e(%rip),%rdi
lea    0xe5d(%rip),%rsi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x98(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x98(%rbp)
mov    -0x98(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x98(%rbp)
mov    -0x98(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x98(%rbp)
mov    -0x98(%rbp),%rdx
lea    0xdea(%rip),%rdi
lea    0xe2d(%rip),%rsi
mov    $0x0,%al
call   1050 <printf@plt>
lea    -0x40(%rbp),%rdx
lea    0xdd1(%rip),%rdi
lea    0xe40(%rip),%rsi
mov    $0x0,%al
call   1050 <printf@plt>
lea    -0x40(%rbp),%rdi
call   1030 <reverse@plt>
lea    -0x40(%rbp),%rdx
lea    0xdaf(%rip),%rdi
lea    0xe3d(%rip),%rsi
mov    $0x0,%al
call   1050 <printf@plt>
lea    0xe4d(%rip),%rdi
lea    0xe4b(%rip),%rsi
mov    $0x0,%al
call   1050 <printf@plt>
lea    -0x90(%rbp),%rdi
call   1040 <parseSentence@plt>
xor    %eax,%eax
add    $0xa0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
sub    $0xa0,%rsp
movups 0xeb6(%rip),%xmm0
movups %xmm0,0x19(%rsp)
movaps 0xea1(%rip),%xmm0
movaps %xmm0,0x10(%rsp)
movups 0xebf(%rip),%xmm0
movups %xmm0,0x3a(%rsp)
movaps 0xea9(%rip),%xmm0
movaps %xmm0,0x30(%rsp)
lea    0xeb7(%rip),%rdi
lea    0xeb4(%rip),%rsi
xor    %eax,%eax
call   1050 <printf@plt>
mov    0x2e50(%rip),%rax
mov    (%rax),%edx
lea    0x50(%rsp),%r14
mov    %r14,%rdi
mov    $0x50,%esi
call   1060 <fgets@plt>
mov    %r14,(%rsp)
lea    0xea1(%rip),%rdi
lea    0xeae(%rip),%rsi
lea    0xeb0(%rip),%rcx
lea    0xeb2(%rip),%r9
lea    0x10(%rsp),%rdx
lea    0x30(%rsp),%r15
mov    %r15,%r8
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xea0(%rip),%rdi
lea    0xe9f(%rip),%rsi
mov    %r14,%rdx
xor    %eax,%eax
call   1050 <printf@plt>
lea    0x53(%rsp),%rdx
lea    0xe61(%rip),%rbx
lea    0xea4(%rip),%rsi
mov    %rbx,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xebf(%rip),%rsi
mov    %rbx,%rdi
mov    %r15,%rdx
xor    %eax,%eax
call   1050 <printf@plt>
mov    %r15,%rdi
call   1030 <reverse@plt>
lea    0xec2(%rip),%rsi
mov    %rbx,%rdi
mov    %r15,%rdx
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xecc(%rip),%rdi
lea    0xeca(%rip),%rsi
xor    %eax,%eax
call   1050 <printf@plt>
mov    %r14,%rdi
call   1040 <parseSentence@plt>
xor    %eax,%eax
add    $0xa0,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@__const.main.buffer1 = [25 x i8] c"this is the first buffer\00"
@__const.main.buffer2 = [26 x i8] c"this is the second buffer\00"
@.str = [4 x i8] c"\0A%s\00"
@.str.1 = [26 x i8] c"Please enter a sentence: \00"
@stdin = global i32 0
@.str.2 = [20 x i8] c"\0A%s %s\0A%s %s\0A%s %s\0A\00"
@.str.3 = [9 x i8] c"buffer1:\00"
@.str.4 = [9 x i8] c"buffer2:\00"
@.str.5 = [9 x i8] c"buffer3:\00"
@.str.6 = [6 x i8] c"%s %s\00"
@.str.7 = [34 x i8] c"pBuffer before being incremented:\00"
@.str.8 = [7 x i8] c"%s %s\0A\00"
@.str.9 = [44 x i8] c"pBuffer after being incremented by 3 chars:\00"
@.str.10 = [31 x i8] c"buffer2 before being reversed:\00"
@.str.11 = [30 x i8] c"buffer2 after being reversed:\00"
@.str.12 = [5 x i8] c"\0A%s\0A\00"
@.str.13 = [26 x i8] c"Your sentence tokenized: \00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [25 x i8]
%3 = alloca [26 x i8]
%4 = alloca [80 x i8]
%5 = alloca i8*
store i32 0, i32* %1
%6 = bitcast [25 x i8]* %2 to i8*
%7 = bitcast [26 x i8]* %3 to i8*
%8 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.1, i64 0, i64 0))
%9 = getelementptr inbounds [80 x i8], [80 x i8]* %4, i64 0, i64 0
%10 = load i32, i32* @stdin
%11 = call i32 @fgets(i8* %9, i32 80, i32 %10)
%12 = getelementptr inbounds [25 x i8], [25 x i8]* %2, i64 0, i64 0
%13 = getelementptr inbounds [26 x i8], [26 x i8]* %3, i64 0, i64 0
%14 = getelementptr inbounds [80 x i8], [80 x i8]* %4, i64 0, i64 0
%15 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.3, i64 0, i64 0), i8* %12, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.4, i64 0, i64 0), i8* %13, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.5, i64 0, i64 0), i8* %14)
%16 = getelementptr inbounds [80 x i8], [80 x i8]* %4, i64 0, i64 0
store i8* %16, i8** %5
%17 = load i8*, i8** %5
%18 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.6, i64 0, i64 0), i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.7, i64 0, i64 0), i8* %17)
%19 = load i8*, i8** %5
%20 = getelementptr inbounds i8, i8* %19, i32 1
store i8* %20, i8** %5
%21 = load i8*, i8** %5
%22 = getelementptr inbounds i8, i8* %21, i32 1
store i8* %22, i8** %5
%23 = load i8*, i8** %5
%24 = getelementptr inbounds i8, i8* %23, i32 1
store i8* %24, i8** %5
%25 = load i8*, i8** %5
%26 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.8, i64 0, i64 0), i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str.9, i64 0, i64 0), i8* %25)
%27 = getelementptr inbounds [26 x i8], [26 x i8]* %3, i64 0, i64 0
%28 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.8, i64 0, i64 0), i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.10, i64 0, i64 0), i8* %27)
%29 = getelementptr inbounds [26 x i8], [26 x i8]* %3, i64 0, i64 0
%30 = call i32 @reverse(i8* %29)
%31 = getelementptr inbounds [26 x i8], [26 x i8]* %3, i64 0, i64 0
%32 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.8, i64 0, i64 0), i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.11, i64 0, i64 0), i8* %31)
%33 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.12, i64 0, i64 0), i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.13, i64 0, i64 0))
%34 = getelementptr inbounds [80 x i8], [80 x i8]* %4, i64 0, i64 0
%35 = call i32 @parseSentence(i8* %34)
ret i32 0
}

LLVM IR (-O2):
@__const.main.buffer1 = [25 x i8] c"this is the first buffer\00"
@__const.main.buffer2 = [26 x i8] c"this is the second buffer\00"
@.str = [4 x i8] c"\0A%s\00"
@.str.1 = [26 x i8] c"Please enter a sentence: \00"
@stdin = global i32 0
@.str.2 = [20 x i8] c"\0A%s %s\0A%s %s\0A%s %s\0A\00"
@.str.3 = [9 x i8] c"buffer1:\00"
@.str.4 = [9 x i8] c"buffer2:\00"
@.str.5 = [9 x i8] c"buffer3:\00"
@.str.6 = [6 x i8] c"%s %s\00"
@.str.7 = [34 x i8] c"pBuffer before being incremented:\00"
@.str.8 = [7 x i8] c"%s %s\0A\00"
@.str.9 = [44 x i8] c"pBuffer after being incremented by 3 chars:\00"
@.str.10 = [31 x i8] c"buffer2 before being reversed:\00"
@.str.11 = [30 x i8] c"buffer2 after being reversed:\00"
@.str.12 = [5 x i8] c"\0A%s\0A\00"
@.str.13 = [26 x i8] c"Your sentence tokenized: \00"
define i32 @main() {
%1 = alloca [25 x i8]
%2 = alloca [26 x i8]
%3 = alloca [80 x i8]
%4 = getelementptr inbounds [25 x i8], [25 x i8]* %1, i64 0, i64 0
%5 = getelementptr inbounds [26 x i8], [26 x i8]* %2, i64 0, i64 0
%6 = getelementptr inbounds [80 x i8], [80 x i8]* %3, i64 0, i64 0
%7 = tail call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.1, i64 0, i64 0))
%8 = load i32, i32* @stdin
%9 = call i32 @fgets(i8* %6, i32 80, i32 %8)
%10 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.3, i64 0, i64 0), i8* %4, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.4, i64 0, i64 0), i8* %5, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.5, i64 0, i64 0), i8* %6)
%11 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.6, i64 0, i64 0), i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.7, i64 0, i64 0), i8* %6)
%12 = getelementptr inbounds [80 x i8], [80 x i8]* %3, i64 0, i64 3
%13 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.8, i64 0, i64 0), i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str.9, i64 0, i64 0), i8* %12)
%14 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.8, i64 0, i64 0), i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.10, i64 0, i64 0), i8* %5)
%15 = call i32 @reverse(i8* %5)
%16 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.8, i64 0, i64 0), i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.11, i64 0, i64 0), i8* %5)
%17 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.12, i64 0, i64 0), i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.13, i64 0, i64 0))
%18 = call i32 @parseSentence(i8* %6)
ret i32 0
}