#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 size_t wint_t;
typedef void *wchar_t;
typedef int ptrdiff_t;

/* Variables and functions */
scalar_t__ compare_buffers(int, int, int, char *, char *);
int inner0(char *, char, short, void *, int, size_t);
int inner1(char *, long, long long, void *, int, size_t);
char *malloc(int);
int /*<<< orphan*/ memset(char *, int, int);
int outer(int, char *, long, long long, void *, int, size_t);
int main() {
  char c = 0x03L;
  short s = (0x04L << ((2 - 1) * 8)) + 0xff;
  wchar_t wc = (0x05L << ((4 - 1) * 8)) + 0xfe;
  int i = (0x06L << ((4 - 1) * 8)) + 0xfd;
  wint_t wi = (0x07L << ((4 - 1) * 8)) + 0xfc;
  long l = (0x08L << ((8 - 1) * 8)) + 0xfb;
  long long ll = (0x09LL << ((8 - 1) * 8)) + 0xfa;
  void *ptr = (void *)((0x0aL << ((8 - 1) * 8)) + 0xf9);
  ptrdiff_t pd = (0x0bL << ((8 - 1) * 8)) + 0xf9;
  size_t sz = (0x0cL << ((8 - 1) * 8)) + 0xf8;
  char *buf[2];
  for (int j = 0; j < 2; j++)
    buf[j] = malloc(2048);
  int ret[2];
  int errors = 0;
  for (int j = 0; j < 2; j++)
    memset(buf[j], 0, 2048);
  ret[0] = outer(0, buf[0], c, s, wc, i, wi);
  ret[1] = inner0(buf[1], c, s, wc, i, wi);
  errors += compare_buffers(0, ret[0], ret[1], buf[0], buf[1]);
  for (int j = 0; j < 2; j++)
    memset(buf[j], 1, 2048);
  ret[0] = outer(1, buf[0], l, ll, ptr, pd, sz);
  ret[1] = inner1(buf[1], l, ll, ptr, pd, sz);
  errors += compare_buffers(1, ret[0], ret[1], buf[0], buf[1]);
  return (int)errors;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x80,%rsp
movl   $0x0,-0x4(%rbp)
movb   $0x3,-0x5(%rbp)
movw   $0x4ff,-0x8(%rbp)
mov    $0x50000fe,%eax
mov    %rax,-0x10(%rbp)
movl   $0x60000fd,-0x14(%rbp)
movq   $0x70000fc,-0x20(%rbp)
07
movabs $0x8000000000000fb,%rax
mov    %rax,-0x28(%rbp)
movabs $0x9000000000000fa,%rax
mov    %rax,-0x30(%rbp)
movabs $0xa000000000000f9,%rax
mov    %rax,-0x38(%rbp)
movl   $0xf9,-0x3c(%rbp)
movabs $0xc000000000000f8,%rax
mov    %rax,-0x48(%rbp)
movl   $0x0,-0x64(%rbp)
cmpl   $0x2,-0x64(%rbp)
jge    1208 <main+0xa8>
mov    $0x800,%edi
call   1080 <malloc@plt>
mov    %rax,%rcx
movslq -0x64(%rbp),%rax
mov    %rcx,-0x60(%rbp,%rax,8)
mov    -0x64(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x64(%rbp)
jmp    11da <main+0x7a>
movl   $0x0,-0x70(%rbp)
movl   $0x0,-0x74(%rbp)
cmpl   $0x2,-0x74(%rbp)
jge    1243 <main+0xe3>
movslq -0x74(%rbp),%rax
mov    -0x60(%rbp,%rax,8),%rdi
xor    %esi,%esi
mov    $0x800,%edx
call   1060 <memset@plt>
mov    -0x74(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x74(%rbp)
jmp    1216 <main+0xb6>
mov    -0x60(%rbp),%rsi
movsbq -0x5(%rbp),%rdx
movswq -0x8(%rbp),%rcx
mov    -0x10(%rbp),%r8
mov    -0x14(%rbp),%r9d
mov    -0x20(%rbp),%rax
xor    %edi,%edi
mov    %rax,(%rsp)
call   1040 <outer@plt>
mov    %eax,-0x6c(%rbp)
mov    -0x58(%rbp),%rdi
mov    -0x5(%rbp),%dl
mov    -0x8(%rbp),%ax
mov    -0x10(%rbp),%rcx
mov    -0x14(%rbp),%r8d
mov    -0x20(%rbp),%r9
movsbl %dl,%esi
movswl %ax,%edx
call   1030 <inner0@plt>
mov    %eax,-0x68(%rbp)
mov    -0x6c(%rbp),%esi
mov    -0x68(%rbp),%edx
mov    -0x60(%rbp),%rcx
mov    -0x58(%rbp),%r8
xor    %edi,%edi
call   1050 <compare_buffers@plt>
mov    %rax,%rcx
movslq -0x70(%rbp),%rax
add    %rcx,%rax
mov    %eax,-0x70(%rbp)
movl   $0x0,-0x78(%rbp)
cmpl   $0x2,-0x78(%rbp)
jge    12e9 <main+0x189>
movslq -0x78(%rbp),%rax
mov    -0x60(%rbp,%rax,8),%rdi
mov    $0x1,%esi
mov    $0x800,%edx
call   1060 <memset@plt>
mov    -0x78(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x78(%rbp)
jmp    12b9 <main+0x159>
mov    -0x60(%rbp),%rsi
mov    -0x28(%rbp),%rdx
mov    -0x30(%rbp),%rcx
mov    -0x38(%rbp),%r8
mov    -0x3c(%rbp),%r9d
mov    -0x48(%rbp),%rax
mov    $0x1,%edi
mov    %rax,(%rsp)
call   1040 <outer@plt>
mov    %eax,-0x6c(%rbp)
mov    -0x58(%rbp),%rdi
mov    -0x28(%rbp),%rsi
mov    -0x30(%rbp),%rdx
mov    -0x38(%rbp),%rcx
mov    -0x3c(%rbp),%r8d
mov    -0x48(%rbp),%r9
call   1070 <inner1@plt>
mov    %eax,-0x68(%rbp)
mov    -0x6c(%rbp),%esi
mov    -0x68(%rbp),%edx
mov    -0x60(%rbp),%rcx
mov    -0x58(%rbp),%r8
mov    $0x1,%edi
call   1050 <compare_buffers@plt>
mov    %rax,%rcx
movslq -0x70(%rbp),%rax
add    %rcx,%rax
mov    %eax,-0x70(%rbp)
mov    -0x70(%rbp),%eax
add    $0x80,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    $0x800,%edi
call   1080 <malloc@plt>
mov    %rax,%r14
mov    $0x800,%edi
call   1080 <malloc@plt>
mov    %rax,%rbx
mov    %r14,%rdi
xor    %esi,%esi
mov    $0x800,%edx
call   1060 <memset@plt>
mov    %rbx,%rdi
xor    %esi,%esi
mov    $0x800,%edx
call   1060 <memset@plt>
movq   $0x70000fc,(%rsp)
07
mov    $0x3,%edx
mov    $0x4ff,%ecx
mov    $0x50000fe,%r8d
xor    %edi,%edi
mov    %r14,%rsi
mov    $0x60000fd,%r9d
call   1040 <outer@plt>
mov    %eax,%ebp
mov    $0x50000fe,%ecx
mov    $0x70000fc,%r9d
mov    %rbx,%rdi
mov    $0x3,%esi
mov    $0x4ff,%edx
mov    $0x60000fd,%r8d
call   1030 <inner0@plt>
xor    %edi,%edi
mov    %ebp,%esi
mov    %eax,%edx
mov    %r14,%rcx
mov    %rbx,%r8
call   1050 <compare_buffers@plt>
mov    %rax,0x10(%rsp)
mov    %r14,%rdi
mov    $0x1,%esi
mov    $0x800,%edx
call   1060 <memset@plt>
mov    %rbx,%rdi
mov    $0x1,%esi
mov    $0x800,%edx
call   1060 <memset@plt>
movabs $0xc000000000000f8,%rax
mov    %rax,(%rsp)
movabs $0x8000000000000fb,%rbp
movabs $0x9000000000000fa,%r13
movabs $0xa000000000000f9,%r15
mov    $0x1,%edi
mov    %r14,%rsi
mov    %rbp,%rdx
mov    %r13,%rcx
mov    %r15,%r8
mov    $0xf9,%r9d
call   1040 <outer@plt>
mov    %eax,%r12d
mov    %rbx,%rdi
mov    %rbp,%rsi
mov    %r13,%rdx
mov    %r15,%rcx
mov    $0xf9,%r8d
movabs $0xc000000000000f8,%r9
call   1070 <inner1@plt>
mov    $0x1,%edi
mov    %r12d,%esi
mov    %eax,%edx
mov    %r14,%rcx
mov    %rbx,%r8
call   1050 <compare_buffers@plt>
add    0x10(%rsp),%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define i32 @main() {
%1 = alloca i32
%2 = alloca i8
%3 = alloca i16
%4 = alloca i8*
%5 = alloca i32
%6 = alloca i64
%7 = alloca i64
%8 = alloca i64
%9 = alloca i8*
%10 = alloca i32
%11 = alloca i64
%12 = alloca [2 x i8*]
%13 = alloca i32
%14 = alloca [2 x i32]
%15 = alloca i32
%16 = alloca i32
%17 = alloca i32
store i32 0, i32* %1
store i8 3, i8* %2
store i16 1279, i16* %3
store i8* inttoptr (i64 83886334 to i8*), i8** %4
store i32 100663549, i32* %5
store i64 117440764, i64* %6
store i64 576460752303423739, i64* %7
store i64 648518346341351674, i64* %8
store i8* inttoptr (i64 720575940379279609 to i8*), i8** %9
store i32 249, i32* %10
store i64 864691128455135480, i64* %11
store i32 0, i32* %13
br label %18
18: ; preds = %26, %0
%19 = load i32, i32* %13
%20 = icmp slt i32 %19, 2
br i1 %20, label %21, label %29
21: ; preds = %18
%22 = call i8* @malloc(i32 2048)
%23 = load i32, i32* %13
%24 = sext i32 %23 to i64
%25 = getelementptr inbounds [2 x i8*], [2 x i8*]* %12, i64 0, i64 %24
store i8* %22, i8** %25
br label %26
26: ; preds = %21
%27 = load i32, i32* %13
%28 = add nsw i32 %27, 1
store i32 %28, i32* %13
br label %18
29: ; preds = %18
store i32 0, i32* %15
store i32 0, i32* %16
br label %30
30: ; preds = %39, %29
%31 = load i32, i32* %16
%32 = icmp slt i32 %31, 2
br i1 %32, label %33, label %42
33: ; preds = %30
%34 = load i32, i32* %16
%35 = sext i32 %34 to i64
%36 = getelementptr inbounds [2 x i8*], [2 x i8*]* %12, i64 0, i64 %35
%37 = load i8*, i8** %36
%38 = call i32 @memset(i8* %37, i32 0, i32 2048)
br label %39
39: ; preds = %33
%40 = load i32, i32* %16
%41 = add nsw i32 %40, 1
store i32 %41, i32* %16
br label %30
42: ; preds = %30
%43 = getelementptr inbounds [2 x i8*], [2 x i8*]* %12, i64 0, i64 0
%44 = load i8*, i8** %43
%45 = load i8, i8* %2
%46 = sext i8 %45 to i64
%47 = load i16, i16* %3
%48 = sext i16 %47 to i64
%49 = load i8*, i8** %4
%50 = load i32, i32* %5
%51 = load i64, i64* %6
%52 = call i32 @outer(i32 0, i8* %44, i64 %46, i64 %48, i8* %49, i32 %50, i64 %51)
%53 = getelementptr inbounds [2 x i32], [2 x i32]* %14, i64 0, i64 0
store i32 %52, i32* %53
%54 = getelementptr inbounds [2 x i8*], [2 x i8*]* %12, i64 0, i64 1
%55 = load i8*, i8** %54
%56 = load i8, i8* %2
%57 = load i16, i16* %3
%58 = load i8*, i8** %4
%59 = load i32, i32* %5
%60 = load i64, i64* %6
%61 = call i32 @inner0(i8* %55, i8 signext %56, i16 signext %57, i8* %58, i32 %59, i64 %60)
%62 = getelementptr inbounds [2 x i32], [2 x i32]* %14, i64 0, i64 1
store i32 %61, i32* %62
%63 = getelementptr inbounds [2 x i32], [2 x i32]* %14, i64 0, i64 0
%64 = load i32, i32* %63
%65 = getelementptr inbounds [2 x i32], [2 x i32]* %14, i64 0, i64 1
%66 = load i32, i32* %65
%67 = getelementptr inbounds [2 x i8*], [2 x i8*]* %12, i64 0, i64 0
%68 = load i8*, i8** %67
%69 = getelementptr inbounds [2 x i8*], [2 x i8*]* %12, i64 0, i64 1
%70 = load i8*, i8** %69
%71 = call i64 @compare_buffers(i32 0, i32 %64, i32 %66, i8* %68, i8* %70)
%72 = load i32, i32* %15
%73 = sext i32 %72 to i64
%74 = add nsw i64 %73, %71
%75 = trunc i64 %74 to i32
store i32 %75, i32* %15
store i32 0, i32* %17
br label %76
76: ; preds = %85, %42
%77 = load i32, i32* %17
%78 = icmp slt i32 %77, 2
br i1 %78, label %79, label %88
79: ; preds = %76
%80 = load i32, i32* %17
%81 = sext i32 %80 to i64
%82 = getelementptr inbounds [2 x i8*], [2 x i8*]* %12, i64 0, i64 %81
%83 = load i8*, i8** %82
%84 = call i32 @memset(i8* %83, i32 1, i32 2048)
br label %85
85: ; preds = %79
%86 = load i32, i32* %17
%87 = add nsw i32 %86, 1
store i32 %87, i32* %17
br label %76
88: ; preds = %76
%89 = getelementptr inbounds [2 x i8*], [2 x i8*]* %12, i64 0, i64 0
%90 = load i8*, i8** %89
%91 = load i64, i64* %7
%92 = load i64, i64* %8
%93 = load i8*, i8** %9
%94 = load i32, i32* %10
%95 = load i64, i64* %11
%96 = call i32 @outer(i32 1, i8* %90, i64 %91, i64 %92, i8* %93, i32 %94, i64 %95)
%97 = getelementptr inbounds [2 x i32], [2 x i32]* %14, i64 0, i64 0
store i32 %96, i32* %97
%98 = getelementptr inbounds [2 x i8*], [2 x i8*]* %12, i64 0, i64 1
%99 = load i8*, i8** %98
%100 = load i64, i64* %7
%101 = load i64, i64* %8
%102 = load i8*, i8** %9
%103 = load i32, i32* %10
%104 = load i64, i64* %11
%105 = call i32 @inner1(i8* %99, i64 %100, i64 %101, i8* %102, i32 %103, i64 %104)
%106 = getelementptr inbounds [2 x i32], [2 x i32]* %14, i64 0, i64 1
store i32 %105, i32* %106
%107 = getelementptr inbounds [2 x i32], [2 x i32]* %14, i64 0, i64 0
%108 = load i32, i32* %107
%109 = getelementptr inbounds [2 x i32], [2 x i32]* %14, i64 0, i64 1
%110 = load i32, i32* %109
%111 = getelementptr inbounds [2 x i8*], [2 x i8*]* %12, i64 0, i64 0
%112 = load i8*, i8** %111
%113 = getelementptr inbounds [2 x i8*], [2 x i8*]* %12, i64 0, i64 1
%114 = load i8*, i8** %113
%115 = call i64 @compare_buffers(i32 1, i32 %108, i32 %110, i8* %112, i8* %114)
%116 = load i32, i32* %15
%117 = sext i32 %116 to i64
%118 = add nsw i64 %117, %115
%119 = trunc i64 %118 to i32
store i32 %119, i32* %15
%120 = load i32, i32* %15
ret i32 %120
}

LLVM IR (-O2):
define i32 @main() {
%1 = tail call dereferenceable_or_null(2048) i8* @malloc(i32 2048)
%2 = tail call dereferenceable_or_null(2048) i8* @malloc(i32 2048)
%3 = tail call i32 @memset(i8* %1, i32 0, i32 2048)
%4 = tail call i32 @memset(i8* %2, i32 0, i32 2048)
%5 = tail call i32 @outer(i32 0, i8* %1, i64 3, i64 1279, i8* inttoptr (i64 83886334 to i8*), i32 100663549, i64 117440764)
%6 = tail call i32 @inner0(i8* %2, i8 signext 3, i16 signext 1279, i8* inttoptr (i64 83886334 to i8*), i32 100663549, i64 117440764)
%7 = tail call i64 @compare_buffers(i32 0, i32 %5, i32 %6, i8* %1, i8* %2)
%8 = tail call i32 @memset(i8* %1, i32 1, i32 2048)
%9 = tail call i32 @memset(i8* %2, i32 1, i32 2048)
%10 = tail call i32 @outer(i32 1, i8* %1, i64 576460752303423739, i64 648518346341351674, i8* inttoptr (i64 720575940379279609 to i8*), i32 249, i64 864691128455135480)
%11 = tail call i32 @inner1(i8* %2, i64 576460752303423739, i64 648518346341351674, i8* inttoptr (i64 720575940379279609 to i8*), i32 249, i64 864691128455135480)
%12 = tail call i64 @compare_buffers(i32 1, i32 %10, i32 %11, i8* %1, i8* %2)
%13 = add i64 %12, %7
%14 = trunc i64 %13 to i32
ret i32 %14
}