#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 = "abcdefghijklmnop" + (i < 3 ? i : 3) * 4;
    const char *q;
    fn1(i ? 0 : 1, 1, 1);
    q = fn1(i, 0, 0);
    if (memcmp(q, p + 1, 3) != 0 || memcmp(q + 3, "RST", 4) != 0)
      abort();
    fn1(i ? 0 : 1, 0, 1);
    q = fn1(i, 1, 0);
    if (memcmp(q, p, 4) != 0 || memcmp(q + 4, "HIJKLMN", 8) != 0)
      abort();
    fn1(i ? 0 : 1, 1, 0);
    q = fn1(i, 0, 1);
    if (memcmp(q, p + 1, 3) != 0 || memcmp(q + 3, "OPQ", 4) != 0)
      abort();
    fn1(i ? 0 : 1, 0, 0);
    q = fn1(i, 1, 1);
    if (memcmp(q, p, 4) != 0 || memcmp(q + 4, "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    1372 <main+0x242>
cmpl   $0x3,-0x8(%rbp)
jge    1165 <main+0x35>
mov    -0x8(%rbp),%eax
mov    %eax,-0x1c(%rbp)
jmp    1172 <main+0x42>
mov    $0x3,%eax
mov    %eax,-0x1c(%rbp)
jmp    1172 <main+0x42>
mov    -0x1c(%rbp),%eax
shl    $0x2,%eax
movslq %eax,%rcx
lea    0xe7e(%rip),%rax
add    %rcx,%rax
mov    %rax,-0x10(%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    $0x3,%edx
call   1050 <memcmp@plt>
cmp    $0x0,%rax
jne    11f8 <main+0xc8>
mov    -0x18(%rbp),%rdi
add    $0x3,%rdi
lea    0xe2d(%rip),%rsi
mov    $0x4,%edx
call   1050 <memcmp@plt>
cmp    $0x0,%rax
je     11ff <main+0xcf>
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    $0x4,%edx
call   1050 <memcmp@plt>
cmp    $0x0,%rax
jne    126d <main+0x13d>
mov    -0x18(%rbp),%rdi
add    $0x4,%rdi
lea    0xdbc(%rip),%rsi
mov    $0x8,%edx
call   1050 <memcmp@plt>
cmp    $0x0,%rax
je     1274 <main+0x144>
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    $0x3,%edx
call   1050 <memcmp@plt>
cmp    $0x0,%rax
jne    12e6 <main+0x1b6>
mov    -0x18(%rbp),%rdi
add    $0x3,%rdi
lea    0xd4b(%rip),%rsi
mov    $0x4,%edx
call   1050 <memcmp@plt>
cmp    $0x0,%rax
je     12ed <main+0x1bd>
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    $0x4,%edx
call   1050 <memcmp@plt>
cmp    $0x0,%rax
jne    1358 <main+0x228>
mov    -0x18(%rbp),%rdi
add    $0x4,%rdi
lea    0xcdd(%rip),%rsi
mov    $0x8,%edx
call   1050 <memcmp@plt>
cmp    $0x0,%rax
je     135f <main+0x22f>
mov    $0x0,%al
call   1030 <abort@plt>
jmp    1364 <main+0x234>
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
push   %rax
xor    %r13d,%r13d
lea    0xebb(%rip),%rbx
cs nopw 0x0(%rax,%rax,1)
nop
cmp    $0x3,%r13d
mov    $0x3,%ebp
cmovb  %r13d,%ebp
shl    $0x2,%ebp
xor    %r14d,%r14d
test   %r13d,%r13d
sete   %r14b
mov    %r14d,%edi
mov    $0x1,%esi
mov    $0x1,%edx
call   1040 <fn1@plt>
mov    %r13d,%edi
xor    %esi,%esi
xor    %edx,%edx
call   1040 <fn1@plt>
mov    %rax,%r12
lea    (%rbx,%rbp,1),%r15
add    $0x1,%r15
mov    %rax,%rdi
mov    %r15,%rsi
mov    $0x3,%edx
call   1050 <memcmp@plt>
test   %rax,%rax
jne    12fa <main+0x1ca>
add    $0x3,%r12
mov    %r12,%rdi
lea    0xe57(%rip),%rsi
mov    $0x4,%edx
call   1050 <memcmp@plt>
test   %rax,%rax
jne    12fa <main+0x1ca>
mov    %rbx,%r12
add    %rbx,%rbp
mov    %r14d,%edi
xor    %esi,%esi
mov    $0x1,%edx
call   1040 <fn1@plt>
mov    %r13d,%edi
mov    $0x1,%esi
xor    %edx,%edx
call   1040 <fn1@plt>
mov    %rax,%rbx
mov    %rax,%rdi
mov    %rbp,%rsi
mov    $0x4,%edx
call   1050 <memcmp@plt>
test   %rax,%rax
jne    12fa <main+0x1ca>
add    $0x4,%rbx
mov    %rbx,%rdi
lea    0xdfa(%rip),%rsi
mov    $0x8,%edx
call   1050 <memcmp@plt>
test   %rax,%rax
jne    12fa <main+0x1ca>
mov    %r14d,%edi
mov    $0x1,%esi
xor    %edx,%edx
call   1040 <fn1@plt>
mov    %r13d,%edi
xor    %esi,%esi
mov    $0x1,%edx
call   1040 <fn1@plt>
mov    %rax,%rbx
mov    %rax,%rdi
mov    %r15,%rsi
mov    $0x3,%edx
call   1050 <memcmp@plt>
test   %rax,%rax
jne    12fa <main+0x1ca>
add    $0x3,%rbx
mov    %rbx,%rdi
lea    0xda7(%rip),%rsi
mov    $0x4,%edx
call   1050 <memcmp@plt>
test   %rax,%rax
jne    12fa <main+0x1ca>
mov    %r14d,%edi
xor    %esi,%esi
xor    %edx,%edx
call   1040 <fn1@plt>
mov    %r13d,%edi
mov    $0x1,%esi
mov    $0x1,%edx
call   1040 <fn1@plt>
mov    %rax,%rbx
mov    %rax,%rdi
mov    %rbp,%rsi
mov    $0x4,%edx
call   1050 <memcmp@plt>
test   %rax,%rax
jne    12fa <main+0x1ca>
add    $0x4,%rbx
mov    %rbx,%rdi
lea    0xd58(%rip),%rsi
mov    $0x8,%edx
call   1050 <memcmp@plt>
test   %rax,%rax
jne    12fa <main+0x1ca>
add    $0x1,%r13d
cmp    $0x5,%r13d
mov    %r12,%rbx
jne    1150 <main+0x20>
xor    %eax,%eax
add    $0x8,%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 = [17 x i8] c"abcdefghijklmnop\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*
store i32 0, i32* %1
store i32 0, i32* %2
br label %5
5: ; preds = %97, %0
%6 = load i32, i32* %2
%7 = icmp slt i32 %6, 5
br i1 %7, label %8, label %100
8: ; preds = %5
%9 = load i32, i32* %2
%10 = icmp slt i32 %9, 3
br i1 %10, label %11, label %13
11: ; preds = %8
%12 = load i32, i32* %2
br label %14
13: ; preds = %8
br label %14
14: ; preds = %13, %11
%15 = phi i32 [ %12, %11 ], [ 3, %13 ]
%16 = mul nsw i32 %15, 4
%17 = sext i32 %16 to i64
%18 = getelementptr inbounds i8, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0), i64 %17
store i8* %18, i8** %3
%19 = load i32, i32* %2
%20 = icmp ne i32 %19, 0
%21 = zext i1 %20 to i64
%22 = select i1 %20, i32 0, i32 1
%23 = call i8* @fn1(i32 %22, i32 1, i32 1)
%24 = load i32, i32* %2
%25 = call i8* @fn1(i32 %24, i32 0, i32 0)
store i8* %25, i8** %4
%26 = load i8*, i8** %4
%27 = load i8*, i8** %3
%28 = getelementptr inbounds i8, i8* %27, i64 1
%29 = call i64 @memcmp(i8* %26, i8* %28, i32 3)
%30 = icmp ne i64 %29, 0
br i1 %30, label %36, label %31
31: ; preds = %14
%32 = load i8*, i8** %4
%33 = getelementptr inbounds i8, i8* %32, i64 3
%34 = call i64 @memcmp(i8* %33, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 4)
%35 = icmp ne i64 %34, 0
br i1 %35, label %36, label %38
36: ; preds = %31, %14
%37 = call i32 (...) @abort()
unreachable
38: ; preds = %31
%39 = load i32, i32* %2
%40 = icmp ne i32 %39, 0
%41 = zext i1 %40 to i64
%42 = select i1 %40, i32 0, i32 1
%43 = call i8* @fn1(i32 %42, i32 0, i32 1)
%44 = load i32, i32* %2
%45 = call i8* @fn1(i32 %44, i32 1, i32 0)
store i8* %45, i8** %4
%46 = load i8*, i8** %4
%47 = load i8*, i8** %3
%48 = call i64 @memcmp(i8* %46, i8* %47, i32 4)
%49 = icmp ne i64 %48, 0
br i1 %49, label %55, label %50
50: ; preds = %38
%51 = load i8*, i8** %4
%52 = getelementptr inbounds i8, i8* %51, i64 4
%53 = call i64 @memcmp(i8* %52, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0), i32 8)
%54 = icmp ne i64 %53, 0
br i1 %54, label %55, label %57
55: ; preds = %50, %38
%56 = call i32 (...) @abort()
unreachable
57: ; preds = %50
%58 = load i32, i32* %2
%59 = icmp ne i32 %58, 0
%60 = zext i1 %59 to i64
%61 = select i1 %59, i32 0, i32 1
%62 = call i8* @fn1(i32 %61, i32 1, i32 0)
%63 = load i32, i32* %2
%64 = call i8* @fn1(i32 %63, i32 0, i32 1)
store i8* %64, i8** %4
%65 = load i8*, i8** %4
%66 = load i8*, i8** %3
%67 = getelementptr inbounds i8, i8* %66, i64 1
%68 = call i64 @memcmp(i8* %65, i8* %67, i32 3)
%69 = icmp ne i64 %68, 0
br i1 %69, label %75, label %70
70: ; preds = %57
%71 = load i8*, i8** %4
%72 = getelementptr inbounds i8, i8* %71, i64 3
%73 = call i64 @memcmp(i8* %72, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i32 4)
%74 = icmp ne i64 %73, 0
br i1 %74, label %75, label %77
75: ; preds = %70, %57
%76 = call i32 (...) @abort()
unreachable
77: ; preds = %70
%78 = load i32, i32* %2
%79 = icmp ne i32 %78, 0
%80 = zext i1 %79 to i64
%81 = select i1 %79, i32 0, i32 1
%82 = call i8* @fn1(i32 %81, i32 0, i32 0)
%83 = load i32, i32* %2
%84 = call i8* @fn1(i32 %83, i32 1, i32 1)
store i8* %84, i8** %4
%85 = load i8*, i8** %4
%86 = load i8*, i8** %3
%87 = call i64 @memcmp(i8* %85, i8* %86, i32 4)
%88 = icmp ne i64 %87, 0
br i1 %88, label %94, label %89
89: ; preds = %77
%90 = load i8*, i8** %4
%91 = getelementptr inbounds i8, i8* %90, i64 4
%92 = call i64 @memcmp(i8* %91, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.4, i64 0, i64 0), i32 8)
%93 = icmp ne i64 %92, 0
br i1 %93, label %94, label %96
94: ; preds = %89, %77
%95 = call i32 (...) @abort()
unreachable
96: ; preds = %89
br label %97
97: ; preds = %96
%98 = load i32, i32* %2
%99 = add nsw i32 %98, 1
store i32 %99, i32* %2
br label %5
100: ; preds = %5
ret i32 0
}

LLVM IR (-O2):
@.str = [17 x i8] c"abcdefghijklmnop\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 = %51
%2 = add nuw nsw i32 %5, 1
%3 = icmp eq i32 %2, 5
br i1 %3, label %57, 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 [17 x i8], [17 x i8]* @.str, i64 0, i64 %9
%11 = icmp eq i32 %5, 0
%12 = zext i1 %11 to i32
%13 = tail call i8* @fn1(i32 %12, i32 1, i32 1)
%14 = tail call i8* @fn1(i32 %5, i32 0, i32 0)
%15 = getelementptr inbounds i8, i8* %10, i64 1
%16 = tail call i64 @memcmp(i8* %14, i8* %15, i32 3)
%17 = icmp eq i64 %16, 0
br i1 %17, label %18, label %22
18: ; preds = %4
%19 = getelementptr inbounds i8, i8* %14, i64 3
%20 = tail call i64 @memcmp(i8* %19, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 4)
%21 = icmp eq i64 %20, 0
br i1 %21, label %24, label %22
22: ; preds = %18, %4
%23 = tail call i32 (...) @abort()
unreachable
24: ; preds = %18
%25 = tail call i8* @fn1(i32 %12, i32 0, i32 1)
%26 = tail call i8* @fn1(i32 %5, i32 1, i32 0)
%27 = tail call i64 @memcmp(i8* %26, i8* %10, i32 4)
%28 = icmp eq i64 %27, 0
br i1 %28, label %29, label %33
29: ; preds = %24
%30 = getelementptr inbounds i8, i8* %26, i64 4
%31 = tail call i64 @memcmp(i8* %30, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0), i32 8)
%32 = icmp eq i64 %31, 0
br i1 %32, label %35, label %33
33: ; preds = %29, %24
%34 = tail call i32 (...) @abort()
unreachable
35: ; preds = %29
%36 = tail call i8* @fn1(i32 %12, i32 1, i32 0)
%37 = tail call i8* @fn1(i32 %5, i32 0, i32 1)
%38 = tail call i64 @memcmp(i8* %37, i8* %15, i32 3)
%39 = icmp eq i64 %38, 0
br i1 %39, label %40, label %44
40: ; preds = %35
%41 = getelementptr inbounds i8, i8* %37, i64 3
%42 = tail call i64 @memcmp(i8* %41, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i32 4)
%43 = icmp eq i64 %42, 0
br i1 %43, label %46, label %44
44: ; preds = %40, %35
%45 = tail call i32 (...) @abort()
unreachable
46: ; preds = %40
%47 = tail call i8* @fn1(i32 %12, i32 0, i32 0)
%48 = tail call i8* @fn1(i32 %5, i32 1, i32 1)
%49 = tail call i64 @memcmp(i8* %48, i8* %10, i32 4)
%50 = icmp eq i64 %49, 0
br i1 %50, label %51, label %55
51: ; preds = %46
%52 = getelementptr inbounds i8, i8* %48, i64 4
%53 = tail call i64 @memcmp(i8* %52, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.4, i64 0, i64 0), i32 8)
%54 = icmp eq i64 %53, 0
br i1 %54, label %1, label %55
55: ; preds = %51, %46
%56 = tail call i32 (...) @abort()
unreachable
57: ; preds = %1
ret i32 0
}