#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_string(char *, char *, int, int /*<<< orphan*/);
int /*<<< orphan*/ scanf(char *, ...);
int main() {
  int n;
  scanf("%d", &n);
  char str1[n], str2[n];
  for (int i = 0; i < n - 1; i++) {
    scanf("%c", &str1[i]);
  }
  reverse_string(str1, str2, n - 1, 0);
  for (int i = 0; i < n; i++) {
    printf("%c", str2[i]);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeba(%rip),%rdi
xor    %eax,%eax
lea    -0x8(%rbp),%rsi
call   1050 <scanf@plt>
mov    -0x8(%rbp),%eax
mov    %rsp,%rcx
mov    %rcx,-0x10(%rbp)
mov    %rax,%rdx
add    $0xf,%rdx
and    $0xfffffffffffffff0,%rdx
mov    %rsp,%rcx
sub    %rdx,%rcx
mov    %rcx,-0x38(%rbp)
mov    %rcx,%rsp
mov    %rax,-0x18(%rbp)
mov    -0x8(%rbp),%eax
mov    %rax,%rdx
add    $0xf,%rdx
and    $0xfffffffffffffff0,%rdx
mov    %rsp,%rcx
sub    %rdx,%rcx
mov    %rcx,-0x30(%rbp)
mov    %rcx,%rsp
mov    %rax,-0x20(%rbp)
movl   $0x0,-0x24(%rbp)
mov    -0x24(%rbp),%eax
mov    -0x8(%rbp),%ecx
sub    $0x1,%ecx
cmp    %ecx,%eax
jge    11d5 <main+0xa5>
mov    -0x38(%rbp),%rsi
movslq -0x24(%rbp),%rax
add    %rax,%rsi
lea    0xe43(%rip),%rdi
mov    $0x0,%al
call   1050 <scanf@plt>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    119d <main+0x6d>
mov    -0x30(%rbp),%rsi
mov    -0x38(%rbp),%rdi
mov    -0x8(%rbp),%edx
sub    $0x1,%edx
xor    %ecx,%ecx
call   1030 <reverse_string@plt>
movl   $0x0,-0x28(%rbp)
mov    -0x28(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    1223 <main+0xf3>
mov    -0x30(%rbp),%rax
movslq -0x28(%rbp),%rcx
lea    0xdf7(%rip),%rdi
movsbl (%rax,%rcx,1),%esi
call   1040 <printf@plt>
mov    -0x28(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x28(%rbp)
jmp    11f1 <main+0xc1>
movl   $0x0,-0x4(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,%rsp
mov    -0x4(%rbp),%eax
mov    %rbp,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
mov    %rsp,%rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
lea    0xebb(%rip),%rdi
lea    -0x2c(%rbp),%rsi
xor    %eax,%eax
call   1050 <scanf@plt>
mov    %rsp,%r12
mov    -0x2c(%rbp),%eax
mov    %rsp,%r13
add    $0xf,%rax
and    $0xfffffffffffffff0,%rax
sub    %rax,%r13
mov    %r13,%rsp
mov    -0x2c(%rbp),%eax
mov    %rsp,%r14
mov    %rax,%rcx
add    $0xf,%rcx
and    $0xfffffffffffffff0,%rcx
sub    %rcx,%r14
mov    %r14,%rsp
cmp    $0x2,%eax
jl     11b1 <main+0x81>
lea    0xe79(%rip),%r15
xor    %ebx,%ebx
nopl   0x0(%rax)
lea    (%rbx,%r13,1),%rsi
mov    %r15,%rdi
xor    %eax,%eax
call   1050 <scanf@plt>
add    $0x1,%rbx
movslq -0x2c(%rbp),%rdx
add    $0xffffffffffffffff,%rdx
cmp    %rdx,%rbx
jl     1190 <main+0x60>
jmp    11b4 <main+0x84>
lea    -0x1(%rax),%edx
mov    %r13,%rdi
mov    %r14,%rsi
xor    %ecx,%ecx
call   1030 <reverse_string@plt>
cmpl   $0x0,-0x2c(%rbp)
jle    11ea <main+0xba>
xor    %ebx,%ebx
lea    0xe33(%rip),%r15
movsbl (%r14,%rbx,1),%esi
mov    %r15,%rdi
call   1040 <printf@plt>
add    $0x1,%rbx
movslq -0x2c(%rbp),%rax
cmp    %rax,%rbx
jl     11d0 <main+0xa0>
mov    %r12,%rsp
xor    %eax,%eax
lea    -0x28(%rbp),%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [3 x i8] c"%d\00"
@.str.1 = [3 x i8] c"%c\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i8*
%4 = alloca i64
%5 = alloca i64
%6 = alloca i32
%7 = alloca i32
store i32 0, i32* %1
%8 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %2)
%9 = load i32, i32* %2
%10 = zext i32 %9 to i64
%11 = call i8* @llvm.stacksave()
store i8* %11, i8** %3
%12 = alloca i8, i64 %10
store i64 %10, i64* %4
%13 = load i32, i32* %2
%14 = zext i32 %13 to i64
%15 = alloca i8, i64 %14
store i64 %14, i64* %5
store i32 0, i32* %6
br label %16
16: ; preds = %26, %0
%17 = load i32, i32* %6
%18 = load i32, i32* %2
%19 = sub nsw i32 %18, 1
%20 = icmp slt i32 %17, %19
br i1 %20, label %21, label %29
21: ; preds = %16
%22 = load i32, i32* %6
%23 = sext i32 %22 to i64
%24 = getelementptr inbounds i8, i8* %12, i64 %23
%25 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %24)
br label %26
26: ; preds = %21
%27 = load i32, i32* %6
%28 = add nsw i32 %27, 1
store i32 %28, i32* %6
br label %16
29: ; preds = %16
%30 = load i32, i32* %2
%31 = sub nsw i32 %30, 1
%32 = call i32 @reverse_string(i8* %12, i8* %15, i32 %31, i32 0)
store i32 0, i32* %7
br label %33
33: ; preds = %43, %29
%34 = load i32, i32* %7
%35 = load i32, i32* %2
%36 = icmp slt i32 %34, %35
br i1 %36, label %37, label %46
37: ; preds = %33
%38 = load i32, i32* %7
%39 = sext i32 %38 to i64
%40 = getelementptr inbounds i8, i8* %15, i64 %39
%41 = load i8, i8* %40
%42 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8 signext %41)
br label %43
43: ; preds = %37
%44 = load i32, i32* %7
%45 = add nsw i32 %44, 1
store i32 %45, i32* %7
br label %33
46: ; preds = %33
store i32 0, i32* %1
%47 = load i8*, i8** %3
%48 = load i32, i32* %1
ret i32 %48
}

LLVM IR (-O2):
@.str = [3 x i8] c"%d\00"
@.str.1 = [3 x i8] c"%c\00"
define i32 @main() {
%1 = alloca i32
%2 = bitcast i32* %1 to i8*
%3 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %1)
%4 = load i32, i32* %1
%5 = zext i32 %4 to i64
%6 = call i8* @llvm.stacksave()
%7 = alloca i8, i64 %5
%8 = load i32, i32* %1
%9 = zext i32 %8 to i64
%10 = alloca i8, i64 %9
%11 = add nsw i32 %8, -1
%12 = icmp sgt i32 %8, 1
br i1 %12, label %18, label %13
13: ; preds = %18, %0
%14 = phi i32 [ %11, %0 ], [ %24, %18 ]
%15 = call i32 @reverse_string(i8* %7, i8* %10, i32 %14, i32 0)
%16 = load i32, i32* %1
%17 = icmp sgt i32 %16, 0
br i1 %17, label %28, label %27
18: ; preds = %0, %18
%19 = phi i64 [ %22, %18 ], [ 0, %0 ]
%20 = getelementptr inbounds i8, i8* %7, i64 %19
%21 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %20)
%22 = add nuw nsw i64 %19, 1
%23 = load i32, i32* %1
%24 = add nsw i32 %23, -1
%25 = sext i32 %24 to i64
%26 = icmp slt i64 %22, %25
br i1 %26, label %18, label %13
27: ; preds = %28, %13
ret i32 0
28: ; preds = %13, %28
%29 = phi i64 [ %33, %28 ], [ 0, %13 ]
%30 = getelementptr inbounds i8, i8* %10, i64 %29
%31 = load i8, i8* %30
%32 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8 signext %31)
%33 = add nuw nsw i64 %29, 1
%34 = load i32, i32* %1
%35 = sext i32 %34 to i64
%36 = icmp slt i64 %33, %35
br i1 %36, label %28, label %27
}