#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 */
typedef int /*<<< orphan*/ words_in;

/* Variables and functions */
int /*<<< orphan*/ assert(int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, ...);
char *rev_w(char const *);
int /*<<< orphan*/ stdout;
scalar_t__ strcmp(char *, char const *);
int main(int argc, char **argv) {
  int i;
  const char *words_in[] = {"hello", "Village", "GitHub", "elephant",
                            "wow",   "k",       ""};
  const char *words_out[] = {"olleh", "egalliV", "buHtiG", "tnahpele",
                             "wow",   "k",       ""};
  for (i = 0; i < sizeof(words_in) / sizeof(words_in[0]); i++) {
    fprintf(stdout, "---\n%s %s %s\n", words_in[i], words_out[i],
            rev_w(words_in[i]));
    fprintf(stdout, "Test %d: ", i + 1);
    assert(strcmp(rev_w(words_in[i]), words_out[i]) == 0);
    fprintf(stdout, "OK\n");
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0xb0,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    -0x50(%rbp),%rdi
lea    0x2c2c(%rip),%rsi
mov    $0x38,%edx
call   1070 <memcpy@plt>
lea    -0x90(%rbp),%rdi
lea    0x2c54(%rip),%rsi
mov    $0x38,%edx
call   1070 <memcpy@plt>
movl   $0x0,-0x14(%rbp)
movslq -0x14(%rbp),%rax
cmp    $0x7,%rax
jae    1285 <main+0x135>
mov    0x2e2e(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0xa4(%rbp)
movslq -0x14(%rbp),%rax
mov    -0x50(%rbp,%rax,8),%rax
mov    %rax,-0xa0(%rbp)
movslq -0x14(%rbp),%rax
mov    -0x90(%rbp,%rax,8),%rax
ff
mov    %rax,-0x98(%rbp)
movslq -0x14(%rbp),%rax
mov    -0x50(%rbp,%rax,8),%rdi
call   1030 <rev_w@plt>
mov    -0xa4(%rbp),%edi
mov    -0xa0(%rbp),%rdx
mov    -0x98(%rbp),%rcx
mov    %rax,%r8
lea    0xe39(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
mov    0x2dc9(%rip),%rax
mov    (%rax),%edi
mov    -0x14(%rbp),%edx
add    $0x1,%edx
lea    0xe2a(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
movslq -0x14(%rbp),%rax
mov    -0x50(%rbp,%rax,8),%rdi
call   1030 <rev_w@plt>
mov    %rax,%rdi
movslq -0x14(%rbp),%rax
mov    -0x90(%rbp,%rax,8),%rsi
ff
call   1040 <strcmp@plt>
cmp    $0x0,%rax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1050 <assert@plt>
mov    0x2d79(%rip),%rax
mov    (%rax),%edi
lea    0xdea(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    119d <main+0x4d>
xor    %eax,%eax
add    $0xb0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    $0x1,%ebx
mov    0x2e89(%rip),%r15
xor    %r12d,%r12d
nopw   0x0(%rax,%rax,1)
mov    (%r15),%ebp
lea    0x2c36(%rip),%rax
mov    (%r12,%rax,1),%r14
lea    0x2c6b(%rip),%rax
mov    (%r12,%rax,1),%r13
mov    %r14,%rdi
call   1030 <rev_w@plt>
mov    %ebp,%edi
lea    0xeb8(%rip),%rsi
mov    %r14,%rdx
mov    %r13,%rcx
mov    %rax,%r8
xor    %eax,%eax
call   1060 <fprintf@plt>
mov    (%r15),%edi
lea    0xeac(%rip),%rsi
mov    %ebx,%edx
xor    %eax,%eax
call   1060 <fprintf@plt>
mov    %r14,%rdi
call   1030 <rev_w@plt>
mov    %rax,%rdi
mov    %r13,%rsi
call   1040 <strcmp@plt>
xor    %edi,%edi
test   %rax,%rax
sete   %dil
call   1050 <assert@plt>
mov    (%r15),%edi
lea    0xe82(%rip),%rsi
xor    %eax,%eax
call   1060 <fprintf@plt>
add    $0x8,%r12
add    $0x1,%ebx
cmp    $0x38,%r12
jne    1160 <main+0x20>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [6 x i8] c"hello\00"
@.str.1 = [8 x i8] c"Village\00"
@.str.2 = [7 x i8] c"GitHub\00"
@.str.3 = [9 x i8] c"elephant\00"
@.str.4 = [4 x i8] c"wow\00"
@.str.5 = [2 x i8] c"k\00"
@.str.6 = [1 x i8] zeroinitializer
@__const.main.words_in = [7 x i8*] [i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i32 0, i32 0), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i32 0, i32 0), i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i32 0, i32 0), i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.3, i32 0, i32 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i32 0, i32 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i32 0, i32 0), i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.6, i32 0, i32 0)]
@.str.7 = [6 x i8] c"olleh\00"
@.str.8 = [8 x i8] c"egalliV\00"
@.str.9 = [7 x i8] c"buHtiG\00"
@.str.10 = [9 x i8] c"tnahpele\00"
@__const.main.words_out = [7 x i8*] [i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.7, i32 0, i32 0), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.8, i32 0, i32 0), i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.9, i32 0, i32 0), i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.10, i32 0, i32 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i32 0, i32 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i32 0, i32 0), i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.6, i32 0, i32 0)]
@stdout = global i32 0
@.str.11 = [14 x i8] c"---\0A%s %s %s\0A\00"
@.str.12 = [10 x i8] c"Test %d: \00"
@.str.13 = [4 x i8] c"OK\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca [7 x i8*]
%8 = alloca [7 x i8*]
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%9 = bitcast [7 x i8*]* %7 to i8*
%10 = bitcast [7 x i8*]* %8 to i8*
store i32 0, i32* %6
br label %11
11: ; preds = %50, %2
%12 = load i32, i32* %6
%13 = sext i32 %12 to i64
%14 = icmp ult i64 %13, 7
br i1 %14, label %15, label %53
15: ; preds = %11
%16 = load i32, i32* @stdout
%17 = load i32, i32* %6
%18 = sext i32 %17 to i64
%19 = getelementptr inbounds [7 x i8*], [7 x i8*]* %7, i64 0, i64 %18
%20 = load i8*, i8** %19
%21 = load i32, i32* %6
%22 = sext i32 %21 to i64
%23 = getelementptr inbounds [7 x i8*], [7 x i8*]* %8, i64 0, i64 %22
%24 = load i8*, i8** %23
%25 = load i32, i32* %6
%26 = sext i32 %25 to i64
%27 = getelementptr inbounds [7 x i8*], [7 x i8*]* %7, i64 0, i64 %26
%28 = load i8*, i8** %27
%29 = call i8* @rev_w(i8* %28)
%30 = call i32 (i32, i8*, ...) @fprintf(i32 %16, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.11, i64 0, i64 0), i8* %20, i8* %24, i8* %29)
%31 = load i32, i32* @stdout
%32 = load i32, i32* %6
%33 = add nsw i32 %32, 1
%34 = call i32 (i32, i8*, ...) @fprintf(i32 %31, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.12, i64 0, i64 0), i32 %33)
%35 = load i32, i32* %6
%36 = sext i32 %35 to i64
%37 = getelementptr inbounds [7 x i8*], [7 x i8*]* %7, i64 0, i64 %36
%38 = load i8*, i8** %37
%39 = call i8* @rev_w(i8* %38)
%40 = load i32, i32* %6
%41 = sext i32 %40 to i64
%42 = getelementptr inbounds [7 x i8*], [7 x i8*]* %8, i64 0, i64 %41
%43 = load i8*, i8** %42
%44 = call i64 @strcmp(i8* %39, i8* %43)
%45 = icmp eq i64 %44, 0
%46 = zext i1 %45 to i32
%47 = call i32 @assert(i32 %46)
%48 = load i32, i32* @stdout
%49 = call i32 (i32, i8*, ...) @fprintf(i32 %48, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.13, i64 0, i64 0))
br label %50
50: ; preds = %15
%51 = load i32, i32* %6
%52 = add nsw i32 %51, 1
store i32 %52, i32* %6
br label %11
53: ; preds = %11
ret i32 0
}

LLVM IR (-O2):
@.str = [6 x i8] c"hello\00"
@.str.1 = [8 x i8] c"Village\00"
@.str.2 = [7 x i8] c"GitHub\00"
@.str.3 = [9 x i8] c"elephant\00"
@.str.4 = [4 x i8] c"wow\00"
@.str.5 = [2 x i8] c"k\00"
@.str.6 = [1 x i8] zeroinitializer
@__const.main.words_in = [7 x i8*] [i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i32 0, i32 0), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i32 0, i32 0), i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i32 0, i32 0), i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.3, i32 0, i32 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i32 0, i32 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i32 0, i32 0), i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.6, i32 0, i32 0)]
@.str.7 = [6 x i8] c"olleh\00"
@.str.8 = [8 x i8] c"egalliV\00"
@.str.9 = [7 x i8] c"buHtiG\00"
@.str.10 = [9 x i8] c"tnahpele\00"
@__const.main.words_out = [7 x i8*] [i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.7, i32 0, i32 0), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.8, i32 0, i32 0), i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.9, i32 0, i32 0), i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.10, i32 0, i32 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i32 0, i32 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i32 0, i32 0), i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.6, i32 0, i32 0)]
@stdout = global i32 0
@.str.11 = [14 x i8] c"---\0A%s %s %s\0A\00"
@.str.12 = [10 x i8] c"Test %d: \00"
@.str.13 = [4 x i8] c"OK\0A\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
br label %3
3: ; preds = %2, %3
%4 = phi i64 [ 0, %2 ], [ %13, %3 ]
%5 = load i32, i32* @stdout
%6 = getelementptr inbounds [7 x i8*], [7 x i8*]* @__const.main.words_in, i64 0, i64 %4
%7 = load i8*, i8** %6
%8 = getelementptr inbounds [7 x i8*], [7 x i8*]* @__const.main.words_out, i64 0, i64 %4
%9 = load i8*, i8** %8
%10 = tail call i8* @rev_w(i8* %7)
%11 = tail call i32 (i32, i8*, ...) @fprintf(i32 %5, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.11, i64 0, i64 0), i8* %7, i8* %9, i8* %10)
%12 = load i32, i32* @stdout
%13 = add nuw nsw i64 %4, 1
%14 = trunc i64 %13 to i32
%15 = tail call i32 (i32, i8*, ...) @fprintf(i32 %12, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.12, i64 0, i64 0), i32 %14)
%16 = tail call i8* @rev_w(i8* %7)
%17 = tail call i64 @strcmp(i8* %16, i8* %9)
%18 = icmp eq i64 %17, 0
%19 = zext i1 %18 to i32
%20 = tail call i32 @assert(i32 %19)
%21 = load i32, i32* @stdout
%22 = tail call i32 (i32, i8*, ...) @fprintf(i32 %21, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.13, i64 0, i64 0))
%23 = icmp eq i64 %13, 7
br i1 %23, label %24, label %3
24: ; preds = %3
ret i32 0
}