#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*/ scanf(char *, char *);
int /*<<< orphan*/ strcat(char *, char *);
scalar_t__ strcmp(char *, char *);
int /*<<< orphan*/ strcpy(char *, char *);
int strlen(char *);
int main() {
  char Name[40 + 1];
  char FirstName[20 + 1], LastName[20 + 1];
  int NameLength;
  printf("String Function Example 1\n\n");
  printf("Enter your first name: ");
  scanf("%s", FirstName);
  printf("Enter your last name: ");
  scanf("%s", LastName);
  strcpy(Name, LastName);
  strcat(Name, ", ");
  strcat(Name, FirstName);
  printf("\nYour full name is: %s\n\n", Name);
  NameLength = strlen(Name);
  printf("The length of your name is: %d\n\n", NameLength);
  if (strcmp(Name, "Smith, Emmitt") == 0)
    printf("Hello, Emmitt!\n\n");
  else
    printf("You must not be Emmitt Smith.\n\n");
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x80,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xe87(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    0xe95(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    -0x50(%rbp),%rsi
lea    0xe9b(%rip),%rdi
call   1070 <scanf@plt>
lea    0xe92(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    -0x70(%rbp),%rsi
lea    0xe7d(%rip),%rdi
call   1070 <scanf@plt>
lea    -0x30(%rbp),%rdi
lea    -0x70(%rbp),%rsi
call   1030 <strcpy@plt>
lea    -0x30(%rbp),%rdi
lea    0xe7a(%rip),%rsi
call   1080 <strcat@plt>
lea    -0x30(%rbp),%rdi
lea    -0x50(%rbp),%rsi
call   1080 <strcat@plt>
lea    -0x30(%rbp),%rsi
lea    0xe60(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    -0x30(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,-0x74(%rbp)
mov    -0x74(%rbp),%esi
lea    0xe5c(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    -0x30(%rbp),%rdi
lea    0xe6b(%rip),%rsi
call   1060 <strcmp@plt>
cmp    $0x0,%rax
jne    1242 <main+0xe2>
lea    0xe63(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
jmp    1250 <main+0xf0>
lea    0xe61(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
xor    %eax,%eax
add    $0x80,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
sub    $0x70,%rsp
lea    0xefd(%rip),%rdi
call   1040 <puts@plt>
lea    0xe74(%rip),%rdi
xor    %eax,%eax
call   1060 <printf@plt>
lea    0xe7e(%rip),%rbx
lea    0x20(%rsp),%r14
mov    %rbx,%rdi
mov    %r14,%rsi
call   1080 <scanf@plt>
lea    0xe6a(%rip),%rdi
xor    %eax,%eax
call   1060 <printf@plt>
mov    %rsp,%r15
mov    %rbx,%rdi
mov    %r15,%rsi
call   1080 <scanf@plt>
lea    0x40(%rsp),%rbx
mov    %rbx,%rdi
mov    %r15,%rsi
call   1030 <strcpy@plt>
lea    0xe55(%rip),%rsi
mov    %rbx,%rdi
call   1090 <strcat@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
call   1090 <strcat@plt>
lea    0xe3e(%rip),%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1060 <printf@plt>
mov    %rbx,%rdi
call   1050 <strlen@plt>
lea    0xe3e(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1060 <printf@plt>
lea    0xe4f(%rip),%rsi
mov    %rbx,%rdi
call   1070 <strcmp@plt>
test   %rax,%rax
lea    0xe85(%rip),%rax
lea    0xe5f(%rip),%rdi
cmove  %rax,%rdi
call   1040 <puts@plt>
xor    %eax,%eax
add    $0x70,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [28 x i8] c"String Function Example 1\0A\0A\00"
@.str.1 = [24 x i8] c"Enter your first name: \00"
@.str.2 = [3 x i8] c"%s\00"
@.str.3 = [23 x i8] c"Enter your last name: \00"
@.str.4 = [3 x i8] c", \00"
@.str.5 = [25 x i8] c"\0AYour full name is: %s\0A\0A\00"
@.str.6 = [33 x i8] c"The length of your name is: %d\0A\0A\00"
@.str.7 = [14 x i8] c"Smith, Emmitt\00"
@.str.8 = [17 x i8] c"Hello, Emmitt!\0A\0A\00"
@.str.9 = [32 x i8] c"You must not be Emmitt Smith.\0A\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [41 x i8]
%3 = alloca [21 x i8]
%4 = alloca [21 x i8]
%5 = alloca i32
store i32 0, i32* %1
%6 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str, i64 0, i64 0))
%7 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.1, i64 0, i64 0))
%8 = getelementptr inbounds [21 x i8], [21 x i8]* %3, i64 0, i64 0
%9 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i8* %8)
%10 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.3, i64 0, i64 0))
%11 = getelementptr inbounds [21 x i8], [21 x i8]* %4, i64 0, i64 0
%12 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i8* %11)
%13 = getelementptr inbounds [41 x i8], [41 x i8]* %2, i64 0, i64 0
%14 = getelementptr inbounds [21 x i8], [21 x i8]* %4, i64 0, i64 0
%15 = call i32 @strcpy(i8* %13, i8* %14)
%16 = getelementptr inbounds [41 x i8], [41 x i8]* %2, i64 0, i64 0
%17 = call i32 @strcat(i8* %16, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0))
%18 = getelementptr inbounds [41 x i8], [41 x i8]* %2, i64 0, i64 0
%19 = getelementptr inbounds [21 x i8], [21 x i8]* %3, i64 0, i64 0
%20 = call i32 @strcat(i8* %18, i8* %19)
%21 = getelementptr inbounds [41 x i8], [41 x i8]* %2, i64 0, i64 0
%22 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.5, i64 0, i64 0), i8* %21)
%23 = getelementptr inbounds [41 x i8], [41 x i8]* %2, i64 0, i64 0
%24 = call i32 @strlen(i8* %23)
store i32 %24, i32* %5
%25 = load i32, i32* %5
%26 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.6, i64 0, i64 0), i32 %25)
%27 = getelementptr inbounds [41 x i8], [41 x i8]* %2, i64 0, i64 0
%28 = call i64 @strcmp(i8* %27, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.7, i64 0, i64 0))
%29 = icmp eq i64 %28, 0
br i1 %29, label %30, label %32
30: ; preds = %0
%31 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.8, i64 0, i64 0))
br label %34
32: ; preds = %0
%33 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.9, i64 0, i64 0))
br label %34
34: ; preds = %32, %30
ret i32 0
}

LLVM IR (-O2):
@.str.1 = [24 x i8] c"Enter your first name: \00"
@.str.2 = [3 x i8] c"%s\00"
@.str.3 = [23 x i8] c"Enter your last name: \00"
@.str.4 = [3 x i8] c", \00"
@.str.5 = [25 x i8] c"\0AYour full name is: %s\0A\0A\00"
@.str.6 = [33 x i8] c"The length of your name is: %d\0A\0A\00"
@.str.7 = [14 x i8] c"Smith, Emmitt\00"
@str = [27 x i8] c"String Function Example 1\0A\00"
@str.10 = [31 x i8] c"You must not be Emmitt Smith.\0A\00"
@str.11 = [16 x i8] c"Hello, Emmitt!\0A\00"
define i32 @main() {
%1 = alloca [41 x i8]
%2 = alloca [21 x i8]
%3 = alloca [21 x i8]
%4 = getelementptr inbounds [41 x i8], [41 x i8]* %1, i64 0, i64 0
%5 = getelementptr inbounds [21 x i8], [21 x i8]* %2, i64 0, i64 0
%6 = getelementptr inbounds [21 x i8], [21 x i8]* %3, i64 0, i64 0
%7 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @str, i64 0, i64 0))
%8 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @.str.1, i64 0, i64 0))
%9 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i8* %5)
%10 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @.str.3, i64 0, i64 0))
%11 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i8* %6)
%12 = call i32 @strcpy(i8* %4, i8* %6)
%13 = call i32 @strcat(i8* %4, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0))
%14 = call i32 @strcat(i8* %4, i8* %5)
%15 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @.str.5, i64 0, i64 0), i8* %4)
%16 = call i32 @strlen(i8* %4)
%17 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([33 x i8], [33 x i8]* @.str.6, i64 0, i64 0), i32 %16)
%18 = call i64 @strcmp(i8* %4, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.7, i64 0, i64 0))
%19 = icmp eq i64 %18, 0
%20 = select i1 %19, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @str.11, i64 0, i64 0), i8* getelementptr inbounds ([31 x i8], [31 x i8]* @str.10, i64 0, i64 0)
%21 = call i32 @puts(i8* dereferenceable(1) %20)
ret i32 0
}