#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++) {
    b[j] = a[j];
  }
  for (i = 0; a[i] != '\0'; i++) {
    b[i] = a[j -= 1];
  }
  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     1173 <main+0x63>
movslq -0xc(%rbp),%rax
mov    -0x13(%rbp,%rax,1),%cl
movslq -0xc(%rbp),%rax
mov    %cl,-0x70(%rbp,%rax,1)
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     11b1 <main+0xa1>
mov    -0xc(%rbp),%eax
sub    $0x1,%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    117a <main+0x6a>
movslq -0x8(%rbp),%rax
movb   $0x0,-0x70(%rbp,%rax,1)
lea    -0x13(%rbp),%rsi
lea    0xe42(%rip),%rdi
call   1030 <printf@plt>
lea    -0x70(%rbp),%rsi
lea    0xe39(%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
mov    $0x6f,%cl
xor    %eax,%eax
nopl   0x0(%rax,%rax,1)
mov    %cl,0x10(%rsp,%rax,1)
movzbl 0x9(%rsp,%rax,1),%ecx
add    $0x1,%rax
test   %cl,%cl
jne    1130 <main+0x20>
cltq
add    $0xffffffffffffffff,%rax
xor    %ecx,%ecx
nopl   0x0(%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 = %22, %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 %25
14: ; preds = %7
%15 = load i32, i32* %3
%16 = sext i32 %15 to i64
%17 = getelementptr inbounds [7 x i8], [7 x i8]* %4, i64 0, i64 %16
%18 = load i8, i8* %17
%19 = load i32, i32* %3
%20 = sext i32 %19 to i64
%21 = getelementptr inbounds [80 x i8], [80 x i8]* %5, i64 0, i64 %20
store i8 %18, i8* %21
br label %22
22: ; preds = %14
%23 = load i32, i32* %3
%24 = add nsw i32 %23, 1
store i32 %24, i32* %3
br label %7
25: ; preds = %7
store i32 0, i32* %2
br label %26
26: ; preds = %42, %25
%27 = load i32, i32* %2
%28 = sext i32 %27 to i64
%29 = getelementptr inbounds [7 x i8], [7 x i8]* %4, i64 0, i64 %28
%30 = load i8, i8* %29
%31 = sext i8 %30 to i32
%32 = icmp ne i32 %31, 0
br i1 %32, label %33, label %45
33: ; preds = %26
%34 = load i32, i32* %3
%35 = sub nsw i32 %34, 1
store i32 %35, i32* %3
%36 = sext i32 %35 to i64
%37 = getelementptr inbounds [7 x i8], [7 x i8]* %4, i64 0, i64 %36
%38 = load i8, i8* %37
%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 %38, i8* %41
br label %42
42: ; preds = %33
%43 = load i32, i32* %2
%44 = add nsw i32 %43, 1
store i32 %44, i32* %2
br label %26
45: ; preds = %26
%46 = load i32, i32* %2
%47 = sext i32 %46 to i64
%48 = getelementptr inbounds [80 x i8], [80 x i8]* %5, i64 0, i64 %47
store i8 0, i8* %48
%49 = getelementptr inbounds [7 x i8], [7 x i8]* %4, i64 0, i64 0
%50 = call i32 @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i8* %49)
%51 = getelementptr inbounds [80 x i8], [80 x i8]* %5, i64 0, i64 0
%52 = call i32 @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), i8* %51)
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 %8
5: ; preds = %8
%6 = shl i64 %12, 32
%7 = ashr exact i64 %6, 32
br label %16
8: ; preds = %0, %8
%9 = phi i64 [ 0, %0 ], [ %12, %8 ]
%10 = phi i8 [ 111, %0 ], [ %14, %8 ]
%11 = getelementptr inbounds [80 x i8], [80 x i8]* %2, i64 0, i64 %9
store i8 %10, i8* %11
%12 = add nuw nsw i64 %9, 1
%13 = getelementptr inbounds [7 x i8], [7 x i8]* %1, i64 0, i64 %12
%14 = load i8, i8* %13
%15 = icmp eq i8 %14, 0
br i1 %15, label %5, label %8
16: ; preds = %5, %16
%17 = phi i64 [ 0, %5 ], [ %23, %16 ]
%18 = phi i64 [ %7, %5 ], [ %19, %16 ]
%19 = add i64 %18, -1
%20 = getelementptr inbounds [7 x i8], [7 x i8]* %1, i64 0, i64 %19
%21 = load i8, i8* %20
%22 = getelementptr inbounds [80 x i8], [80 x i8]* %2, i64 0, i64 %17
store i8 %21, i8* %22
%23 = add nuw nsw i64 %17, 1
%24 = getelementptr inbounds [7 x i8], [7 x i8]* %1, i64 0, i64 %23
%25 = load i8, i8* %24
%26 = icmp eq i8 %25, 0
br i1 %26, label %27, label %16
27: ; preds = %16
%28 = and i64 %23, 4294967295
%29 = getelementptr inbounds [80 x i8], [80 x i8]* %2, i64 0, i64 %28
store i8 0, i8* %29
%30 = call i32 @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i8* %3)
%31 = call i32 @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), i8* %4)
ret i32 0
}