#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*/ abort();
char *fn1(int, int, int);
scalar_t__ memcmp(char const *, char const *, int);
int main() {
  int i;
  for (i = 0; i < 5; i++) {
    const char *p = "abcdefghijklmnopq" + (i < 3 ? i : 3) * 4;
    const char *q;
    int j = i >= 3;
    fn1(i ? 0 : 1, 1, 1);
    q = fn1(i, 0, 0);
    if (memcmp(q, p + 1, 3 + j) != 0 || memcmp(q + 3 + j, "RST", 4) != 0)
      abort();
    fn1(i ? 0 : 1, 0, 1);
    q = fn1(i, 1, 0);
    if (memcmp(q, p, 4 + j) != 0 || memcmp(q + 4 + j, "HIJKLMN", 8) != 0)
      abort();
    fn1(i ? 0 : 1, 1, 0);
    q = fn1(i, 0, 1);
    if (memcmp(q, p + 1, 3 + j) != 0 || memcmp(q + 3 + j, "OPQ", 4) != 0)
      abort();
    fn1(i ? 0 : 1, 0, 0);
    q = fn1(i, 1, 1);
    if (memcmp(q, p, 4 + j) != 0 || memcmp(q + 4 + j, "ABCDEFG", 8) != 0)
      abort();
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x8(%rbp)
cmpl   $0x5,-0x8(%rbp)
jge    13a1 <main+0x271>
cmpl   $0x3,-0x8(%rbp)
jge    1165 <main+0x35>
mov    -0x8(%rbp),%eax
mov    %eax,-0x20(%rbp)
jmp    1172 <main+0x42>
mov    $0x3,%eax
mov    %eax,-0x20(%rbp)
jmp    1172 <main+0x42>
mov    -0x20(%rbp),%eax
shl    $0x2,%eax
movslq %eax,%rcx
lea    0xe7e(%rip),%rax
add    %rcx,%rax
mov    %rax,-0x10(%rbp)
cmpl   $0x3,-0x8(%rbp)
setge  %al
and    $0x1,%al
movzbl %al,%eax
mov    %eax,-0x1c(%rbp)
mov    -0x8(%rbp),%ecx
mov    $0x1,%edi
xor    %eax,%eax
cmp    $0x0,%ecx
cmovne %eax,%edi
mov    $0x1,%edx
mov    %edx,%esi
call   1040 <fn1@plt>
mov    -0x8(%rbp),%edi
xor    %edx,%edx
mov    %edx,%esi
call   1040 <fn1@plt>
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
mov    -0x10(%rbp),%rsi
add    $0x1,%rsi
mov    -0x1c(%rbp),%edx
add    $0x3,%edx
call   1050 <memcmp@plt>
cmp    $0x0,%rax
jne    120f <main+0xdf>
mov    -0x18(%rbp),%rdi
add    $0x3,%rdi
movslq -0x1c(%rbp),%rax
add    %rax,%rdi
lea    0xe17(%rip),%rsi
mov    $0x4,%edx
call   1050 <memcmp@plt>
cmp    $0x0,%rax
je     1216 <main+0xe6>
mov    $0x0,%al
call   1030 <abort@plt>
mov    -0x8(%rbp),%ecx
mov    $0x1,%edi
xor    %eax,%eax
cmp    $0x0,%ecx
cmovne %eax,%edi
xor    %esi,%esi
mov    $0x1,%edx
call   1040 <fn1@plt>
mov    -0x8(%rbp),%edi
mov    $0x1,%esi
xor    %edx,%edx
call   1040 <fn1@plt>
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x1c(%rbp),%edx
add    $0x4,%edx
call   1050 <memcmp@plt>
cmp    $0x0,%rax
jne    128c <main+0x15c>
mov    -0x18(%rbp),%rdi
add    $0x4,%rdi
movslq -0x1c(%rbp),%rax
add    %rax,%rdi
lea    0xd9e(%rip),%rsi
mov    $0x8,%edx
call   1050 <memcmp@plt>
cmp    $0x0,%rax
je     1293 <main+0x163>
mov    $0x0,%al
call   1030 <abort@plt>
mov    -0x8(%rbp),%ecx
mov    $0x1,%edi
xor    %eax,%eax
cmp    $0x0,%ecx
cmovne %eax,%edi
mov    $0x1,%esi
xor    %edx,%edx
call   1040 <fn1@plt>
mov    -0x8(%rbp),%edi
xor    %esi,%esi
mov    $0x1,%edx
call   1040 <fn1@plt>
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
mov    -0x10(%rbp),%rsi
add    $0x1,%rsi
mov    -0x1c(%rbp),%edx
add    $0x3,%edx
call   1050 <memcmp@plt>
cmp    $0x0,%rax
jne    130d <main+0x1dd>
mov    -0x18(%rbp),%rdi
add    $0x3,%rdi
movslq -0x1c(%rbp),%rax
add    %rax,%rdi
lea    0xd25(%rip),%rsi
mov    $0x4,%edx
call   1050 <memcmp@plt>
cmp    $0x0,%rax
je     1314 <main+0x1e4>
mov    $0x0,%al
call   1030 <abort@plt>
mov    -0x8(%rbp),%ecx
mov    $0x1,%edi
xor    %eax,%eax
cmp    $0x0,%ecx
cmovne %eax,%edi
xor    %edx,%edx
mov    %edx,%esi
call   1040 <fn1@plt>
mov    -0x8(%rbp),%edi
mov    $0x1,%edx
mov    %edx,%esi
call   1040 <fn1@plt>
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x1c(%rbp),%edx
add    $0x4,%edx
call   1050 <memcmp@plt>
cmp    $0x0,%rax
jne    1387 <main+0x257>
mov    -0x18(%rbp),%rdi
add    $0x4,%rdi
movslq -0x1c(%rbp),%rax
add    %rax,%rdi
lea    0xcaf(%rip),%rsi
mov    $0x8,%edx
call   1050 <memcmp@plt>
cmp    $0x0,%rax
je     138e <main+0x25e>
mov    $0x0,%al
call   1030 <abort@plt>
jmp    1393 <main+0x263>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    1146 <main+0x16>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
xor    %ebx,%ebx
cmp    $0x3,%ebx
mov    $0x3,%ebp
cmovb  %ebx,%ebp
mov    $0x3,%r15d
sbb    $0xffffffff,%r15d
shl    $0x2,%ebp
xor    %r14d,%r14d
test   %ebx,%ebx
sete   %r14b
mov    %r14d,%edi
mov    $0x1,%esi
mov    $0x1,%edx
call   1040 <fn1@plt>
mov    %ebx,%edi
xor    %esi,%esi
xor    %edx,%edx
call   1040 <fn1@plt>
mov    %rax,%r12
lea    0xe78(%rip),%rax
lea    (%rax,%rbp,1),%rsi
add    $0x1,%rsi
mov    %r12,%rdi
mov    %rsi,0x10(%rsp)
mov    %r15d,%edx
call   1050 <memcmp@plt>
test   %rax,%rax
jne    1317 <main+0x1e7>
xor    %r13d,%r13d
cmp    $0x3,%ebx
setae  %r13b
lea    (%r12,%r13,1),%rdi
add    $0x3,%rdi
lea    0xe50(%rip),%rsi
mov    $0x4,%edx
call   1050 <memcmp@plt>
test   %rax,%rax
jne    1317 <main+0x1e7>
lea    0xe24(%rip),%rax
add    %rax,%rbp
xor    %r12d,%r12d
cmp    $0x3,%ebx
setae  %r12b
mov    %r14d,%edi
xor    %esi,%esi
mov    $0x1,%edx
call   1040 <fn1@plt>
mov    %ebx,0xc(%rsp)
mov    %ebx,%edi
mov    $0x1,%esi
xor    %edx,%edx
call   1040 <fn1@plt>
mov    %rax,%rbx
or     $0x4,%r12d
mov    %rax,%rdi
mov    %rbp,%rsi
mov    %r12d,%edx
call   1050 <memcmp@plt>
test   %rax,%rax
jne    1317 <main+0x1e7>
lea    (%rbx,%r13,1),%rdi
add    $0x4,%rdi
lea    0xddf(%rip),%rsi
mov    $0x8,%edx
call   1050 <memcmp@plt>
test   %rax,%rax
jne    1317 <main+0x1e7>
mov    %r14d,%edi
mov    $0x1,%esi
xor    %edx,%edx
call   1040 <fn1@plt>
mov    0xc(%rsp),%edi
xor    %esi,%esi
mov    $0x1,%edx
call   1040 <fn1@plt>
mov    %rax,%rbx
mov    %rax,%rdi
mov    0x10(%rsp),%rsi
mov    %r15d,%edx
call   1050 <memcmp@plt>
test   %rax,%rax
jne    1317 <main+0x1e7>
lea    (%rbx,%r13,1),%rdi
add    $0x3,%rdi
lea    0xd8a(%rip),%rsi
mov    $0x4,%edx
call   1050 <memcmp@plt>
test   %rax,%rax
jne    1317 <main+0x1e7>
mov    %r14d,%edi
xor    %esi,%esi
xor    %edx,%edx
call   1040 <fn1@plt>
mov    0xc(%rsp),%edi
mov    $0x1,%esi
mov    $0x1,%edx
call   1040 <fn1@plt>
mov    %rax,%rbx
mov    %rax,%rdi
mov    %rbp,%rsi
mov    %r12d,%edx
call   1050 <memcmp@plt>
test   %rax,%rax
jne    1317 <main+0x1e7>
lea    (%rbx,%r13,1),%rdi
add    $0x4,%rdi
lea    0xd3b(%rip),%rsi
mov    $0x8,%edx
call   1050 <memcmp@plt>
test   %rax,%rax
jne    1317 <main+0x1e7>
mov    0xc(%rsp),%ebx
add    $0x1,%ebx
cmp    $0x5,%ebx
jne    1140 <main+0x10>
xor    %eax,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
xor    %eax,%eax
call   1030 <abort@plt>

LLVM IR (-O0):
@.str = [18 x i8] c"abcdefghijklmnopq\00"
@.str.1 = [4 x i8] c"RST\00"
@.str.2 = [8 x i8] c"HIJKLMN\00"
@.str.3 = [4 x i8] c"OPQ\00"
@.str.4 = [8 x i8] c"ABCDEFG\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i32
store i32 0, i32* %1
store i32 0, i32* %2
br label %6
6: ; preds = %121, %0
%7 = load i32, i32* %2
%8 = icmp slt i32 %7, 5
br i1 %8, label %9, label %124
9: ; preds = %6
%10 = load i32, i32* %2
%11 = icmp slt i32 %10, 3
br i1 %11, label %12, label %14
12: ; preds = %9
%13 = load i32, i32* %2
br label %15
14: ; preds = %9
br label %15
15: ; preds = %14, %12
%16 = phi i32 [ %13, %12 ], [ 3, %14 ]
%17 = mul nsw i32 %16, 4
%18 = sext i32 %17 to i64
%19 = getelementptr inbounds i8, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0), i64 %18
store i8* %19, i8** %3
%20 = load i32, i32* %2
%21 = icmp sge i32 %20, 3
%22 = zext i1 %21 to i32
store i32 %22, i32* %5
%23 = load i32, i32* %2
%24 = icmp ne i32 %23, 0
%25 = zext i1 %24 to i64
%26 = select i1 %24, i32 0, i32 1
%27 = call i8* @fn1(i32 %26, i32 1, i32 1)
%28 = load i32, i32* %2
%29 = call i8* @fn1(i32 %28, i32 0, i32 0)
store i8* %29, i8** %4
%30 = load i8*, i8** %4
%31 = load i8*, i8** %3
%32 = getelementptr inbounds i8, i8* %31, i64 1
%33 = load i32, i32* %5
%34 = add nsw i32 3, %33
%35 = call i64 @memcmp(i8* %30, i8* %32, i32 %34)
%36 = icmp ne i64 %35, 0
br i1 %36, label %45, label %37
37: ; preds = %15
%38 = load i8*, i8** %4
%39 = getelementptr inbounds i8, i8* %38, i64 3
%40 = load i32, i32* %5
%41 = sext i32 %40 to i64
%42 = getelementptr inbounds i8, i8* %39, i64 %41
%43 = call i64 @memcmp(i8* %42, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 4)
%44 = icmp ne i64 %43, 0
br i1 %44, label %45, label %47
45: ; preds = %37, %15
%46 = call i32 (...) @abort()
unreachable
47: ; preds = %37
%48 = load i32, i32* %2
%49 = icmp ne i32 %48, 0
%50 = zext i1 %49 to i64
%51 = select i1 %49, i32 0, i32 1
%52 = call i8* @fn1(i32 %51, i32 0, i32 1)
%53 = load i32, i32* %2
%54 = call i8* @fn1(i32 %53, i32 1, i32 0)
store i8* %54, i8** %4
%55 = load i8*, i8** %4
%56 = load i8*, i8** %3
%57 = load i32, i32* %5
%58 = add nsw i32 4, %57
%59 = call i64 @memcmp(i8* %55, i8* %56, i32 %58)
%60 = icmp ne i64 %59, 0
br i1 %60, label %69, label %61
61: ; preds = %47
%62 = load i8*, i8** %4
%63 = getelementptr inbounds i8, i8* %62, i64 4
%64 = load i32, i32* %5
%65 = sext i32 %64 to i64
%66 = getelementptr inbounds i8, i8* %63, i64 %65
%67 = call i64 @memcmp(i8* %66, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0), i32 8)
%68 = icmp ne i64 %67, 0
br i1 %68, label %69, label %71
69: ; preds = %61, %47
%70 = call i32 (...) @abort()
unreachable
71: ; preds = %61
%72 = load i32, i32* %2
%73 = icmp ne i32 %72, 0
%74 = zext i1 %73 to i64
%75 = select i1 %73, i32 0, i32 1
%76 = call i8* @fn1(i32 %75, i32 1, i32 0)
%77 = load i32, i32* %2
%78 = call i8* @fn1(i32 %77, i32 0, i32 1)
store i8* %78, i8** %4
%79 = load i8*, i8** %4
%80 = load i8*, i8** %3
%81 = getelementptr inbounds i8, i8* %80, i64 1
%82 = load i32, i32* %5
%83 = add nsw i32 3, %82
%84 = call i64 @memcmp(i8* %79, i8* %81, i32 %83)
%85 = icmp ne i64 %84, 0
br i1 %85, label %94, label %86
86: ; preds = %71
%87 = load i8*, i8** %4
%88 = getelementptr inbounds i8, i8* %87, i64 3
%89 = load i32, i32* %5
%90 = sext i32 %89 to i64
%91 = getelementptr inbounds i8, i8* %88, i64 %90
%92 = call i64 @memcmp(i8* %91, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i32 4)
%93 = icmp ne i64 %92, 0
br i1 %93, label %94, label %96
94: ; preds = %86, %71
%95 = call i32 (...) @abort()
unreachable
96: ; preds = %86
%97 = load i32, i32* %2
%98 = icmp ne i32 %97, 0
%99 = zext i1 %98 to i64
%100 = select i1 %98, i32 0, i32 1
%101 = call i8* @fn1(i32 %100, i32 0, i32 0)
%102 = load i32, i32* %2
%103 = call i8* @fn1(i32 %102, i32 1, i32 1)
store i8* %103, i8** %4
%104 = load i8*, i8** %4
%105 = load i8*, i8** %3
%106 = load i32, i32* %5
%107 = add nsw i32 4, %106
%108 = call i64 @memcmp(i8* %104, i8* %105, i32 %107)
%109 = icmp ne i64 %108, 0
br i1 %109, label %118, label %110
110: ; preds = %96
%111 = load i8*, i8** %4
%112 = getelementptr inbounds i8, i8* %111, i64 4
%113 = load i32, i32* %5
%114 = sext i32 %113 to i64
%115 = getelementptr inbounds i8, i8* %112, i64 %114
%116 = call i64 @memcmp(i8* %115, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.4, i64 0, i64 0), i32 8)
%117 = icmp ne i64 %116, 0
br i1 %117, label %118, label %120
118: ; preds = %110, %96
%119 = call i32 (...) @abort()
unreachable
120: ; preds = %110
br label %121
121: ; preds = %120
%122 = load i32, i32* %2
%123 = add nsw i32 %122, 1
store i32 %123, i32* %2
br label %6
124: ; preds = %6
ret i32 0
}

LLVM IR (-O2):
@.str = [18 x i8] c"abcdefghijklmnopq\00"
@.str.1 = [4 x i8] c"RST\00"
@.str.2 = [8 x i8] c"HIJKLMN\00"
@.str.3 = [4 x i8] c"OPQ\00"
@.str.4 = [8 x i8] c"ABCDEFG\00"
define i32 @main() {
br label %4
1: ; preds = %58
%2 = add nuw nsw i32 %5, 1
%3 = icmp eq i32 %2, 5
br i1 %3, label %65, label %4
4: ; preds = %0, %1
%5 = phi i32 [ 0, %0 ], [ %2, %1 ]
%6 = icmp ult i32 %5, 3
%7 = select i1 %6, i32 %5, i32 3
%8 = shl nuw nsw i32 %7, 2
%9 = zext i32 %8 to i64
%10 = getelementptr inbounds [18 x i8], [18 x i8]* @.str, i64 0, i64 %9
%11 = icmp ugt i32 %5, 2
%12 = icmp eq i32 %5, 0
%13 = zext i1 %12 to i32
%14 = tail call i8* @fn1(i32 %13, i32 1, i32 1)
%15 = tail call i8* @fn1(i32 %5, i32 0, i32 0)
%16 = getelementptr inbounds i8, i8* %10, i64 1
%17 = select i1 %11, i32 4, i32 3
%18 = tail call i64 @memcmp(i8* %15, i8* %16, i32 %17)
%19 = icmp eq i64 %18, 0
br i1 %19, label %20, label %26
20: ; preds = %4
%21 = getelementptr inbounds i8, i8* %15, i64 3
%22 = zext i1 %11 to i64
%23 = getelementptr inbounds i8, i8* %21, i64 %22
%24 = tail call i64 @memcmp(i8* %23, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 4)
%25 = icmp eq i64 %24, 0
br i1 %25, label %28, label %26
26: ; preds = %20, %4
%27 = tail call i32 (...) @abort()
unreachable
28: ; preds = %20
%29 = tail call i8* @fn1(i32 %13, i32 0, i32 1)
%30 = tail call i8* @fn1(i32 %5, i32 1, i32 0)
%31 = select i1 %11, i32 5, i32 4
%32 = tail call i64 @memcmp(i8* %30, i8* %10, i32 %31)
%33 = icmp eq i64 %32, 0
br i1 %33, label %34, label %39
34: ; preds = %28
%35 = getelementptr inbounds i8, i8* %30, i64 4
%36 = getelementptr inbounds i8, i8* %35, i64 %22
%37 = tail call i64 @memcmp(i8* %36, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0), i32 8)
%38 = icmp eq i64 %37, 0
br i1 %38, label %41, label %39
39: ; preds = %34, %28
%40 = tail call i32 (...) @abort()
unreachable
41: ; preds = %34
%42 = tail call i8* @fn1(i32 %13, i32 1, i32 0)
%43 = tail call i8* @fn1(i32 %5, i32 0, i32 1)
%44 = tail call i64 @memcmp(i8* %43, i8* %16, i32 %17)
%45 = icmp eq i64 %44, 0
br i1 %45, label %46, label %51
46: ; preds = %41
%47 = getelementptr inbounds i8, i8* %43, i64 3
%48 = getelementptr inbounds i8, i8* %47, i64 %22
%49 = tail call i64 @memcmp(i8* %48, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i32 4)
%50 = icmp eq i64 %49, 0
br i1 %50, label %53, label %51
51: ; preds = %46, %41
%52 = tail call i32 (...) @abort()
unreachable
53: ; preds = %46
%54 = tail call i8* @fn1(i32 %13, i32 0, i32 0)
%55 = tail call i8* @fn1(i32 %5, i32 1, i32 1)
%56 = tail call i64 @memcmp(i8* %55, i8* %10, i32 %31)
%57 = icmp eq i64 %56, 0
br i1 %57, label %58, label %63
58: ; preds = %53
%59 = getelementptr inbounds i8, i8* %55, i64 4
%60 = getelementptr inbounds i8, i8* %59, i64 %22
%61 = tail call i64 @memcmp(i8* %60, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.4, i64 0, i64 0), i32 8)
%62 = icmp eq i64 %61, 0
br i1 %62, label %1, label %63
63: ; preds = %58, %53
%64 = tail call i32 (...) @abort()
unreachable
65: ; preds = %1
ret i32 0
}