#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 */
scalar_t__ malloc(int);
int /*<<< orphan*/ printf(char *, ...);
int main(void) {
  char *s1, *s2;
  s1 = (char *)malloc(10 * sizeof(char));
  s2 = (char *)malloc(10 * sizeof(char));
  s1 = "1234567890";
  s2 = "abcdefghij";
  printf("s1 address %p\ns2 address %p\n", s1, s2);
  printf("s1 value %s\ns2 value %s\n", s1, s2);
  int x;
  printf(" |s1--------s2--------|\n  ");
  for (x = 0; x < 10; x++) {
    printf("%c", s1[x]);
  }
  for (x = 0; x < 10; x++) {
    printf("%c", s2[x]);
  }
  printf("    print s1[0-9] s2[0-9]\n  ");
  for (x = 0; x < 22; x++) {
    printf("%c", s1[x]);
  }
  printf("    print s1[0-22] ( ( n + \\0 ) * 2) \n");
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    $0xa,%edi
call   1040 <malloc@plt>
mov    %rax,-0x10(%rbp)
mov    $0xa,%edi
call   1040 <malloc@plt>
mov    %rax,-0x18(%rbp)
lea    0xeae(%rip),%rax
mov    %rax,-0x10(%rbp)
lea    0xeae(%rip),%rax
mov    %rax,-0x18(%rbp)
mov    -0x10(%rbp),%rsi
mov    -0x18(%rbp),%rdx
lea    0xea6(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x10(%rbp),%rsi
mov    -0x18(%rbp),%rdx
lea    0xead(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xeb8(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x1c(%rbp)
cmpl   $0xa,-0x1c(%rbp)
jge    11d4 <main+0xb4>
mov    -0x10(%rbp),%rax
movslq -0x1c(%rbp),%rcx
movsbl (%rax,%rcx,1),%esi
lea    0xea8(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    11a2 <main+0x82>
movl   $0x0,-0x1c(%rbp)
cmpl   $0xa,-0x1c(%rbp)
jge    120d <main+0xed>
mov    -0x18(%rbp),%rax
movslq -0x1c(%rbp),%rcx
movsbl (%rax,%rcx,1),%esi
lea    0xe6f(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    11db <main+0xbb>
lea    0xe56(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x1c(%rbp)
cmpl   $0x16,-0x1c(%rbp)
jge    1254 <main+0x134>
mov    -0x10(%rbp),%rax
movslq -0x1c(%rbp),%rcx
movsbl (%rax,%rcx,1),%esi
lea    0xe28(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    1222 <main+0x102>
lea    0xe2c(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
push   %rax
mov    $0xa,%edi
call   1060 <malloc@plt>
mov    $0xa,%edi
call   1060 <malloc@plt>
lea    0xeb7(%rip),%rdi
lea    0xe9a(%rip),%rbx
lea    0xe9e(%rip),%r14
mov    %rbx,%rsi
mov    %r14,%rdx
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xeb2(%rip),%rdi
mov    %rbx,%rsi
mov    %r14,%rdx
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xeb7(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    $0x31,%edi
call   1030 <putchar@plt>
mov    $0x32,%edi
call   1030 <putchar@plt>
mov    $0x33,%edi
call   1030 <putchar@plt>
mov    $0x34,%edi
call   1030 <putchar@plt>
mov    $0x35,%edi
call   1030 <putchar@plt>
mov    $0x36,%edi
call   1030 <putchar@plt>
mov    $0x37,%edi
call   1030 <putchar@plt>
mov    $0x38,%edi
call   1030 <putchar@plt>
mov    $0x39,%edi
call   1030 <putchar@plt>
mov    $0x30,%edi
call   1030 <putchar@plt>
mov    $0x61,%edi
call   1030 <putchar@plt>
mov    $0x62,%edi
call   1030 <putchar@plt>
mov    $0x63,%edi
call   1030 <putchar@plt>
mov    $0x64,%edi
call   1030 <putchar@plt>
mov    $0x65,%edi
call   1030 <putchar@plt>
mov    $0x66,%edi
call   1030 <putchar@plt>
mov    $0x67,%edi
call   1030 <putchar@plt>
mov    $0x68,%edi
call   1030 <putchar@plt>
mov    $0x69,%edi
call   1030 <putchar@plt>
mov    $0x6a,%edi
call   1030 <putchar@plt>
lea    0xdfc(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    $0x31,%edi
call   1030 <putchar@plt>
mov    $0x32,%edi
call   1030 <putchar@plt>
mov    $0x33,%edi
call   1030 <putchar@plt>
mov    $0x34,%edi
call   1030 <putchar@plt>
mov    $0x35,%edi
call   1030 <putchar@plt>
mov    $0x36,%edi
call   1030 <putchar@plt>
mov    $0x37,%edi
call   1030 <putchar@plt>
mov    $0x38,%edi
call   1030 <putchar@plt>
mov    $0x39,%edi
call   1030 <putchar@plt>
mov    $0x30,%edi
call   1030 <putchar@plt>
xor    %edi,%edi
call   1030 <putchar@plt>
xor    %edi,%edi
call   1030 <putchar@plt>
xor    %edi,%edi
call   1030 <putchar@plt>
xor    %edi,%edi
call   1030 <putchar@plt>
xor    %edi,%edi
call   1030 <putchar@plt>
xor    %edi,%edi
call   1030 <putchar@plt>
xor    %edi,%edi
call   1030 <putchar@plt>
xor    %edi,%edi
call   1030 <putchar@plt>
xor    %edi,%edi
call   1030 <putchar@plt>
xor    %edi,%edi
call   1030 <putchar@plt>
xor    %edi,%edi
call   1030 <putchar@plt>
xor    %edi,%edi
call   1030 <putchar@plt>
lea    0xd53(%rip),%rdi
call   1040 <puts@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [11 x i8] c"1234567890\00"
@.str.1 = [11 x i8] c"abcdefghij\00"
@.str.2 = [29 x i8] c"s1 address %p\0As2 address %p\0A\00"
@.str.3 = [25 x i8] c"s1 value %s\0As2 value %s\0A\00"
@.str.4 = [27 x i8] c" |s1--------s2--------|\0A \00"
@.str.5 = [3 x i8] c"%c\00"
@.str.6 = [29 x i8] c" print s1[0-9] s2[0-9]\0A \00"
@.str.7 = [39 x i8] c" print s1[0-22] ( ( n + \\0 ) * 2) \0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i8*
%3 = alloca i8*
%4 = alloca i32
store i32 0, i32* %1
%5 = call i64 @malloc(i32 10)
%6 = inttoptr i64 %5 to i8*
store i8* %6, i8** %2
%7 = call i64 @malloc(i32 10)
%8 = inttoptr i64 %7 to i8*
store i8* %8, i8** %3
store i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i8** %2
store i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0), i8** %3
%9 = load i8*, i8** %2
%10 = load i8*, i8** %3
%11 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.2, i64 0, i64 0), i8* %9, i8* %10)
%12 = load i8*, i8** %2
%13 = load i8*, i8** %3
%14 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.3, i64 0, i64 0), i8* %12, i8* %13)
%15 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.4, i64 0, i64 0))
store i32 0, i32* %4
br label %16
16: ; preds = %27, %0
%17 = load i32, i32* %4
%18 = icmp slt i32 %17, 10
br i1 %18, label %19, label %30
19: ; preds = %16
%20 = load i8*, i8** %2
%21 = load i32, i32* %4
%22 = sext i32 %21 to i64
%23 = getelementptr inbounds i8, i8* %20, i64 %22
%24 = load i8, i8* %23
%25 = sext i8 %24 to i32
%26 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0), i32 %25)
br label %27
27: ; preds = %19
%28 = load i32, i32* %4
%29 = add nsw i32 %28, 1
store i32 %29, i32* %4
br label %16
30: ; preds = %16
store i32 0, i32* %4
br label %31
31: ; preds = %42, %30
%32 = load i32, i32* %4
%33 = icmp slt i32 %32, 10
br i1 %33, label %34, label %45
34: ; preds = %31
%35 = load i8*, i8** %3
%36 = load i32, i32* %4
%37 = sext i32 %36 to i64
%38 = getelementptr inbounds i8, i8* %35, i64 %37
%39 = load i8, i8* %38
%40 = sext i8 %39 to i32
%41 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0), i32 %40)
br label %42
42: ; preds = %34
%43 = load i32, i32* %4
%44 = add nsw i32 %43, 1
store i32 %44, i32* %4
br label %31
45: ; preds = %31
%46 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.6, i64 0, i64 0))
store i32 0, i32* %4
br label %47
47: ; preds = %58, %45
%48 = load i32, i32* %4
%49 = icmp slt i32 %48, 22
br i1 %49, label %50, label %61
50: ; preds = %47
%51 = load i8*, i8** %2
%52 = load i32, i32* %4
%53 = sext i32 %52 to i64
%54 = getelementptr inbounds i8, i8* %51, i64 %53
%55 = load i8, i8* %54
%56 = sext i8 %55 to i32
%57 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0), i32 %56)
br label %58
58: ; preds = %50
%59 = load i32, i32* %4
%60 = add nsw i32 %59, 1
store i32 %60, i32* %4
br label %47
61: ; preds = %47
%62 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.7, i64 0, i64 0))
ret i32 0
}

LLVM IR (-O2):
@.str = [11 x i8] c"1234567890\00"
@.str.1 = [11 x i8] c"abcdefghij\00"
@.str.2 = [29 x i8] c"s1 address %p\0As2 address %p\0A\00"
@.str.3 = [25 x i8] c"s1 value %s\0As2 value %s\0A\00"
@.str.4 = [27 x i8] c" |s1--------s2--------|\0A \00"
@.str.6 = [29 x i8] c" print s1[0-9] s2[0-9]\0A \00"
@str = [38 x i8] c" print s1[0-22] ( ( n + \\0 ) * 2) \00"
define i32 @main() {
%1 = tail call i64 @malloc(i32 10)
%2 = tail call i64 @malloc(i32 10)
%3 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([29 x i8], [29 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0))
%4 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0))
%5 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @.str.4, i64 0, i64 0))
%6 = tail call i32 @putchar(i32 49)
%7 = tail call i32 @putchar(i32 50)
%8 = tail call i32 @putchar(i32 51)
%9 = tail call i32 @putchar(i32 52)
%10 = tail call i32 @putchar(i32 53)
%11 = tail call i32 @putchar(i32 54)
%12 = tail call i32 @putchar(i32 55)
%13 = tail call i32 @putchar(i32 56)
%14 = tail call i32 @putchar(i32 57)
%15 = tail call i32 @putchar(i32 48)
%16 = tail call i32 @putchar(i32 97)
%17 = tail call i32 @putchar(i32 98)
%18 = tail call i32 @putchar(i32 99)
%19 = tail call i32 @putchar(i32 100)
%20 = tail call i32 @putchar(i32 101)
%21 = tail call i32 @putchar(i32 102)
%22 = tail call i32 @putchar(i32 103)
%23 = tail call i32 @putchar(i32 104)
%24 = tail call i32 @putchar(i32 105)
%25 = tail call i32 @putchar(i32 106)
%26 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([29 x i8], [29 x i8]* @.str.6, i64 0, i64 0))
%27 = tail call i32 @putchar(i32 49)
%28 = tail call i32 @putchar(i32 50)
%29 = tail call i32 @putchar(i32 51)
%30 = tail call i32 @putchar(i32 52)
%31 = tail call i32 @putchar(i32 53)
%32 = tail call i32 @putchar(i32 54)
%33 = tail call i32 @putchar(i32 55)
%34 = tail call i32 @putchar(i32 56)
%35 = tail call i32 @putchar(i32 57)
%36 = tail call i32 @putchar(i32 48)
%37 = tail call i32 @putchar(i32 0)
%38 = tail call i32 @putchar(i32 0)
%39 = tail call i32 @putchar(i32 0)
%40 = tail call i32 @putchar(i32 0)
%41 = tail call i32 @putchar(i32 0)
%42 = tail call i32 @putchar(i32 0)
%43 = tail call i32 @putchar(i32 0)
%44 = tail call i32 @putchar(i32 0)
%45 = tail call i32 @putchar(i32 0)
%46 = tail call i32 @putchar(i32 0)
%47 = tail call i32 @putchar(i32 0)
%48 = tail call i32 @putchar(i32 0)
%49 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([38 x i8], [38 x i8]* @str, i64 0, i64 0))
ret i32 0
}