#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 /*<<< orphan*/ puts(char *);
int /*<<< orphan*/ stringcat(char *, char *, char *);
int strlen(char *);
void main() {
  char str[255];
  char str1[] = "hello";
  char str2[] = "world";
  printf("%d\n", strlen(str1));
  stringcat(str, str1, str2);
  puts(str);
  for (int i = 0; i <= 9; i++)
    printf("%c", str[i]);
  printf("\n");
  printf("%c\n", str[5]);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x110,%rsp
mov    0xeaf(%rip),%eax
mov    %eax,-0x106(%rbp)
mov    0xea6(%rip),%ax
mov    %ax,-0x102(%rbp)
mov    0xe9b(%rip),%eax
mov    %eax,-0x10c(%rbp)
mov    0xe92(%rip),%ax
mov    %ax,-0x108(%rbp)
lea    -0x106(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,%esi
lea    0xe78(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    -0x100(%rbp),%rdi
lea    -0x106(%rbp),%rsi
lea    -0x10c(%rbp),%rdx
call   1060 <stringcat@plt>
lea    -0x100(%rbp),%rdi
call   1030 <puts@plt>
movl   $0x0,-0x110(%rbp)
cmpl   $0x9,-0x110(%rbp)
jg     1209 <main+0xc9>
movslq -0x110(%rbp),%rax
movsbl -0x100(%rbp,%rax,1),%esi
ff
lea    0xe22(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x110(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x110(%rbp)
jmp    11cb <main+0x8b>
lea    0xe05(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
movsbl -0xfb(%rbp),%esi
lea    0xdee(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
add    $0x110,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
sub    $0x118,%rsp
movw   $0x6f,0xc(%rsp)
movl   $0x6c6c6568,0x8(%rsp)
6c
movw   $0x64,0x4(%rsp)
movl   $0x6c726f77,(%rsp)
lea    0x8(%rsp),%r14
mov    %r14,%rdi
call   1050 <strlen@plt>
lea    0xe81(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1060 <printf@plt>
lea    0x10(%rsp),%rbx
mov    %rsp,%rdx
mov    %rbx,%rdi
mov    %r14,%rsi
call   1070 <stringcat@plt>
mov    %rbx,%rdi
call   1040 <puts@plt>
movsbl 0x10(%rsp),%edi
call   1030 <putchar@plt>
movsbl 0x11(%rsp),%edi
call   1030 <putchar@plt>
movsbl 0x12(%rsp),%edi
call   1030 <putchar@plt>
movsbl 0x13(%rsp),%edi
call   1030 <putchar@plt>
movsbl 0x14(%rsp),%edi
call   1030 <putchar@plt>
movsbl 0x15(%rsp),%edi
call   1030 <putchar@plt>
movsbl 0x16(%rsp),%edi
call   1030 <putchar@plt>
movsbl 0x17(%rsp),%edi
call   1030 <putchar@plt>
movsbl 0x18(%rsp),%edi
call   1030 <putchar@plt>
movsbl 0x19(%rsp),%edi
call   1030 <putchar@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
movsbl 0x15(%rsp),%esi
lea    0xde7(%rip),%rdi
xor    %eax,%eax
call   1060 <printf@plt>
add    $0x118,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@__const.main.str1 = [6 x i8] c"hello\00"
@__const.main.str2 = [6 x i8] c"world\00"
@.str = [4 x i8] c"%d\0A\00"
@.str.1 = [3 x i8] c"%c\00"
@.str.2 = [2 x i8] c"\0A\00"
@.str.3 = [4 x i8] c"%c\0A\00"
define void @main() {
%1 = alloca [255 x i8]
%2 = alloca [6 x i8]
%3 = alloca [6 x i8]
%4 = alloca i32
%5 = bitcast [6 x i8]* %2 to i8*
%6 = bitcast [6 x i8]* %3 to i8*
%7 = getelementptr inbounds [6 x i8], [6 x i8]* %2, i64 0, i64 0
%8 = call i32 @strlen(i8* %7)
%9 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %8)
%10 = getelementptr inbounds [255 x i8], [255 x i8]* %1, i64 0, i64 0
%11 = getelementptr inbounds [6 x i8], [6 x i8]* %2, i64 0, i64 0
%12 = getelementptr inbounds [6 x i8], [6 x i8]* %3, i64 0, i64 0
%13 = call i32 @stringcat(i8* %10, i8* %11, i8* %12)
%14 = getelementptr inbounds [255 x i8], [255 x i8]* %1, i64 0, i64 0
%15 = call i32 @puts(i8* %14)
store i32 0, i32* %4
br label %16
16: ; preds = %26, %0
%17 = load i32, i32* %4
%18 = icmp sle i32 %17, 9
br i1 %18, label %19, label %29
19: ; preds = %16
%20 = load i32, i32* %4
%21 = sext i32 %20 to i64
%22 = getelementptr inbounds [255 x i8], [255 x i8]* %1, i64 0, i64 %21
%23 = load i8, i8* %22
%24 = sext i8 %23 to i32
%25 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32 %24)
br label %26
26: ; preds = %19
%27 = load i32, i32* %4
%28 = add nsw i32 %27, 1
store i32 %28, i32* %4
br label %16
29: ; preds = %16
%30 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%31 = getelementptr inbounds [255 x i8], [255 x i8]* %1, i64 0, i64 5
%32 = load i8, i8* %31
%33 = sext i8 %32 to i32
%34 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i32 %33)
ret void
}

LLVM IR (-O2):
@__const.main.str1 = [6 x i8] c"hello\00"
@__const.main.str2 = [6 x i8] c"world\00"
@.str = [4 x i8] c"%d\0A\00"
@.str.3 = [4 x i8] c"%c\0A\00"
define void @main() {
%1 = alloca [255 x i8]
%2 = alloca [6 x i8]
%3 = alloca [6 x i8]
%4 = getelementptr inbounds [255 x i8], [255 x i8]* %1, i64 0, i64 0
%5 = getelementptr inbounds [6 x i8], [6 x i8]* %2, i64 0, i64 0
%6 = getelementptr inbounds [6 x i8], [6 x i8]* %3, i64 0, i64 0
%7 = call i32 @strlen(i8* %5)
%8 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %7)
%9 = call i32 @stringcat(i8* %4, i8* %5, i8* %6)
%10 = call i32 @puts(i8* %4)
%11 = load i8, i8* %4
%12 = sext i8 %11 to i32
%13 = call i32 @putchar(i32 %12)
%14 = getelementptr inbounds [255 x i8], [255 x i8]* %1, i64 0, i64 1
%15 = load i8, i8* %14
%16 = sext i8 %15 to i32
%17 = call i32 @putchar(i32 %16)
%18 = getelementptr inbounds [255 x i8], [255 x i8]* %1, i64 0, i64 2
%19 = load i8, i8* %18
%20 = sext i8 %19 to i32
%21 = call i32 @putchar(i32 %20)
%22 = getelementptr inbounds [255 x i8], [255 x i8]* %1, i64 0, i64 3
%23 = load i8, i8* %22
%24 = sext i8 %23 to i32
%25 = call i32 @putchar(i32 %24)
%26 = getelementptr inbounds [255 x i8], [255 x i8]* %1, i64 0, i64 4
%27 = load i8, i8* %26
%28 = sext i8 %27 to i32
%29 = call i32 @putchar(i32 %28)
%30 = getelementptr inbounds [255 x i8], [255 x i8]* %1, i64 0, i64 5
%31 = load i8, i8* %30
%32 = sext i8 %31 to i32
%33 = call i32 @putchar(i32 %32)
%34 = getelementptr inbounds [255 x i8], [255 x i8]* %1, i64 0, i64 6
%35 = load i8, i8* %34
%36 = sext i8 %35 to i32
%37 = call i32 @putchar(i32 %36)
%38 = getelementptr inbounds [255 x i8], [255 x i8]* %1, i64 0, i64 7
%39 = load i8, i8* %38
%40 = sext i8 %39 to i32
%41 = call i32 @putchar(i32 %40)
%42 = getelementptr inbounds [255 x i8], [255 x i8]* %1, i64 0, i64 8
%43 = load i8, i8* %42
%44 = sext i8 %43 to i32
%45 = call i32 @putchar(i32 %44)
%46 = getelementptr inbounds [255 x i8], [255 x i8]* %1, i64 0, i64 9
%47 = load i8, i8* %46
%48 = sext i8 %47 to i32
%49 = call i32 @putchar(i32 %48)
%50 = call i32 @putchar(i32 10)
%51 = load i8, i8* %30
%52 = sext i8 %51 to i32
%53 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i32 %52)
ret void
}