#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 strlen(char *);
void stringTest(char *string) {
  unsigned int i = 0;
  unsigned int length = 0;
  unsigned int flag = 0;
  length = strlen(string);
  printf("\n");
  printf("********************************************************\n");
  printf("*              Welcome in String Test v1.0             *\n");
  printf("********************************************************\n");
  printf("\n");
  printf("Address : ");
  if (string != NULL) {
    printf("%p", string);
    printf("\n");
  } else {
    printf("Pointing to non initialized value \n");
  }
  printf("Length : ");
  printf("%d", length);
  printf("\n");
  printf("Presence of end token : ");
  for (i = 0; i < strlen(string) + 1; i++) {
    if (string[i] == '\0') {
      flag = 1;
      printf("%d", flag);
    }
  }
  printf("\n");
  printf("String : ");
  for (i = 0; i < length; i++) {
    printf("%c", string[i]);
  }
  printf("\n\n");
  printf("See you later for another segmentation fault !\n");
  printf("\n");
}


x86 assembly (clang, -O0):
<stringTest>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
movl   $0x0,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
mov    -0x8(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,-0x10(%rbp)
lea    0xf86(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xe9e(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xeca(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xe82(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xf4e(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xeda(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
cmpq   $0x0,-0x8(%rbp)
je     11d1 <stringTest+0xb1>
mov    -0x8(%rbp),%rsi
lea    0xec8(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xf15(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    11df <stringTest+0xbf>
lea    0xeaa(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xec0(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x10(%rbp),%esi
lea    0xeb9(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xed5(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xea0(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x0,-0xc(%rbp)
mov    -0xc(%rbp),%eax
mov    %eax,-0x18(%rbp)
mov    -0x8(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,%ecx
mov    -0x18(%rbp),%eax
add    $0x1,%ecx
cmp    %ecx,%eax
jae    127f <stringTest+0x15f>
mov    -0x8(%rbp),%rax
mov    -0xc(%rbp),%ecx
movsbl (%rax,%rcx,1),%eax
cmp    $0x0,%eax
jne    126c <stringTest+0x14c>
movl   $0x1,-0x14(%rbp)
mov    -0x14(%rbp),%esi
lea    0xe4b(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    1271 <stringTest+0x151>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1221 <stringTest+0x101>
lea    0xe54(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xe38(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x0,-0xc(%rbp)
mov    -0xc(%rbp),%eax
cmp    -0x10(%rbp),%eax
jae    12d5 <stringTest+0x1b5>
mov    -0x8(%rbp),%rax
mov    -0xc(%rbp),%ecx
movsbl (%rax,%rcx,1),%esi
lea    0xe16(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    12a2 <stringTest+0x182>
lea    0xdfd(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xdf2(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xde2(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<stringTest>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %rdi,%r12
call   1050 <strlen@plt>
mov    %eax,%r14d
mov    $0xa,%edi
call   1030 <putchar@plt>
lea    0xf13(%rip),%rbp
mov    %rbp,%rdi
call   1040 <puts@plt>
lea    0xecb(%rip),%rdi
call   1040 <puts@plt>
mov    %rbp,%rdi
call   1040 <puts@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
lea    0xe6f(%rip),%rdi
xor    %eax,%eax
call   1060 <printf@plt>
test   %r12,%r12
je     11ba <stringTest+0x7a>
lea    0xe67(%rip),%rdi
mov    %r12,%rsi
xor    %eax,%eax
call   1060 <printf@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
jmp    11c6 <stringTest+0x86>
lea    0xeef(%rip),%rdi
call   1040 <puts@plt>
lea    0xe41(%rip),%rdi
xor    %eax,%eax
call   1060 <printf@plt>
lea    0xe3d(%rip),%rdi
mov    %r14d,%esi
xor    %eax,%eax
call   1060 <printf@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
lea    0xe25(%rip),%rdi
xor    %eax,%eax
call   1060 <printf@plt>
mov    %r12,%rdi
call   1050 <strlen@plt>
cmp    $0xffffffff,%eax
je     124c <stringTest+0x10c>
lea    0xe07(%rip),%r15
xor    %ebp,%ebp
jmp    1234 <stringTest+0xf4>
cs nopw 0x0(%rax,%rax,1)
nop
add    $0x1,%rbp
mov    %r12,%rdi
call   1050 <strlen@plt>
add    $0x1,%eax
cmp    %rax,%rbp
jae    124c <stringTest+0x10c>
cmpb   $0x0,(%r12,%rbp,1)
jne    1220 <stringTest+0xe0>
mov    %r15,%rdi
mov    $0x1,%esi
xor    %eax,%eax
call   1060 <printf@plt>
jmp    1220 <stringTest+0xe0>
mov    $0xa,%edi
call   1030 <putchar@plt>
lea    0xdd7(%rip),%rdi
xor    %eax,%eax
call   1060 <printf@plt>
test   %r14d,%r14d
je     1283 <stringTest+0x143>
mov    %r14d,%ebp
xor    %ebx,%ebx
xchg   %ax,%ax
movsbl (%r12,%rbx,1),%edi
call   1030 <putchar@plt>
add    $0x1,%rbx
cmp    %rbx,%rbp
jne    1270 <stringTest+0x130>
lea    0xe49(%rip),%rdi
call   1040 <puts@plt>
lea    0xe3f(%rip),%rdi
call   1040 <puts@plt>
mov    $0xa,%edi
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <putchar@plt>

LLVM IR (-O0):
@.str = [2 x i8] c"\0A\00"
@.str.1 = [58 x i8] c"********************************************************\0A\00"
@.str.2 = [58 x i8] c"* Welcome in String Test v1.0 *\0A\00"
@.str.3 = [11 x i8] c"Address : \00"
@.str.4 = [3 x i8] c"%p\00"
@.str.5 = [36 x i8] c"Pointing to non initialized value \0A\00"
@.str.6 = [10 x i8] c"Length : \00"
@.str.7 = [3 x i8] c"%d\00"
@.str.8 = [25 x i8] c"Presence of end token : \00"
@.str.9 = [10 x i8] c"String : \00"
@.str.10 = [3 x i8] c"%c\00"
@.str.11 = [3 x i8] c"\0A\0A\00"
@.str.12 = [48 x i8] c"See you later for another segmentation fault !\0A\00"
define void @stringTest(i8* %0) {
%2 = alloca i8*
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
store i8* %0, i8** %2
store i32 0, i32* %3
store i32 0, i32* %4
store i32 0, i32* %5
%6 = load i8*, i8** %2
%7 = call i32 @strlen(i8* %6)
store i32 %7, i32* %4
%8 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%9 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([58 x i8], [58 x i8]* @.str.1, i64 0, i64 0))
%10 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([58 x i8], [58 x i8]* @.str.2, i64 0, i64 0))
%11 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([58 x i8], [58 x i8]* @.str.1, i64 0, i64 0))
%12 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%13 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.3, i64 0, i64 0))
%14 = load i8*, i8** %2
%15 = icmp ne i8* %14, null
br i1 %15, label %16, label %20
16: ; preds = %1
%17 = load i8*, i8** %2
%18 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i8* %17)
%19 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
br label %22
20: ; preds = %1
%21 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.5, i64 0, i64 0))
br label %22
22: ; preds = %20, %16
%23 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.6, i64 0, i64 0))
%24 = load i32, i32* %4
%25 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.7, i64 0, i64 0), i32 %24)
%26 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%27 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.8, i64 0, i64 0))
store i32 0, i32* %3
br label %28
28: ; preds = %46, %22
%29 = load i32, i32* %3
%30 = load i8*, i8** %2
%31 = call i32 @strlen(i8* %30)
%32 = add nsw i32 %31, 1
%33 = icmp ult i32 %29, %32
br i1 %33, label %34, label %49
34: ; preds = %28
%35 = load i8*, i8** %2
%36 = load i32, i32* %3
%37 = zext i32 %36 to i64
%38 = getelementptr inbounds i8, i8* %35, i64 %37
%39 = load i8, i8* %38
%40 = sext i8 %39 to i32
%41 = icmp eq i32 %40, 0
br i1 %41, label %42, label %45
42: ; preds = %34
store i32 1, i32* %5
%43 = load i32, i32* %5
%44 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.7, i64 0, i64 0), i32 %43)
br label %45
45: ; preds = %42, %34
br label %46
46: ; preds = %45
%47 = load i32, i32* %3
%48 = add i32 %47, 1
store i32 %48, i32* %3
br label %28
49: ; preds = %28
%50 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%51 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.9, i64 0, i64 0))
store i32 0, i32* %3
br label %52
52: ; preds = %64, %49
%53 = load i32, i32* %3
%54 = load i32, i32* %4
%55 = icmp ult i32 %53, %54
br i1 %55, label %56, label %67
56: ; preds = %52
%57 = load i8*, i8** %2
%58 = load i32, i32* %3
%59 = zext i32 %58 to i64
%60 = getelementptr inbounds i8, i8* %57, i64 %59
%61 = load i8, i8* %60
%62 = sext i8 %61 to i32
%63 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.10, i64 0, i64 0), i32 %62)
br label %64
64: ; preds = %56
%65 = load i32, i32* %3
%66 = add i32 %65, 1
store i32 %66, i32* %3
br label %52
67: ; preds = %52
%68 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.11, i64 0, i64 0))
%69 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([48 x i8], [48 x i8]* @.str.12, i64 0, i64 0))
%70 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
ret void
}

LLVM IR (-O2):
@.str.3 = [11 x i8] c"Address : \00"
@.str.4 = [3 x i8] c"%p\00"
@.str.6 = [10 x i8] c"Length : \00"
@.str.7 = [3 x i8] c"%d\00"
@.str.8 = [25 x i8] c"Presence of end token : \00"
@.str.9 = [10 x i8] c"String : \00"
@str.13 = [57 x i8] c"* Welcome in String Test v1.0 *\00"
@str.14 = [57 x i8] c"********************************************************\00"
@str.15 = [35 x i8] c"Pointing to non initialized value \00"
@str.16 = [2 x i8] c"\0A\00"
@str.17 = [47 x i8] c"See you later for another segmentation fault !\00"
define void @stringTest(i8* %0) {
%2 = tail call i32 @strlen(i8* %0)
%3 = tail call i32 @putchar(i32 10)
%4 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([57 x i8], [57 x i8]* @str.14, i64 0, i64 0))
%5 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([57 x i8], [57 x i8]* @str.13, i64 0, i64 0))
%6 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([57 x i8], [57 x i8]* @str.14, i64 0, i64 0))
%7 = tail call i32 @putchar(i32 10)
%8 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @.str.3, i64 0, i64 0))
%9 = icmp eq i8* %0, null
br i1 %9, label %13, label %10
10: ; preds = %1
%11 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i8* %0)
%12 = tail call i32 @putchar(i32 10)
br label %15
13: ; preds = %1
%14 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([35 x i8], [35 x i8]* @str.15, i64 0, i64 0))
br label %15
15: ; preds = %13, %10
%16 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @.str.6, i64 0, i64 0))
%17 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.7, i64 0, i64 0), i32 %2)
%18 = tail call i32 @putchar(i32 10)
%19 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @.str.8, i64 0, i64 0))
%20 = tail call i32 @strlen(i8* %0)
%21 = icmp eq i32 %20, -1
br i1 %21, label %35, label %22
22: ; preds = %15, %29
%23 = phi i64 [ %30, %29 ], [ 0, %15 ]
%24 = getelementptr inbounds i8, i8* %0, i64 %23
%25 = load i8, i8* %24
%26 = icmp eq i8 %25, 0
br i1 %26, label %27, label %29
27: ; preds = %22
%28 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.7, i64 0, i64 0), i32 1)
br label %29
29: ; preds = %22, %27
%30 = add nuw nsw i64 %23, 1
%31 = tail call i32 @strlen(i8* %0)
%32 = add nsw i32 %31, 1
%33 = zext i32 %32 to i64
%34 = icmp ult i64 %30, %33
br i1 %34, label %22, label %35
35: ; preds = %29, %15
%36 = tail call i32 @putchar(i32 10)
%37 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @.str.9, i64 0, i64 0))
%38 = icmp eq i32 %2, 0
br i1 %38, label %49, label %39
39: ; preds = %35
%40 = zext i32 %2 to i64
br label %41
41: ; preds = %39, %41
%42 = phi i64 [ 0, %39 ], [ %47, %41 ]
%43 = getelementptr inbounds i8, i8* %0, i64 %42
%44 = load i8, i8* %43
%45 = sext i8 %44 to i32
%46 = tail call i32 @putchar(i32 %45)
%47 = add nuw nsw i64 %42, 1
%48 = icmp eq i64 %47, %40
br i1 %48, label %49, label %41
49: ; preds = %41, %35
%50 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([2 x i8], [2 x i8]* @str.16, i64 0, i64 0))
%51 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([47 x i8], [47 x i8]* @str.17, i64 0, i64 0))
%52 = tail call i32 @putchar(i32 10)
ret void
}