#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*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ reverse(char *);
int /*<<< orphan*/ strcat(char *, char *);
int /*<<< orphan*/ strcpy(char *, char *);
int main(int argc, char **argv) {
  if (argc < 2) {
    printf("Usage : reverse <string>\n");
    exit(0);
  }
  char string[256];
  strcpy(string, "");
  int i;
  for (i = 1; i < argc; i++) {
    strcat(string, argv[i]);
    if (i != (argc - 1))
      strcat(string, " ");
  }
  printf("Reverse of String = ");
  reverse(string);
  printf("\n");
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x120,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x2,-0x8(%rbp)
jge    1186 <main+0x36>
lea    0xe86(%rip),%rdi
call   1050 <printf@plt>
xor    %edi,%edi
call   1070 <exit@plt>
lea    -0x110(%rbp),%rdi
lea    0xe85(%rip),%rsi
call   1040 <strcpy@plt>
movl   $0x1,-0x114(%rbp)
mov    -0x114(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    120d <main+0xbd>
lea    -0x110(%rbp),%rdi
mov    -0x10(%rbp),%rax
movslq -0x114(%rbp),%rcx
mov    (%rax,%rcx,8),%rsi
call   1060 <strcat@plt>
mov    -0x114(%rbp),%eax
mov    -0x8(%rbp),%ecx
sub    $0x1,%ecx
cmp    %ecx,%eax
je     11f4 <main+0xa4>
lea    -0x110(%rbp),%rdi
lea    0xe3e(%rip),%rsi
call   1060 <strcat@plt>
jmp    11f9 <main+0xa9>
mov    -0x114(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x114(%rbp)
jmp    11a3 <main+0x53>
lea    0xe06(%rip),%rdi
call   1050 <printf@plt>
lea    -0x110(%rbp),%rdi
call   1030 <reverse@plt>
lea    0xdec(%rip),%rdi
call   1050 <printf@plt>
mov    -0x4(%rbp),%eax
add    $0x120,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x108,%rsp
cmp    $0x1,%edi
jle    1219 <main+0xa9>
mov    %rsi,%r12
mov    %edi,%r15d
lea    0xe7d(%rip),%rsi
mov    %rsp,%r14
mov    %r14,%rdi
call   1050 <strcpy@plt>
lea    -0x1(%r15),%r13d
mov    %r15d,%ebx
mov    $0x1,%ebp
lea    0xe5e(%rip),%r15
jmp    11c9 <main+0x59>
nopw   0x0(%rax,%rax,1)
add    $0x1,%rbp
cmp    %rbp,%rbx
je     11e7 <main+0x77>
mov    (%r12,%rbp,8),%rsi
mov    %r14,%rdi
call   1080 <strcat@plt>
cmp    %rbp,%r13
je     11c0 <main+0x50>
mov    %r14,%rdi
mov    %r15,%rsi
call   1080 <strcat@plt>
jmp    11c0 <main+0x50>
lea    0xe12(%rip),%rdi
call   1070 <printf@plt>
mov    %rsp,%rdi
call   1030 <reverse@plt>
mov    $0xa,%edi
call   1040 <putchar@plt>
xor    %eax,%eax
add    $0x108,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xdf5(%rip),%rdi
call   1060 <puts@plt>
xor    %edi,%edi
call   1090 <exit@plt>

LLVM IR (-O0):
@.str = [26 x i8] c"Usage : reverse <string>\0A\00"
@.str.1 = [1 x i8] zeroinitializer
@.str.2 = [2 x i8] c" \00"
@.str.3 = [21 x i8] c"Reverse of String = \00"
@.str.4 = [2 x i8] c"\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca [256 x i8]
%7 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%8 = load i32, i32* %4
%9 = icmp slt i32 %8, 2
br i1 %9, label %10, label %13
10: ; preds = %2
%11 = call i32 @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str, i64 0, i64 0))
%12 = call i32 @exit(i32 0)
unreachable
13: ; preds = %2
%14 = getelementptr inbounds [256 x i8], [256 x i8]* %6, i64 0, i64 0
%15 = call i32 @strcpy(i8* %14, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.1, i64 0, i64 0))
store i32 1, i32* %7
br label %16
16: ; preds = %36, %13
%17 = load i32, i32* %7
%18 = load i32, i32* %4
%19 = icmp slt i32 %17, %18
br i1 %19, label %20, label %39
20: ; preds = %16
%21 = getelementptr inbounds [256 x i8], [256 x i8]* %6, i64 0, i64 0
%22 = load i8**, i8*** %5
%23 = load i32, i32* %7
%24 = sext i32 %23 to i64
%25 = getelementptr inbounds i8*, i8** %22, i64 %24
%26 = load i8*, i8** %25
%27 = call i32 @strcat(i8* %21, i8* %26)
%28 = load i32, i32* %7
%29 = load i32, i32* %4
%30 = sub nsw i32 %29, 1
%31 = icmp ne i32 %28, %30
br i1 %31, label %32, label %35
32: ; preds = %20
%33 = getelementptr inbounds [256 x i8], [256 x i8]* %6, i64 0, i64 0
%34 = call i32 @strcat(i8* %33, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
br label %35
35: ; preds = %32, %20
br label %36
36: ; preds = %35
%37 = load i32, i32* %7
%38 = add nsw i32 %37, 1
store i32 %38, i32* %7
br label %16
39: ; preds = %16
%40 = call i32 @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.3, i64 0, i64 0))
%41 = getelementptr inbounds [256 x i8], [256 x i8]* %6, i64 0, i64 0
%42 = call i32 @reverse(i8* %41)
%43 = call i32 @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
%44 = load i32, i32* %3
ret i32 %44
}

LLVM IR (-O2):
@.str.1 = [1 x i8] zeroinitializer
@.str.2 = [2 x i8] c" \00"
@.str.3 = [21 x i8] c"Reverse of String = \00"
@str = [25 x i8] c"Usage : reverse <string>\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca [256 x i8]
%4 = icmp slt i32 %0, 2
br i1 %4, label %5, label %8
5: ; preds = %2
%6 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @str, i64 0, i64 0))
%7 = tail call i32 @exit(i32 0)
unreachable
8: ; preds = %2
%9 = getelementptr inbounds [256 x i8], [256 x i8]* %3, i64 0, i64 0
%10 = call i32 @strcpy(i8* %9, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.1, i64 0, i64 0))
%11 = add nsw i32 %0, -1
%12 = zext i32 %11 to i64
%13 = zext i32 %0 to i64
br label %14
14: ; preds = %8, %22
%15 = phi i64 [ 1, %8 ], [ %23, %22 ]
%16 = getelementptr inbounds i8*, i8** %1, i64 %15
%17 = load i8*, i8** %16
%18 = call i32 @strcat(i8* %9, i8* %17)
%19 = icmp eq i64 %15, %12
br i1 %19, label %22, label %20
20: ; preds = %14
%21 = call i32 @strcat(i8* %9, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
br label %22
22: ; preds = %14, %20
%23 = add nuw nsw i64 %15, 1
%24 = icmp eq i64 %23, %13
br i1 %24, label %25, label %14
25: ; preds = %22
%26 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @.str.3, i64 0, i64 0))
%27 = call i32 @reverse(i8* %9)
%28 = call i32 @putchar(i32 10)
ret i32 0
}