#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 */
typedef int uint32_t;
typedef int /*<<< orphan*/ buf2;

/* Variables and functions */
int lib_memcmp(char *, char *, size_t);
int lib_strncmp(char *, char *, size_t);
int /*<<< orphan*/ memset(char *, char, int);
int rand();
void stub1(char *, char *, int);
void stub10(char *, char *, int);
void stub11(char *, char *, int);
void stub12(char *, char *, int);
void stub13(char *, char *, int);
void stub14(char *, char *, int);
void stub2(char *, char *, int);
void stub3(char *, char *, int);
void stub4(char *, char *, int);
void stub5(char *, char *, int);
void stub6(char *, char *, int);
void stub7(char *, char *, int);
void stub8(char *, char *, int);
void stub9(char *, char *, int);
void test_driver_memcmp(void(test_memcmp)(const char *, const char *, int),
                        void(test_strncmp)(const char *, const char *, int),
                        size_t sz, int align) {
  char buf1[200 * 2 + 10], buf2[200 * 2 + 10];
  size_t test_sz = (sz < 200) ? sz : 200;
  size_t diff_pos, zero_pos;
  uint32_t e;
  int i, j, l;
  for (l = 0; l < sz; l++) {
    for (i = 0; i < 10000 / sz; i++) {
      for (j = 0; j < l; j++) {
        buf1[j] = rand() & 0xff;
        buf2[j] = buf1[j];
      }
      for (j = l; j < sz; j++) {
        buf1[j] = rand() & 0xff;
        buf2[j] = rand() & 0xff;
      }
    }
    e = lib_memcmp(buf1, buf2, sz);
    (*test_memcmp)(buf1, buf2, e);
    e = lib_strncmp(buf1, buf2, sz);
    (*test_strncmp)(buf1, buf2, e);
  }
  for (diff_pos = ((test_sz > 10) ? (test_sz - 10) : 0);
       diff_pos < test_sz + 10; diff_pos++)
    for (zero_pos = ((test_sz > 10) ? (test_sz - 10) : 0);
         zero_pos < test_sz + 10; zero_pos++) {
      memset(buf1, 'A', 2 * test_sz);
      memset(buf2, 'A', 2 * test_sz);
      buf2[diff_pos] = 'B';
      buf1[zero_pos] = 0;
      buf2[zero_pos] = 0;
      e = lib_memcmp(buf1, buf2, sz);
      (*test_memcmp)(buf1, buf2, e);
      (*test_memcmp)(buf2, buf1, -e);
      (*test_memcmp)(buf2, buf2, 0);
      e = lib_strncmp(buf1, buf2, sz);
      (*test_strncmp)(buf1, buf2, e);
      (*test_strncmp)(buf2, buf1, -e);
      (*test_strncmp)(buf2, buf2, 0);
      buf2[diff_pos] = 0;
      e = lib_memcmp(buf1, buf2, sz);
      (*test_memcmp)(buf1, buf2, e);
      e = lib_strncmp(buf1, buf2, sz);
      (*test_strncmp)(buf1, buf2, e);
      memset(buf2 + diff_pos, 'B', sizeof(buf2) - diff_pos);
      buf2[zero_pos] = 0;
      e = lib_memcmp(buf1, buf2, sz);
      (*test_memcmp)(buf1, buf2, e);
      (*test_memcmp)(buf2, buf1, -e);
      e = lib_strncmp(buf1, buf2, sz);
      (*test_strncmp)(buf1, buf2, e);
      (*test_strncmp)(buf2, buf1, -e);
    }
}


x86 assembly (clang, -O0):
<test_driver_memcmp>:
push   %rbp
mov    %rsp,%rbp
sub    $0x3b0,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %ecx,-0x1c(%rbp)
cmpq   $0xc8,-0x18(%rbp)
jae    1178 <test_driver_memcmp+0x38>
mov    -0x18(%rbp),%rax
mov    %rax,-0x390(%rbp)
jmp    1189 <test_driver_memcmp+0x49>
mov    $0xc8,%eax
mov    %rax,-0x390(%rbp)
jmp    1189 <test_driver_memcmp+0x49>
mov    -0x390(%rbp),%rax
mov    %rax,-0x368(%rbp)
movl   $0x0,-0x388(%rbp)
movslq -0x388(%rbp),%rax
cmp    -0x18(%rbp),%rax
jae    1356 <test_driver_memcmp+0x216>
movl   $0x0,-0x380(%rbp)
movslq -0x380(%rbp),%rax
mov    %rax,-0x398(%rbp)
mov    $0x2710,%eax
xor    %ecx,%ecx
mov    %ecx,%edx
divq   -0x18(%rbp)
mov    %rax,%rcx
mov    -0x398(%rbp),%rax
cmp    %rcx,%rax
jae    12d4 <test_driver_memcmp+0x194>
movl   $0x0,-0x384(%rbp)
mov    -0x384(%rbp),%eax
cmp    -0x388(%rbp),%eax
jge    1252 <test_driver_memcmp+0x112>
mov    $0x0,%al
call   1060 <rand@plt>
and    $0xff,%eax
mov    %al,%cl
movslq -0x384(%rbp),%rax
mov    %cl,-0x1c0(%rbp,%rax,1)
movslq -0x384(%rbp),%rax
mov    -0x1c0(%rbp,%rax,1),%cl
movslq -0x384(%rbp),%rax
mov    %cl,-0x360(%rbp,%rax,1)
mov    -0x384(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x384(%rbp)
jmp    11f4 <test_driver_memcmp+0xb4>
mov    -0x388(%rbp),%eax
mov    %eax,-0x384(%rbp)
movslq -0x384(%rbp),%rax
cmp    -0x18(%rbp),%rax
jae    12bb <test_driver_memcmp+0x17b>
mov    $0x0,%al
call   1060 <rand@plt>
and    $0xff,%eax
mov    %al,%cl
movslq -0x384(%rbp),%rax
mov    %cl,-0x1c0(%rbp,%rax,1)
mov    $0x0,%al
call   1060 <rand@plt>
and    $0xff,%eax
mov    %al,%cl
movslq -0x384(%rbp),%rax
mov    %cl,-0x360(%rbp,%rax,1)
mov    -0x384(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x384(%rbp)
jmp    125e <test_driver_memcmp+0x11e>
jmp    12c0 <test_driver_memcmp+0x180>
mov    -0x380(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x380(%rbp)
jmp    11bc <test_driver_memcmp+0x7c>
lea    -0x1c0(%rbp),%rdi
lea    -0x360(%rbp),%rsi
mov    -0x18(%rbp),%rdx
call   1040 <lib_memcmp@plt>
mov    %eax,-0x37c(%rbp)
mov    -0x8(%rbp),%rax
lea    -0x1c0(%rbp),%rdi
lea    -0x360(%rbp),%rsi
mov    -0x37c(%rbp),%edx
call   *%rax
lea    -0x1c0(%rbp),%rdi
lea    -0x360(%rbp),%rsi
mov    -0x18(%rbp),%rdx
call   1030 <lib_strncmp@plt>
mov    %eax,-0x37c(%rbp)
mov    -0x10(%rbp),%rax
lea    -0x1c0(%rbp),%rdi
lea    -0x360(%rbp),%rsi
mov    -0x37c(%rbp),%edx
call   *%rax
mov    -0x388(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x388(%rbp)
jmp    11a1 <test_driver_memcmp+0x61>
cmpq   $0xa,-0x368(%rbp)
0a
jbe    137b <test_driver_memcmp+0x23b>
mov    -0x368(%rbp),%rax
sub    $0xa,%rax
mov    %rax,-0x3a0(%rbp)
jmp    1389 <test_driver_memcmp+0x249>
xor    %eax,%eax
mov    %rax,-0x3a0(%rbp)
jmp    1389 <test_driver_memcmp+0x249>
mov    -0x3a0(%rbp),%rax
mov    %rax,-0x370(%rbp)
mov    -0x370(%rbp),%rax
mov    -0x368(%rbp),%rcx
add    $0xa,%rcx
cmp    %rcx,%rax
jae    16d4 <test_driver_memcmp+0x594>
cmpq   $0xa,-0x368(%rbp)
0a
jbe    13d7 <test_driver_memcmp+0x297>
mov    -0x368(%rbp),%rax
sub    $0xa,%rax
mov    %rax,-0x3a8(%rbp)
jmp    13e5 <test_driver_memcmp+0x2a5>
xor    %eax,%eax
mov    %rax,-0x3a8(%rbp)
jmp    13e5 <test_driver_memcmp+0x2a5>
mov    -0x3a8(%rbp),%rax
mov    %rax,-0x378(%rbp)
mov    -0x378(%rbp),%rax
mov    -0x368(%rbp),%rcx
add    $0xa,%rcx
cmp    %rcx,%rax
jae    16b8 <test_driver_memcmp+0x578>
lea    -0x1c0(%rbp),%rdi
mov    -0x368(%rbp),%rax
shl    $0x1,%rax
mov    %eax,%edx
mov    $0x41,%esi
call   1050 <memset@plt>
lea    -0x360(%rbp),%rdi
mov    -0x368(%rbp),%rax
shl    $0x1,%rax
mov    %eax,%edx
mov    $0x41,%esi
call   1050 <memset@plt>
mov    -0x370(%rbp),%rax
movb   $0x42,-0x360(%rbp,%rax,1)
42
mov    -0x378(%rbp),%rax
movb   $0x0,-0x1c0(%rbp,%rax,1)
mov    -0x378(%rbp),%rax
movb   $0x0,-0x360(%rbp,%rax,1)
lea    -0x1c0(%rbp),%rdi
lea    -0x360(%rbp),%rsi
mov    -0x18(%rbp),%rdx
call   1040 <lib_memcmp@plt>
mov    %eax,-0x37c(%rbp)
mov    -0x8(%rbp),%rax
lea    -0x1c0(%rbp),%rdi
lea    -0x360(%rbp),%rsi
mov    -0x37c(%rbp),%edx
call   *%rax
mov    -0x8(%rbp),%rax
lea    -0x360(%rbp),%rdi
lea    -0x1c0(%rbp),%rsi
xor    %edx,%edx
sub    -0x37c(%rbp),%edx
call   *%rax
mov    -0x8(%rbp),%rax
lea    -0x360(%rbp),%rdi
lea    -0x360(%rbp),%rsi
xor    %edx,%edx
call   *%rax
lea    -0x1c0(%rbp),%rdi
lea    -0x360(%rbp),%rsi
mov    -0x18(%rbp),%rdx
call   1030 <lib_strncmp@plt>
mov    %eax,-0x37c(%rbp)
mov    -0x10(%rbp),%rax
lea    -0x1c0(%rbp),%rdi
lea    -0x360(%rbp),%rsi
mov    -0x37c(%rbp),%edx
call   *%rax
mov    -0x10(%rbp),%rax
lea    -0x360(%rbp),%rdi
lea    -0x1c0(%rbp),%rsi
xor    %edx,%edx
sub    -0x37c(%rbp),%edx
call   *%rax
mov    -0x10(%rbp),%rax
lea    -0x360(%rbp),%rdi
lea    -0x360(%rbp),%rsi
xor    %edx,%edx
call   *%rax
mov    -0x370(%rbp),%rax
movb   $0x0,-0x360(%rbp,%rax,1)
lea    -0x1c0(%rbp),%rdi
lea    -0x360(%rbp),%rsi
mov    -0x18(%rbp),%rdx
call   1040 <lib_memcmp@plt>
mov    %eax,-0x37c(%rbp)
mov    -0x8(%rbp),%rax
lea    -0x1c0(%rbp),%rdi
lea    -0x360(%rbp),%rsi
mov    -0x37c(%rbp),%edx
call   *%rax
lea    -0x1c0(%rbp),%rdi
lea    -0x360(%rbp),%rsi
mov    -0x18(%rbp),%rdx
call   1030 <lib_strncmp@plt>
mov    %eax,-0x37c(%rbp)
mov    -0x10(%rbp),%rax
lea    -0x1c0(%rbp),%rdi
lea    -0x360(%rbp),%rsi
mov    -0x37c(%rbp),%edx
call   *%rax
lea    -0x360(%rbp),%rdi
add    -0x370(%rbp),%rdi
mov    $0x19a,%eax
sub    -0x370(%rbp),%rax
mov    %eax,%edx
mov    $0x42,%esi
call   1050 <memset@plt>
mov    -0x378(%rbp),%rax
movb   $0x0,-0x360(%rbp,%rax,1)
lea    -0x1c0(%rbp),%rdi
lea    -0x360(%rbp),%rsi
mov    -0x18(%rbp),%rdx
call   1040 <lib_memcmp@plt>
mov    %eax,-0x37c(%rbp)
mov    -0x8(%rbp),%rax
lea    -0x1c0(%rbp),%rdi
lea    -0x360(%rbp),%rsi
mov    -0x37c(%rbp),%edx
call   *%rax
mov    -0x8(%rbp),%rax
lea    -0x360(%rbp),%rdi
lea    -0x1c0(%rbp),%rsi
xor    %edx,%edx
sub    -0x37c(%rbp),%edx
call   *%rax
lea    -0x1c0(%rbp),%rdi
lea    -0x360(%rbp),%rsi
mov    -0x18(%rbp),%rdx
call   1030 <lib_strncmp@plt>
mov    %eax,-0x37c(%rbp)
mov    -0x10(%rbp),%rax
lea    -0x1c0(%rbp),%rdi
lea    -0x360(%rbp),%rsi
mov    -0x37c(%rbp),%edx
call   *%rax
mov    -0x10(%rbp),%rax
lea    -0x360(%rbp),%rdi
lea    -0x1c0(%rbp),%rsi
xor    %edx,%edx
sub    -0x37c(%rbp),%edx
call   *%rax
mov    -0x378(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x378(%rbp)
jmp    13f3 <test_driver_memcmp+0x2b3>
jmp    16bd <test_driver_memcmp+0x57d>
mov    -0x370(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x370(%rbp)
jmp    1397 <test_driver_memcmp+0x257>
add    $0x3b0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<test_driver_memcmp>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x3a8,%rsp
mov    %rdx,%rbx
mov    %rsi,0x28(%rsp)
mov    %rdi,0x20(%rsp)
cmp    $0xc8,%rdx
mov    $0xc8,%eax
cmovb  %rdx,%rax
mov    %rax,0x10(%rsp)
test   %rdx,%rdx
je     1270 <test_driver_memcmp+0x130>
cmp    $0x2710,%rbx
ja     1190 <test_driver_memcmp+0x50>
mov    $0x2710,%eax
xor    %edx,%edx
div    %ebx
jmp    1192 <test_driver_memcmp+0x52>
xor    %eax,%eax
cmp    $0x2,%rax
mov    $0x1,%r13d
cmovae %rax,%r13
lea    0x60(%rsp),%r15
xor    %r12d,%r12d
jmp    11f5 <test_driver_memcmp+0xb5>
nopw   0x0(%rax,%rax,1)
lea    0x200(%rsp),%rbp
mov    %rbp,%rdi
mov    %r15,%rsi
mov    %rbx,%rdx
call   1040 <lib_memcmp@plt>
mov    %rbp,%rdi
mov    %r15,%rsi
mov    %eax,%edx
call   *0x20(%rsp)
mov    %rbp,%rdi
mov    %r15,%rsi
mov    %rbx,%rdx
call   1030 <lib_strncmp@plt>
mov    %rbp,%rdi
mov    %r15,%rsi
mov    %eax,%edx
call   *0x28(%rsp)
add    $0x1,%r12
cmp    %rbx,%r12
je     1270 <test_driver_memcmp+0x130>
cmp    $0x2710,%rbx
ja     11b0 <test_driver_memcmp+0x70>
xor    %r14d,%r14d
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
test   %r12,%r12
je     123b <test_driver_memcmp+0xfb>
xor    %ebp,%ebp
nopw   0x0(%rax,%rax,1)
xor    %eax,%eax
call   1060 <rand@plt>
mov    %al,0x200(%rsp,%rbp,1)
mov    %al,0x60(%rsp,%rbp,1)
add    $0x1,%rbp
cmp    %rbp,%r12
jne    1220 <test_driver_memcmp+0xe0>
mov    %r12,%rbp
xchg   %ax,%ax
xor    %eax,%eax
call   1060 <rand@plt>
mov    %al,0x200(%rsp,%rbp,1)
xor    %eax,%eax
call   1060 <rand@plt>
mov    %al,0x60(%rsp,%rbp,1)
add    $0x1,%rbp
cmp    %rbx,%rbp
jb     1240 <test_driver_memcmp+0x100>
add    $0x1,%r14
cmp    %r13,%r14
jne    1210 <test_driver_memcmp+0xd0>
jmp    11b0 <test_driver_memcmp+0x70>
xor    %ecx,%ecx
mov    0x10(%rsp),%rdx
mov    %rdx,%rax
sub    $0xa,%rax
cmovae %rax,%rcx
lea    0xa(%rdx),%rax
mov    %rax,0x48(%rsp)
cmp    %rax,%rcx
jae    14a0 <test_driver_memcmp+0x360>
lea    (%rdx,%rdx,1),%eax
mov    %eax,0xc(%rsp)
cmp    $0xa,%rbx
mov    $0xa,%eax
cmovb  %rbx,%rax
neg    %rax
mov    %rax,0x40(%rsp)
lea    (%rsp,%rdx,1),%r12
add    $0x60,%r12
lea    (%rsp,%rdx,1),%rbp
add    $0x200,%rbp
lea    0x200(%rsp),%r13
mov    %r12,0x30(%rsp)
mov    %rbp,0x58(%rsp)
cs nopw 0x0(%rax,%rax,1)
nop
lea    (%rsp,%rcx,1),%rax
add    $0x60,%rax
mov    %rax,0x38(%rsp)
mov    $0x19a,%eax
mov    %rcx,0x50(%rsp)
sub    %ecx,%eax
mov    %eax,0x1c(%rsp)
mov    0x40(%rsp),%r14
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    %r13,%rdi
mov    $0x41,%esi
mov    0xc(%rsp),%edx
call   1050 <memset@plt>
lea    0x60(%rsp),%r15
mov    %r15,%rdi
mov    $0x41,%esi
mov    0xc(%rsp),%edx
call   1050 <memset@plt>
mov    0x38(%rsp),%rax
movb   $0x42,(%rax)
mov    %r14,0x10(%rsp)
movb   $0x0,0x0(%rbp,%r14,1)
movb   $0x0,(%r12,%r14,1)
mov    %r13,%rdi
mov    %r15,%rsi
mov    %rbx,%rdx
call   1040 <lib_memcmp@plt>
mov    %eax,%r12d
mov    %r13,%rdi
mov    %r15,%rsi
mov    %eax,%edx
mov    0x20(%rsp),%rbp
call   *%rbp
neg    %r12d
mov    %r15,%rdi
mov    %r13,%rsi
mov    %r12d,%edx
call   *%rbp
mov    %r15,%rdi
mov    %r15,%rsi
xor    %edx,%edx
call   *%rbp
mov    %rbp,%r12
mov    %r13,%rdi
mov    %r15,%rsi
mov    %rbx,%rdx
call   1030 <lib_strncmp@plt>
mov    %eax,%ebp
mov    %r13,%rdi
mov    %r15,%rsi
mov    %eax,%edx
mov    0x28(%rsp),%r14
call   *%r14
neg    %ebp
mov    %r15,%rdi
mov    %r13,%rsi
mov    %ebp,%edx
call   *%r14
mov    %r15,%rdi
mov    %r15,%rsi
xor    %edx,%edx
call   *%r14
mov    0x38(%rsp),%rbp
movb   $0x0,0x0(%rbp)
mov    %r13,%rdi
mov    %r15,%rsi
mov    %rbx,%rdx
call   1040 <lib_memcmp@plt>
mov    %r13,%rdi
mov    %r15,%rsi
mov    %eax,%edx
call   *%r12
mov    %r13,%rdi
mov    %r15,%rsi
mov    %rbx,%rdx
call   1030 <lib_strncmp@plt>
mov    %r13,%rdi
mov    %r15,%rsi
mov    %eax,%edx
call   *%r14
mov    %rbp,%rdi
mov    $0x42,%esi
mov    0x1c(%rsp),%edx
call   1050 <memset@plt>
mov    0x30(%rsp),%rax
mov    0x10(%rsp),%rcx
movb   $0x0,(%rax,%rcx,1)
mov    %r13,%rdi
mov    %r15,%rsi
mov    %rbx,%rdx
call   1040 <lib_memcmp@plt>
mov    %eax,%ebp
mov    %r13,%rdi
mov    %r15,%rsi
mov    %eax,%edx
call   *%r12
neg    %ebp
mov    %r15,%rdi
mov    %r13,%rsi
mov    %ebp,%edx
call   *%r12
mov    %r13,%rdi
mov    %r15,%rsi
mov    %rbx,%rdx
call   1030 <lib_strncmp@plt>
mov    %eax,%ebp
mov    %r13,%rdi
mov    %r15,%rsi
mov    %eax,%edx
call   *%r14
neg    %ebp
mov    %r15,%rdi
mov    %r13,%rsi
mov    %ebp,%edx
mov    0x58(%rsp),%rbp
mov    0x30(%rsp),%r12
call   *%r14
mov    0x10(%rsp),%rax
add    $0x1,%rax
mov    %rax,%r14
cmp    $0xa,%rax
jne    1310 <test_driver_memcmp+0x1d0>
mov    0x50(%rsp),%rcx
add    $0x1,%rcx
cmp    0x48(%rsp),%rcx
jne    12e0 <test_driver_memcmp+0x1a0>
add    $0x3a8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define void @test_driver_memcmp(void (i8*, i8*, i32)* %0, void (i8*, i8*, i32)* %1, i64 %2, i32 %3) {
%5 = alloca void (i8*, i8*, i32)*
%6 = alloca void (i8*, i8*, i32)*
%7 = alloca i64
%8 = alloca i32
%9 = alloca [410 x i8]
%10 = alloca [410 x i8]
%11 = alloca i64
%12 = alloca i64
%13 = alloca i64
%14 = alloca i32
%15 = alloca i32
%16 = alloca i32
%17 = alloca i32
store void (i8*, i8*, i32)* %0, void (i8*, i8*, i32)** %5
store void (i8*, i8*, i32)* %1, void (i8*, i8*, i32)** %6
store i64 %2, i64* %7
store i32 %3, i32* %8
%18 = load i64, i64* %7
%19 = icmp ult i64 %18, 200
br i1 %19, label %20, label %22
20: ; preds = %4
%21 = load i64, i64* %7
br label %23
22: ; preds = %4
br label %23
23: ; preds = %22, %20
%24 = phi i64 [ %21, %20 ], [ 200, %22 ]
store i64 %24, i64* %11
store i32 0, i32* %17
br label %25
25: ; preds = %103, %23
%26 = load i32, i32* %17
%27 = sext i32 %26 to i64
%28 = load i64, i64* %7
%29 = icmp ult i64 %27, %28
br i1 %29, label %30, label %106
30: ; preds = %25
store i32 0, i32* %15
br label %31
31: ; preds = %83, %30
%32 = load i32, i32* %15
%33 = sext i32 %32 to i64
%34 = load i64, i64* %7
%35 = udiv i64 10000, %34
%36 = icmp ult i64 %33, %35
br i1 %36, label %37, label %86
37: ; preds = %31
store i32 0, i32* %16
br label %38
38: ; preds = %56, %37
%39 = load i32, i32* %16
%40 = load i32, i32* %17
%41 = icmp slt i32 %39, %40
br i1 %41, label %42, label %59
42: ; preds = %38
%43 = call i32 (...) @rand()
%44 = and i32 %43, 255
%45 = trunc i32 %44 to i8
%46 = load i32, i32* %16
%47 = sext i32 %46 to i64
%48 = getelementptr inbounds [410 x i8], [410 x i8]* %9, i64 0, i64 %47
store i8 %45, i8* %48
%49 = load i32, i32* %16
%50 = sext i32 %49 to i64
%51 = getelementptr inbounds [410 x i8], [410 x i8]* %9, i64 0, i64 %50
%52 = load i8, i8* %51
%53 = load i32, i32* %16
%54 = sext i32 %53 to i64
%55 = getelementptr inbounds [410 x i8], [410 x i8]* %10, i64 0, i64 %54
store i8 %52, i8* %55
br label %56
56: ; preds = %42
%57 = load i32, i32* %16
%58 = add nsw i32 %57, 1
store i32 %58, i32* %16
br label %38
59: ; preds = %38
%60 = load i32, i32* %17
store i32 %60, i32* %16
br label %61
61: ; preds = %79, %59
%62 = load i32, i32* %16
%63 = sext i32 %62 to i64
%64 = load i64, i64* %7
%65 = icmp ult i64 %63, %64
br i1 %65, label %66, label %82
66: ; preds = %61
%67 = call i32 (...) @rand()
%68 = and i32 %67, 255
%69 = trunc i32 %68 to i8
%70 = load i32, i32* %16
%71 = sext i32 %70 to i64
%72 = getelementptr inbounds [410 x i8], [410 x i8]* %9, i64 0, i64 %71
store i8 %69, i8* %72
%73 = call i32 (...) @rand()
%74 = and i32 %73, 255
%75 = trunc i32 %74 to i8
%76 = load i32, i32* %16
%77 = sext i32 %76 to i64
%78 = getelementptr inbounds [410 x i8], [410 x i8]* %10, i64 0, i64 %77
store i8 %75, i8* %78
br label %79
79: ; preds = %66
%80 = load i32, i32* %16
%81 = add nsw i32 %80, 1
store i32 %81, i32* %16
br label %61
82: ; preds = %61
br label %83
83: ; preds = %82
%84 = load i32, i32* %15
%85 = add nsw i32 %84, 1
store i32 %85, i32* %15
br label %31
86: ; preds = %31
%87 = getelementptr inbounds [410 x i8], [410 x i8]* %9, i64 0, i64 0
%88 = getelementptr inbounds [410 x i8], [410 x i8]* %10, i64 0, i64 0
%89 = load i64, i64* %7
%90 = call i32 @lib_memcmp(i8* %87, i8* %88, i64 %89)
store i32 %90, i32* %14
%91 = load void (i8*, i8*, i32)*, void (i8*, i8*, i32)** %5
%92 = getelementptr inbounds [410 x i8], [410 x i8]* %9, i64 0, i64 0
%93 = getelementptr inbounds [410 x i8], [410 x i8]* %10, i64 0, i64 0
%94 = load i32, i32* %14
%95 = getelementptr inbounds [410 x i8], [410 x i8]* %9, i64 0, i64 0
%96 = getelementptr inbounds [410 x i8], [410 x i8]* %10, i64 0, i64 0
%97 = load i64, i64* %7
%98 = call i32 @lib_strncmp(i8* %95, i8* %96, i64 %97)
store i32 %98, i32* %14
%99 = load void (i8*, i8*, i32)*, void (i8*, i8*, i32)** %6
%100 = getelementptr inbounds [410 x i8], [410 x i8]* %9, i64 0, i64 0
%101 = getelementptr inbounds [410 x i8], [410 x i8]* %10, i64 0, i64 0
%102 = load i32, i32* %14
br label %103
103: ; preds = %86
%104 = load i32, i32* %17
%105 = add nsw i32 %104, 1
store i32 %105, i32* %17
br label %25
106: ; preds = %25
%107 = load i64, i64* %11
%108 = icmp ugt i64 %107, 10
br i1 %108, label %109, label %112
109: ; preds = %106
%110 = load i64, i64* %11
%111 = sub i64 %110, 10
br label %113
112: ; preds = %106
br label %113
113: ; preds = %112, %109
%114 = phi i64 [ %111, %109 ], [ 0, %112 ]
store i64 %114, i64* %12
br label %115
115: ; preds = %240, %113
%116 = load i64, i64* %12
%117 = load i64, i64* %11
%118 = add i64 %117, 10
%119 = icmp ult i64 %116, %118
br i1 %119, label %120, label %243
120: ; preds = %115
%121 = load i64, i64* %11
%122 = icmp ugt i64 %121, 10
br i1 %122, label %123, label %126
123: ; preds = %120
%124 = load i64, i64* %11
%125 = sub i64 %124, 10
br label %127
126: ; preds = %120
br label %127
127: ; preds = %126, %123
%128 = phi i64 [ %125, %123 ], [ 0, %126 ]
store i64 %128, i64* %13
br label %129
129: ; preds = %236, %127
%130 = load i64, i64* %13
%131 = load i64, i64* %11
%132 = add i64 %131, 10
%133 = icmp ult i64 %130, %132
br i1 %133, label %134, label %239
134: ; preds = %129
%135 = getelementptr inbounds [410 x i8], [410 x i8]* %9, i64 0, i64 0
%136 = load i64, i64* %11
%137 = mul i64 2, %136
%138 = trunc i64 %137 to i32
%139 = call i32 @memset(i8* %135, i8 signext 65, i32 %138)
%140 = getelementptr inbounds [410 x i8], [410 x i8]* %10, i64 0, i64 0
%141 = load i64, i64* %11
%142 = mul i64 2, %141
%143 = trunc i64 %142 to i32
%144 = call i32 @memset(i8* %140, i8 signext 65, i32 %143)
%145 = load i64, i64* %12
%146 = getelementptr inbounds [410 x i8], [410 x i8]* %10, i64 0, i64 %145
store i8 66, i8* %146
%147 = load i64, i64* %13
%148 = getelementptr inbounds [410 x i8], [410 x i8]* %9, i64 0, i64 %147
store i8 0, i8* %148
%149 = load i64, i64* %13
%150 = getelementptr inbounds [410 x i8], [410 x i8]* %10, i64 0, i64 %149
store i8 0, i8* %150
%151 = getelementptr inbounds [410 x i8], [410 x i8]* %9, i64 0, i64 0
%152 = getelementptr inbounds [410 x i8], [410 x i8]* %10, i64 0, i64 0
%153 = load i64, i64* %7
%154 = call i32 @lib_memcmp(i8* %151, i8* %152, i64 %153)
store i32 %154, i32* %14
%155 = load void (i8*, i8*, i32)*, void (i8*, i8*, i32)** %5
%156 = getelementptr inbounds [410 x i8], [410 x i8]* %9, i64 0, i64 0
%157 = getelementptr inbounds [410 x i8], [410 x i8]* %10, i64 0, i64 0
%158 = load i32, i32* %14
%159 = load void (i8*, i8*, i32)*, void (i8*, i8*, i32)** %5
%160 = getelementptr inbounds [410 x i8], [410 x i8]* %10, i64 0, i64 0
%161 = getelementptr inbounds [410 x i8], [410 x i8]* %9, i64 0, i64 0
%162 = load i32, i32* %14
%163 = sub nsw i32 0, %162
%164 = load void (i8*, i8*, i32)*, void (i8*, i8*, i32)** %5
%165 = getelementptr inbounds [410 x i8], [410 x i8]* %10, i64 0, i64 0
%166 = getelementptr inbounds [410 x i8], [410 x i8]* %10, i64 0, i64 0
%167 = getelementptr inbounds [410 x i8], [410 x i8]* %9, i64 0, i64 0
%168 = getelementptr inbounds [410 x i8], [410 x i8]* %10, i64 0, i64 0
%169 = load i64, i64* %7
%170 = call i32 @lib_strncmp(i8* %167, i8* %168, i64 %169)
store i32 %170, i32* %14
%171 = load void (i8*, i8*, i32)*, void (i8*, i8*, i32)** %6
%172 = getelementptr inbounds [410 x i8], [410 x i8]* %9, i64 0, i64 0
%173 = getelementptr inbounds [410 x i8], [410 x i8]* %10, i64 0, i64 0
%174 = load i32, i32* %14
%175 = load void (i8*, i8*, i32)*, void (i8*, i8*, i32)** %6
%176 = getelementptr inbounds [410 x i8], [410 x i8]* %10, i64 0, i64 0
%177 = getelementptr inbounds [410 x i8], [410 x i8]* %9, i64 0, i64 0
%178 = load i32, i32* %14
%179 = sub nsw i32 0, %178
%180 = load void (i8*, i8*, i32)*, void (i8*, i8*, i32)** %6
%181 = getelementptr inbounds [410 x i8], [410 x i8]* %10, i64 0, i64 0
%182 = getelementptr inbounds [410 x i8], [410 x i8]* %10, i64 0, i64 0
%183 = load i64, i64* %12
%184 = getelementptr inbounds [410 x i8], [410 x i8]* %10, i64 0, i64 %183
store i8 0, i8* %184
%185 = getelementptr inbounds [410 x i8], [410 x i8]* %9, i64 0, i64 0
%186 = getelementptr inbounds [410 x i8], [410 x i8]* %10, i64 0, i64 0
%187 = load i64, i64* %7
%188 = call i32 @lib_memcmp(i8* %185, i8* %186, i64 %187)
store i32 %188, i32* %14
%189 = load void (i8*, i8*, i32)*, void (i8*, i8*, i32)** %5
%190 = getelementptr inbounds [410 x i8], [410 x i8]* %9, i64 0, i64 0
%191 = getelementptr inbounds [410 x i8], [410 x i8]* %10, i64 0, i64 0
%192 = load i32, i32* %14
%193 = getelementptr inbounds [410 x i8], [410 x i8]* %9, i64 0, i64 0
%194 = getelementptr inbounds [410 x i8], [410 x i8]* %10, i64 0, i64 0
%195 = load i64, i64* %7
%196 = call i32 @lib_strncmp(i8* %193, i8* %194, i64 %195)
store i32 %196, i32* %14
%197 = load void (i8*, i8*, i32)*, void (i8*, i8*, i32)** %6
%198 = getelementptr inbounds [410 x i8], [410 x i8]* %9, i64 0, i64 0
%199 = getelementptr inbounds [410 x i8], [410 x i8]* %10, i64 0, i64 0
%200 = load i32, i32* %14
%201 = getelementptr inbounds [410 x i8], [410 x i8]* %10, i64 0, i64 0
%202 = load i64, i64* %12
%203 = getelementptr inbounds i8, i8* %201, i64 %202
%204 = load i64, i64* %12
%205 = sub i64 410, %204
%206 = trunc i64 %205 to i32
%207 = call i32 @memset(i8* %203, i8 signext 66, i32 %206)
%208 = load i64, i64* %13
%209 = getelementptr inbounds [410 x i8], [410 x i8]* %10, i64 0, i64 %208
store i8 0, i8* %209
%210 = getelementptr inbounds [410 x i8], [410 x i8]* %9, i64 0, i64 0
%211 = getelementptr inbounds [410 x i8], [410 x i8]* %10, i64 0, i64 0
%212 = load i64, i64* %7
%213 = call i32 @lib_memcmp(i8* %210, i8* %211, i64 %212)
store i32 %213, i32* %14
%214 = load void (i8*, i8*, i32)*, void (i8*, i8*, i32)** %5
%215 = getelementptr inbounds [410 x i8], [410 x i8]* %9, i64 0, i64 0
%216 = getelementptr inbounds [410 x i8], [410 x i8]* %10, i64 0, i64 0
%217 = load i32, i32* %14
%218 = load void (i8*, i8*, i32)*, void (i8*, i8*, i32)** %5
%219 = getelementptr inbounds [410 x i8], [410 x i8]* %10, i64 0, i64 0
%220 = getelementptr inbounds [410 x i8], [410 x i8]* %9, i64 0, i64 0
%221 = load i32, i32* %14
%222 = sub nsw i32 0, %221
%223 = getelementptr inbounds [410 x i8], [410 x i8]* %9, i64 0, i64 0
%224 = getelementptr inbounds [410 x i8], [410 x i8]* %10, i64 0, i64 0
%225 = load i64, i64* %7
%226 = call i32 @lib_strncmp(i8* %223, i8* %224, i64 %225)
store i32 %226, i32* %14
%227 = load void (i8*, i8*, i32)*, void (i8*, i8*, i32)** %6
%228 = getelementptr inbounds [410 x i8], [410 x i8]* %9, i64 0, i64 0
%229 = getelementptr inbounds [410 x i8], [410 x i8]* %10, i64 0, i64 0
%230 = load i32, i32* %14
%231 = load void (i8*, i8*, i32)*, void (i8*, i8*, i32)** %6
%232 = getelementptr inbounds [410 x i8], [410 x i8]* %10, i64 0, i64 0
%233 = getelementptr inbounds [410 x i8], [410 x i8]* %9, i64 0, i64 0
%234 = load i32, i32* %14
%235 = sub nsw i32 0, %234
br label %236
236: ; preds = %134
%237 = load i64, i64* %13
%238 = add i64 %237, 1
store i64 %238, i64* %13
br label %129
239: ; preds = %129
br label %240
240: ; preds = %239
%241 = load i64, i64* %12
%242 = add i64 %241, 1
store i64 %242, i64* %12
br label %115
243: ; preds = %115
ret void
}

LLVM IR (-O2):
define void @test_driver_memcmp(void (i8*, i8*, i32)* nocapture %0, void (i8*, i8*, i32)* nocapture %1, i64 %2, i32 %3) {
%5 = alloca [410 x i8]
%6 = alloca [410 x i8]
%7 = getelementptr inbounds [410 x i8], [410 x i8]* %5, i64 0, i64 0
%8 = getelementptr inbounds [410 x i8], [410 x i8]* %6, i64 0, i64 0
%9 = icmp ult i64 %2, 200
%10 = select i1 %9, i64 %2, i64 200
%11 = icmp eq i64 %2, 0
br i1 %11, label %49, label %12
12: ; preds = %4
%13 = udiv i64 10000, %2
%14 = icmp ugt i64 %2, 10000
%15 = call i64 @llvm.umax.i64(i64 %13, i64 1)
br label %16
16: ; preds = %12, %44
%17 = phi i64 [ 0, %12 ], [ %47, %44 ]
br i1 %14, label %44, label %18
18: ; preds = %16
%19 = icmp eq i64 %17, 0
br label %20
20: ; preds = %18, %41
%21 = phi i64 [ 0, %18 ], [ %42, %41 ]
br i1 %19, label %30, label %22
22: ; preds = %20, %22
%23 = phi i64 [ %28, %22 ], [ 0, %20 ]
%24 = call i32 (...) @rand()
%25 = trunc i32 %24 to i8
%26 = getelementptr inbounds [410 x i8], [410 x i8]* %5, i64 0, i64 %23
store i8 %25, i8* %26
%27 = getelementptr inbounds [410 x i8], [410 x i8]* %6, i64 0, i64 %23
store i8 %25, i8* %27
%28 = add nuw nsw i64 %23, 1
%29 = icmp eq i64 %28, %17
br i1 %29, label %30, label %22
30: ; preds = %22, %20
br label %31
31: ; preds = %30, %31
%32 = phi i64 [ %39, %31 ], [ %17, %30 ]
%33 = call i32 (...) @rand()
%34 = trunc i32 %33 to i8
%35 = getelementptr inbounds [410 x i8], [410 x i8]* %5, i64 0, i64 %32
store i8 %34, i8* %35
%36 = call i32 (...) @rand()
%37 = trunc i32 %36 to i8
%38 = getelementptr inbounds [410 x i8], [410 x i8]* %6, i64 0, i64 %32
store i8 %37, i8* %38
%39 = add nuw i64 %32, 1
%40 = icmp ult i64 %39, %2
br i1 %40, label %31, label %41
41: ; preds = %31
%42 = add nuw nsw i64 %21, 1
%43 = icmp eq i64 %42, %15
br i1 %43, label %44, label %20
44: ; preds = %41, %16
%45 = call i32 @lib_memcmp(i8* %7, i8* %8, i64 %2)
%46 = call i32 @lib_strncmp(i8* %7, i8* %8, i64 %2)
%47 = add nuw i64 %17, 1
%48 = icmp eq i64 %47, %2
br i1 %48, label %49, label %16
49: ; preds = %44, %4
%50 = call i64 @llvm.usub.sat.i64(i64 %10, i64 10)
%51 = add nuw nsw i64 %10, 10
%52 = icmp ult i64 %50, %51
br i1 %52, label %53, label %83
53: ; preds = %49
%54 = trunc i64 %10 to i32
%55 = shl nuw nsw i32 %54, 1
br label %56
56: ; preds = %80, %53
%57 = phi i64 [ %50, %53 ], [ %81, %80 ]
%58 = getelementptr inbounds [410 x i8], [410 x i8]* %6, i64 0, i64 %57
%59 = trunc i64 %57 to i32
%60 = sub i32 410, %59
br label %61
61: ; preds = %56, %61
%62 = phi i64 [ %50, %56 ], [ %78, %61 ]
%63 = call i32 @memset(i8* %7, i8 signext 65, i32 %55)
%64 = call i32 @memset(i8* %8, i8 signext 65, i32 %55)
store i8 66, i8* %58
%65 = getelementptr inbounds [410 x i8], [410 x i8]* %5, i64 0, i64 %62
store i8 0, i8* %65
%66 = getelementptr inbounds [410 x i8], [410 x i8]* %6, i64 0, i64 %62
store i8 0, i8* %66
%67 = call i32 @lib_memcmp(i8* %7, i8* %8, i64 %2)
%68 = sub nsw i32 0, %67
%69 = call i32 @lib_strncmp(i8* %7, i8* %8, i64 %2)
%70 = sub nsw i32 0, %69
store i8 0, i8* %58
%71 = call i32 @lib_memcmp(i8* %7, i8* %8, i64 %2)
%72 = call i32 @lib_strncmp(i8* %7, i8* %8, i64 %2)
%73 = call i32 @memset(i8* %58, i8 signext 66, i32 %60)
store i8 0, i8* %66
%74 = call i32 @lib_memcmp(i8* %7, i8* %8, i64 %2)
%75 = sub nsw i32 0, %74
%76 = call i32 @lib_strncmp(i8* %7, i8* %8, i64 %2)
%77 = sub nsw i32 0, %76
%78 = add nuw nsw i64 %62, 1
%79 = icmp eq i64 %78, %51
br i1 %79, label %80, label %61
80: ; preds = %61
%81 = add nuw nsw i64 %57, 1
%82 = icmp eq i64 %81, %51
br i1 %82, label %83, label %56
83: ; preds = %80, %49
ret void
}