#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 main() {
  int i, j;
  char a[] = "orange";
  char b[80];
  for (j = 0; a[j] != '\0'; j++)
    ;
  for (i = 0; a[i] != '\0'; i++) {
    b[i] = a[--j];
  }
  b[i] = '\0';
  printf("a: %s\n", a);
  printf("b: %s\n", b);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
movl   $0x0,-0x4(%rbp)
mov    0xedb(%rip),%eax
mov    %eax,-0x13(%rbp)
mov    0xed5(%rip),%ax
mov    %ax,-0xf(%rbp)
mov    0xecd(%rip),%al
mov    %al,-0xd(%rbp)
movl   $0x0,-0xc(%rbp)
movslq -0xc(%rbp),%rax
movsbl -0x13(%rbp,%rax,1),%eax
cmp    $0x0,%eax
je     1168 <main+0x58>
jmp    115a <main+0x4a>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1143 <main+0x33>
movl   $0x0,-0x8(%rbp)
movslq -0x8(%rbp),%rax
movsbl -0x13(%rbp,%rax,1),%eax
cmp    $0x0,%eax
je     11a6 <main+0x96>
mov    -0xc(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0xc(%rbp)
cltq
mov    -0x13(%rbp,%rax,1),%cl
movslq -0x8(%rbp),%rax
mov    %cl,-0x70(%rbp,%rax,1)
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    116f <main+0x5f>
movslq -0x8(%rbp),%rax
movb   $0x0,-0x70(%rbp,%rax,1)
lea    -0x13(%rbp),%rsi
lea    0xe4d(%rip),%rdi
call   1030 <printf@plt>
lea    -0x70(%rbp),%rsi
lea    0xe44(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x70,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
sub    $0x68,%rsp
movl   $0x65676e,0xb(%rsp)
movl   $0x6e61726f,0x8(%rsp)
6e
xor    %eax,%eax
cs nopw 0x0(%rax,%rax,1)
cmpb   $0x0,0x9(%rsp,%rax,1)
lea    0x1(%rax),%rax
jne    1130 <main+0x20>
cltq
add    $0xffffffffffffffff,%rax
xor    %ecx,%ecx
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
movzbl 0x8(%rsp,%rax,1),%edx
mov    %dl,0x10(%rsp,%rcx,1)
add    $0xffffffffffffffff,%rax
cmpb   $0x0,0x9(%rsp,%rcx,1)
lea    0x1(%rcx),%rcx
jne    1150 <main+0x40>
mov    %ecx,%eax
movb   $0x0,0x10(%rsp,%rax,1)
lea    0xe91(%rip),%rdi
lea    0x8(%rsp),%rsi
call   1030 <printf@plt>
lea    0xe87(%rip),%rdi
lea    0x10(%rsp),%rsi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x68,%rsp
ret

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

LLVM IR (-O2):
@__const.main.a = [7 x i8] c"orange\00"
@.str = [7 x i8] c"a: %s\0A\00"
@.str.1 = [7 x i8] c"b: %s\0A\00"
define i32 @main() {
%1 = alloca [7 x i8]
%2 = alloca [80 x i8]
%3 = getelementptr inbounds [7 x i8], [7 x i8]* %1, i64 0, i64 0
%4 = getelementptr inbounds [80 x i8], [80 x i8]* %2, i64 0, i64 0
br label %5
5: ; preds = %0, %5
%6 = phi i64 [ 1, %0 ], [ %10, %5 ]
%7 = getelementptr inbounds [7 x i8], [7 x i8]* %1, i64 0, i64 %6
%8 = load i8, i8* %7
%9 = icmp eq i8 %8, 0
%10 = add nuw i64 %6, 1
br i1 %9, label %11, label %5
11: ; preds = %5
%12 = shl i64 %6, 32
%13 = ashr exact i64 %12, 32
br label %14
14: ; preds = %11, %14
%15 = phi i64 [ 0, %11 ], [ %21, %14 ]
%16 = phi i64 [ %13, %11 ], [ %17, %14 ]
%17 = add i64 %16, -1
%18 = getelementptr inbounds [7 x i8], [7 x i8]* %1, i64 0, i64 %17
%19 = load i8, i8* %18
%20 = getelementptr inbounds [80 x i8], [80 x i8]* %2, i64 0, i64 %15
store i8 %19, i8* %20
%21 = add nuw nsw i64 %15, 1
%22 = getelementptr inbounds [7 x i8], [7 x i8]* %1, i64 0, i64 %21
%23 = load i8, i8* %22
%24 = icmp eq i8 %23, 0
br i1 %24, label %25, label %14
25: ; preds = %14
%26 = and i64 %21, 4294967295
%27 = getelementptr inbounds [80 x i8], [80 x i8]* %2, i64 0, i64 %26
store i8 0, i8* %27
%28 = call i32 @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i8* %3)
%29 = call i32 @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), i8* %4)
ret i32 0
}