#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*/ EXIT_FAILURE;
int EXIT_SUCCESS;
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ test_strcat(char *, char *);
int main(int argc, char **argv) {
  if (argc == 1) {
    printf("\nRunning null string test...\n");
    test_strcat("\0", "\0");
    return EXIT_SUCCESS;
  } else if (argc != 3) {
    printf("\nUsage: ./strcat <string1> <string2>\n\n");
    exit(EXIT_FAILURE);
  }
  test_strcat(argv[1], argv[2]);
  return EXIT_SUCCESS;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x1,-0x8(%rbp)
jne    117c <main+0x4c>
lea    0xea9(%rip),%rdi
call   1040 <printf@plt>
lea    0xee2(%rip),%rsi
mov    %rsi,%rdi
call   1030 <test_strcat@plt>
mov    0x2e66(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    11c6 <main+0x96>
cmpl   $0x3,-0x8(%rbp)
je     11a0 <main+0x70>
lea    0xe91(%rip),%rdi
call   1040 <printf@plt>
mov    0x2e47(%rip),%rax
mov    (%rax),%edi
call   1050 <exit@plt>
jmp    11a5 <main+0x75>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rsi
call   1030 <test_strcat@plt>
mov    0x2e17(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rax
cmp    $0x3,%edi
je     1153 <main+0x23>
cmp    $0x1,%edi
jne    116b <main+0x3b>
lea    0xee6(%rip),%rdi
call   1040 <puts@plt>
lea    0xeb2(%rip),%rdi
mov    %rdi,%rsi
jmp    115b <main+0x2b>
mov    0x8(%rsi),%rdi
mov    0x10(%rsi),%rsi
call   1030 <test_strcat@plt>
mov    0x2e71(%rip),%rax
mov    (%rax),%eax
pop    %rcx
ret
lea    0xe90(%rip),%rdi
call   1040 <puts@plt>
mov    0x2e62(%rip),%rax
mov    (%rax),%edi
call   1050 <exit@plt>

LLVM IR (-O0):
@.str = [30 x i8] c"\0ARunning null string test...\0A\00"
@.str.1 = [2 x i8] zeroinitializer
@EXIT_SUCCESS = global i32 0
@.str.2 = [39 x i8] c"\0AUsage: ./strcat <string1> <string2>\0A\0A\00"
@EXIT_FAILURE = global i32 0
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%6 = load i32, i32* %4
%7 = icmp eq i32 %6, 1
br i1 %7, label %8, label %12
8: ; preds = %2
%9 = call i32 @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str, i64 0, i64 0))
%10 = call i32 @test_strcat(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%11 = load i32, i32* @EXIT_SUCCESS
store i32 %11, i32* %3
br label %29
12: ; preds = %2
%13 = load i32, i32* %4
%14 = icmp ne i32 %13, 3
br i1 %14, label %15, label %19
15: ; preds = %12
%16 = call i32 @printf(i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.2, i64 0, i64 0))
%17 = load i32, i32* @EXIT_FAILURE
%18 = call i32 @exit(i32 %17)
unreachable
19: ; preds = %12
br label %20
20: ; preds = %19
%21 = load i8**, i8*** %5
%22 = getelementptr inbounds i8*, i8** %21, i64 1
%23 = load i8*, i8** %22
%24 = load i8**, i8*** %5
%25 = getelementptr inbounds i8*, i8** %24, i64 2
%26 = load i8*, i8** %25
%27 = call i32 @test_strcat(i8* %23, i8* %26)
%28 = load i32, i32* @EXIT_SUCCESS
store i32 %28, i32* %3
br label %29
29: ; preds = %20, %8
%30 = load i32, i32* %3
ret i32 %30
}

LLVM IR (-O2):
@.str.1 = [2 x i8] zeroinitializer
@EXIT_SUCCESS = global i32 0
@EXIT_FAILURE = global i32 0
@str = [38 x i8] c"\0AUsage: ./strcat <string1> <string2>\0A\00"
@str.3 = [29 x i8] c"\0ARunning null string test...\00"
define i32 @main(i32 %0, i8** nocapture %1) {
switch i32 %0, label %6 [
i32 1, label %3
i32 3, label %10
]
3: ; preds = %2
%4 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([29 x i8], [29 x i8]* @str.3, i64 0, i64 0))
%5 = tail call i32 @test_strcat(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
br label %16
6: ; preds = %2
%7 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([38 x i8], [38 x i8]* @str, i64 0, i64 0))
%8 = load i32, i32* @EXIT_FAILURE
%9 = tail call i32 @exit(i32 %8)
unreachable
10: ; preds = %2
%11 = getelementptr inbounds i8*, i8** %1, i64 1
%12 = load i8*, i8** %11
%13 = getelementptr inbounds i8*, i8** %1, i64 2
%14 = load i8*, i8** %13
%15 = tail call i32 @test_strcat(i8* %12, i8* %14)
br label %16
16: ; preds = %10, %3
%17 = load i32, i32* @EXIT_SUCCESS
ret i32 %17
}