#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 /*<<< orphan*/ FILE;

/* Variables and functions */
unsigned int calc(unsigned int, unsigned int);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/ *, char *, unsigned int);
int /*<<< orphan*/ fread(unsigned int *, int, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ free(unsigned int *);
scalar_t__ malloc(int);
int /*<<< orphan*/ *stdout;
void runTestbench(int numberOfWords, char *inputFileName,
                  char *outputFileName0) {
  unsigned int *theBigAllocatedThing;
  unsigned int *theInputArray;
  unsigned int *theOutputArray0;
  FILE *inputFile;
  FILE *outputFile0;
  unsigned int readData;
  unsigned int bits0;
  int counter;
  int tmp;
  theBigAllocatedThing =
      (unsigned int *)malloc((numberOfWords * sizeof(unsigned int) * 2));
  theInputArray = theBigAllocatedThing;
  theOutputArray0 = theBigAllocatedThing + numberOfWords;
  inputFile = fopen(inputFileName, "r");
  fread(theInputArray, numberOfWords, sizeof(unsigned int), inputFile);
  fclose(inputFile);
  for (tmp = 0; tmp < numberOfWords; ++tmp)
    for (counter = 0; counter < numberOfWords; counter++) {
      bits0 = theInputArray[counter];
      theOutputArray0[counter] = calc(bits0 & 0xff, bits0 >> 8);
    }
  outputFile0 = stdout;
  for (counter = 0; counter < (numberOfWords); counter += 128) {
    bits0 = theOutputArray0[counter];
    fprintf(outputFile0, "%8.8X\n", bits0);
  }
  free(theBigAllocatedThing);
}


x86 assembly (clang, -O0):
<runTestbench>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
movslq -0x4(%rbp),%rax
shl    $0x2,%rax
shl    $0x1,%rax
mov    %eax,%edi
call   1080 <malloc@plt>
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    -0x20(%rbp),%rax
movslq -0x4(%rbp),%rcx
shl    $0x2,%rcx
add    %rcx,%rax
mov    %rax,-0x30(%rbp)
mov    -0x10(%rbp),%rdi
lea    0xe40(%rip),%rsi
call   1090 <fopen@plt>
mov    %rax,-0x38(%rbp)
mov    -0x28(%rbp),%rdi
mov    -0x4(%rbp),%esi
mov    -0x38(%rbp),%rcx
mov    $0x4,%edx
call   1040 <fread@plt>
mov    -0x38(%rbp),%rdi
call   1050 <fclose@plt>
movl   $0x0,-0x50(%rbp)
mov    -0x50(%rbp),%eax
cmp    -0x4(%rbp),%eax
jge    125d <runTestbench+0xed>
movl   $0x0,-0x4c(%rbp)
mov    -0x4c(%rbp),%eax
cmp    -0x4(%rbp),%eax
jge    124a <runTestbench+0xda>
mov    -0x28(%rbp),%rax
movslq -0x4c(%rbp),%rcx
mov    (%rax,%rcx,4),%eax
mov    %eax,-0x48(%rbp)
mov    -0x48(%rbp),%edi
and    $0xff,%edi
mov    -0x48(%rbp),%esi
shr    $0x8,%esi
call   1060 <calc@plt>
mov    %eax,%edx
mov    -0x30(%rbp),%rax
movslq -0x4c(%rbp),%rcx
mov    %edx,(%rax,%rcx,4)
mov    -0x4c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x4c(%rbp)
jmp    1201 <runTestbench+0x91>
jmp    124f <runTestbench+0xdf>
mov    -0x50(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x50(%rbp)
jmp    11ee <runTestbench+0x7e>
mov    0x2d7c(%rip),%rax
mov    (%rax),%rax
mov    %rax,-0x40(%rbp)
movl   $0x0,-0x4c(%rbp)
mov    -0x4c(%rbp),%eax
cmp    -0x4(%rbp),%eax
jge    12af <runTestbench+0x13f>
mov    -0x30(%rbp),%rax
movslq -0x4c(%rbp),%rcx
mov    (%rax,%rcx,4),%eax
mov    %eax,-0x48(%rbp)
mov    -0x40(%rbp),%rdi
mov    -0x48(%rbp),%edx
lea    0xd68(%rip),%rsi
call   1070 <fprintf@plt>
mov    -0x4c(%rbp),%eax
add    $0x80,%eax
mov    %eax,-0x4c(%rbp)
jmp    1272 <runTestbench+0x102>
mov    -0x20(%rbp),%rdi
call   1030 <free@plt>
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<runTestbench>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rsi,%r15
mov    %edi,%r14d
lea    0x0(,%r14,8),%edi
call   1080 <malloc@plt>
mov    %rax,%r13
lea    0xe68(%rip),%rsi
mov    %r15,%rdi
call   1090 <fopen@plt>
mov    %rax,%r15
mov    %r13,%rdi
mov    %r14d,%esi
mov    $0x4,%edx
mov    %rax,%rcx
call   1040 <fread@plt>
mov    %r15,%rdi
call   1050 <fclose@plt>
test   %r14d,%r14d
jle    1248 <runTestbench+0xd8>
movslq %r14d,%rax
lea    0x0(,%rax,4),%r12
add    %r13,%r12
mov    %r14d,%ebx
xor    %r15d,%r15d
nopl   0x0(%rax,%rax,1)
xor    %ebp,%ebp
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    0x0(%r13,%rbp,4),%esi
movzbl %sil,%edi
shr    $0x8,%esi
call   1060 <calc@plt>
mov    %eax,(%r12,%rbp,4)
add    $0x1,%rbp
cmp    %rbp,%rbx
jne    11f0 <runTestbench+0x80>
add    $0x1,%r15d
cmp    %r14d,%r15d
jne    11e0 <runTestbench+0x70>
test   %r14d,%r14d
jle    1248 <runTestbench+0xd8>
mov    0x2dbd(%rip),%rax
mov    (%rax),%r15
xor    %ebp,%ebp
lea    0xdd3(%rip),%rbx
nop
mov    (%r12,%rbp,4),%edx
mov    %r15,%rdi
mov    %rbx,%rsi
call   1070 <fprintf@plt>
sub    $0xffffffffffffff80,%rbp
cmp    %r14d,%ebp
jl     1230 <runTestbench+0xc0>
mov    %r13,%rdi
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <free@plt>

LLVM IR (-O0):
@.str = [2 x i8] c"r\00"
@stdout = global i32* null
@.str.1 = [7 x i8] c"%8.8X\0A\00"
define void @runTestbench(i32 %0, i8* %1, i8* %2) {
%4 = alloca i32
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca i32*
%8 = alloca i32*
%9 = alloca i32*
%10 = alloca i32*
%11 = alloca i32*
%12 = alloca i32
%13 = alloca i32
%14 = alloca i32
%15 = alloca i32
store i32 %0, i32* %4
store i8* %1, i8** %5
store i8* %2, i8** %6
%16 = load i32, i32* %4
%17 = sext i32 %16 to i64
%18 = mul i64 %17, 4
%19 = mul i64 %18, 2
%20 = trunc i64 %19 to i32
%21 = call i64 @malloc(i32 %20)
%22 = inttoptr i64 %21 to i32*
store i32* %22, i32** %7
%23 = load i32*, i32** %7
store i32* %23, i32** %8
%24 = load i32*, i32** %7
%25 = load i32, i32* %4
%26 = sext i32 %25 to i64
%27 = getelementptr inbounds i32, i32* %24, i64 %26
store i32* %27, i32** %9
%28 = load i8*, i8** %5
%29 = call i32* @fopen(i8* %28, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i32* %29, i32** %10
%30 = load i32*, i32** %8
%31 = load i32, i32* %4
%32 = load i32*, i32** %10
%33 = call i32 @fread(i32* %30, i32 %31, i32 4, i32* %32)
%34 = load i32*, i32** %10
%35 = call i32 @fclose(i32* %34)
store i32 0, i32* %15
br label %36
36: ; preds = %64, %3
%37 = load i32, i32* %15
%38 = load i32, i32* %4
%39 = icmp slt i32 %37, %38
br i1 %39, label %40, label %67
40: ; preds = %36
store i32 0, i32* %14
br label %41
41: ; preds = %60, %40
%42 = load i32, i32* %14
%43 = load i32, i32* %4
%44 = icmp slt i32 %42, %43
br i1 %44, label %45, label %63
45: ; preds = %41
%46 = load i32*, i32** %8
%47 = load i32, i32* %14
%48 = sext i32 %47 to i64
%49 = getelementptr inbounds i32, i32* %46, i64 %48
%50 = load i32, i32* %49
store i32 %50, i32* %13
%51 = load i32, i32* %13
%52 = and i32 %51, 255
%53 = load i32, i32* %13
%54 = lshr i32 %53, 8
%55 = call i32 @calc(i32 %52, i32 %54)
%56 = load i32*, i32** %9
%57 = load i32, i32* %14
%58 = sext i32 %57 to i64
%59 = getelementptr inbounds i32, i32* %56, i64 %58
store i32 %55, i32* %59
br label %60
60: ; preds = %45
%61 = load i32, i32* %14
%62 = add nsw i32 %61, 1
store i32 %62, i32* %14
br label %41
63: ; preds = %41
br label %64
64: ; preds = %63
%65 = load i32, i32* %15
%66 = add nsw i32 %65, 1
store i32 %66, i32* %15
br label %36
67: ; preds = %36
%68 = load i32*, i32** @stdout
store i32* %68, i32** %11
store i32 0, i32* %14
br label %69
69: ; preds = %82, %67
%70 = load i32, i32* %14
%71 = load i32, i32* %4
%72 = icmp slt i32 %70, %71
br i1 %72, label %73, label %85
73: ; preds = %69
%74 = load i32*, i32** %9
%75 = load i32, i32* %14
%76 = sext i32 %75 to i64
%77 = getelementptr inbounds i32, i32* %74, i64 %76
%78 = load i32, i32* %77
store i32 %78, i32* %13
%79 = load i32*, i32** %11
%80 = load i32, i32* %13
%81 = call i32 @fprintf(i32* %79, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), i32 %80)
br label %82
82: ; preds = %73
%83 = load i32, i32* %14
%84 = add nsw i32 %83, 128
store i32 %84, i32* %14
br label %69
85: ; preds = %69
%86 = load i32*, i32** %7
%87 = call i32 @free(i32* %86)
ret void
}

LLVM IR (-O2):
@.str = [2 x i8] c"r\00"
@stdout = global i32* null
@.str.1 = [7 x i8] c"%8.8X\0A\00"
define void @runTestbench(i32 %0, i8* nocapture %1, i8* nocapture readnone %2) {
%4 = sext i32 %0 to i64
%5 = shl i32 %0, 3
%6 = tail call i64 @malloc(i32 %5)
%7 = inttoptr i64 %6 to i32*
%8 = getelementptr inbounds i32, i32* %7, i64 %4
%9 = tail call i32* @fopen(i8* %1, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%10 = tail call i32 @fread(i32* %7, i32 %0, i32 4, i32* %9)
%11 = tail call i32 @fclose(i32* %9)
%12 = icmp sgt i32 %0, 0
br i1 %12, label %13, label %40
13: ; preds = %3
%14 = zext i32 %0 to i64
br label %15
15: ; preds = %27, %13
%16 = phi i32 [ 0, %13 ], [ %28, %27 ]
br label %17
17: ; preds = %15, %17
%18 = phi i64 [ 0, %15 ], [ %25, %17 ]
%19 = getelementptr inbounds i32, i32* %7, i64 %18
%20 = load i32, i32* %19
%21 = and i32 %20, 255
%22 = lshr i32 %20, 8
%23 = tail call i32 @calc(i32 %21, i32 %22)
%24 = getelementptr inbounds i32, i32* %8, i64 %18
store i32 %23, i32* %24
%25 = add nuw nsw i64 %18, 1
%26 = icmp eq i64 %25, %14
br i1 %26, label %27, label %17
27: ; preds = %17
%28 = add nuw nsw i32 %16, 1
%29 = icmp eq i32 %28, %0
br i1 %29, label %30, label %15
30: ; preds = %27
%31 = load i32*, i32** @stdout
br i1 %12, label %32, label %40
32: ; preds = %30, %32
%33 = phi i64 [ %37, %32 ], [ 0, %30 ]
%34 = getelementptr inbounds i32, i32* %8, i64 %33
%35 = load i32, i32* %34
%36 = tail call i32 @fprintf(i32* %31, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), i32 %35)
%37 = add nuw i64 %33, 128
%38 = trunc i64 %37 to i32
%39 = icmp slt i32 %38, %0
br i1 %39, label %32, label %40
40: ; preds = %32, %3, %30
%41 = tail call i32 @free(i32* %7)
ret void
}