#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 main() {
  int x = 'a';
  char y = x;
  char *a = "hello";
  printf("%s\n", a);
  int c;
  c = *a;
  char *b;
  for (b = a; *b != 0; b++)
    printf("%c: %d\n", *b, *b);
  char destarray[10];
  char *dest = &destarray[0];
  char *src = a;
  while (*src != 0)
    *dest++ = *src++;
  *dest = 0;
  printf("copied string is %s\n", destarray);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x61,-0x8(%rbp)
mov    -0x8(%rbp),%eax
mov    %al,-0x9(%rbp)
lea    0xecd(%rip),%rax
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rsi
lea    0xedd(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x18(%rbp),%rax
movsbl (%rax),%eax
mov    %eax,-0x1c(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
je     1198 <main+0x88>
mov    -0x28(%rbp),%rax
movsbl (%rax),%esi
mov    -0x28(%rbp),%rax
movsbl (%rax),%edx
lea    0xe86(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x28(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x28(%rbp)
jmp    115b <main+0x4b>
lea    -0x32(%rbp),%rax
mov    %rax,-0x40(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,-0x48(%rbp)
mov    -0x48(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
je     11df <main+0xcf>
mov    -0x48(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x48(%rbp)
mov    (%rax),%cl
mov    -0x40(%rbp),%rax
mov    %rax,%rdx
add    $0x1,%rdx
mov    %rdx,-0x40(%rbp)
mov    %cl,(%rax)
jmp    11a8 <main+0x98>
mov    -0x40(%rbp),%rax
movb   $0x0,(%rax)
lea    -0x32(%rbp),%rsi
lea    0xe1d(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x10,%rsp
lea    0xed4(%rip),%rdi
call   1030 <puts@plt>
lea    0xece(%rip),%rbx
mov    %rbx,%rdi
mov    $0x68,%esi
mov    $0x68,%edx
xor    %eax,%eax
call   1040 <printf@plt>
mov    %rbx,%rdi
mov    $0x65,%esi
mov    $0x65,%edx
xor    %eax,%eax
call   1040 <printf@plt>
mov    %rbx,%rdi
mov    $0x6c,%esi
mov    $0x6c,%edx
xor    %eax,%eax
call   1040 <printf@plt>
mov    %rbx,%rdi
mov    $0x6c,%esi
mov    $0x6c,%edx
xor    %eax,%eax
call   1040 <printf@plt>
mov    %rbx,%rdi
mov    $0x6f,%esi
mov    $0x6f,%edx
xor    %eax,%eax
call   1040 <printf@plt>
movl   $0x6c6c6568,0x6(%rsp)
6c
movw   $0x6f,0xa(%rsp)
lea    0xe5c(%rip),%rdi
lea    0x6(%rsp),%rsi
xor    %eax,%eax
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
ret

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

LLVM IR (-O2):
@.str = [6 x i8] c"hello\00"
@.str.2 = [8 x i8] c"%c: %d\0A\00"
@.str.3 = [21 x i8] c"copied string is %s\0A\00"
define i32 @main() {
%1 = alloca [10 x i8]
%2 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0))
%3 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0), i32 104, i32 104)
%4 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0), i32 101, i32 101)
%5 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0), i32 108, i32 108)
%6 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0), i32 108, i32 108)
%7 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0), i32 111, i32 111)
%8 = getelementptr inbounds [10 x i8], [10 x i8]* %1, i64 0, i64 0
%9 = getelementptr inbounds [10 x i8], [10 x i8]* %1, i64 0, i64 1
store i8 104, i8* %8
%10 = getelementptr inbounds [10 x i8], [10 x i8]* %1, i64 0, i64 2
store i8 101, i8* %9
%11 = getelementptr inbounds [10 x i8], [10 x i8]* %1, i64 0, i64 3
store i8 108, i8* %10
%12 = getelementptr inbounds [10 x i8], [10 x i8]* %1, i64 0, i64 4
store i8 108, i8* %11
%13 = getelementptr inbounds [10 x i8], [10 x i8]* %1, i64 0, i64 5
store i8 111, i8* %12
store i8 0, i8* %13
%14 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @.str.3, i64 0, i64 0), i8* %8)
ret i32 0
}