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


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x80,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x78(%rbp)
lea    0xec0(%rip),%rdi
lea    -0x74(%rbp),%rsi
mov    $0x0,%al
call   1030 <scanf@plt>
mov    -0x78(%rbp),%eax
mov    -0x74(%rbp),%ecx
sub    $0x1,%ecx
cmp    %ecx,%eax
je     1183 <main+0x63>
movslq -0x78(%rbp),%rax
lea    -0x70(%rbp),%rsi
add    %rax,%rsi
lea    0xe96(%rip),%rdi
mov    $0x0,%al
call   1030 <scanf@plt>
mov    -0x78(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x78(%rbp)
jmp    114b <main+0x2b>
movslq -0x78(%rbp),%rax
movb   $0x0,-0x70(%rbp,%rax,1)
movl   $0x0,-0x78(%rbp)
lea    -0x70(%rbp),%rdi
mov    -0x74(%rbp),%esi
mov    -0x78(%rbp),%edx
call   1040 <print_rev@plt>
xor    %eax,%eax
add    $0x80,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
sub    $0x78,%rsp
lea    0xed2(%rip),%rdi
xor    %ebx,%ebx
lea    0xc(%rsp),%rsi
xor    %eax,%eax
call   1030 <scanf@plt>
cmpl   $0x1,0xc(%rsp)
jne    114a <main+0x2a>
mov    $0x1,%esi
jmp    1184 <main+0x64>
lea    0xeb3(%rip),%r14
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
lea    (%rsp,%rbx,1),%rsi
add    $0x10,%rsi
mov    %r14,%rdi
xor    %eax,%eax
call   1030 <scanf@plt>
add    $0x1,%rbx
mov    0xc(%rsp),%esi
lea    -0x1(%rsi),%eax
cmp    %rax,%rbx
jne    1160 <main+0x40>
mov    %ebx,%ebx
movb   $0x0,0x10(%rsp,%rbx,1)
lea    0x10(%rsp),%rdi
xor    %edx,%edx
call   1040 <print_rev@plt>
xor    %eax,%eax
add    $0x78,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [4 x i8] c"%c\0A\00"
@.str.1 = [3 x i8] c"%c\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [100 x i8]
%3 = alloca i32
%4 = alloca i32
store i32 0, i32* %1
store i32 0, i32* %4
%5 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32* %3)
br label %6
6: ; preds = %11, %0
%7 = load i32, i32* %4
%8 = load i32, i32* %3
%9 = sub nsw i32 %8, 1
%10 = icmp ne i32 %7, %9
br i1 %10, label %11, label %18
11: ; preds = %6
%12 = load i32, i32* %4
%13 = sext i32 %12 to i64
%14 = getelementptr inbounds [100 x i8], [100 x i8]* %2, i64 0, i64 %13
%15 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %14)
%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* %4
%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
store i32 0, i32* %4
%22 = getelementptr inbounds [100 x i8], [100 x i8]* %2, i64 0, i64 0
%23 = load i32, i32* %3
%24 = load i32, i32* %4
%25 = call i32 @print_rev(i8* %22, i32 %23, i32 %24)
ret i32 0
}

LLVM IR (-O2):
@.str = [4 x i8] c"%c\0A\00"
@.str.1 = [3 x i8] c"%c\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 ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32* %2)
%6 = load i32, i32* %2
%7 = icmp eq i32 %6, 1
br i1 %7, label %19, label %8
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 i64 %9, 1
%13 = load i32, i32* %2
%14 = add nsw i32 %13, -1
%15 = zext i32 %14 to i64
%16 = icmp eq i64 %12, %15
br i1 %16, label %17, label %8
17: ; preds = %8
%18 = and i64 %12, 4294967295
br label %19
19: ; preds = %17, %0
%20 = phi i64 [ 0, %0 ], [ %18, %17 ]
%21 = phi i32 [ 1, %0 ], [ %13, %17 ]
%22 = getelementptr inbounds [100 x i8], [100 x i8]* %1, i64 0, i64 %20
store i8 0, i8* %22
%23 = call i32 @print_rev(i8* %3, i32 %21, i32 0)
ret i32 0
}