int main() {
  char buf[64];
  char *volatile p = buf;
  char *volatile q = "ABCDEF";
  buf[7] = 'G';
  if (fn1(p, q) != 0 || memcmp(buf, "ABCDEF\0G", 8))
    abort();
  q = "HIJ";
  if (fn2(p + 1, q) != 0 || memcmp(buf, "AHIJ\0F\0G", 8))
    abort();
  buf[6] = 'K';
  if (fn3(p + 1) != 4 || memcmp(buf, "Aabcd\0KG", 8))
    abort();
  if (fn4(p) != 3 || memcmp(buf, "efg\0hiKG", 8))
    abort();
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
movl   $0x0,-0x4(%rbp)
lea    -0x50(%rbp),%rax
mov    %rax,-0x58(%rbp)
lea    0xe92(%rip),%rax
mov    %rax,-0x60(%rbp)
movb   $0x47,-0x49(%rbp)
mov    -0x58(%rbp),%rdi
mov    -0x60(%rbp),%rsi
mov    $0x0,%al
call   1040 <fn1@plt>
cmp    $0x0,%eax
jne    11b1 <main+0x61>
lea    -0x50(%rbp),%rax
mov    (%rax),%rax
movabs $0x4700464544434241,%rcx
sub    %rcx,%rax
setne  %al
movzbl %al,%eax
cmp    $0x0,%eax
je     11b6 <main+0x66>
call   1030 <abort@plt>
lea    0xe4a(%rip),%rax
mov    %rax,-0x60(%rbp)
mov    -0x58(%rbp),%rdi
add    $0x1,%rdi
mov    -0x60(%rbp),%rsi
mov    $0x0,%al
call   1070 <fn2@plt>
cmp    $0x0,%eax
jne    1200 <main+0xb0>
lea    -0x50(%rbp),%rax
mov    (%rax),%rax
movabs $0x470046004a494841,%rcx
sub    %rcx,%rax
setne  %al
movzbl %al,%eax
cmp    $0x0,%eax
je     1205 <main+0xb5>
call   1030 <abort@plt>
movb   $0x4b,-0x4a(%rbp)
mov    -0x58(%rbp),%rdi
add    $0x1,%rdi
mov    $0x0,%al
call   1050 <fn3@plt>
cmp    $0x4,%eax
jne    1244 <main+0xf4>
lea    -0x50(%rbp),%rax
mov    (%rax),%rax
movabs $0x474b006463626141,%rcx
sub    %rcx,%rax
setne  %al
movzbl %al,%eax
cmp    $0x0,%eax
je     1249 <main+0xf9>
call   1030 <abort@plt>
mov    -0x58(%rbp),%rdi
mov    $0x0,%al
call   1060 <fn4@plt>
cmp    $0x3,%eax
jne    1280 <main+0x130>
lea    -0x50(%rbp),%rax
mov    (%rax),%rax
movabs $0x474b696800676665,%rcx
69 4b 47
sub    %rcx,%rax
setne  %al
movzbl %al,%eax
cmp    $0x0,%eax
je     1285 <main+0x135>
call   1030 <abort@plt>
xor    %eax,%eax
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
sub    $0x58,%rsp
lea    0x10(%rsp),%rax
mov    %rax,(%rsp)
lea    0xe9c(%rip),%rax
mov    %rax,0x8(%rsp)
movb   $0x47,0x17(%rsp)
mov    (%rsp),%rdi
mov    0x8(%rsp),%rsi
xor    %eax,%eax
call   1040 <fn1@plt>
test   %eax,%eax
jne    1222 <main+0xd2>
movabs $0x4700464544434241,%rax
cmp    %rax,0x10(%rsp)
jne    1222 <main+0xd2>
lea    0xe65(%rip),%rax
mov    %rax,0x8(%rsp)
mov    (%rsp),%rdi
add    $0x1,%rdi
mov    0x8(%rsp),%rsi
xor    %eax,%eax
call   1070 <fn2@plt>
test   %eax,%eax
jne    1222 <main+0xd2>
movabs $0x470046004a494841,%rax
cmp    %rax,0x10(%rsp)
jne    1222 <main+0xd2>
movb   $0x4b,0x16(%rsp)
mov    (%rsp),%rdi
add    $0x1,%rdi
xor    %eax,%eax
call   1050 <fn3@plt>
cmp    $0x4,%eax
jne    1222 <main+0xd2>
movabs $0x474b006463626141,%rax
cmp    %rax,0x10(%rsp)
jne    1222 <main+0xd2>
mov    (%rsp),%rdi
xor    %eax,%eax
call   1060 <fn4@plt>
cmp    $0x3,%eax
jne    1222 <main+0xd2>
movabs $0x474b696800676665,%rax
69 4b 47
cmp    %rax,0x10(%rsp)
jne    1222 <main+0xd2>
xor    %eax,%eax
add    $0x58,%rsp
ret
call   1030 <abort@plt>

LLVM IR (-O0):
@.str = [7 x i8] c"ABCDEF\00"
@.str.1 = [9 x i8] c"ABCDEF\00G\00"
@.str.2 = [4 x i8] c"HIJ\00"
@.str.3 = [9 x i8] c"AHIJ\00F\00G\00"
@.str.4 = [9 x i8] c"Aabcd\00KG\00"
@.str.5 = [9 x i8] c"efg\00hiKG\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [64 x i8]
%3 = alloca i8*
%4 = alloca i8*
store i32 0, i32* %1
%5 = getelementptr inbounds [64 x i8], [64 x i8]* %2, i64 0, i64 0
store volatile i8* %5, i8** %3
store volatile i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i8** %4
%6 = getelementptr inbounds [64 x i8], [64 x i8]* %2, i64 0, i64 7
store i8 71, i8* %6
%7 = load volatile i8*, i8** %3
%8 = load volatile i8*, i8** %4
%9 = call i32 (i8*, i8*, ...) bitcast (i32 (...)* @fn1 to i32 (i8*, i8*, ...)*)(i8* %7, i8* %8)
%10 = icmp ne i32 %9, 0
br i1 %10, label %15, label %11
11: ; preds = %0
%12 = getelementptr inbounds [64 x i8], [64 x i8]* %2, i64 0, i64 0
%13 = call i32 @memcmp(i8* %12, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), i64 8)
%14 = icmp ne i32 %13, 0
br i1 %14, label %15, label %16
15: ; preds = %11, %0
unreachable
16: ; preds = %11
store volatile i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i8** %4
%17 = load volatile i8*, i8** %3
%18 = getelementptr inbounds i8, i8* %17, i64 1
%19 = load volatile i8*, i8** %4
%20 = call i32 (i8*, i8*, ...) bitcast (i32 (...)* @fn2 to i32 (i8*, i8*, ...)*)(i8* %18, i8* %19)
%21 = icmp ne i32 %20, 0
br i1 %21, label %26, label %22
22: ; preds = %16
%23 = getelementptr inbounds [64 x i8], [64 x i8]* %2, i64 0, i64 0
%24 = call i32 @memcmp(i8* %23, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.3, i64 0, i64 0), i64 8)
%25 = icmp ne i32 %24, 0
br i1 %25, label %26, label %27
26: ; preds = %22, %16
unreachable
27: ; preds = %22
%28 = getelementptr inbounds [64 x i8], [64 x i8]* %2, i64 0, i64 6
store i8 75, i8* %28
%29 = load volatile i8*, i8** %3
%30 = getelementptr inbounds i8, i8* %29, i64 1
%31 = call i32 (i8*, ...) bitcast (i32 (...)* @fn3 to i32 (i8*, ...)*)(i8* %30)
%32 = icmp ne i32 %31, 4
br i1 %32, label %37, label %33
33: ; preds = %27
%34 = getelementptr inbounds [64 x i8], [64 x i8]* %2, i64 0, i64 0
%35 = call i32 @memcmp(i8* %34, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.4, i64 0, i64 0), i64 8)
%36 = icmp ne i32 %35, 0
br i1 %36, label %37, label %38
37: ; preds = %33, %27
unreachable
38: ; preds = %33
%39 = load volatile i8*, i8** %3
%40 = call i32 (i8*, ...) bitcast (i32 (...)* @fn4 to i32 (i8*, ...)*)(i8* %39)
%41 = icmp ne i32 %40, 3
br i1 %41, label %46, label %42
42: ; preds = %38
%43 = getelementptr inbounds [64 x i8], [64 x i8]* %2, i64 0, i64 0
%44 = call i32 @memcmp(i8* %43, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.5, i64 0, i64 0), i64 8)
%45 = icmp ne i32 %44, 0
br i1 %45, label %46, label %47
46: ; preds = %42, %38
unreachable
47: ; preds = %42
ret i32 0
}

LLVM IR (-O2):
@.str = [7 x i8] c"ABCDEF\00"
@.str.2 = [4 x i8] c"HIJ\00"
define i32 @main() {
%1 = alloca [64 x i8]
%2 = alloca i8*
%3 = alloca i8*
%4 = getelementptr inbounds [64 x i8], [64 x i8]* %1, i64 0, i64 0
%5 = bitcast i8** %2 to i8*
store volatile i8* %4, i8** %2
%6 = bitcast i8** %3 to i8*
store volatile i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i8** %3
%7 = getelementptr inbounds [64 x i8], [64 x i8]* %1, i64 0, i64 7
store i8 71, i8* %7
%8 = load volatile i8*, i8** %2
%9 = load volatile i8*, i8** %3
%10 = call i32 (i8*, i8*, ...) bitcast (i32 (...)* @fn1 to i32 (i8*, i8*, ...)*)(i8* %8, i8* %9)
%11 = icmp eq i32 %10, 0
%12 = bitcast [64 x i8]* %1 to i64*
%13 = load i64, i64* %12
%14 = icmp eq i64 %13, 5116166440004829761
%15 = select i1 %11, i1 %14, i1 false
br i1 %15, label %17, label %16
16: ; preds = %0
unreachable
17: ; preds = %0
store volatile i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i8** %3
%18 = load volatile i8*, i8** %2
%19 = getelementptr inbounds i8, i8* %18, i64 1
%20 = load volatile i8*, i8** %3
%21 = call i32 (i8*, i8*, ...) bitcast (i32 (...)* @fn2 to i32 (i8*, i8*, ...)*)(i8* %19, i8* %20)
%22 = icmp eq i32 %21, 0
%23 = load i64, i64* %12
%24 = icmp eq i64 %23, 5116166143753144385
%25 = select i1 %22, i1 %24, i1 false
br i1 %25, label %27, label %26
26: ; preds = %17
unreachable
27: ; preds = %17
%28 = getelementptr inbounds [64 x i8], [64 x i8]* %1, i64 0, i64 6
store i8 75, i8* %28
%29 = load volatile i8*, i8** %2
%30 = getelementptr inbounds i8, i8* %29, i64 1
%31 = call i32 (i8*, ...) bitcast (i32 (...)* @fn3 to i32 (i8*, ...)*)(i8* %30)
%32 = icmp eq i32 %31, 4
%33 = load i64, i64* %12
%34 = icmp eq i64 %33, 5137200231110304065
%35 = select i1 %32, i1 %34, i1 false
br i1 %35, label %37, label %36
36: ; preds = %27
unreachable
37: ; preds = %27
%38 = load volatile i8*, i8** %2
%39 = call i32 (i8*, ...) bitcast (i32 (...)* @fn4 to i32 (i8*, ...)*)(i8* %38)
%40 = icmp eq i32 %39, 3
%41 = load i64, i64* %12
%42 = icmp eq i64 %41, 5137315695350474341
%43 = select i1 %40, i1 %42, i1 false
br i1 %43, label %45, label %44
44: ; preds = %37
unreachable
45: ; preds = %37
ret i32 0
}