#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 */
char **getWords(char *);
int /*<<< orphan*/ printReverse(char *);
int /*<<< orphan*/ printf(char *);
int main(int argc, char **argv) {
  int i;
  char **words = getWords("Here is an apple");
  for (i = 0; i < 50; i++) {
    if (words[i]) {
      printReverse(words[i]);
      printf(" ");
    } else {
      break;
    }
  }
  printf("\n");
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    0xeb3(%rip),%rdi
call   1050 <getWords@plt>
mov    %rax,-0x20(%rbp)
movl   $0x0,-0x14(%rbp)
cmpl   $0x32,-0x14(%rbp)
jge    11b4 <main+0x84>
mov    -0x20(%rbp),%rax
movslq -0x14(%rbp),%rcx
cmpq   $0x0,(%rax,%rcx,8)
je     119c <main+0x6c>
mov    -0x20(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
call   1040 <printReverse@plt>
lea    0xe7f(%rip),%rdi
call   1030 <printf@plt>
jmp    11a1 <main+0x71>
jmp    11b4 <main+0x84>
jmp    11a6 <main+0x76>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    115d <main+0x2d>
lea    0xe58(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
push   %rax
lea    0xec5(%rip),%rdi
call   1050 <getWords@plt>
mov    %rax,%r14
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
nop
mov    (%r14,%rbx,8),%rdi
test   %rdi,%rdi
je     1172 <main+0x42>
call   1040 <printReverse@plt>
mov    $0x20,%edi
call   1030 <putchar@plt>
add    $0x1,%rbx
cmp    $0x32,%rbx
jne    1150 <main+0x20>
mov    $0xa,%edi
call   1030 <putchar@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [17 x i8] c"Here is an apple\00"
@.str.1 = [2 x i8] c" \00"
@.str.2 = [2 x i8] c"\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i8**
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%8 = call i8** @getWords(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0))
store i8** %8, i8*** %7
store i32 0, i32* %6
br label %9
9: ; preds = %29, %2
%10 = load i32, i32* %6
%11 = icmp slt i32 %10, 50
br i1 %11, label %12, label %32
12: ; preds = %9
%13 = load i8**, i8*** %7
%14 = load i32, i32* %6
%15 = sext i32 %14 to i64
%16 = getelementptr inbounds i8*, i8** %13, i64 %15
%17 = load i8*, i8** %16
%18 = icmp ne i8* %17, null
br i1 %18, label %19, label %27
19: ; preds = %12
%20 = load i8**, i8*** %7
%21 = load i32, i32* %6
%22 = sext i32 %21 to i64
%23 = getelementptr inbounds i8*, i8** %20, i64 %22
%24 = load i8*, i8** %23
%25 = call i32 @printReverse(i8* %24)
%26 = call i32 @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
br label %28
27: ; preds = %12
br label %32
28: ; preds = %19
br label %29
29: ; preds = %28
%30 = load i32, i32* %6
%31 = add nsw i32 %30, 1
store i32 %31, i32* %6
br label %9
32: ; preds = %27, %9
%33 = call i32 @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
ret i32 0
}

LLVM IR (-O2):
@.str = [17 x i8] c"Here is an apple\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = tail call i8** @getWords(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0))
br label %4
4: ; preds = %2, %9
%5 = phi i64 [ 0, %2 ], [ %12, %9 ]
%6 = getelementptr inbounds i8*, i8** %3, i64 %5
%7 = load i8*, i8** %6
%8 = icmp eq i8* %7, null
br i1 %8, label %14, label %9
9: ; preds = %4
%10 = tail call i32 @printReverse(i8* %7)
%11 = tail call i32 @putchar(i32 32)
%12 = add nuw nsw i64 %5, 1
%13 = icmp eq i64 %12, 50
br i1 %13, label %14, label %4
14: ; preds = %4, %9
%15 = tail call i32 @putchar(i32 10)
ret i32 0
}