#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 *, ...);
main() {
  void strcat(char *, char *, int);
  void strcopy(char *, char *, int);
  int strcmp(char *, char *, int);
  char begin[1000];
  char front[] = "I'm at the front";
  char end[] = " add me to the end";
  char snip[] = "I'm at the end";
  int t;
  strcopy(begin, front, 5);
  printf("Starting string: %s\n", begin);
  strcat(begin, end, 5);
  printf("Final string: %s\n", begin);
  t = strcmp(front, snip, 13);
  printf("The first %d characters of \"%s\" cmp \"%s\": %d \n", 13, snip, front,
         t);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x450,%rsp
mov    0xeae(%rip),%rax
mov    %rax,-0x410(%rbp)
mov    0xea8(%rip),%rax
mov    %rax,-0x408(%rbp)
mov    0xea3(%rip),%al
mov    %al,-0x400(%rbp)
mov    0xea6(%rip),%rax
mov    %rax,-0x430(%rbp)
mov    0xea0(%rip),%rax
mov    %rax,-0x428(%rbp)
mov    0xe9a(%rip),%ax
mov    %ax,-0x420(%rbp)
mov    0xe8f(%rip),%al
mov    %al,-0x41e(%rbp)
mov    0xe83(%rip),%rax
mov    %rax,-0x43f(%rbp)
mov    0xe7e(%rip),%eax
mov    %eax,-0x437(%rbp)
mov    0xe75(%rip),%ax
mov    %ax,-0x433(%rbp)
mov    0xe6a(%rip),%al
mov    %al,-0x431(%rbp)
lea    -0x3f0(%rbp),%rdi
lea    -0x410(%rbp),%rsi
mov    $0x5,%edx
call   1050 <strcopy@plt>
lea    -0x3f0(%rbp),%rsi
lea    0xe3f(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    -0x3f0(%rbp),%rdi
lea    -0x430(%rbp),%rsi
mov    $0x5,%edx
call   1060 <strcat@plt>
lea    -0x3f0(%rbp),%rsi
lea    0xe27(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    -0x410(%rbp),%rdi
lea    -0x43f(%rbp),%rsi
mov    $0xd,%edx
call   1040 <strcmp@plt>
mov    %eax,-0x444(%rbp)
lea    -0x43f(%rbp),%rdx
lea    -0x410(%rbp),%rcx
mov    -0x444(%rbp),%r8d
lea    0xdf8(%rip),%rdi
mov    $0xd,%esi
mov    $0x0,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x450,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
sub    $0x438,%rsp
movaps 0xeaf(%rip),%xmm0
movaps %xmm0,0x10(%rsp)
movb   $0x0,0x20(%rsp)
movaps 0xebe(%rip),%xmm0
movaps %xmm0,0x30(%rsp)
movl   $0x646e65,0x3f(%rsp)
movabs $0x646e6520656874,%rax
mov    %rax,0x7(%rsp)
movabs $0x74207461206d2749,%rax
74 20 74
mov    %rax,(%rsp)
lea    0x50(%rsp),%rbx
lea    0x10(%rsp),%r14
mov    %rbx,%rdi
mov    %r14,%rsi
mov    $0x5,%edx
call   1050 <strcopy@plt>
lea    0xe95(%rip),%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0x30(%rsp),%rsi
mov    %rbx,%rdi
mov    $0x5,%edx
call   1060 <strcat@plt>
lea    0xe87(%rip),%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1030 <printf@plt>
mov    %rsp,%rbx
mov    %r14,%rdi
mov    %rbx,%rsi
mov    $0xd,%edx
call   1040 <strcmp@plt>
lea    0xe75(%rip),%rdi
mov    $0xd,%esi
mov    %rbx,%rdx
mov    %r14,%rcx
mov    %eax,%r8d
xor    %eax,%eax
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x438,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@__const.main.front = [17 x i8] c"I'm at the front\00"
@__const.main.end = [19 x i8] c" add me to the end\00"
@__const.main.snip = [15 x i8] c"I'm at the end\00"
@.str = [21 x i8] c"Starting string: %s\0A\00"
@.str.1 = [18 x i8] c"Final string: %s\0A\00"
@.str.2 = [47 x i8] c"The first %d characters of \22%s\22 cmp \22%s\22: %d \0A\00"
define i32 @main() {
%1 = alloca [1000 x i8]
%2 = alloca [17 x i8]
%3 = alloca [19 x i8]
%4 = alloca [15 x i8]
%5 = alloca i32
%6 = bitcast [17 x i8]* %2 to i8*
%7 = bitcast [19 x i8]* %3 to i8*
%8 = bitcast [15 x i8]* %4 to i8*
%9 = getelementptr inbounds [1000 x i8], [1000 x i8]* %1, i64 0, i64 0
%10 = getelementptr inbounds [17 x i8], [17 x i8]* %2, i64 0, i64 0
%11 = getelementptr inbounds [1000 x i8], [1000 x i8]* %1, i64 0, i64 0
%12 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0), i8* %11)
%13 = getelementptr inbounds [1000 x i8], [1000 x i8]* %1, i64 0, i64 0
%14 = getelementptr inbounds [19 x i8], [19 x i8]* %3, i64 0, i64 0
%15 = getelementptr inbounds [1000 x i8], [1000 x i8]* %1, i64 0, i64 0
%16 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.1, i64 0, i64 0), i8* %15)
%17 = getelementptr inbounds [17 x i8], [17 x i8]* %2, i64 0, i64 0
%18 = getelementptr inbounds [15 x i8], [15 x i8]* %4, i64 0, i64 0
%19 = call i32 @strcmp(i8* %17, i8* %18, i32 13)
store i32 %19, i32* %5
%20 = getelementptr inbounds [15 x i8], [15 x i8]* %4, i64 0, i64 0
%21 = getelementptr inbounds [17 x i8], [17 x i8]* %2, i64 0, i64 0
%22 = load i32, i32* %5
%23 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([47 x i8], [47 x i8]* @.str.2, i64 0, i64 0), i32 13, i8* %20, i8* %21, i32 %22)
ret i32 0
}

LLVM IR (-O2):
@__const.main.front = [17 x i8] c"I'm at the front\00"
@__const.main.end = [19 x i8] c" add me to the end\00"
@__const.main.snip = [15 x i8] c"I'm at the end\00"
@.str = [21 x i8] c"Starting string: %s\0A\00"
@.str.1 = [18 x i8] c"Final string: %s\0A\00"
@.str.2 = [47 x i8] c"The first %d characters of \22%s\22 cmp \22%s\22: %d \0A\00"
define i32 @main() {
%1 = alloca [1000 x i8]
%2 = alloca [17 x i8]
%3 = alloca [19 x i8]
%4 = alloca [15 x i8]
%5 = getelementptr inbounds [1000 x i8], [1000 x i8]* %1, i64 0, i64 0
%6 = getelementptr inbounds [17 x i8], [17 x i8]* %2, i64 0, i64 0
%7 = getelementptr inbounds [19 x i8], [19 x i8]* %3, i64 0, i64 0
%8 = getelementptr inbounds [15 x i8], [15 x i8]* %4, i64 0, i64 0
%9 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0), i8* %5)
%10 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @.str.1, i64 0, i64 0), i8* %5)
%11 = call i32 @strcmp(i8* %6, i8* %8, i32 13)
%12 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([47 x i8], [47 x i8]* @.str.2, i64 0, i64 0), i32 13, i8* %8, i8* %6, i32 %11)
ret i32 0
}