#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 *, char *);
int /*<<< orphan*/ reverse(char *, int /*<<< orphan*/, int);
int /*<<< orphan*/ scanf(char *, ...);
int main() {
  char str[100];
  int size, i;
  scanf("%d", &size);
  for (i = 0; i < size; i++)
    scanf("%c", &str[i]);
  str[size] = '\0';
  reverse(str, 0, size - 1);
  printf("%s\n", str);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x80,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeb7(%rip),%rdi
lea    -0x74(%rbp),%rsi
mov    $0x0,%al
call   1050 <scanf@plt>
movl   $0x0,-0x78(%rbp)
mov    -0x78(%rbp),%eax
cmp    -0x74(%rbp),%eax
jge    118e <main+0x5e>
movslq -0x78(%rbp),%rax
lea    -0x70(%rbp),%rsi
add    %rax,%rsi
lea    0xe8a(%rip),%rdi
mov    $0x0,%al
call   1050 <scanf@plt>
mov    -0x78(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x78(%rbp)
jmp    115b <main+0x2b>
movslq -0x74(%rbp),%rax
movb   $0x0,-0x70(%rbp,%rax,1)
lea    -0x70(%rbp),%rdi
mov    -0x74(%rbp),%edx
sub    $0x1,%edx
xor    %esi,%esi
call   1030 <reverse@plt>
lea    -0x70(%rbp),%rsi
lea    0xe53(%rip),%rdi
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x80,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
sub    $0x78,%rsp
lea    0xec2(%rip),%rdi
lea    0xc(%rsp),%rsi
xor    %eax,%eax
call   1050 <scanf@plt>
mov    0xc(%rsp),%eax
test   %eax,%eax
jle    1180 <main+0x50>
lea    0xeaa(%rip),%r14
xor    %ebx,%ebx
nopl   0x0(%rax,%rax,1)
lea    (%rsp,%rbx,1),%rsi
add    $0x10,%rsi
mov    %r14,%rdi
xor    %eax,%eax
call   1050 <scanf@plt>
add    $0x1,%rbx
movslq 0xc(%rsp),%rax
cmp    %rax,%rbx
jl     1160 <main+0x30>
movslq %eax,%rdx
movb   $0x0,0x10(%rsp,%rdx,1)
add    $0xffffffff,%edx
lea    0x10(%rsp),%rbx
mov    %rbx,%rdi
xor    %esi,%esi
call   1030 <reverse@plt>
lea    0xe65(%rip),%rdi
mov    %rbx,%rsi
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x78,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [3 x i8] c"%d\00"
@.str.1 = [3 x i8] c"%c\00"
@.str.2 = [4 x i8] c"%s\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [100 x i8]
%3 = alloca i32
%4 = alloca i32
store i32 0, i32* %1
%5 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %3)
store i32 0, i32* %4
br label %6
6: ; preds = %15, %0
%7 = load i32, i32* %4
%8 = load i32, i32* %3
%9 = icmp slt i32 %7, %8
br i1 %9, label %10, label %18
10: ; preds = %6
%11 = load i32, i32* %4
%12 = sext i32 %11 to i64
%13 = getelementptr inbounds [100 x i8], [100 x i8]* %2, i64 0, i64 %12
%14 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %13)
br label %15
15: ; preds = %10
%16 = load i32, i32* %4
%17 = add nsw i32 %16, 1
store i32 %17, i32* %4
br label %6
18: ; preds = %6
%19 = load i32, i32* %3
%20 = sext i32 %19 to i64
%21 = getelementptr inbounds [100 x i8], [100 x i8]* %2, i64 0, i64 %20
store i8 0, i8* %21
%22 = getelementptr inbounds [100 x i8], [100 x i8]* %2, i64 0, i64 0
%23 = load i32, i32* %3
%24 = sub nsw i32 %23, 1
%25 = call i32 @reverse(i8* %22, i32 0, i32 %24)
%26 = getelementptr inbounds [100 x i8], [100 x i8]* %2, i64 0, i64 0
%27 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i8* %26)
ret i32 0
}

LLVM IR (-O2):
@.str = [3 x i8] c"%d\00"
@.str.1 = [3 x i8] c"%c\00"
@.str.2 = [4 x i8] c"%s\0A\00"
define i32 @main() {
%1 = alloca [100 x i8]
%2 = alloca i32
%3 = getelementptr inbounds [100 x i8], [100 x i8]* %1, i64 0, i64 0
%4 = bitcast i32* %2 to i8*
%5 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %2)
%6 = load i32, i32* %2
%7 = icmp sgt i32 %6, 0
br i1 %7, label %8, label %16
8: ; preds = %0, %8
%9 = phi i64 [ %12, %8 ], [ 0, %0 ]
%10 = getelementptr inbounds [100 x i8], [100 x i8]* %1, i64 0, i64 %9
%11 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %10)
%12 = add nuw nsw i64 %9, 1
%13 = load i32, i32* %2
%14 = sext i32 %13 to i64
%15 = icmp slt i64 %12, %14
br i1 %15, label %8, label %16
16: ; preds = %8, %0
%17 = phi i32 [ %6, %0 ], [ %13, %8 ]
%18 = sext i32 %17 to i64
%19 = getelementptr inbounds [100 x i8], [100 x i8]* %1, i64 0, i64 %18
store i8 0, i8* %19
%20 = add nsw i32 %17, -1
%21 = call i32 @reverse(i8* %3, i32 0, i32 %20)
%22 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i8* %3)
ret i32 0
}