#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*/ strcat(char *, char *);
scalar_t__ strcmp(char *, char *);
int /*<<< orphan*/ strcpy(char *, char *);
int /*<<< orphan*/ strlen(char *);
int /*<<< orphan*/ strncat(char *, char *, int);
int main(int argc, char **argv) {
  char *chaineStatique = "Universite du Quebec a Montreal";
  char buffer[40 + 1];
  char *pointeur;
  char *pointeur2;
  printf("La taille de la chaine statique : %lu\n", strlen(chaineStatique));
  buffer[0] = 'A';
  buffer[1] = 'l';
  buffer[2] = 'l';
  buffer[3] = 'o';
  buffer[4] = '\0';
  printf("Chaine construite par caractere : %s\n", buffer);
  pointeur = chaineStatique + 23;
  printf("Fraction de chaine par pointeur : %s\n", pointeur);
  strcpy(buffer, pointeur);
  printf("Copie : %s\n", buffer);
  strcat(buffer, ", ");
  pointeur2 = chaineStatique + 14;
  strncat(buffer, pointeur2, 6);
  printf("Resultat de concatenations : %s\n", buffer);
  if (strcmp(buffer, "Montreal, Quebec") == 0)
    printf("Chaines egales\n");
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    0xe83(%rip),%rax
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,%esi
lea    0xe8d(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
movb   $0x41,-0x50(%rbp)
movb   $0x6c,-0x4f(%rbp)
movb   $0x6c,-0x4e(%rbp)
movb   $0x6f,-0x4d(%rbp)
movb   $0x0,-0x4c(%rbp)
lea    -0x50(%rbp),%rsi
lea    0xe8e(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x18(%rbp),%rax
add    $0x17,%rax
mov    %rax,-0x58(%rbp)
mov    -0x58(%rbp),%rsi
lea    0xe96(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    -0x50(%rbp),%rdi
mov    -0x58(%rbp),%rsi
call   1030 <strcpy@plt>
lea    -0x50(%rbp),%rsi
lea    0xe9d(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    -0x50(%rbp),%rdi
lea    0xe97(%rip),%rsi
call   1080 <strcat@plt>
mov    -0x18(%rbp),%rax
add    $0xe,%rax
mov    %rax,-0x60(%rbp)
lea    -0x50(%rbp),%rdi
mov    -0x60(%rbp),%rsi
mov    $0x6,%edx
call   1060 <strncat@plt>
lea    -0x50(%rbp),%rsi
lea    0xe6c(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    -0x50(%rbp),%rdi
lea    0xe7b(%rip),%rsi
call   1070 <strcmp@plt>
cmp    $0x0,%rax
jne    1265 <main+0x105>
lea    0xe76(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
xor    %eax,%eax
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
sub    $0x38,%rsp
lea    0xe82(%rip),%rdi
call   1050 <strlen@plt>
lea    0xe96(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1060 <printf@plt>
movl   $0x6f6c6c41,(%rsp)
movb   $0x0,0x4(%rsp)
lea    0xea1(%rip),%rdi
mov    %rsp,%rbx
mov    %rbx,%rsi
xor    %eax,%eax
call   1060 <printf@plt>
lea    0xeb3(%rip),%rdi
lea    0xe56(%rip),%r14
mov    %r14,%rsi
xor    %eax,%eax
call   1060 <printf@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
call   1030 <strcpy@plt>
lea    0xeb6(%rip),%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1060 <printf@plt>
lea    0xeb1(%rip),%rsi
mov    %rbx,%rdi
call   1090 <strcat@plt>
lea    0xe11(%rip),%rsi
mov    %rbx,%rdi
mov    $0x6,%edx
call   1070 <strncat@plt>
lea    0xe91(%rip),%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1060 <printf@plt>
lea    0xea1(%rip),%rsi
mov    %rbx,%rdi
call   1080 <strcmp@plt>
test   %rax,%rax
jne    123b <main+0xcb>
lea    0xe9e(%rip),%rdi
call   1040 <puts@plt>
xor    %eax,%eax
add    $0x38,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [32 x i8] c"Universite du Quebec a Montreal\00"
@.str.1 = [39 x i8] c"La taille de la chaine statique : %lu\0A\00"
@.str.2 = [38 x i8] c"Chaine construite par caractere : %s\0A\00"
@.str.3 = [38 x i8] c"Fraction de chaine par pointeur : %s\0A\00"
@.str.4 = [12 x i8] c"Copie : %s\0A\00"
@.str.5 = [3 x i8] c", \00"
@.str.6 = [33 x i8] c"Resultat de concatenations : %s\0A\00"
@.str.7 = [17 x i8] c"Montreal, Quebec\00"
@.str.8 = [16 x i8] c"Chaines egales\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i8*
%7 = alloca [41 x i8]
%8 = alloca i8*
%9 = alloca i8*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str, i64 0, i64 0), i8** %6
%10 = load i8*, i8** %6
%11 = call i32 @strlen(i8* %10)
%12 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.1, i64 0, i64 0), i32 %11)
%13 = getelementptr inbounds [41 x i8], [41 x i8]* %7, i64 0, i64 0
store i8 65, i8* %13
%14 = getelementptr inbounds [41 x i8], [41 x i8]* %7, i64 0, i64 1
store i8 108, i8* %14
%15 = getelementptr inbounds [41 x i8], [41 x i8]* %7, i64 0, i64 2
store i8 108, i8* %15
%16 = getelementptr inbounds [41 x i8], [41 x i8]* %7, i64 0, i64 3
store i8 111, i8* %16
%17 = getelementptr inbounds [41 x i8], [41 x i8]* %7, i64 0, i64 4
store i8 0, i8* %17
%18 = getelementptr inbounds [41 x i8], [41 x i8]* %7, i64 0, i64 0
%19 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.2, i64 0, i64 0), i8* %18)
%20 = load i8*, i8** %6
%21 = getelementptr inbounds i8, i8* %20, i64 23
store i8* %21, i8** %8
%22 = load i8*, i8** %8
%23 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.3, i64 0, i64 0), i8* %22)
%24 = getelementptr inbounds [41 x i8], [41 x i8]* %7, i64 0, i64 0
%25 = load i8*, i8** %8
%26 = call i32 @strcpy(i8* %24, i8* %25)
%27 = getelementptr inbounds [41 x i8], [41 x i8]* %7, i64 0, i64 0
%28 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.4, i64 0, i64 0), i8* %27)
%29 = getelementptr inbounds [41 x i8], [41 x i8]* %7, i64 0, i64 0
%30 = call i32 @strcat(i8* %29, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0))
%31 = load i8*, i8** %6
%32 = getelementptr inbounds i8, i8* %31, i64 14
store i8* %32, i8** %9
%33 = getelementptr inbounds [41 x i8], [41 x i8]* %7, i64 0, i64 0
%34 = load i8*, i8** %9
%35 = call i32 @strncat(i8* %33, i8* %34, i32 6)
%36 = getelementptr inbounds [41 x i8], [41 x i8]* %7, i64 0, i64 0
%37 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.6, i64 0, i64 0), i8* %36)
%38 = getelementptr inbounds [41 x i8], [41 x i8]* %7, i64 0, i64 0
%39 = call i64 @strcmp(i8* %38, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.7, i64 0, i64 0))
%40 = icmp eq i64 %39, 0
br i1 %40, label %41, label %43
41: ; preds = %2
%42 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.8, i64 0, i64 0))
br label %43
43: ; preds = %41, %2
ret i32 0
}

LLVM IR (-O2):
@.str = [32 x i8] c"Universite du Quebec a Montreal\00"
@.str.1 = [39 x i8] c"La taille de la chaine statique : %lu\0A\00"
@.str.2 = [38 x i8] c"Chaine construite par caractere : %s\0A\00"
@.str.3 = [38 x i8] c"Fraction de chaine par pointeur : %s\0A\00"
@.str.4 = [12 x i8] c"Copie : %s\0A\00"
@.str.5 = [3 x i8] c", \00"
@.str.6 = [33 x i8] c"Resultat de concatenations : %s\0A\00"
@.str.7 = [17 x i8] c"Montreal, Quebec\00"
@str = [15 x i8] c"Chaines egales\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca [41 x i8]
%4 = getelementptr inbounds [41 x i8], [41 x i8]* %3, i64 0, i64 0
%5 = tail call i32 @strlen(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str, i64 0, i64 0))
%6 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([39 x i8], [39 x i8]* @.str.1, i64 0, i64 0), i32 %5)
store i8 65, i8* %4
%7 = getelementptr inbounds [41 x i8], [41 x i8]* %3, i64 0, i64 1
store i8 108, i8* %7
%8 = getelementptr inbounds [41 x i8], [41 x i8]* %3, i64 0, i64 2
store i8 108, i8* %8
%9 = getelementptr inbounds [41 x i8], [41 x i8]* %3, i64 0, i64 3
store i8 111, i8* %9
%10 = getelementptr inbounds [41 x i8], [41 x i8]* %3, i64 0, i64 4
store i8 0, i8* %10
%11 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([38 x i8], [38 x i8]* @.str.2, i64 0, i64 0), i8* %4)
%12 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([38 x i8], [38 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str, i64 0, i64 23))
%13 = call i32 @strcpy(i8* %4, i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str, i64 0, i64 23))
%14 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str.4, i64 0, i64 0), i8* %4)
%15 = call i32 @strcat(i8* %4, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0))
%16 = call i32 @strncat(i8* %4, i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str, i64 0, i64 14), i32 6)
%17 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([33 x i8], [33 x i8]* @.str.6, i64 0, i64 0), i8* %4)
%18 = call i64 @strcmp(i8* %4, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.7, i64 0, i64 0))
%19 = icmp eq i64 %18, 0
br i1 %19, label %20, label %22
20: ; preds = %2
%21 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @str, i64 0, i64 0))
br label %22
22: ; preds = %20, %2
ret i32 0
}