#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*/ printf(char *, ...);
int strlen(char *);
main(int argc, char *argv[]) {
  if (argc != 2) {
    printf("Improper Arguments\n");
  } else {
    int len = strlen(argv[1]);
    int i;
    for (i = len - 1; i >= 0; i--) {
      printf("%c", argv[1][i]);
    }
    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)
cmpl   $0x2,-0x8(%rbp)
je     1153 <main+0x33>
lea    0xeb9(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    11b0 <main+0x90>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1030 <strlen@plt>
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%eax
sub    $0x1,%eax
mov    %eax,-0x18(%rbp)
cmpl   $0x0,-0x18(%rbp)
jl     11a2 <main+0x82>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rax
movslq -0x18(%rbp),%rcx
movsbl (%rax,%rcx,1),%esi
lea    0xe87(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x18(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x18(%rbp)
jmp    116c <main+0x4c>
lea    0xe69(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
push   %rax
cmp    $0x2,%edi
jne    1176 <main+0x46>
mov    %rsi,%r14
mov    0x8(%rsi),%rdi
call   1050 <strlen@plt>
test   %eax,%eax
jle    116a <main+0x3a>
mov    %eax,%ebx
add    $0x1,%rbx
nop
lea    -0x2(%rbx),%eax
mov    0x8(%r14),%rcx
movsbl (%rcx,%rax,1),%edi
call   1030 <putchar@plt>
add    $0xffffffffffffffff,%rbx
cmp    $0x1,%rbx
ja     1150 <main+0x20>
mov    $0xa,%edi
call   1030 <putchar@plt>
jmp    1182 <main+0x52>
lea    0xe83(%rip),%rdi
call   1040 <puts@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [20 x i8] c"Improper Arguments\0A\00"
@.str.1 = [3 x i8] c"%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 i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%8 = load i32, i32* %4
%9 = icmp ne i32 %8, 2
br i1 %9, label %10, label %12
10: ; preds = %2
%11 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0))
br label %37
12: ; preds = %2
%13 = load i8**, i8*** %5
%14 = getelementptr inbounds i8*, i8** %13, i64 1
%15 = load i8*, i8** %14
%16 = call i32 @strlen(i8* %15)
store i32 %16, i32* %6
%17 = load i32, i32* %6
%18 = sub nsw i32 %17, 1
store i32 %18, i32* %7
br label %19
19: ; preds = %32, %12
%20 = load i32, i32* %7
%21 = icmp sge i32 %20, 0
br i1 %21, label %22, label %35
22: ; preds = %19
%23 = load i8**, i8*** %5
%24 = getelementptr inbounds i8*, i8** %23, i64 1
%25 = load i8*, i8** %24
%26 = load i32, i32* %7
%27 = sext i32 %26 to i64
%28 = getelementptr inbounds i8, i8* %25, i64 %27
%29 = load i8, i8* %28
%30 = sext i8 %29 to i32
%31 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32 %30)
br label %32
32: ; preds = %22
%33 = load i32, i32* %7
%34 = add nsw i32 %33, -1
store i32 %34, i32* %7
br label %19
35: ; preds = %19
%36 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
br label %37
37: ; preds = %35, %10
ret i32 0
}

LLVM IR (-O2):
@str = [19 x i8] c"Improper Arguments\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = icmp eq i32 %0, 2
br i1 %3, label %6, label %4
4: ; preds = %2
%5 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @str, i64 0, i64 0))
br label %25
6: ; preds = %2
%7 = getelementptr inbounds i8*, i8** %1, i64 1
%8 = load i8*, i8** %7
%9 = tail call i32 @strlen(i8* %8)
%10 = icmp sgt i32 %9, 0
br i1 %10, label %11, label %23
11: ; preds = %6
%12 = zext i32 %9 to i64
br label %13
13: ; preds = %11, %13
%14 = phi i64 [ %12, %11 ], [ %15, %13 ]
%15 = add nsw i64 %14, -1
%16 = load i8*, i8** %7
%17 = and i64 %15, 4294967295
%18 = getelementptr inbounds i8, i8* %16, i64 %17
%19 = load i8, i8* %18
%20 = sext i8 %19 to i32
%21 = tail call i32 @putchar(i32 %20)
%22 = icmp ugt i64 %14, 1
br i1 %22, label %13, label %23
23: ; preds = %13, %6
%24 = tail call i32 @putchar(i32 10)
br label %25
25: ; preds = %23, %4
ret i32 0
}