#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 */
scalar_t__ Test(int, int);
int /*<<< orphan*/ printf(char *, ...);
int main() {
  int offset[] = {0,
                  1,
                  2,
                  (1 * (1024 * 1024)) / 2,
                  (1 * (1024 * 1024)) - 2,
                  (1 * (1024 * 1024)) - 1};
  int onum = 6;
  int errors = 0;
  for (int s1 = 0; s1 < 6; s1++) {
    for (int s2 = 0; s2 < 6; s2++) {
      errors += Test(offset[s1], (8 * (1 * (1024 * 1024))) - offset[s2]);
      if (errors > 20) {
        printf("abort due to errors\n");
        return errors;
      }
    }
  }
  printf("finished with %d errors\n", errors);
  return errors;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    0xeca(%rip),%rax
mov    %rax,-0x20(%rbp)
mov    0xec7(%rip),%rax
mov    %rax,-0x18(%rbp)
mov    0xec4(%rip),%rax
mov    %rax,-0x10(%rbp)
movl   $0x6,-0x24(%rbp)
movl   $0x0,-0x28(%rbp)
movl   $0x0,-0x2c(%rbp)
cmpl   $0x6,-0x2c(%rbp)
jge    11f0 <main+0xd0>
movl   $0x0,-0x30(%rbp)
cmpl   $0x6,-0x30(%rbp)
jge    11dd <main+0xbd>
movslq -0x2c(%rbp),%rax
mov    -0x20(%rbp,%rax,4),%edi
movslq -0x30(%rbp),%rax
mov    $0x800000,%esi
sub    -0x20(%rbp,%rax,4),%esi
call   1040 <Test@plt>
mov    %rax,%rcx
movslq -0x28(%rbp),%rax
add    %rcx,%rax
mov    %eax,-0x28(%rbp)
cmpl   $0x14,-0x28(%rbp)
jle    11ca <main+0xaa>
lea    0xe60(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x28(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    1207 <main+0xe7>
jmp    11cf <main+0xaf>
mov    -0x30(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x30(%rbp)
jmp    1176 <main+0x56>
jmp    11e2 <main+0xc2>
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
jmp    1165 <main+0x45>
mov    -0x28(%rbp),%esi
lea    0xe33(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x28(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
xor    %r14d,%r14d
lea    0xebe(%rip),%r15
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    %ebx,%r12d
mov    (%r14,%r15,1),%ebp
mov    %ebp,%edi
mov    $0x800000,%esi
call   1050 <Test@plt>
mov    %rax,%rbx
add    %r12d,%ebx
cmp    $0x14,%ebx
jg     11ed <main+0xbd>
mov    %ebp,%edi
mov    $0x7fffff,%esi
call   1050 <Test@plt>
add    %eax,%ebx
cmp    $0x14,%ebx
jg     11ed <main+0xbd>
mov    %ebp,%edi
mov    $0x7ffffe,%esi
call   1050 <Test@plt>
add    %eax,%ebx
cmp    $0x14,%ebx
jg     11ed <main+0xbd>
mov    %ebp,%edi
mov    $0x780000,%esi
call   1050 <Test@plt>
add    %eax,%ebx
cmp    $0x14,%ebx
jg     11ed <main+0xbd>
mov    %ebp,%edi
mov    $0x700002,%esi
call   1050 <Test@plt>
add    %eax,%ebx
cmp    $0x14,%ebx
jg     11ed <main+0xbd>
mov    %ebp,%edi
mov    $0x700001,%esi
call   1050 <Test@plt>
add    %eax,%ebx
cmp    $0x14,%ebx
jg     11ed <main+0xbd>
add    $0x4,%r14
cmp    $0x18,%r14
jne    1150 <main+0x20>
lea    0xe36(%rip),%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1040 <printf@plt>
jmp    11f9 <main+0xc9>
lea    0xe3d(%rip),%rdi
call   1030 <puts@plt>
mov    %ebx,%eax
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@__const.main.offset = [6 x i32] [i32 0, i32 1, i32 2, i32 524288, i32 1048574, i32 1048575]
@.str = [21 x i8] c"abort due to errors\0A\00"
@.str.1 = [25 x i8] c"finished with %d errors\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [6 x i32]
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
store i32 0, i32* %1
%7 = bitcast [6 x i32]* %2 to i8*
store i32 6, i32* %3
store i32 0, i32* %4
store i32 0, i32* %5
br label %8
8: ; preds = %40, %0
%9 = load i32, i32* %5
%10 = icmp slt i32 %9, 6
br i1 %10, label %11, label %43
11: ; preds = %8
store i32 0, i32* %6
br label %12
12: ; preds = %36, %11
%13 = load i32, i32* %6
%14 = icmp slt i32 %13, 6
br i1 %14, label %15, label %39
15: ; preds = %12
%16 = load i32, i32* %5
%17 = sext i32 %16 to i64
%18 = getelementptr inbounds [6 x i32], [6 x i32]* %2, i64 0, i64 %17
%19 = load i32, i32* %18
%20 = load i32, i32* %6
%21 = sext i32 %20 to i64
%22 = getelementptr inbounds [6 x i32], [6 x i32]* %2, i64 0, i64 %21
%23 = load i32, i32* %22
%24 = sub nsw i32 8388608, %23
%25 = call i64 @Test(i32 %19, i32 %24)
%26 = load i32, i32* %4
%27 = sext i32 %26 to i64
%28 = add nsw i64 %27, %25
%29 = trunc i64 %28 to i32
store i32 %29, i32* %4
%30 = load i32, i32* %4
%31 = icmp sgt i32 %30, 20
br i1 %31, label %32, label %35
32: ; preds = %15
%33 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0))
%34 = load i32, i32* %4
store i32 %34, i32* %1
br label %47
35: ; preds = %15
br label %36
36: ; preds = %35
%37 = load i32, i32* %6
%38 = add nsw i32 %37, 1
store i32 %38, i32* %6
br label %12
39: ; preds = %12
br label %40
40: ; preds = %39
%41 = load i32, i32* %5
%42 = add nsw i32 %41, 1
store i32 %42, i32* %5
br label %8
43: ; preds = %8
%44 = load i32, i32* %4
%45 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.1, i64 0, i64 0), i32 %44)
%46 = load i32, i32* %4
store i32 %46, i32* %1
br label %47
47: ; preds = %43, %32
%48 = load i32, i32* %1
ret i32 %48
}

LLVM IR (-O2):
@__const.main.offset = [6 x i32] [i32 0, i32 1, i32 2, i32 524288, i32 1048574, i32 1048575]
@.str.1 = [25 x i8] c"finished with %d errors\0A\00"
@str = [20 x i8] c"abort due to errors\00"
define i32 @main() {
br label %1
1: ; preds = %0, %35
%2 = phi i64 [ 0, %0 ], [ %36, %35 ]
%3 = phi i32 [ 0, %0 ], [ %33, %35 ]
%4 = getelementptr inbounds [6 x i32], [6 x i32]* @__const.main.offset, i64 0, i64 %2
%5 = load i32, i32* %4
%6 = tail call i64 @Test(i32 %5, i32 8388608)
%7 = trunc i64 %6 to i32
%8 = add i32 %3, %7
%9 = icmp sgt i32 %8, 20
br i1 %9, label %38, label %10
10: ; preds = %1
%11 = tail call i64 @Test(i32 %5, i32 8388607)
%12 = trunc i64 %11 to i32
%13 = add i32 %8, %12
%14 = icmp sgt i32 %13, 20
br i1 %14, label %38, label %15
15: ; preds = %10
%16 = tail call i64 @Test(i32 %5, i32 8388606)
%17 = trunc i64 %16 to i32
%18 = add i32 %13, %17
%19 = icmp sgt i32 %18, 20
br i1 %19, label %38, label %20
20: ; preds = %15
%21 = tail call i64 @Test(i32 %5, i32 7864320)
%22 = trunc i64 %21 to i32
%23 = add i32 %18, %22
%24 = icmp sgt i32 %23, 20
br i1 %24, label %38, label %25
25: ; preds = %20
%26 = tail call i64 @Test(i32 %5, i32 7340034)
%27 = trunc i64 %26 to i32
%28 = add i32 %23, %27
%29 = icmp sgt i32 %28, 20
br i1 %29, label %38, label %30
30: ; preds = %25
%31 = tail call i64 @Test(i32 %5, i32 7340033)
%32 = trunc i64 %31 to i32
%33 = add i32 %28, %32
%34 = icmp sgt i32 %33, 20
br i1 %34, label %38, label %35
35: ; preds = %30
%36 = add nuw nsw i64 %2, 1
%37 = icmp eq i64 %36, 6
br i1 %37, label %41, label %1
38: ; preds = %30, %25, %20, %15, %10, %1
%39 = phi i32 [ %8, %1 ], [ %13, %10 ], [ %18, %15 ], [ %23, %20 ], [ %28, %25 ], [ %33, %30 ]
%40 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @str, i64 0, i64 0))
br label %43
41: ; preds = %35
%42 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @.str.1, i64 0, i64 0), i32 %33)
br label %43
43: ; preds = %38, %41
%44 = phi i32 [ %39, %38 ], [ %33, %41 ]
ret i32 %44
}