int main(int argc, char *argv[]) {
  char str1[128], str2[128];
  char *p;
  printf("Step 1: more string comparision functions\n");
  printf("Input two strings:\n");
  printf("?: ");
  scanf("%s", str1);
  printf("?: ");
  scanf("%s", str2);
  printf("strcasecmp(%s, %s) is %d\n", str1, str2, strcasecmp(str1, str2));
  printf("Step 2: strdup() function\n");
  printf("Input a string: ");
  scanf("%s", str1);
  p = strdup(str1);
  printf("str2 = strdup( %s ) is %s\n", str1, p);
  free(p);
  printf("strpbrk( '12-31-1999', '/-' ) = '%s'\n", strpbrk("12-31-1999", "/-"));
  printf("strspn('12/31/1999', '/-') is %d\n", strspn("12/31/1999", "/-"));
  printf("strcspn('12/31/1999', '0123456789') is %d\n",
         strcspn("12/31/1999", "!@#$"));
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x130,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    0xe60(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    0xe7d(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    0xe83(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    -0x90(%rbp),%rsi
lea    0xe72(%rip),%rdi
mov    $0x0,%al
call   1090 <scanf@plt>
lea    0xe60(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    -0x110(%rbp),%rsi
lea    0xe4f(%rip),%rdi
mov    $0x0,%al
call   1090 <scanf@plt>
lea    -0x90(%rbp),%rax
mov    %rax,-0x128(%rbp)
lea    -0x110(%rbp),%rax
mov    %rax,-0x120(%rbp)
lea    -0x90(%rbp),%rdi
lea    -0x110(%rbp),%rsi
call   1040 <strcasecmp@plt>
mov    -0x128(%rbp),%rsi
mov    -0x120(%rbp),%rdx
mov    %eax,%ecx
lea    0xe05(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    0xe11(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    0xe1e(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    -0x90(%rbp),%rsi
lea    0xdd1(%rip),%rdi
mov    $0x0,%al
call   1090 <scanf@plt>
lea    -0x90(%rbp),%rdi
call   10a0 <strdup@plt>
mov    %rax,-0x118(%rbp)
lea    -0x90(%rbp),%rsi
mov    -0x118(%rbp),%rdx
lea    0xdeb(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x118(%rbp),%rdi
call   1030 <free@plt>
lea    0xe12(%rip),%rdi
lea    0xe16(%rip),%rsi
call   1080 <strpbrk@plt>
mov    %rax,%rsi
lea    0xdd6(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    0xe1e(%rip),%rdi
lea    0xdf2(%rip),%rsi
call   1060 <strspn@plt>
mov    %rax,%rsi
lea    0xde6(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    0xdfa(%rip),%rdi
lea    0xe29(%rip),%rsi
call   1070 <strcspn@plt>
mov    %rax,%rsi
lea    0xdef(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
xor    %eax,%eax
add    $0x130,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x108,%rsp
lea    0xf56(%rip),%rdi
call   1050 <puts@plt>
lea    0xf74(%rip),%rdi
call   1050 <puts@plt>
lea    0xe73(%rip),%r15
mov    %r15,%rdi
xor    %eax,%eax
call   1060 <printf@plt>
lea    0xe66(%rip),%r14
lea    0x80(%rsp),%r12
mov    %r14,%rdi
mov    %r12,%rsi
xor    %eax,%eax
call   1070 <scanf@plt>
mov    %r15,%rdi
xor    %eax,%eax
call   1060 <printf@plt>
mov    %rsp,%rbx
mov    %r14,%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1070 <scanf@plt>
mov    %r12,%rdi
mov    %rbx,%rsi
call   1040 <strcasecmp@plt>
lea    0xe28(%rip),%rdi
mov    %r12,%rsi
mov    %rbx,%rdx
mov    %eax,%ecx
xor    %eax,%eax
call   1060 <printf@plt>
lea    0xf13(%rip),%rdi
call   1050 <puts@plt>
lea    0xe20(%rip),%rdi
xor    %eax,%eax
call   1060 <printf@plt>
mov    %r14,%rdi
mov    %r12,%rsi
xor    %eax,%eax
call   1070 <scanf@plt>
mov    %r12,%rdi
call   1080 <strdup@plt>
mov    %rax,%rbx
lea    0xe0b(%rip),%rdi
mov    %r12,%rsi
mov    %rax,%rdx
xor    %eax,%eax
call   1060 <printf@plt>
mov    %rbx,%rdi
call   1030 <free@plt>
lea    0xe0a(%rip),%rdi
lea    0xe2b(%rip),%rsi
xor    %eax,%eax
call   1060 <printf@plt>
lea    0xe26(%rip),%rdi
xor    %esi,%esi
xor    %eax,%eax
call   1060 <printf@plt>
lea    0xe38(%rip),%rdi
mov    $0xa,%esi
xor    %eax,%eax
call   1060 <printf@plt>
xor    %eax,%eax
add    $0x108,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [43 x i8] c"Step 1: more string comparision functions\0A\00"
@.str.1 = [20 x i8] c"Input two strings:\0A\00"
@.str.2 = [4 x i8] c"?: \00"
@.str.3 = [3 x i8] c"%s\00"
@.str.4 = [26 x i8] c"strcasecmp(%s, %s) is %d\0A\00"
@.str.5 = [27 x i8] c"Step 2: strdup() function\0A\00"
@.str.6 = [17 x i8] c"Input a string: \00"
@.str.7 = [27 x i8] c"str2 = strdup( %s ) is %s\0A\00"
@.str.8 = [38 x i8] c"strpbrk( '12-31-1999', '/-' ) = '%s'\0A\00"
@.str.9 = [11 x i8] c"12-31-1999\00"
@.str.10 = [3 x i8] c"/-\00"
@.str.11 = [34 x i8] c"strspn('12/31/1999', '/-') is %d\0A\00"
@.str.12 = [11 x i8] c"12/31/1999\00"
@.str.13 = [43 x i8] c"strcspn('12/31/1999', '0123456789') is %d\0A\00"
@.str.14 = [5 x i8] c"!@#$\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca [128 x i8]
%7 = alloca [128 x i8]
%8 = alloca i8*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%9 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str, i64 0, i64 0))
%10 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.1, i64 0, i64 0))
%11 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0))
%12 = getelementptr inbounds [128 x i8], [128 x i8]* %6, i64 0, i64 0
%13 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i8* %12)
%14 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0))
%15 = getelementptr inbounds [128 x i8], [128 x i8]* %7, i64 0, i64 0
%16 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i8* %15)
%17 = getelementptr inbounds [128 x i8], [128 x i8]* %6, i64 0, i64 0
%18 = getelementptr inbounds [128 x i8], [128 x i8]* %7, i64 0, i64 0
%19 = getelementptr inbounds [128 x i8], [128 x i8]* %6, i64 0, i64 0
%20 = getelementptr inbounds [128 x i8], [128 x i8]* %7, i64 0, i64 0
%21 = call i32 @strcasecmp(i8* %19, i8* %20)
%22 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.4, i64 0, i64 0), i8* %17, i8* %18, i32 %21)
%23 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.5, i64 0, i64 0))
%24 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.6, i64 0, i64 0))
%25 = getelementptr inbounds [128 x i8], [128 x i8]* %6, i64 0, i64 0
%26 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i8* %25)
%27 = getelementptr inbounds [128 x i8], [128 x i8]* %6, i64 0, i64 0
%28 = call i8* @strdup(i8* %27)
store i8* %28, i8** %8
%29 = getelementptr inbounds [128 x i8], [128 x i8]* %6, i64 0, i64 0
%30 = load i8*, i8** %8
%31 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.7, i64 0, i64 0), i8* %29, i8* %30)
%32 = load i8*, i8** %8
%33 = call i8* @strpbrk(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.9, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.10, i64 0, i64 0))
%34 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.8, i64 0, i64 0), i8* %33)
%35 = call i64 @strspn(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.12, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.10, i64 0, i64 0))
%36 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.11, i64 0, i64 0), i64 %35)
%37 = call i64 @strcspn(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.12, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.14, i64 0, i64 0))
%38 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str.13, i64 0, i64 0), i64 %37)
ret i32 0
}

LLVM IR (-O2):
@.str.2 = [4 x i8] c"?: \00"
@.str.3 = [3 x i8] c"%s\00"
@.str.4 = [26 x i8] c"strcasecmp(%s, %s) is %d\0A\00"
@.str.6 = [17 x i8] c"Input a string: \00"
@.str.7 = [27 x i8] c"str2 = strdup( %s ) is %s\0A\00"
@.str.8 = [38 x i8] c"strpbrk( '12-31-1999', '/-' ) = '%s'\0A\00"
@.str.9 = [11 x i8] c"12-31-1999\00"
@.str.11 = [34 x i8] c"strspn('12/31/1999', '/-') is %d\0A\00"
@.str.13 = [43 x i8] c"strcspn('12/31/1999', '0123456789') is %d\0A\00"
@str = [42 x i8] c"Step 1: more string comparision functions\00"
@str.15 = [19 x i8] c"Input two strings:\00"
@str.16 = [26 x i8] c"Step 2: strdup() function\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca [128 x i8]
%4 = alloca [128 x i8]
%5 = getelementptr inbounds [128 x i8], [128 x i8]* %3, i64 0, i64 0
%6 = getelementptr inbounds [128 x i8], [128 x i8]* %4, i64 0, i64 0
%7 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([42 x i8], [42 x i8]* @str, i64 0, i64 0))
%8 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @str.15, i64 0, i64 0))
%9 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0))
%10 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i8* %5)
%11 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0))
%12 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i8* %6)
%13 = call i32 @strcasecmp(i8* %5, i8* %6)
%14 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @.str.4, i64 0, i64 0), i8* %5, i8* %6, i32 %13)
%15 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @str.16, i64 0, i64 0))
%16 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @.str.6, i64 0, i64 0))
%17 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i8* %5)
%18 = call i8* @strdup(i8* %5)
%19 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @.str.7, i64 0, i64 0), i8* %5, i8* %18)
%20 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([38 x i8], [38 x i8]* @.str.8, i64 0, i64 0), i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.9, i64 0, i64 2))
%21 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([34 x i8], [34 x i8]* @.str.11, i64 0, i64 0), i64 0)
%22 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([43 x i8], [43 x i8]* @.str.13, i64 0, i64 0), i64 10)
ret i32 0
}