#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*/ sprintf(char *, char *, char *, char *);
int /*<<< orphan*/ strncat(char *, char *, int);
scalar_t__ strncmp(char *, char *, int);
int main() {
  char *first_name = "John";
  char last_name[] = "Doe";
  char name[9];
  last_name[0] = 'B';
  sprintf(name, "%s %s", first_name, last_name);
  if (strncmp(name, "John Boe", 8) == 0) {
    printf("Done!\n");
  }
  name[0] = '\0';
  strncat(name, first_name, 4);
  strncat(name, last_name, 20);
  printf("%s\n", name);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeaa(%rip),%rax
mov    %rax,-0x10(%rbp)
mov    0xea5(%rip),%eax
mov    %eax,-0x14(%rbp)
movb   $0x42,-0x14(%rbp)
lea    -0x1d(%rbp),%rdi
mov    -0x10(%rbp),%rdx
lea    -0x14(%rbp),%rcx
lea    0xe8f(%rip),%rsi
call   1060 <sprintf@plt>
lea    -0x1d(%rbp),%rdi
lea    0xe85(%rip),%rsi
mov    $0x8,%edx
call   1030 <strncmp@plt>
cmp    $0x0,%rax
jne    11ac <main+0x6c>
lea    0xe73(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movb   $0x0,-0x1d(%rbp)
lea    -0x1d(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    $0x4,%edx
call   1050 <strncat@plt>
lea    -0x1d(%rbp),%rdi
lea    -0x14(%rbp),%rsi
mov    $0x14,%edx
call   1050 <strncat@plt>
lea    -0x1d(%rbp),%rsi
lea    0xe40(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x10,%rsp
movl   $0x656f42,(%rsp)
lea    0xeb2(%rip),%rsi
lea    0xea6(%rip),%rdx
lea    0x7(%rsp),%rbx
mov    %rsp,%rcx
mov    %rbx,%rdi
call   1060 <sprintf@plt>
lea    0xe9a(%rip),%rsi
mov    %rbx,%rdi
mov    $0x8,%edx
call   1030 <strncmp@plt>
test   %rax,%rax
jne    118f <main+0x4f>
lea    0xe8a(%rip),%rdi
call   1040 <puts@plt>
movb   $0x0,0x7(%rsp)
lea    0xe65(%rip),%rsi
lea    0x7(%rsp),%rbx
mov    %rbx,%rdi
mov    $0x4,%edx
call   1050 <strncat@plt>
mov    %rsp,%rsi
mov    %rbx,%rdi
mov    $0x14,%edx
call   1050 <strncat@plt>
mov    %rbx,%rdi
call   1040 <puts@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [5 x i8] c"John\00"
@__const.main.last_name = [4 x i8] c"Doe\00"
@.str.1 = [6 x i8] c"%s %s\00"
@.str.2 = [9 x i8] c"John Boe\00"
@.str.3 = [7 x i8] c"Done!\0A\00"
@.str.4 = [4 x i8] c"%s\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i8*
%3 = alloca [4 x i8]
%4 = alloca [9 x i8]
store i32 0, i32* %1
store i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i8** %2
%5 = bitcast [4 x i8]* %3 to i8*
%6 = getelementptr inbounds [4 x i8], [4 x i8]* %3, i64 0, i64 0
store i8 66, i8* %6
%7 = getelementptr inbounds [9 x i8], [9 x i8]* %4, i64 0, i64 0
%8 = load i8*, i8** %2
%9 = getelementptr inbounds [4 x i8], [4 x i8]* %3, i64 0, i64 0
%10 = call i32 @sprintf(i8* %7, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i8* %8, i8* %9)
%11 = getelementptr inbounds [9 x i8], [9 x i8]* %4, i64 0, i64 0
%12 = call i64 @strncmp(i8* %11, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0), i32 8)
%13 = icmp eq i64 %12, 0
br i1 %13, label %14, label %16
14: ; preds = %0
%15 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0))
br label %16
16: ; preds = %14, %0
%17 = getelementptr inbounds [9 x i8], [9 x i8]* %4, i64 0, i64 0
store i8 0, i8* %17
%18 = getelementptr inbounds [9 x i8], [9 x i8]* %4, i64 0, i64 0
%19 = load i8*, i8** %2
%20 = call i32 @strncat(i8* %18, i8* %19, i32 4)
%21 = getelementptr inbounds [9 x i8], [9 x i8]* %4, i64 0, i64 0
%22 = getelementptr inbounds [4 x i8], [4 x i8]* %3, i64 0, i64 0
%23 = call i32 @strncat(i8* %21, i8* %22, i32 20)
%24 = getelementptr inbounds [9 x i8], [9 x i8]* %4, i64 0, i64 0
%25 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0), i8* %24)
ret i32 0
}

LLVM IR (-O2):
@.str = [5 x i8] c"John\00"
@.str.1 = [6 x i8] c"%s %s\00"
@.str.2 = [9 x i8] c"John Boe\00"
@str = [6 x i8] c"Done!\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [9 x i8]
%3 = bitcast i32* %1 to i8*
store i32 6647618, i32* %1
%4 = getelementptr inbounds [9 x i8], [9 x i8]* %2, i64 0, i64 0
%5 = call i32 @sprintf(i8* %4, i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i8* %3)
%6 = call i64 @strncmp(i8* %4, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0), i32 8)
%7 = icmp eq i64 %6, 0
br i1 %7, label %8, label %10
8: ; preds = %0
%9 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @str, i64 0, i64 0))
br label %10
10: ; preds = %8, %0
store i8 0, i8* %4
%11 = call i32 @strncat(i8* %4, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i32 4)
%12 = call i32 @strncat(i8* %4, i8* %3, i32 20)
%13 = call i32 @puts(i8* %4)
ret i32 0
}