int main() {
  char s[20] = "blabooboo";
  char *op = strchr(s, 'o');
  printf("%s, %s, %ld\n", s, op, op - s);
  char *o = strchr(s, '\n');
  printf("%s   %c", o, o);
  if (o) {
    printf("Shit");
  } else
    printf("Crap");
  char *p = strchr(s, 'o');
  printf("Here%s, %s, %ld\n", s, p, p - s);
  char *w = strchrnul(s, '\n');
  printf("Not here: %s   %c", w, w);
  if (*w == '\0') {
    printf("ShitNULL");
  } else
    printf("Crap");
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
mov    0xeba(%rip),%rax
mov    %rax,-0x20(%rbp)
mov    0xeb7(%rip),%rax
mov    %rax,-0x18(%rbp)
mov    0xeb5(%rip),%eax
mov    %eax,-0x10(%rbp)
lea    -0x20(%rbp),%rdi
mov    $0x6f,%esi
call   1040 <strchr@plt>
mov    %rax,-0x28(%rbp)
lea    -0x20(%rbp),%rsi
mov    -0x28(%rbp),%rdx
mov    -0x28(%rbp),%rcx
lea    -0x20(%rbp),%rax
sub    %rax,%rcx
lea    0xe98(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    -0x20(%rbp),%rdi
mov    $0xa,%esi
call   1040 <strchr@plt>
mov    %rax,-0x30(%rbp)
mov    -0x30(%rbp),%rsi
mov    -0x30(%rbp),%rdx
lea    0xe87(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
cmpq   $0x0,-0x30(%rbp)
je     11d7 <main+0xa7>
lea    0xe49(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
jmp    11e5 <main+0xb5>
lea    0xe3b(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    -0x20(%rbp),%rdi
mov    $0x6f,%esi
call   1040 <strchr@plt>
mov    %rax,-0x38(%rbp)
lea    -0x20(%rbp),%rsi
mov    -0x38(%rbp),%rdx
mov    -0x38(%rbp),%rcx
lea    -0x20(%rbp),%rax
sub    %rax,%rcx
lea    0xe0d(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    -0x20(%rbp),%rdi
mov    $0xa,%esi
mov    $0x0,%al
call   1030 <strchrnul@plt>
cltq
mov    %rax,-0x40(%rbp)
mov    -0x40(%rbp),%rsi
mov    -0x40(%rbp),%rdx
lea    0xdf2(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x40(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
jne    1267 <main+0x137>
lea    0xde6(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
jmp    1275 <main+0x145>
lea    0xdab(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
xor    %eax,%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
sub    $0x20,%rsp
movaps 0xec0(%rip),%xmm0
movaps %xmm0,(%rsp)
movl   $0x0,0x10(%rsp)
mov    %rsp,%r14
mov    %r14,%rdi
mov    $0x6f,%esi
call   1040 <strchr@plt>
mov    %rax,%rcx
sub    %r14,%rcx
lea    0xeb9(%rip),%rdi
mov    %r14,%rsi
mov    %rax,%rdx
xor    %eax,%eax
call   1050 <printf@plt>
mov    %r14,%rdi
mov    $0xa,%esi
call   1040 <strchr@plt>
mov    %rax,%rbx
lea    0xeac(%rip),%rdi
mov    %rax,%rsi
mov    %rax,%rdx
xor    %eax,%eax
call   1050 <printf@plt>
test   %rbx,%rbx
lea    0xe75(%rip),%r15
lea    0xe69(%rip),%rdi
cmove  %r15,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    %r14,%rdi
mov    $0x6f,%esi
call   1040 <strchr@plt>
mov    %rax,%rcx
sub    %r14,%rcx
lea    0xe4e(%rip),%rdi
mov    %r14,%rsi
mov    %rax,%rdx
xor    %eax,%eax
call   1050 <printf@plt>
mov    %r14,%rdi
mov    $0xa,%esi
xor    %eax,%eax
call   1030 <strchrnul@plt>
movslq %eax,%rbx
lea    0xe39(%rip),%rdi
mov    %rbx,%rsi
mov    %rbx,%rdx
xor    %eax,%eax
call   1050 <printf@plt>
cmpb   $0x0,(%rbx)
lea    0xe34(%rip),%rdi
cmovne %r15,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@__const.main.s = [20 x i8] c"blabooboo\00\00\00\00\00\00\00\00\00\00\00"
@.str = [13 x i8] c"%s, %s, %ld\0A\00"
@.str.1 = [8 x i8] c"%s %c\00"
@.str.2 = [5 x i8] c"Shit\00"
@.str.3 = [5 x i8] c"Crap\00"
@.str.4 = [17 x i8] c"Here%s, %s, %ld\0A\00"
@.str.5 = [18 x i8] c"Not here: %s %c\00"
@.str.6 = [9 x i8] c"ShitNULL\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [20 x i8]
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i8*
store i32 0, i32* %1
%7 = bitcast [20 x i8]* %2 to i8*
%8 = getelementptr inbounds [20 x i8], [20 x i8]* %2, i64 0, i64 0
%9 = call i8* @strchr(i8* %8, i32 111)
store i8* %9, i8** %3
%10 = getelementptr inbounds [20 x i8], [20 x i8]* %2, i64 0, i64 0
%11 = load i8*, i8** %3
%12 = load i8*, i8** %3
%13 = getelementptr inbounds [20 x i8], [20 x i8]* %2, i64 0, i64 0
%14 = ptrtoint i8* %12 to i64
%15 = ptrtoint i8* %13 to i64
%16 = sub i64 %14, %15
%17 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), i8* %10, i8* %11, i64 %16)
%18 = getelementptr inbounds [20 x i8], [20 x i8]* %2, i64 0, i64 0
%19 = call i8* @strchr(i8* %18, i32 10)
store i8* %19, i8** %4
%20 = load i8*, i8** %4
%21 = load i8*, i8** %4
%22 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0), i8* %20, i8* %21)
%23 = load i8*, i8** %4
%24 = icmp ne i8* %23, null
br i1 %24, label %25, label %27
25: ; preds = %0
%26 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0))
br label %29
27: ; preds = %0
%28 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0))
br label %29
29: ; preds = %27, %25
%30 = getelementptr inbounds [20 x i8], [20 x i8]* %2, i64 0, i64 0
%31 = call i8* @strchr(i8* %30, i32 111)
store i8* %31, i8** %5
%32 = getelementptr inbounds [20 x i8], [20 x i8]* %2, i64 0, i64 0
%33 = load i8*, i8** %5
%34 = load i8*, i8** %5
%35 = getelementptr inbounds [20 x i8], [20 x i8]* %2, i64 0, i64 0
%36 = ptrtoint i8* %34 to i64
%37 = ptrtoint i8* %35 to i64
%38 = sub i64 %36, %37
%39 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.4, i64 0, i64 0), i8* %32, i8* %33, i64 %38)
%40 = getelementptr inbounds [20 x i8], [20 x i8]* %2, i64 0, i64 0
%41 = call i32 (i8*, i32, ...) bitcast (i32 (...)* @strchrnul to i32 (i8*, i32, ...)*)(i8* %40, i32 10)
%42 = sext i32 %41 to i64
%43 = inttoptr i64 %42 to i8*
store i8* %43, i8** %6
%44 = load i8*, i8** %6
%45 = load i8*, i8** %6
%46 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.5, i64 0, i64 0), i8* %44, i8* %45)
%47 = load i8*, i8** %6
%48 = load i8, i8* %47
%49 = sext i8 %48 to i32
%50 = icmp eq i32 %49, 0
br i1 %50, label %51, label %53
51: ; preds = %29
%52 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.6, i64 0, i64 0))
br label %55
53: ; preds = %29
%54 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0))
br label %55
55: ; preds = %53, %51
ret i32 0
}

LLVM IR (-O2):
@__const.main.s = [20 x i8] c"blabooboo\00\00\00\00\00\00\00\00\00\00\00"
@.str = [13 x i8] c"%s, %s, %ld\0A\00"
@.str.1 = [8 x i8] c"%s %c\00"
@.str.2 = [5 x i8] c"Shit\00"
@.str.3 = [5 x i8] c"Crap\00"
@.str.4 = [17 x i8] c"Here%s, %s, %ld\0A\00"
@.str.5 = [18 x i8] c"Not here: %s %c\00"
@.str.6 = [9 x i8] c"ShitNULL\00"
define i32 @main() {
%1 = alloca [20 x i8]
%2 = getelementptr inbounds [20 x i8], [20 x i8]* %1, i64 0, i64 0
%3 = call i8* @strchr(i8* %2, i32 111)
%4 = ptrtoint i8* %3 to i64
%5 = ptrtoint [20 x i8]* %1 to i64
%6 = sub i64 %4, %5
%7 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), i8* %2, i8* %3, i64 %6)
%8 = call i8* @strchr(i8* %2, i32 10)
%9 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0), i8* %8, i8* %8)
%10 = icmp eq i8* %8, null
%11 = select i1 %10, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0)
%12 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) %11)
%13 = call i8* @strchr(i8* %2, i32 111)
%14 = ptrtoint i8* %13 to i64
%15 = sub i64 %14, %5
%16 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @.str.4, i64 0, i64 0), i8* %2, i8* %13, i64 %15)
%17 = call i32 (i8*, i32, ...) bitcast (i32 (...)* @strchrnul to i32 (i8*, i32, ...)*)(i8* %2, i32 10)
%18 = sext i32 %17 to i64
%19 = inttoptr i64 %18 to i8*
%20 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @.str.5, i64 0, i64 0), i8* %19, i8* %19)
%21 = load i8, i8* %19
%22 = icmp eq i8 %21, 0
%23 = select i1 %22, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.6, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0)
%24 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) %23)
ret i32 0
}