#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*/ fprintf(int /*<<< orphan*/, char *);
int /*<<< orphan*/ printf(char *, char *);
int /*<<< orphan*/ stderr;
scalar_t__ str_cat(char *, char *);
int main(void) {
  char s1[128] = "hello";
  char *s2 = " world";
  if (str_cat(s1, s2))
    printf("%s\n", s1);
  else
    fprintf(stderr, "str_cat: failed concatenate strings.\n");
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0xa0,%rsp
movl   $0x0,-0x4(%rbp)
lea    -0x90(%rbp),%rdi
xor    %esi,%esi
mov    $0x80,%edx
call   1040 <memset@plt>
movb   $0x68,-0x90(%rbp)
movb   $0x65,-0x8f(%rbp)
movb   $0x6c,-0x8e(%rbp)
movb   $0x6c,-0x8d(%rbp)
movb   $0x6f,-0x8c(%rbp)
lea    0xe71(%rip),%rax
mov    %rax,-0x98(%rbp)
lea    -0x90(%rbp),%rdi
mov    -0x98(%rbp),%rsi
call   1060 <str_cat@plt>
cmp    $0x0,%rax
je     11cb <main+0x8b>
lea    -0x90(%rbp),%rsi
lea    0xe46(%rip),%rdi
call   1030 <printf@plt>
jmp    11e0 <main+0xa0>
mov    0x2e0e(%rip),%rax
mov    (%rax),%edi
lea    0xe30(%rip),%rsi
call   1050 <fprintf@plt>
xor    %eax,%eax
add    $0xa0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
sub    $0x88,%rsp
xorps  %xmm0,%xmm0
movaps %xmm0,(%rsp)
movaps %xmm0,0x70(%rsp)
movaps %xmm0,0x60(%rsp)
movaps %xmm0,0x50(%rsp)
movaps %xmm0,0x40(%rsp)
movaps %xmm0,0x30(%rsp)
movaps %xmm0,0x20(%rsp)
movaps %xmm0,0x10(%rsp)
movl   $0x6c6c6568,(%rsp)
movb   $0x6f,0x4(%rsp)
lea    0xe8c(%rip),%rsi
mov    %rsp,%rdi
call   1050 <str_cat@plt>
test   %rax,%rax
je     1192 <main+0x62>
lea    0xe7f(%rip),%rdi
mov    %rsp,%rsi
call   1030 <printf@plt>
jmp    11a7 <main+0x77>
mov    0x2e47(%rip),%rax
mov    (%rax),%edi
lea    0xe69(%rip),%rsi
call   1040 <fprintf@plt>
xor    %eax,%eax
add    $0x88,%rsp
ret

LLVM IR (-O0):
@.str = [7 x i8] c" world\00"
@.str.1 = [4 x i8] c"%s\0A\00"
@stderr = global i32 0
@.str.2 = [38 x i8] c"str_cat: failed concatenate strings.\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [128 x i8]
%3 = alloca i8*
store i32 0, i32* %1
%4 = bitcast [128 x i8]* %2 to i8*
%5 = bitcast i8* %4 to [128 x i8]*
%6 = getelementptr inbounds [128 x i8], [128 x i8]* %5, i32 0, i32 0
store i8 104, i8* %6
%7 = getelementptr inbounds [128 x i8], [128 x i8]* %5, i32 0, i32 1
store i8 101, i8* %7
%8 = getelementptr inbounds [128 x i8], [128 x i8]* %5, i32 0, i32 2
store i8 108, i8* %8
%9 = getelementptr inbounds [128 x i8], [128 x i8]* %5, i32 0, i32 3
store i8 108, i8* %9
%10 = getelementptr inbounds [128 x i8], [128 x i8]* %5, i32 0, i32 4
store i8 111, i8* %10
store i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i8** %3
%11 = getelementptr inbounds [128 x i8], [128 x i8]* %2, i64 0, i64 0
%12 = load i8*, i8** %3
%13 = call i64 @str_cat(i8* %11, i8* %12)
%14 = icmp ne i64 %13, 0
br i1 %14, label %15, label %18
15: ; preds = %0
%16 = getelementptr inbounds [128 x i8], [128 x i8]* %2, i64 0, i64 0
%17 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8* %16)
br label %21
18: ; preds = %0
%19 = load i32, i32* @stderr
%20 = call i32 @fprintf(i32 %19, i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.2, i64 0, i64 0))
br label %21
21: ; preds = %18, %15
ret i32 0
}

LLVM IR (-O2):
@.str = [7 x i8] c" world\00"
@.str.1 = [4 x i8] c"%s\0A\00"
@stderr = global i32 0
@.str.2 = [38 x i8] c"str_cat: failed concatenate strings.\0A\00"
define i32 @main() {
%1 = alloca [128 x i8]
%2 = getelementptr inbounds [128 x i8], [128 x i8]* %1, i64 0, i64 0
store i8 104, i8* %2
%3 = getelementptr inbounds [128 x i8], [128 x i8]* %1, i64 0, i64 1
store i8 101, i8* %3
%4 = getelementptr inbounds [128 x i8], [128 x i8]* %1, i64 0, i64 2
store i8 108, i8* %4
%5 = getelementptr inbounds [128 x i8], [128 x i8]* %1, i64 0, i64 3
store i8 108, i8* %5
%6 = getelementptr inbounds [128 x i8], [128 x i8]* %1, i64 0, i64 4
store i8 111, i8* %6
%7 = call i64 @str_cat(i8* %2, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0))
%8 = icmp eq i64 %7, 0
br i1 %8, label %11, label %9
9: ; preds = %0
%10 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8* %2)
br label %14
11: ; preds = %0
%12 = load i32, i32* @stderr
%13 = call i32 @fprintf(i32 %12, i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.2, i64 0, i64 0))
br label %14
14: ; preds = %11, %9
ret i32 0
}