#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 *, int, char);
void xxx(char *to, const char *from) {
  int i = 0;
  while (to[i] = from[i] != '\0') {
    printf("to[%i] = %i\n", i, to[i]);
    i++;
  }
  printf("to[%i] = %i\n", i, to[i]);
}


x86 assembly (clang, -O0):
<xxx>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x0,%eax
setne  %al
and    $0x1,%al
movzbl %al,%eax
mov    -0x8(%rbp),%rcx
movslq -0x14(%rbp),%rdx
mov    %al,(%rcx,%rdx,1)
cmp    $0x0,%al
je     117a <xxx+0x6a>
mov    -0x14(%rbp),%esi
mov    -0x8(%rbp),%rax
movslq -0x14(%rbp),%rcx
lea    0xe9d(%rip),%rdi
movsbl (%rax,%rcx,1),%edx
call   1030 <printf@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1127 <xxx+0x17>
mov    -0x14(%rbp),%esi
mov    -0x8(%rbp),%rax
movslq -0x14(%rbp),%rcx
lea    0xe74(%rip),%rdi
movsbl (%rax,%rcx,1),%edx
call   1030 <printf@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<xxx>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
cmpb   $0x0,(%rsi)
setne  (%rdi)
je     1154 <xxx+0x44>
mov    %rsi,%r14
mov    %rdi,%r12
xor    %esi,%esi
lea    0xed1(%rip),%r15
nop
mov    %rsi,%rbx
mov    %r15,%rdi
mov    $0x1,%edx
call   1030 <printf@plt>
cmpb   $0x0,0x1(%r14,%rbx,1)
lea    0x1(%rbx),%rsi
setne  0x1(%r12,%rbx,1)
jne    1130 <xxx+0x20>
jmp    1156 <xxx+0x46>
xor    %esi,%esi
lea    0xea3(%rip),%rdi
xor    %edx,%edx
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
jmp    1030 <printf@plt>

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

LLVM IR (-O2):
@.str = [13 x i8] c"to[%i] = %i\0A\00"
define void @xxx(i8* nocapture writeonly %0, i8* nocapture %1) {
%3 = load i8, i8* %1
%4 = icmp ne i8 %3, 0
%5 = zext i1 %4 to i8
store i8 %5, i8* %0
br i1 %4, label %6, label %18
6: ; preds = %2, %6
%7 = phi i64 [ %10, %6 ], [ 0, %2 ]
%8 = trunc i64 %7 to i32
%9 = tail call i32 @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), i32 %8, i8 signext 1)
%10 = add nuw i64 %7, 1
%11 = getelementptr inbounds i8, i8* %1, i64 %10
%12 = load i8, i8* %11
%13 = icmp ne i8 %12, 0
%14 = zext i1 %13 to i8
%15 = getelementptr inbounds i8, i8* %0, i64 %10
store i8 %14, i8* %15
br i1 %13, label %6, label %16
16: ; preds = %6
%17 = trunc i64 %10 to i32
br label %18
18: ; preds = %16, %2
%19 = phi i32 [ 0, %2 ], [ %17, %16 ]
%20 = tail call i32 @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), i32 %19, i8 signext 0)
ret void
}