#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*/ free(char *);
scalar_t__ malloc(int);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ strcpy(char *, char *);
int strlen(char *);
void print_chars() {
  printf("Regular Chars\n");
  char c1[] = {'T', 'e', 'x', 't', '1', '\0'};
  char c2[] = "Text2";
  char *c3 = "Text3";
  char *c4 = (char *)malloc(6 * sizeof(char));
  strcpy(c4, "Text4");
  char *c5[] = {"Test", "Some", "Strings"};
  printf("String c lengths %i %i %i %i\n", strlen(c1), strlen(c2), strlen(c3),
         strlen(c4));
  printf("String c1 %s\n", c1);
  printf("String c2 %s\n", c2);
  printf("String c3 %s\n", c3);
  printf("String c4 %s\n", c4);
  printf("%s %s %s\n", c5[0], c5[1], c5[2]);
  free(c4);
}


x86 assembly (clang, -O0):
<print_chars>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
lea    0xea1(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    0xea3(%rip),%eax
mov    %eax,-0x6(%rbp)
mov    0xe9d(%rip),%ax
mov    %ax,-0x2(%rbp)
mov    0xe95(%rip),%eax
mov    %eax,-0xc(%rbp)
mov    0xe8f(%rip),%ax
mov    %ax,-0x8(%rbp)
lea    0xe86(%rip),%rax
mov    %rax,-0x18(%rbp)
mov    $0x6,%edi
call   1070 <malloc@plt>
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rdi
lea    0xe6f(%rip),%rsi
call   1040 <strcpy@plt>
mov    0x2c42(%rip),%rax
mov    %rax,-0x40(%rbp)
mov    0x2c3f(%rip),%rax
mov    %rax,-0x38(%rbp)
mov    0x2c3c(%rip),%rax
mov    %rax,-0x30(%rbp)
lea    -0x6(%rbp),%rdi
call   1050 <strlen@plt>
mov    %eax,-0x4c(%rbp)
lea    -0xc(%rbp),%rdi
call   1050 <strlen@plt>
mov    %eax,-0x48(%rbp)
mov    -0x18(%rbp),%rdi
call   1050 <strlen@plt>
mov    %eax,-0x44(%rbp)
mov    -0x20(%rbp),%rdi
call   1050 <strlen@plt>
mov    -0x4c(%rbp),%esi
mov    -0x48(%rbp),%edx
mov    -0x44(%rbp),%ecx
mov    %eax,%r8d
lea    0xe21(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
lea    -0x6(%rbp),%rsi
lea    0xe2d(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
lea    -0xc(%rbp),%rsi
lea    0xe29(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    -0x18(%rbp),%rsi
lea    0xe25(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    -0x20(%rbp),%rsi
lea    0xe21(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    -0x40(%rbp),%rsi
mov    -0x38(%rbp),%rdx
mov    -0x30(%rbp),%rcx
lea    0xe15(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    -0x20(%rbp),%rdi
call   1030 <free@plt>
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<print_chars>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
lea    0xf15(%rip),%rdi
call   1050 <puts@plt>
movw   $0x31,0x14(%rsp)
movl   $0x74786554,0x10(%rsp)
74
movw   $0x32,0xc(%rsp)
movl   $0x74786554,0x8(%rsp)
74
mov    $0x6,%edi
call   1080 <malloc@plt>
mov    %rax,%rbx
lea    0xe66(%rip),%rsi
mov    %rax,%rdi
call   1040 <strcpy@plt>
lea    0x10(%rsp),%r12
mov    %r12,%rdi
call   1060 <strlen@plt>
mov    %eax,%r13d
lea    0x8(%rsp),%r15
mov    %r15,%rdi
call   1060 <strlen@plt>
mov    %eax,%ebp
lea    0xe32(%rip),%rdi
call   1060 <strlen@plt>
mov    %eax,%r14d
mov    %rbx,%rdi
call   1060 <strlen@plt>
lea    0xe39(%rip),%rdi
mov    %r13d,%esi
mov    %ebp,%edx
mov    %r14d,%ecx
mov    %eax,%r8d
xor    %eax,%eax
call   1070 <printf@plt>
lea    0xe3e(%rip),%rdi
mov    %r12,%rsi
xor    %eax,%eax
call   1070 <printf@plt>
lea    0xe3b(%rip),%rdi
mov    %r15,%rsi
xor    %eax,%eax
call   1070 <printf@plt>
lea    0xe38(%rip),%rdi
lea    0xdd9(%rip),%rsi
xor    %eax,%eax
call   1070 <printf@plt>
lea    0xe31(%rip),%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1070 <printf@plt>
lea    0xe2e(%rip),%rdi
lea    0xdbf(%rip),%rsi
lea    0xdbd(%rip),%rdx
lea    0xdbb(%rip),%rcx
xor    %eax,%eax
call   1070 <printf@plt>
mov    %rbx,%rdi
call   1030 <free@plt>
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [15 x i8] c"Regular Chars\0A\00"
@__const.print_chars.c1 = [6 x i8] c"Text1\00"
@__const.print_chars.c2 = [6 x i8] c"Text2\00"
@.str.1 = [6 x i8] c"Text3\00"
@.str.2 = [6 x i8] c"Text4\00"
@.str.3 = [5 x i8] c"Test\00"
@.str.4 = [5 x i8] c"Some\00"
@.str.5 = [8 x i8] c"Strings\00"
@__const.print_chars.c5 = [3 x i8*] [i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i32 0, i32 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i32 0, i32 0), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.5, i32 0, i32 0)]
@.str.6 = [30 x i8] c"String c lengths %i %i %i %i\0A\00"
@.str.7 = [14 x i8] c"String c1 %s\0A\00"
@.str.8 = [14 x i8] c"String c2 %s\0A\00"
@.str.9 = [14 x i8] c"String c3 %s\0A\00"
@.str.10 = [14 x i8] c"String c4 %s\0A\00"
@.str.11 = [10 x i8] c"%s %s %s\0A\00"
define void @print_chars() {
%1 = alloca [6 x i8]
%2 = alloca [6 x i8]
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca [3 x i8*]
%6 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0))
%7 = bitcast [6 x i8]* %1 to i8*
%8 = bitcast [6 x i8]* %2 to i8*
store i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i8** %3
%9 = call i64 @malloc(i32 6)
%10 = inttoptr i64 %9 to i8*
store i8* %10, i8** %4
%11 = load i8*, i8** %4
%12 = call i32 @strcpy(i8* %11, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0))
%13 = bitcast [3 x i8*]* %5 to i8*
%14 = getelementptr inbounds [6 x i8], [6 x i8]* %1, i64 0, i64 0
%15 = call i32 @strlen(i8* %14)
%16 = getelementptr inbounds [6 x i8], [6 x i8]* %2, i64 0, i64 0
%17 = call i32 @strlen(i8* %16)
%18 = load i8*, i8** %3
%19 = call i32 @strlen(i8* %18)
%20 = load i8*, i8** %4
%21 = call i32 @strlen(i8* %20)
%22 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.6, i64 0, i64 0), i32 %15, i32 %17, i32 %19, i32 %21)
%23 = getelementptr inbounds [6 x i8], [6 x i8]* %1, i64 0, i64 0
%24 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.7, i64 0, i64 0), i8* %23)
%25 = getelementptr inbounds [6 x i8], [6 x i8]* %2, i64 0, i64 0
%26 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.8, i64 0, i64 0), i8* %25)
%27 = load i8*, i8** %3
%28 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.9, i64 0, i64 0), i8* %27)
%29 = load i8*, i8** %4
%30 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.10, i64 0, i64 0), i8* %29)
%31 = getelementptr inbounds [3 x i8*], [3 x i8*]* %5, i64 0, i64 0
%32 = load i8*, i8** %31
%33 = getelementptr inbounds [3 x i8*], [3 x i8*]* %5, i64 0, i64 1
%34 = load i8*, i8** %33
%35 = getelementptr inbounds [3 x i8*], [3 x i8*]* %5, i64 0, i64 2
%36 = load i8*, i8** %35
%37 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.11, i64 0, i64 0), i8* %32, i8* %34, i8* %36)
%38 = load i8*, i8** %4
%39 = call i32 @free(i8* %38)
ret void
}

LLVM IR (-O2):
@__const.print_chars.c1 = [6 x i8] c"Text1\00"
@__const.print_chars.c2 = [6 x i8] c"Text2\00"
@.str.1 = [6 x i8] c"Text3\00"
@.str.2 = [6 x i8] c"Text4\00"
@.str.3 = [5 x i8] c"Test\00"
@.str.4 = [5 x i8] c"Some\00"
@.str.5 = [8 x i8] c"Strings\00"
@.str.6 = [30 x i8] c"String c lengths %i %i %i %i\0A\00"
@.str.7 = [14 x i8] c"String c1 %s\0A\00"
@.str.8 = [14 x i8] c"String c2 %s\0A\00"
@.str.9 = [14 x i8] c"String c3 %s\0A\00"
@.str.10 = [14 x i8] c"String c4 %s\0A\00"
@.str.11 = [10 x i8] c"%s %s %s\0A\00"
@str = [14 x i8] c"Regular Chars\00"
define void @print_chars() {
%1 = alloca [6 x i8]
%2 = alloca [6 x i8]
%3 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @str, i64 0, i64 0))
%4 = getelementptr inbounds [6 x i8], [6 x i8]* %1, i64 0, i64 0
%5 = getelementptr inbounds [6 x i8], [6 x i8]* %2, i64 0, i64 0
%6 = tail call i64 @malloc(i32 6)
%7 = inttoptr i64 %6 to i8*
%8 = tail call i32 @strcpy(i8* %7, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0))
%9 = call i32 @strlen(i8* %4)
%10 = call i32 @strlen(i8* %5)
%11 = call i32 @strlen(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0))
%12 = call i32 @strlen(i8* %7)
%13 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([30 x i8], [30 x i8]* @.str.6, i64 0, i64 0), i32 %9, i32 %10, i32 %11, i32 %12)
%14 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @.str.7, i64 0, i64 0), i8* %4)
%15 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @.str.8, i64 0, i64 0), i8* %5)
%16 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @.str.9, i64 0, i64 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0))
%17 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @.str.10, i64 0, i64 0), i8* %7)
%18 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @.str.11, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.5, i64 0, i64 0))
%19 = call i32 @free(i8* %7)
ret void
}