#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*/ test1;
typedef int /*<<< orphan*/ first_array;

/* Variables and functions */
scalar_t__ assert(int, char *, int);
int fix_bad_code(char *);
int is_pointer_in_array(double *, double *, double);
double my_random();
int /*<<< orphan*/ printf(char *, ...);
int sum_of_array_multiplication(int *, int *, int);
int test() {
  int passcount = 0;
  int failcount = 0;
  double first_doubles[] = {1.1, 2.2, 3.9, 0.5, 0.2, 0.0};
  double second_doubles[] = {5.2, 3.3, 10.7, 0.8, 0.0};
  int first_array[] = {1, 2, 2};
  int second_array[] = {8, 9, 10};
  int test1[] = {55, 66, 88, 2};
  int test2[] = {44, 77, 11, 17};
  int result = 0;
  double answer = 0.0;
  printf("\nTests for is_pointer_in_array.......................\n");
  result = is_pointer_in_array(first_doubles, first_doubles, 0.0);
  assert(
      result == 1,
      "Points to the first position in the array so expected a 1 but got a %d",
      result)
      ? passcount++
      : failcount++;
  result = is_pointer_in_array(first_doubles, &first_doubles[4], 0.0);
  assert(result == 1,
         "Points to the last position in the array (before the 0.0) so "
         "expected a 1 but got a %d",
         result)
      ? passcount++
      : failcount++;
  result = is_pointer_in_array(first_doubles, &second_doubles[2], 0.0);
  assert(
      result == 0,
      "Points to a position in a different array so expected a 0 but got a %d",
      result)
      ? passcount++
      : failcount++;
  printf("\nTests for my_random()...............................\n");
  assert((answer = my_random()) == 0.92,
         "First random number must be 0.92 but got a %f", answer)
      ? passcount++
      : failcount++;
  assert((answer = my_random()) == 0.33,
         "Second random number must be 0.33 but got a %f", answer)
      ? passcount++
      : failcount++;
  my_random();
  my_random();
  my_random();
  my_random();
  assert((answer = my_random()) == 0.72,
         "Last random number must be 0.72 but got a %f", answer)
      ? passcount++
      : failcount++;
  assert((answer = my_random()) == 0.92,
         "Must now be back at the first random number of 0.92 but got a %f",
         answer)
      ? passcount++
      : failcount++;
  printf("\nTests for sum_of_array_multiplication..........................\n");
  result = sum_of_array_multiplication(first_array, second_array,
                                       sizeof(first_array) / sizeof(int));
  assert(result == 46, "Sum of the updated first array should be 46 but got %d",
         result)
      ? passcount++
      : failcount++;
  result = sum_of_array_multiplication(first_array, second_array, 0);
  assert(result == 0, "Expected 0 because number of entries is 0 but got %d",
         result)
      ? passcount++
      : failcount++;
  result = sum_of_array_multiplication(first_array, NULL,
                                       sizeof(first_array) / sizeof(int));
  assert(result == 0,
         "Expected 0 because second array is a null pointer but got %d", result)
      ? passcount++
      : failcount++;
  result = sum_of_array_multiplication(NULL, second_array,
                                       sizeof(first_array) / sizeof(int));
  assert(result == 0,
         "Expected 0 because first array is a null pointer but got %d", result)
      ? passcount++
      : failcount++;
  result =
      sum_of_array_multiplication(test1, test2, sizeof(test1) / sizeof(int));
  assert(result == 8504,
         "Sum of the updated first array should be 8504 but got %d", result)
      ? passcount++
      : failcount++;
  printf("\nTests for fix_bad_code..............................\n");
  assert((result = fix_bad_code("1234")) == 0,
         "Expected 0 because there are no lower case letters but got %d",
         result)
      ? passcount++
      : failcount++;
  assert((result = fix_bad_code("9876a")) == 1,
         "Expected 1 because there is one lower case letter but got %d", result)
      ? passcount++
      : failcount++;
  assert((result = fix_bad_code("")) == 0,
         "Expected 0 because it is an empty string but got %d", result)
      ? passcount++
      : failcount++;
  assert((result = fix_bad_code(NULL)) == 0,
         "Expected 0 because the string pointer is a null pointer but got %d",
         result)
      ? passcount++
      : failcount++;
  printf("\nSummary of unit tests:\n%d tests passed\n%d tests failed\n\n",
         passcount, failcount);
  return failcount;
}


x86 assembly (clang, -O0):
<test>:
push   %rbp
mov    %rsp,%rbp
sub    $0xc0,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x8(%rbp)
lea    -0x40(%rbp),%rdi
xor    %esi,%esi
mov    $0x30,%edx
call   1070 <memset@plt>
movsd  0xe9f(%rip),%xmm0
movsd  %xmm0,-0x40(%rbp)
movsd  0xe8a(%rip),%xmm0
movsd  %xmm0,-0x38(%rbp)
movsd  0xe75(%rip),%xmm0
movsd  %xmm0,-0x30(%rbp)
movsd  0xe60(%rip),%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  0xe4b(%rip),%xmm0
movsd  %xmm0,-0x20(%rbp)
lea    -0x70(%rbp),%rdi
xor    %esi,%esi
mov    $0x28,%edx
call   1070 <memset@plt>
movsd  0xe26(%rip),%xmm0
movsd  %xmm0,-0x70(%rbp)
movsd  0xe11(%rip),%xmm0
movsd  %xmm0,-0x68(%rbp)
movsd  0xdfc(%rip),%xmm0
movsd  %xmm0,-0x60(%rbp)
movsd  0xde7(%rip),%xmm0
movsd  %xmm0,-0x58(%rbp)
mov    0xe3b(%rip),%rax
mov    %rax,-0x7c(%rbp)
mov    0xe39(%rip),%eax
mov    %eax,-0x74(%rbp)
mov    0xe33(%rip),%rax
mov    %rax,-0x88(%rbp)
mov    0xe2e(%rip),%eax
mov    %eax,-0x80(%rbp)
mov    0xe30(%rip),%rax
mov    %rax,-0xa0(%rbp)
mov    0xe2a(%rip),%rax
mov    %rax,-0x98(%rbp)
mov    0xe24(%rip),%rax
mov    %rax,-0xb0(%rbp)
mov    0xe1e(%rip),%rax
mov    %rax,-0xa8(%rbp)
movl   $0x0,-0xb4(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0xc0(%rbp)
ff
lea    0xe03(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
lea    -0x40(%rbp),%rdi
lea    -0x40(%rbp),%rsi
xorps  %xmm0,%xmm0
call   1090 <is_pointer_in_array@plt>
mov    %eax,-0xb4(%rbp)
cmpl   $0x1,-0xb4(%rbp)
sete   %al
and    $0x1,%al
movzbl %al,%edi
mov    -0xb4(%rbp),%edx
lea    0xe01(%rip),%rsi
call   1080 <assert@plt>
cmp    $0x0,%rax
je     12f3 <test+0x183>
mov    -0x4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x4(%rbp)
jmp    12fc <test+0x18c>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
lea    -0x40(%rbp),%rdi
lea    -0x40(%rbp),%rsi
add    $0x20,%rsi
xorps  %xmm0,%xmm0
call   1090 <is_pointer_in_array@plt>
mov    %eax,-0xb4(%rbp)
cmpl   $0x1,-0xb4(%rbp)
sete   %al
and    $0x1,%al
movzbl %al,%edi
mov    -0xb4(%rbp),%edx
lea    0xdec(%rip),%rsi
call   1080 <assert@plt>
cmp    $0x0,%rax
je     134f <test+0x1df>
mov    -0x4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x4(%rbp)
jmp    1358 <test+0x1e8>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
lea    -0x40(%rbp),%rdi
lea    -0x70(%rbp),%rsi
add    $0x10,%rsi
xorps  %xmm0,%xmm0
call   1090 <is_pointer_in_array@plt>
mov    %eax,-0xb4(%rbp)
cmpl   $0x0,-0xb4(%rbp)
sete   %al
and    $0x1,%al
movzbl %al,%edi
mov    -0xb4(%rbp),%edx
lea    0xde7(%rip),%rsi
call   1080 <assert@plt>
cmp    $0x0,%rax
je     13ab <test+0x23b>
mov    -0x4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x4(%rbp)
jmp    13b4 <test+0x244>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
lea    0xe01(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    $0x0,%al
call   1030 <my_random@plt>
movsd  %xmm0,-0xc0(%rbp)
ff
movsd  0xc6f(%rip),%xmm1
ucomisd %xmm1,%xmm0
sete   %al
setnp  %cl
and    %cl,%al
and    $0x1,%al
movzbl %al,%edi
cvttsd2si -0xc0(%rbp),%edx
ff
lea    0xdfa(%rip),%rsi
call   1080 <assert@plt>
cmp    $0x0,%rax
je     1416 <test+0x2a6>
mov    -0x4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x4(%rbp)
jmp    141f <test+0x2af>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
mov    $0x0,%al
call   1030 <my_random@plt>
movsd  %xmm0,-0xc0(%rbp)
ff
movsd  0xc1a(%rip),%xmm1
ucomisd %xmm1,%xmm0
sete   %al
setnp  %cl
and    %cl,%al
and    $0x1,%al
movzbl %al,%edi
cvttsd2si -0xc0(%rbp),%edx
ff
lea    0xdcb(%rip),%rsi
call   1080 <assert@plt>
cmp    $0x0,%rax
je     1473 <test+0x303>
mov    -0x4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x4(%rbp)
jmp    147c <test+0x30c>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
mov    $0x0,%al
call   1030 <my_random@plt>
mov    $0x0,%al
call   1030 <my_random@plt>
mov    $0x0,%al
call   1030 <my_random@plt>
mov    $0x0,%al
call   1030 <my_random@plt>
mov    $0x0,%al
call   1030 <my_random@plt>
movsd  %xmm0,-0xc0(%rbp)
ff
movsd  0xba9(%rip),%xmm1
ucomisd %xmm1,%xmm0
sete   %al
setnp  %cl
and    %cl,%al
and    $0x1,%al
movzbl %al,%edi
cvttsd2si -0xc0(%rbp),%edx
ff
lea    0xd81(%rip),%rsi
call   1080 <assert@plt>
cmp    $0x0,%rax
je     14ec <test+0x37c>
mov    -0x4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x4(%rbp)
jmp    14f5 <test+0x385>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
mov    $0x0,%al
call   1030 <my_random@plt>
movsd  %xmm0,-0xc0(%rbp)
ff
movsd  0xb3c(%rip),%xmm1
ucomisd %xmm1,%xmm0
sete   %al
setnp  %cl
and    %cl,%al
and    $0x1,%al
movzbl %al,%edi
cvttsd2si -0xc0(%rbp),%edx
ff
lea    0xd51(%rip),%rsi
call   1080 <assert@plt>
cmp    $0x0,%rax
je     1549 <test+0x3d9>
mov    -0x4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x4(%rbp)
jmp    1552 <test+0x3e2>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
lea    0xd65(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
lea    -0x7c(%rbp),%rdi
lea    -0x88(%rbp),%rsi
mov    $0x3,%edx
call   1040 <sum_of_array_multiplication@plt>
mov    %eax,-0xb4(%rbp)
cmpl   $0x2e,-0xb4(%rbp)
sete   %al
and    $0x1,%al
movzbl %al,%edi
mov    -0xb4(%rbp),%edx
lea    0xd69(%rip),%rsi
call   1080 <assert@plt>
cmp    $0x0,%rax
je     15b4 <test+0x444>
mov    -0x4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x4(%rbp)
jmp    15bd <test+0x44d>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
lea    -0x7c(%rbp),%rdi
lea    -0x88(%rbp),%rsi
xor    %edx,%edx
call   1040 <sum_of_array_multiplication@plt>
mov    %eax,-0xb4(%rbp)
cmpl   $0x0,-0xb4(%rbp)
sete   %al
and    $0x1,%al
movzbl %al,%edi
mov    -0xb4(%rbp),%edx
lea    0xd46(%rip),%rsi
call   1080 <assert@plt>
cmp    $0x0,%rax
je     160e <test+0x49e>
mov    -0x4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x4(%rbp)
jmp    1617 <test+0x4a7>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
lea    -0x7c(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%esi
mov    $0x3,%edx
call   1040 <sum_of_array_multiplication@plt>
mov    %eax,-0xb4(%rbp)
cmpl   $0x0,-0xb4(%rbp)
sete   %al
and    $0x1,%al
movzbl %al,%edi
mov    -0xb4(%rbp),%edx
lea    0xd21(%rip),%rsi
call   1080 <assert@plt>
cmp    $0x0,%rax
je     1668 <test+0x4f8>
mov    -0x4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x4(%rbp)
jmp    1671 <test+0x501>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
lea    -0x88(%rbp),%rsi
xor    %eax,%eax
mov    %eax,%edi
mov    $0x3,%edx
call   1040 <sum_of_array_multiplication@plt>
mov    %eax,-0xb4(%rbp)
cmpl   $0x0,-0xb4(%rbp)
sete   %al
and    $0x1,%al
movzbl %al,%edi
mov    -0xb4(%rbp),%edx
lea    0xd01(%rip),%rsi
call   1080 <assert@plt>
cmp    $0x0,%rax
je     16c5 <test+0x555>
mov    -0x4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x4(%rbp)
jmp    16ce <test+0x55e>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
lea    -0xa0(%rbp),%rdi
lea    -0xb0(%rbp),%rsi
mov    $0x4,%edx
call   1040 <sum_of_array_multiplication@plt>
mov    %eax,-0xb4(%rbp)
cmpl   $0x2138,-0xb4(%rbp)
sete   %al
and    $0x1,%al
movzbl %al,%edi
mov    -0xb4(%rbp),%edx
lea    0xcda(%rip),%rsi
call   1080 <assert@plt>
cmp    $0x0,%rax
je     1728 <test+0x5b8>
mov    -0x4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x4(%rbp)
jmp    1731 <test+0x5c1>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
lea    0xce6(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
lea    0xd0f(%rip),%rdi
call   1050 <fix_bad_code@plt>
mov    %eax,-0xb4(%rbp)
cmp    $0x0,%eax
sete   %al
and    $0x1,%al
movzbl %al,%edi
mov    -0xb4(%rbp),%edx
lea    0xcf1(%rip),%rsi
call   1080 <assert@plt>
cmp    $0x0,%rax
je     1786 <test+0x616>
mov    -0x4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x4(%rbp)
jmp    178f <test+0x61f>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
lea    0xd02(%rip),%rdi
call   1050 <fix_bad_code@plt>
mov    %eax,-0xb4(%rbp)
cmp    $0x1,%eax
sete   %al
and    $0x1,%al
movzbl %al,%edi
mov    -0xb4(%rbp),%edx
lea    0xce5(%rip),%rsi
call   1080 <assert@plt>
cmp    $0x0,%rax
je     17d6 <test+0x666>
mov    -0x4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x4(%rbp)
jmp    17df <test+0x66f>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
lea    0xda5(%rip),%rdi
call   1050 <fix_bad_code@plt>
mov    %eax,-0xb4(%rbp)
cmp    $0x0,%eax
sete   %al
and    $0x1,%al
movzbl %al,%edi
mov    -0xb4(%rbp),%edx
lea    0xcd2(%rip),%rsi
call   1080 <assert@plt>
cmp    $0x0,%rax
je     1826 <test+0x6b6>
mov    -0x4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x4(%rbp)
jmp    182f <test+0x6bf>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
xor    %eax,%eax
mov    %eax,%edi
call   1050 <fix_bad_code@plt>
mov    %eax,-0xb4(%rbp)
cmp    $0x0,%eax
sete   %al
and    $0x1,%al
movzbl %al,%edi
mov    -0xb4(%rbp),%edx
lea    0xcb9(%rip),%rsi
call   1080 <assert@plt>
cmp    $0x0,%rax
je     1873 <test+0x703>
mov    -0x4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x4(%rbp)
jmp    187c <test+0x70c>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
mov    -0x4(%rbp),%esi
mov    -0x8(%rbp),%edx
lea    0xcc9(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    -0x8(%rbp),%eax
add    $0xc0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<test>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x98,%rsp
lea    0x60(%rsp),%r15
xorps  %xmm0,%xmm0
movaps %xmm0,0x60(%rsp)
movaps 0xe6b(%rip),%xmm0
movaps %xmm0,0x40(%rsp)
movaps 0xe6f(%rip),%xmm0
movaps %xmm0,0x50(%rsp)
movabs $0x3fc999999999999a,%rax
99 c9 3f
mov    %rax,0x60(%rsp)
movq   $0x0,0x90(%rsp)
movaps 0xe58(%rip),%xmm0
movaps %xmm0,0x70(%rsp)
movaps 0xe5c(%rip),%xmm0
movaps %xmm0,0x80(%rsp)
mov    0xe9e(%rip),%eax
mov    %eax,0x18(%rsp)
mov    0xe8b(%rip),%rax
mov    %rax,0x10(%rsp)
mov    0xe94(%rip),%eax
mov    %eax,0x8(%rsp)
mov    0xe81(%rip),%rax
mov    %rax,(%rsp)
movaps 0xe32(%rip),%xmm0
movaps %xmm0,0x30(%rsp)
movapd 0xe35(%rip),%xmm0
movapd %xmm0,0x20(%rsp)
lea    0x126d(%rip),%rdi
call   1050 <puts@plt>
lea    0x40(%rsp),%r12
xorpd  %xmm0,%xmm0
mov    %r12,%rdi
mov    %r12,%rsi
call   1090 <is_pointer_in_array@plt>
xor    %edi,%edi
cmp    $0x1,%eax
sete   %dil
lea    0xe3f(%rip),%rsi
mov    %eax,%edx
call   1080 <assert@plt>
xor    %ebx,%ebx
xor    %r14d,%r14d
test   %rax,%rax
sete   %bl
setne  %r14b
xorpd  %xmm0,%xmm0
mov    %r12,%rdi
mov    %r15,%rsi
call   1090 <is_pointer_in_array@plt>
xor    %edi,%edi
cmp    $0x1,%eax
sete   %dil
lea    0xe51(%rip),%rsi
mov    %eax,%edx
call   1080 <assert@plt>
mov    $0x2,%ebp
sub    %ebx,%ebp
lea    0x1(%rbx),%r13d
test   %rax,%rax
cmove  %r14d,%ebp
cmovne %ebx,%r13d
xorpd  %xmm0,%xmm0
mov    %r12,%rdi
lea    0x80(%rsp),%rsi
call   1090 <is_pointer_in_array@plt>
xor    %edi,%edi
test   %eax,%eax
sete   %dil
lea    0xe68(%rip),%rsi
mov    %eax,%edx
call   1080 <assert@plt>
xor    %r14d,%r14d
xor    %r15d,%r15d
test   %rax,%rax
sete   %r14b
setne  %r15b
add    %ebp,%r15d
add    %r13d,%r14d
lea    0x11e0(%rip),%rdi
call   1050 <puts@plt>
xor    %eax,%eax
call   1030 <my_random@plt>
cvttsd2si %xmm0,%edx
cmpeqsd 0xd5c(%rip),%xmm0
movq   %xmm0,%rdi
and    $0x1,%edi
lea    0xe62(%rip),%rsi
call   1080 <assert@plt>
xor    %ebx,%ebx
xor    %ebp,%ebp
test   %rax,%rax
sete   %bl
setne  %bpl
add    %r15d,%ebp
add    %r14d,%ebx
xor    %eax,%eax
call   1030 <my_random@plt>
cvttsd2si %xmm0,%edx
cmpeqsd 0xd28(%rip),%xmm0
movq   %xmm0,%rdi
and    $0x1,%edi
lea    0xe54(%rip),%rsi
call   1080 <assert@plt>
xor    %r14d,%r14d
xor    %r15d,%r15d
test   %rax,%rax
sete   %r14b
setne  %r15b
add    %ebp,%r15d
add    %ebx,%r14d
xor    %eax,%eax
call   1030 <my_random@plt>
xor    %eax,%eax
call   1030 <my_random@plt>
xor    %eax,%eax
call   1030 <my_random@plt>
xor    %eax,%eax
call   1030 <my_random@plt>
xor    %eax,%eax
call   1030 <my_random@plt>
cvttsd2si %xmm0,%edx
cmpeqsd 0xcd5(%rip),%xmm0
movq   %xmm0,%rdi
and    $0x1,%edi
lea    0xe28(%rip),%rsi
call   1080 <assert@plt>
xor    %ebp,%ebp
xor    %ebx,%ebx
test   %rax,%rax
sete   %bpl
setne  %bl
add    %r15d,%ebx
add    %r14d,%ebp
xor    %eax,%eax
call   1030 <my_random@plt>
movsd  0xc8e(%rip),%xmm1
cmpeqsd %xmm0,%xmm1
movq   %xmm1,%rdi
and    $0x1,%edi
cvttsd2si %xmm0,%edx
lea    0xe15(%rip),%rsi
call   1080 <assert@plt>
xor    %r12d,%r12d
xor    %r13d,%r13d
test   %rax,%rax
sete   %r12b
setne  %r13b
add    %ebx,%r13d
add    %ebp,%r12d
lea    0x10f4(%rip),%rdi
call   1050 <puts@plt>
lea    0x10(%rsp),%r15
mov    %rsp,%rbx
mov    %r15,%rdi
mov    %rbx,%rsi
mov    $0x3,%edx
call   1040 <sum_of_array_multiplication@plt>
xor    %edi,%edi
cmp    $0x2e,%eax
sete   %dil
lea    0xe06(%rip),%rsi
mov    %eax,%edx
call   1080 <assert@plt>
xor    %ebp,%ebp
xor    %r14d,%r14d
test   %rax,%rax
sete   %bpl
setne  %r14b
add    %r13d,%r14d
add    %r12d,%ebp
mov    %r15,%rdi
mov    %rbx,%rsi
mov    %rbx,%r13
xor    %edx,%edx
call   1040 <sum_of_array_multiplication@plt>
xor    %edi,%edi
test   %eax,%eax
sete   %dil
lea    0xe01(%rip),%rsi
mov    %eax,%edx
call   1080 <assert@plt>
xor    %r12d,%r12d
xor    %ebx,%ebx
test   %rax,%rax
sete   %r12b
setne  %bl
add    %r14d,%ebx
add    %ebp,%r12d
mov    %r15,%rdi
xor    %esi,%esi
mov    $0x3,%edx
call   1040 <sum_of_array_multiplication@plt>
xor    %edi,%edi
test   %eax,%eax
sete   %dil
lea    0xdfc(%rip),%rsi
mov    %eax,%edx
call   1080 <assert@plt>
xor    %r14d,%r14d
xor    %ebp,%ebp
test   %rax,%rax
sete   %r14b
setne  %bpl
add    %ebx,%ebp
add    %r12d,%r14d
xor    %edi,%edi
mov    %r13,%rsi
mov    $0x3,%edx
call   1040 <sum_of_array_multiplication@plt>
xor    %edi,%edi
test   %eax,%eax
sete   %dil
lea    0xdff(%rip),%rsi
mov    %eax,%edx
call   1080 <assert@plt>
xor    %r15d,%r15d
xor    %ebx,%ebx
test   %rax,%rax
sete   %r15b
setne  %bl
add    %ebp,%ebx
add    %r14d,%r15d
lea    0x30(%rsp),%rdi
lea    0x20(%rsp),%rsi
mov    $0x4,%edx
call   1040 <sum_of_array_multiplication@plt>
xor    %edi,%edi
cmp    $0x2138,%eax
sete   %dil
lea    0xdfa(%rip),%rsi
mov    %eax,%edx
call   1080 <assert@plt>
xor    %r14d,%r14d
xor    %ebp,%ebp
test   %rax,%rax
sete   %r14b
setne  %bpl
add    %ebx,%ebp
add    %r15d,%r14d
lea    0xff4(%rip),%rdi
call   1050 <puts@plt>
lea    0xe04(%rip),%rdi
call   1060 <fix_bad_code@plt>
xor    %edi,%edi
test   %eax,%eax
sete   %dil
lea    0xdf5(%rip),%rsi
mov    %eax,%edx
call   1080 <assert@plt>
xor    %r15d,%r15d
xor    %ebx,%ebx
test   %rax,%rax
sete   %r15b
setne  %bl
add    %ebp,%ebx
add    %r14d,%r15d
lea    0xe11(%rip),%rdi
call   1060 <fix_bad_code@plt>
xor    %edi,%edi
cmp    $0x1,%eax
sete   %dil
lea    0xe02(%rip),%rsi
mov    %eax,%edx
call   1080 <assert@plt>
xor    %r14d,%r14d
xor    %r12d,%r12d
test   %rax,%rax
sete   %r14b
setne  %r12b
add    %ebx,%r12d
add    %r15d,%r14d
lea    0xeca(%rip),%rdi
call   1060 <fix_bad_code@plt>
xor    %edi,%edi
test   %eax,%eax
sete   %dil
lea    0xe06(%rip),%rsi
mov    %eax,%edx
call   1080 <assert@plt>
xor    %r15d,%r15d
xor    %ebp,%ebp
test   %rax,%rax
sete   %r15b
setne  %bpl
add    %r12d,%ebp
add    %r14d,%r15d
xor    %edi,%edi
call   1060 <fix_bad_code@plt>
xor    %edi,%edi
test   %eax,%eax
sete   %dil
lea    0xe07(%rip),%rsi
mov    %eax,%edx
call   1080 <assert@plt>
xor    %ebx,%ebx
xor    %esi,%esi
test   %rax,%rax
sete   %bl
setne  %sil
add    %ebp,%esi
add    %r15d,%ebx
lea    0xe29(%rip),%rdi
mov    %ebx,%edx
xor    %eax,%eax
call   1070 <printf@plt>
mov    %ebx,%eax
add    $0x98,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@__const.test.first_array = [3 x i32] [i32 1, i32 2, i32 2]
@__const.test.second_array = [3 x i32] [i32 8, i32 9, i32 10]
@__const.test.test1 = [4 x i32] [i32 55, i32 66, i32 88, i32 2]
@__const.test.test2 = [4 x i32] [i32 44, i32 77, i32 11, i32 17]
@.str = [55 x i8] c"\0ATests for is_pointer_in_array.......................\0A\00"
@.str.1 = [71 x i8] c"Points to the first position in the array so expected a 1 but got a %d\00"
@.str.2 = [87 x i8] c"Points to the last position in the array (before the 0.0) so expected a 1 but got a %d\00"
@.str.3 = [71 x i8] c"Points to a position in a different array so expected a 0 but got a %d\00"
@.str.4 = [55 x i8] c"\0ATests for my_random()...............................\0A\00"
@.str.5 = [46 x i8] c"First random number must be 0.92 but got a %f\00"
@.str.6 = [47 x i8] c"Second random number must be 0.33 but got a %f\00"
@.str.7 = [45 x i8] c"Last random number must be 0.72 but got a %f\00"
@.str.8 = [65 x i8] c"Must now be back at the first random number of 0.92 but got a %f\00"
@.str.9 = [66 x i8] c"\0ATests for sum_of_array_multiplication..........................\0A\00"
@.str.10 = [55 x i8] c"Sum of the updated first array should be 46 but got %d\00"
@.str.11 = [53 x i8] c"Expected 0 because number of entries is 0 but got %d\00"
@.str.12 = [61 x i8] c"Expected 0 because second array is a null pointer but got %d\00"
@.str.13 = [60 x i8] c"Expected 0 because first array is a null pointer but got %d\00"
@.str.14 = [57 x i8] c"Sum of the updated first array should be 8504 but got %d\00"
@.str.15 = [55 x i8] c"\0ATests for fix_bad_code..............................\0A\00"
@.str.16 = [5 x i8] c"1234\00"
@.str.17 = [62 x i8] c"Expected 0 because there are no lower case letters but got %d\00"
@.str.18 = [6 x i8] c"9876a\00"
@.str.19 = [61 x i8] c"Expected 1 because there is one lower case letter but got %d\00"
@.str.20 = [1 x i8] zeroinitializer
@.str.21 = [52 x i8] c"Expected 0 because it is an empty string but got %d\00"
@.str.22 = [67 x i8] c"Expected 0 because the string pointer is a null pointer but got %d\00"
@.str.23 = [58 x i8] c"\0ASummary of unit tests:\0A%d tests passed\0A%d tests failed\0A\0A\00"
define i32 @test() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca [6 x double]
%4 = alloca [5 x double]
%5 = alloca [3 x i32]
%6 = alloca [3 x i32]
%7 = alloca [4 x i32]
%8 = alloca [4 x i32]
%9 = alloca i32
%10 = alloca double
store i32 0, i32* %1
store i32 0, i32* %2
%11 = bitcast [6 x double]* %3 to i8*
%12 = bitcast i8* %11 to [6 x double]*
%13 = getelementptr inbounds [6 x double], [6 x double]* %12, i32 0, i32 0
store double 1.100000e+00, double* %13
%14 = getelementptr inbounds [6 x double], [6 x double]* %12, i32 0, i32 1
store double 2.200000e+00, double* %14
%15 = getelementptr inbounds [6 x double], [6 x double]* %12, i32 0, i32 2
store double 3.900000e+00, double* %15
%16 = getelementptr inbounds [6 x double], [6 x double]* %12, i32 0, i32 3
store double 5.000000e-01, double* %16
%17 = getelementptr inbounds [6 x double], [6 x double]* %12, i32 0, i32 4
store double 2.000000e-01, double* %17
%18 = bitcast [5 x double]* %4 to i8*
%19 = bitcast i8* %18 to [5 x double]*
%20 = getelementptr inbounds [5 x double], [5 x double]* %19, i32 0, i32 0
store double 5.200000e+00, double* %20
%21 = getelementptr inbounds [5 x double], [5 x double]* %19, i32 0, i32 1
store double 3.300000e+00, double* %21
%22 = getelementptr inbounds [5 x double], [5 x double]* %19, i32 0, i32 2
store double 1.070000e+01, double* %22
%23 = getelementptr inbounds [5 x double], [5 x double]* %19, i32 0, i32 3
store double 8.000000e-01, double* %23
%24 = bitcast [3 x i32]* %5 to i8*
%25 = bitcast [3 x i32]* %6 to i8*
%26 = bitcast [4 x i32]* %7 to i8*
%27 = bitcast [4 x i32]* %8 to i8*
store i32 0, i32* %9
store double 0.000000e+00, double* %10
%28 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([55 x i8], [55 x i8]* @.str, i64 0, i64 0))
%29 = getelementptr inbounds [6 x double], [6 x double]* %3, i64 0, i64 0
%30 = getelementptr inbounds [6 x double], [6 x double]* %3, i64 0, i64 0
%31 = call i32 @is_pointer_in_array(double* %29, double* %30, double 0.000000e+00)
store i32 %31, i32* %9
%32 = load i32, i32* %9
%33 = icmp eq i32 %32, 1
%34 = zext i1 %33 to i32
%35 = load i32, i32* %9
%36 = call i64 @assert(i32 %34, i8* getelementptr inbounds ([71 x i8], [71 x i8]* @.str.1, i64 0, i64 0), i32 %35)
%37 = icmp ne i64 %36, 0
br i1 %37, label %38, label %41
38: ; preds = %0
%39 = load i32, i32* %1
%40 = add nsw i32 %39, 1
store i32 %40, i32* %1
br label %44
41: ; preds = %0
%42 = load i32, i32* %2
%43 = add nsw i32 %42, 1
store i32 %43, i32* %2
br label %44
44: ; preds = %41, %38
%45 = phi i32 [ %39, %38 ], [ %42, %41 ]
%46 = getelementptr inbounds [6 x double], [6 x double]* %3, i64 0, i64 0
%47 = getelementptr inbounds [6 x double], [6 x double]* %3, i64 0, i64 4
%48 = call i32 @is_pointer_in_array(double* %46, double* %47, double 0.000000e+00)
store i32 %48, i32* %9
%49 = load i32, i32* %9
%50 = icmp eq i32 %49, 1
%51 = zext i1 %50 to i32
%52 = load i32, i32* %9
%53 = call i64 @assert(i32 %51, i8* getelementptr inbounds ([87 x i8], [87 x i8]* @.str.2, i64 0, i64 0), i32 %52)
%54 = icmp ne i64 %53, 0
br i1 %54, label %55, label %58
55: ; preds = %44
%56 = load i32, i32* %1
%57 = add nsw i32 %56, 1
store i32 %57, i32* %1
br label %61
58: ; preds = %44
%59 = load i32, i32* %2
%60 = add nsw i32 %59, 1
store i32 %60, i32* %2
br label %61
61: ; preds = %58, %55
%62 = phi i32 [ %56, %55 ], [ %59, %58 ]
%63 = getelementptr inbounds [6 x double], [6 x double]* %3, i64 0, i64 0
%64 = getelementptr inbounds [5 x double], [5 x double]* %4, i64 0, i64 2
%65 = call i32 @is_pointer_in_array(double* %63, double* %64, double 0.000000e+00)
store i32 %65, i32* %9
%66 = load i32, i32* %9
%67 = icmp eq i32 %66, 0
%68 = zext i1 %67 to i32
%69 = load i32, i32* %9
%70 = call i64 @assert(i32 %68, i8* getelementptr inbounds ([71 x i8], [71 x i8]* @.str.3, i64 0, i64 0), i32 %69)
%71 = icmp ne i64 %70, 0
br i1 %71, label %72, label %75
72: ; preds = %61
%73 = load i32, i32* %1
%74 = add nsw i32 %73, 1
store i32 %74, i32* %1
br label %78
75: ; preds = %61
%76 = load i32, i32* %2
%77 = add nsw i32 %76, 1
store i32 %77, i32* %2
br label %78
78: ; preds = %75, %72
%79 = phi i32 [ %73, %72 ], [ %76, %75 ]
%80 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([55 x i8], [55 x i8]* @.str.4, i64 0, i64 0))
%81 = call double (...) @my_random()
store double %81, double* %10
%82 = fcmp oeq double %81, 9.200000e-01
%83 = zext i1 %82 to i32
%84 = load double, double* %10
%85 = fptosi double %84 to i32
%86 = call i64 @assert(i32 %83, i8* getelementptr inbounds ([46 x i8], [46 x i8]* @.str.5, i64 0, i64 0), i32 %85)
%87 = icmp ne i64 %86, 0
br i1 %87, label %88, label %91
88: ; preds = %78
%89 = load i32, i32* %1
%90 = add nsw i32 %89, 1
store i32 %90, i32* %1
br label %94
91: ; preds = %78
%92 = load i32, i32* %2
%93 = add nsw i32 %92, 1
store i32 %93, i32* %2
br label %94
94: ; preds = %91, %88
%95 = phi i32 [ %89, %88 ], [ %92, %91 ]
%96 = call double (...) @my_random()
store double %96, double* %10
%97 = fcmp oeq double %96, 3.300000e-01
%98 = zext i1 %97 to i32
%99 = load double, double* %10
%100 = fptosi double %99 to i32
%101 = call i64 @assert(i32 %98, i8* getelementptr inbounds ([47 x i8], [47 x i8]* @.str.6, i64 0, i64 0), i32 %100)
%102 = icmp ne i64 %101, 0
br i1 %102, label %103, label %106
103: ; preds = %94
%104 = load i32, i32* %1
%105 = add nsw i32 %104, 1
store i32 %105, i32* %1
br label %109
106: ; preds = %94
%107 = load i32, i32* %2
%108 = add nsw i32 %107, 1
store i32 %108, i32* %2
br label %109
109: ; preds = %106, %103
%110 = phi i32 [ %104, %103 ], [ %107, %106 ]
%111 = call double (...) @my_random()
%112 = call double (...) @my_random()
%113 = call double (...) @my_random()
%114 = call double (...) @my_random()
%115 = call double (...) @my_random()
store double %115, double* %10
%116 = fcmp oeq double %115, 0x3FE70A3D70A3D70A
%117 = zext i1 %116 to i32
%118 = load double, double* %10
%119 = fptosi double %118 to i32
%120 = call i64 @assert(i32 %117, i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str.7, i64 0, i64 0), i32 %119)
%121 = icmp ne i64 %120, 0
br i1 %121, label %122, label %125
122: ; preds = %109
%123 = load i32, i32* %1
%124 = add nsw i32 %123, 1
store i32 %124, i32* %1
br label %128
125: ; preds = %109
%126 = load i32, i32* %2
%127 = add nsw i32 %126, 1
store i32 %127, i32* %2
br label %128
128: ; preds = %125, %122
%129 = phi i32 [ %123, %122 ], [ %126, %125 ]
%130 = call double (...) @my_random()
store double %130, double* %10
%131 = fcmp oeq double %130, 9.200000e-01
%132 = zext i1 %131 to i32
%133 = load double, double* %10
%134 = fptosi double %133 to i32
%135 = call i64 @assert(i32 %132, i8* getelementptr inbounds ([65 x i8], [65 x i8]* @.str.8, i64 0, i64 0), i32 %134)
%136 = icmp ne i64 %135, 0
br i1 %136, label %137, label %140
137: ; preds = %128
%138 = load i32, i32* %1
%139 = add nsw i32 %138, 1
store i32 %139, i32* %1
br label %143
140: ; preds = %128
%141 = load i32, i32* %2
%142 = add nsw i32 %141, 1
store i32 %142, i32* %2
br label %143
143: ; preds = %140, %137
%144 = phi i32 [ %138, %137 ], [ %141, %140 ]
%145 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([66 x i8], [66 x i8]* @.str.9, i64 0, i64 0))
%146 = getelementptr inbounds [3 x i32], [3 x i32]* %5, i64 0, i64 0
%147 = getelementptr inbounds [3 x i32], [3 x i32]* %6, i64 0, i64 0
%148 = call i32 @sum_of_array_multiplication(i32* %146, i32* %147, i32 3)
store i32 %148, i32* %9
%149 = load i32, i32* %9
%150 = icmp eq i32 %149, 46
%151 = zext i1 %150 to i32
%152 = load i32, i32* %9
%153 = call i64 @assert(i32 %151, i8* getelementptr inbounds ([55 x i8], [55 x i8]* @.str.10, i64 0, i64 0), i32 %152)
%154 = icmp ne i64 %153, 0
br i1 %154, label %155, label %158
155: ; preds = %143
%156 = load i32, i32* %1
%157 = add nsw i32 %156, 1
store i32 %157, i32* %1
br label %161
158: ; preds = %143
%159 = load i32, i32* %2
%160 = add nsw i32 %159, 1
store i32 %160, i32* %2
br label %161
161: ; preds = %158, %155
%162 = phi i32 [ %156, %155 ], [ %159, %158 ]
%163 = getelementptr inbounds [3 x i32], [3 x i32]* %5, i64 0, i64 0
%164 = getelementptr inbounds [3 x i32], [3 x i32]* %6, i64 0, i64 0
%165 = call i32 @sum_of_array_multiplication(i32* %163, i32* %164, i32 0)
store i32 %165, i32* %9
%166 = load i32, i32* %9
%167 = icmp eq i32 %166, 0
%168 = zext i1 %167 to i32
%169 = load i32, i32* %9
%170 = call i64 @assert(i32 %168, i8* getelementptr inbounds ([53 x i8], [53 x i8]* @.str.11, i64 0, i64 0), i32 %169)
%171 = icmp ne i64 %170, 0
br i1 %171, label %172, label %175
172: ; preds = %161
%173 = load i32, i32* %1
%174 = add nsw i32 %173, 1
store i32 %174, i32* %1
br label %178
175: ; preds = %161
%176 = load i32, i32* %2
%177 = add nsw i32 %176, 1
store i32 %177, i32* %2
br label %178
178: ; preds = %175, %172
%179 = phi i32 [ %173, %172 ], [ %176, %175 ]
%180 = getelementptr inbounds [3 x i32], [3 x i32]* %5, i64 0, i64 0
%181 = call i32 @sum_of_array_multiplication(i32* %180, i32* null, i32 3)
store i32 %181, i32* %9
%182 = load i32, i32* %9
%183 = icmp eq i32 %182, 0
%184 = zext i1 %183 to i32
%185 = load i32, i32* %9
%186 = call i64 @assert(i32 %184, i8* getelementptr inbounds ([61 x i8], [61 x i8]* @.str.12, i64 0, i64 0), i32 %185)
%187 = icmp ne i64 %186, 0
br i1 %187, label %188, label %191
188: ; preds = %178
%189 = load i32, i32* %1
%190 = add nsw i32 %189, 1
store i32 %190, i32* %1
br label %194
191: ; preds = %178
%192 = load i32, i32* %2
%193 = add nsw i32 %192, 1
store i32 %193, i32* %2
br label %194
194: ; preds = %191, %188
%195 = phi i32 [ %189, %188 ], [ %192, %191 ]
%196 = getelementptr inbounds [3 x i32], [3 x i32]* %6, i64 0, i64 0
%197 = call i32 @sum_of_array_multiplication(i32* null, i32* %196, i32 3)
store i32 %197, i32* %9
%198 = load i32, i32* %9
%199 = icmp eq i32 %198, 0
%200 = zext i1 %199 to i32
%201 = load i32, i32* %9
%202 = call i64 @assert(i32 %200, i8* getelementptr inbounds ([60 x i8], [60 x i8]* @.str.13, i64 0, i64 0), i32 %201)
%203 = icmp ne i64 %202, 0
br i1 %203, label %204, label %207
204: ; preds = %194
%205 = load i32, i32* %1
%206 = add nsw i32 %205, 1
store i32 %206, i32* %1
br label %210
207: ; preds = %194
%208 = load i32, i32* %2
%209 = add nsw i32 %208, 1
store i32 %209, i32* %2
br label %210
210: ; preds = %207, %204
%211 = phi i32 [ %205, %204 ], [ %208, %207 ]
%212 = getelementptr inbounds [4 x i32], [4 x i32]* %7, i64 0, i64 0
%213 = getelementptr inbounds [4 x i32], [4 x i32]* %8, i64 0, i64 0
%214 = call i32 @sum_of_array_multiplication(i32* %212, i32* %213, i32 4)
store i32 %214, i32* %9
%215 = load i32, i32* %9
%216 = icmp eq i32 %215, 8504
%217 = zext i1 %216 to i32
%218 = load i32, i32* %9
%219 = call i64 @assert(i32 %217, i8* getelementptr inbounds ([57 x i8], [57 x i8]* @.str.14, i64 0, i64 0), i32 %218)
%220 = icmp ne i64 %219, 0
br i1 %220, label %221, label %224
221: ; preds = %210
%222 = load i32, i32* %1
%223 = add nsw i32 %222, 1
store i32 %223, i32* %1
br label %227
224: ; preds = %210
%225 = load i32, i32* %2
%226 = add nsw i32 %225, 1
store i32 %226, i32* %2
br label %227
227: ; preds = %224, %221
%228 = phi i32 [ %222, %221 ], [ %225, %224 ]
%229 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([55 x i8], [55 x i8]* @.str.15, i64 0, i64 0))
%230 = call i32 @fix_bad_code(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.16, i64 0, i64 0))
store i32 %230, i32* %9
%231 = icmp eq i32 %230, 0
%232 = zext i1 %231 to i32
%233 = load i32, i32* %9
%234 = call i64 @assert(i32 %232, i8* getelementptr inbounds ([62 x i8], [62 x i8]* @.str.17, i64 0, i64 0), i32 %233)
%235 = icmp ne i64 %234, 0
br i1 %235, label %236, label %239
236: ; preds = %227
%237 = load i32, i32* %1
%238 = add nsw i32 %237, 1
store i32 %238, i32* %1
br label %242
239: ; preds = %227
%240 = load i32, i32* %2
%241 = add nsw i32 %240, 1
store i32 %241, i32* %2
br label %242
242: ; preds = %239, %236
%243 = phi i32 [ %237, %236 ], [ %240, %239 ]
%244 = call i32 @fix_bad_code(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.18, i64 0, i64 0))
store i32 %244, i32* %9
%245 = icmp eq i32 %244, 1
%246 = zext i1 %245 to i32
%247 = load i32, i32* %9
%248 = call i64 @assert(i32 %246, i8* getelementptr inbounds ([61 x i8], [61 x i8]* @.str.19, i64 0, i64 0), i32 %247)
%249 = icmp ne i64 %248, 0
br i1 %249, label %250, label %253
250: ; preds = %242
%251 = load i32, i32* %1
%252 = add nsw i32 %251, 1
store i32 %252, i32* %1
br label %256
253: ; preds = %242
%254 = load i32, i32* %2
%255 = add nsw i32 %254, 1
store i32 %255, i32* %2
br label %256
256: ; preds = %253, %250
%257 = phi i32 [ %251, %250 ], [ %254, %253 ]
%258 = call i32 @fix_bad_code(i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.20, i64 0, i64 0))
store i32 %258, i32* %9
%259 = icmp eq i32 %258, 0
%260 = zext i1 %259 to i32
%261 = load i32, i32* %9
%262 = call i64 @assert(i32 %260, i8* getelementptr inbounds ([52 x i8], [52 x i8]* @.str.21, i64 0, i64 0), i32 %261)
%263 = icmp ne i64 %262, 0
br i1 %263, label %264, label %267
264: ; preds = %256
%265 = load i32, i32* %1
%266 = add nsw i32 %265, 1
store i32 %266, i32* %1
br label %270
267: ; preds = %256
%268 = load i32, i32* %2
%269 = add nsw i32 %268, 1
store i32 %269, i32* %2
br label %270
270: ; preds = %267, %264
%271 = phi i32 [ %265, %264 ], [ %268, %267 ]
%272 = call i32 @fix_bad_code(i8* null)
store i32 %272, i32* %9
%273 = icmp eq i32 %272, 0
%274 = zext i1 %273 to i32
%275 = load i32, i32* %9
%276 = call i64 @assert(i32 %274, i8* getelementptr inbounds ([67 x i8], [67 x i8]* @.str.22, i64 0, i64 0), i32 %275)
%277 = icmp ne i64 %276, 0
br i1 %277, label %278, label %281
278: ; preds = %270
%279 = load i32, i32* %1
%280 = add nsw i32 %279, 1
store i32 %280, i32* %1
br label %284
281: ; preds = %270
%282 = load i32, i32* %2
%283 = add nsw i32 %282, 1
store i32 %283, i32* %2
br label %284
284: ; preds = %281, %278
%285 = phi i32 [ %279, %278 ], [ %282, %281 ]
%286 = load i32, i32* %1
%287 = load i32, i32* %2
%288 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([58 x i8], [58 x i8]* @.str.23, i64 0, i64 0), i32 %286, i32 %287)
%289 = load i32, i32* %2
ret i32 %289
}

LLVM IR (-O2):
@__const.test.first_array = [3 x i32] [i32 1, i32 2, i32 2]
@__const.test.second_array = [3 x i32] [i32 8, i32 9, i32 10]
@__const.test.test1 = [4 x i32] [i32 55, i32 66, i32 88, i32 2]
@__const.test.test2 = [4 x i32] [i32 44, i32 77, i32 11, i32 17]
@.str.1 = [71 x i8] c"Points to the first position in the array so expected a 1 but got a %d\00"
@.str.2 = [87 x i8] c"Points to the last position in the array (before the 0.0) so expected a 1 but got a %d\00"
@.str.3 = [71 x i8] c"Points to a position in a different array so expected a 0 but got a %d\00"
@.str.5 = [46 x i8] c"First random number must be 0.92 but got a %f\00"
@.str.6 = [47 x i8] c"Second random number must be 0.33 but got a %f\00"
@.str.7 = [45 x i8] c"Last random number must be 0.72 but got a %f\00"
@.str.8 = [65 x i8] c"Must now be back at the first random number of 0.92 but got a %f\00"
@.str.10 = [55 x i8] c"Sum of the updated first array should be 46 but got %d\00"
@.str.11 = [53 x i8] c"Expected 0 because number of entries is 0 but got %d\00"
@.str.12 = [61 x i8] c"Expected 0 because second array is a null pointer but got %d\00"
@.str.13 = [60 x i8] c"Expected 0 because first array is a null pointer but got %d\00"
@.str.14 = [57 x i8] c"Sum of the updated first array should be 8504 but got %d\00"
@.str.16 = [5 x i8] c"1234\00"
@.str.17 = [62 x i8] c"Expected 0 because there are no lower case letters but got %d\00"
@.str.18 = [6 x i8] c"9876a\00"
@.str.19 = [61 x i8] c"Expected 1 because there is one lower case letter but got %d\00"
@.str.20 = [1 x i8] zeroinitializer
@.str.21 = [52 x i8] c"Expected 0 because it is an empty string but got %d\00"
@.str.22 = [67 x i8] c"Expected 0 because the string pointer is a null pointer but got %d\00"
@.str.23 = [58 x i8] c"\0ASummary of unit tests:\0A%d tests passed\0A%d tests failed\0A\0A\00"
@str = [54 x i8] c"\0ATests for is_pointer_in_array.......................\00"
@str.24 = [54 x i8] c"\0ATests for my_random()...............................\00"
@str.25 = [65 x i8] c"\0ATests for sum_of_array_multiplication..........................\00"
@str.26 = [54 x i8] c"\0ATests for fix_bad_code..............................\00"
define i32 @test() {
%1 = alloca [6 x double]
%2 = alloca [5 x double]
%3 = alloca [3 x i32]
%4 = alloca [3 x i32]
%5 = alloca [4 x i32]
%6 = alloca [4 x i32]
%7 = bitcast [6 x double]* %1 to i8*
%8 = getelementptr inbounds [6 x double], [6 x double]* %1, i64 0, i64 4
%9 = bitcast double* %8 to i8*
%10 = getelementptr inbounds [6 x double], [6 x double]* %1, i64 0, i64 0
%11 = bitcast [6 x double]* %1 to <2 x double>*
store <2 x double> <double 1.100000e+00, double 2.200000e+00>, <2 x double>* %11
%12 = getelementptr inbounds [6 x double], [6 x double]* %1, i64 0, i64 2
%13 = bitcast double* %12 to <2 x double>*
store <2 x double> <double 3.900000e+00, double 5.000000e-01>, <2 x double>* %13
%14 = getelementptr inbounds [6 x double], [6 x double]* %1, i64 0, i64 4
store double 2.000000e-01, double* %14
%15 = bitcast [5 x double]* %2 to i8*
%16 = getelementptr inbounds [5 x double], [5 x double]* %2, i64 0, i64 4
%17 = bitcast double* %16 to i64*
store i64 0, i64* %17
%18 = bitcast [5 x double]* %2 to <2 x double>*
store <2 x double> <double 5.200000e+00, double 3.300000e+00>, <2 x double>* %18
%19 = getelementptr inbounds [5 x double], [5 x double]* %2, i64 0, i64 2
%20 = bitcast double* %19 to <2 x double>*
store <2 x double> <double 1.070000e+01, double 8.000000e-01>, <2 x double>* %20
%21 = bitcast [3 x i32]* %3 to i8*
%22 = bitcast [3 x i32]* %4 to i8*
%23 = bitcast [4 x i32]* %5 to i8*
%24 = bitcast [4 x i32]* %6 to i8*
%25 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([54 x i8], [54 x i8]* @str, i64 0, i64 0))
%26 = call i32 @is_pointer_in_array(double* %10, double* %10, double 0.000000e+00)
%27 = icmp eq i32 %26, 1
%28 = zext i1 %27 to i32
%29 = call i64 @assert(i32 %28, i8* getelementptr inbounds ([71 x i8], [71 x i8]* @.str.1, i64 0, i64 0), i32 %26)
%30 = icmp eq i64 %29, 0
%31 = xor i1 %30, true
%32 = zext i1 %31 to i32
%33 = zext i1 %30 to i32
%34 = call i32 @is_pointer_in_array(double* %10, double* %14, double 0.000000e+00)
%35 = icmp eq i32 %34, 1
%36 = zext i1 %35 to i32
%37 = call i64 @assert(i32 %36, i8* getelementptr inbounds ([87 x i8], [87 x i8]* @.str.2, i64 0, i64 0), i32 %34)
%38 = icmp eq i64 %37, 0
%39 = select i1 %30, i32 1, i32 2
%40 = select i1 %30, i32 2, i32 1
%41 = select i1 %38, i32 %32, i32 %39
%42 = select i1 %38, i32 %40, i32 %33
%43 = call i32 @is_pointer_in_array(double* %10, double* %19, double 0.000000e+00)
%44 = icmp eq i32 %43, 0
%45 = zext i1 %44 to i32
%46 = call i64 @assert(i32 %45, i8* getelementptr inbounds ([71 x i8], [71 x i8]* @.str.3, i64 0, i64 0), i32 %43)
%47 = icmp eq i64 %46, 0
%48 = xor i1 %47, true
%49 = zext i1 %48 to i32
%50 = add nuw nsw i32 %41, %49
%51 = zext i1 %47 to i32
%52 = add nuw nsw i32 %42, %51
%53 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([54 x i8], [54 x i8]* @str.24, i64 0, i64 0))
%54 = call double (...) @my_random()
%55 = fcmp oeq double %54, 9.200000e-01
%56 = zext i1 %55 to i32
%57 = fptosi double %54 to i32
%58 = call i64 @assert(i32 %56, i8* getelementptr inbounds ([46 x i8], [46 x i8]* @.str.5, i64 0, i64 0), i32 %57)
%59 = icmp eq i64 %58, 0
%60 = xor i1 %59, true
%61 = zext i1 %60 to i32
%62 = add nuw nsw i32 %50, %61
%63 = zext i1 %59 to i32
%64 = add nuw nsw i32 %52, %63
%65 = call double (...) @my_random()
%66 = fcmp oeq double %65, 3.300000e-01
%67 = zext i1 %66 to i32
%68 = fptosi double %65 to i32
%69 = call i64 @assert(i32 %67, i8* getelementptr inbounds ([47 x i8], [47 x i8]* @.str.6, i64 0, i64 0), i32 %68)
%70 = icmp eq i64 %69, 0
%71 = xor i1 %70, true
%72 = zext i1 %71 to i32
%73 = add nuw nsw i32 %62, %72
%74 = zext i1 %70 to i32
%75 = add nuw nsw i32 %64, %74
%76 = call double (...) @my_random()
%77 = call double (...) @my_random()
%78 = call double (...) @my_random()
%79 = call double (...) @my_random()
%80 = call double (...) @my_random()
%81 = fcmp oeq double %80, 0x3FE70A3D70A3D70A
%82 = zext i1 %81 to i32
%83 = fptosi double %80 to i32
%84 = call i64 @assert(i32 %82, i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str.7, i64 0, i64 0), i32 %83)
%85 = icmp eq i64 %84, 0
%86 = xor i1 %85, true
%87 = zext i1 %86 to i32
%88 = add nuw nsw i32 %73, %87
%89 = zext i1 %85 to i32
%90 = add nuw nsw i32 %75, %89
%91 = call double (...) @my_random()
%92 = fcmp oeq double %91, 9.200000e-01
%93 = zext i1 %92 to i32
%94 = fptosi double %91 to i32
%95 = call i64 @assert(i32 %93, i8* getelementptr inbounds ([65 x i8], [65 x i8]* @.str.8, i64 0, i64 0), i32 %94)
%96 = icmp eq i64 %95, 0
%97 = xor i1 %96, true
%98 = zext i1 %97 to i32
%99 = add nuw nsw i32 %88, %98
%100 = zext i1 %96 to i32
%101 = add nuw nsw i32 %90, %100
%102 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([65 x i8], [65 x i8]* @str.25, i64 0, i64 0))
%103 = getelementptr inbounds [3 x i32], [3 x i32]* %3, i64 0, i64 0
%104 = getelementptr inbounds [3 x i32], [3 x i32]* %4, i64 0, i64 0
%105 = call i32 @sum_of_array_multiplication(i32* %103, i32* %104, i32 3)
%106 = icmp eq i32 %105, 46
%107 = zext i1 %106 to i32
%108 = call i64 @assert(i32 %107, i8* getelementptr inbounds ([55 x i8], [55 x i8]* @.str.10, i64 0, i64 0), i32 %105)
%109 = icmp eq i64 %108, 0
%110 = xor i1 %109, true
%111 = zext i1 %110 to i32
%112 = add nuw nsw i32 %99, %111
%113 = zext i1 %109 to i32
%114 = add nuw nsw i32 %101, %113
%115 = call i32 @sum_of_array_multiplication(i32* %103, i32* %104, i32 0)
%116 = icmp eq i32 %115, 0
%117 = zext i1 %116 to i32
%118 = call i64 @assert(i32 %117, i8* getelementptr inbounds ([53 x i8], [53 x i8]* @.str.11, i64 0, i64 0), i32 %115)
%119 = icmp eq i64 %118, 0
%120 = xor i1 %119, true
%121 = zext i1 %120 to i32
%122 = add nuw nsw i32 %112, %121
%123 = zext i1 %119 to i32
%124 = add nuw nsw i32 %114, %123
%125 = call i32 @sum_of_array_multiplication(i32* %103, i32* null, i32 3)
%126 = icmp eq i32 %125, 0
%127 = zext i1 %126 to i32
%128 = call i64 @assert(i32 %127, i8* getelementptr inbounds ([61 x i8], [61 x i8]* @.str.12, i64 0, i64 0), i32 %125)
%129 = icmp eq i64 %128, 0
%130 = xor i1 %129, true
%131 = zext i1 %130 to i32
%132 = add nuw nsw i32 %122, %131
%133 = zext i1 %129 to i32
%134 = add nuw nsw i32 %124, %133
%135 = call i32 @sum_of_array_multiplication(i32* null, i32* %104, i32 3)
%136 = icmp eq i32 %135, 0
%137 = zext i1 %136 to i32
%138 = call i64 @assert(i32 %137, i8* getelementptr inbounds ([60 x i8], [60 x i8]* @.str.13, i64 0, i64 0), i32 %135)
%139 = icmp eq i64 %138, 0
%140 = xor i1 %139, true
%141 = zext i1 %140 to i32
%142 = add nuw nsw i32 %132, %141
%143 = zext i1 %139 to i32
%144 = add nuw nsw i32 %134, %143
%145 = getelementptr inbounds [4 x i32], [4 x i32]* %5, i64 0, i64 0
%146 = getelementptr inbounds [4 x i32], [4 x i32]* %6, i64 0, i64 0
%147 = call i32 @sum_of_array_multiplication(i32* %145, i32* %146, i32 4)
%148 = icmp eq i32 %147, 8504
%149 = zext i1 %148 to i32
%150 = call i64 @assert(i32 %149, i8* getelementptr inbounds ([57 x i8], [57 x i8]* @.str.14, i64 0, i64 0), i32 %147)
%151 = icmp eq i64 %150, 0
%152 = xor i1 %151, true
%153 = zext i1 %152 to i32
%154 = add nuw nsw i32 %142, %153
%155 = zext i1 %151 to i32
%156 = add nuw nsw i32 %144, %155
%157 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([54 x i8], [54 x i8]* @str.26, i64 0, i64 0))
%158 = call i32 @fix_bad_code(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.16, i64 0, i64 0))
%159 = icmp eq i32 %158, 0
%160 = zext i1 %159 to i32
%161 = call i64 @assert(i32 %160, i8* getelementptr inbounds ([62 x i8], [62 x i8]* @.str.17, i64 0, i64 0), i32 %158)
%162 = icmp eq i64 %161, 0
%163 = xor i1 %162, true
%164 = zext i1 %163 to i32
%165 = add nuw nsw i32 %154, %164
%166 = zext i1 %162 to i32
%167 = add nuw nsw i32 %156, %166
%168 = call i32 @fix_bad_code(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.18, i64 0, i64 0))
%169 = icmp eq i32 %168, 1
%170 = zext i1 %169 to i32
%171 = call i64 @assert(i32 %170, i8* getelementptr inbounds ([61 x i8], [61 x i8]* @.str.19, i64 0, i64 0), i32 %168)
%172 = icmp eq i64 %171, 0
%173 = xor i1 %172, true
%174 = zext i1 %173 to i32
%175 = add nuw nsw i32 %165, %174
%176 = zext i1 %172 to i32
%177 = add nuw nsw i32 %167, %176
%178 = call i32 @fix_bad_code(i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.20, i64 0, i64 0))
%179 = icmp eq i32 %178, 0
%180 = zext i1 %179 to i32
%181 = call i64 @assert(i32 %180, i8* getelementptr inbounds ([52 x i8], [52 x i8]* @.str.21, i64 0, i64 0), i32 %178)
%182 = icmp eq i64 %181, 0
%183 = xor i1 %182, true
%184 = zext i1 %183 to i32
%185 = add nuw nsw i32 %175, %184
%186 = zext i1 %182 to i32
%187 = add nuw nsw i32 %177, %186
%188 = call i32 @fix_bad_code(i8* null)
%189 = icmp eq i32 %188, 0
%190 = zext i1 %189 to i32
%191 = call i64 @assert(i32 %190, i8* getelementptr inbounds ([67 x i8], [67 x i8]* @.str.22, i64 0, i64 0), i32 %188)
%192 = icmp eq i64 %191, 0
%193 = xor i1 %192, true
%194 = zext i1 %193 to i32
%195 = add nuw nsw i32 %185, %194
%196 = zext i1 %192 to i32
%197 = add nuw nsw i32 %187, %196
%198 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([58 x i8], [58 x i8]* @.str.23, i64 0, i64 0), i32 %195, i32 %197)
ret i32 %197
}