#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 */
float RAND_MAX;
int /*<<< orphan*/ free(char *);
char *malloc(int);
int /*<<< orphan*/ printf(char *, ...);
scalar_t__ random();
int main(int argc, char *argv[]) {
  int i;
  char *a = malloc(20 * sizeof(char));
  for (i = 0; i < 20; ++i)
    a[i] = (char)(65 + (int)(4 * ((float)random() / RAND_MAX)));
  for (i = 0; i < 20; ++i)
    printf("%c ", a[i]);
  printf("\n");
  int lim = (20 - 8 > 8) ? 8 : 20 - 8;
  int im, side;
  printf("Starting to look at %i|%c\n", 8, a[8]);
  im = 8;
  for (i = 0; i < lim; ++i) {
    side = 2 * (i % 2) - 1;
    im += (i + 1) * side;
    printf("%i|%c\n", im, a[im]);
  }
  free(a);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    $0x14,%edi
call   1060 <malloc@plt>
mov    %rax,-0x20(%rbp)
movl   $0x0,-0x14(%rbp)
cmpl   $0x14,-0x14(%rbp)
jge    11ba <main+0x7a>
mov    $0x0,%al
call   1050 <random@plt>
cvtsi2ss %rax,%xmm1
mov    0x2e60(%rip),%rax
divss  (%rax),%xmm1
movss  0xe6c(%rip),%xmm0
mulss  %xmm1,%xmm0
cvttss2si %xmm0,%eax
add    $0x41,%eax
mov    %al,%dl
mov    -0x20(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    %dl,(%rax,%rcx,1)
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    116b <main+0x2b>
movl   $0x0,-0x14(%rbp)
cmpl   $0x14,-0x14(%rbp)
jge    11f3 <main+0xb3>
mov    -0x20(%rbp),%rax
movslq -0x14(%rbp),%rcx
movsbl (%rax,%rcx,1),%esi
lea    0xe26(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    11c1 <main+0x81>
lea    0xe27(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x8,-0x24(%rbp)
mov    -0x20(%rbp),%rax
movsbl 0x8(%rax),%edx
lea    0xdf1(%rip),%rdi
mov    $0x8,%esi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x8,-0x28(%rbp)
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x24(%rbp),%eax
jge    128e <main+0x14e>
mov    -0x14(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %edx,%eax
shl    $0x1,%eax
sub    $0x1,%eax
mov    %eax,-0x2c(%rbp)
mov    -0x14(%rbp),%eax
add    $0x1,%eax
imul   -0x2c(%rbp),%eax
add    -0x28(%rbp),%eax
mov    %eax,-0x28(%rbp)
mov    -0x28(%rbp),%esi
mov    -0x20(%rbp),%rax
movslq -0x28(%rbp),%rcx
movsbl (%rax,%rcx,1),%edx
lea    0xda3(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1231 <main+0xf1>
mov    -0x20(%rbp),%rdi
call   1030 <free@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
mov    $0x14,%edi
call   1070 <malloc@plt>
mov    %rax,%r15
mov    0x2e7f(%rip),%r14
xor    %ebx,%ebx
nopl   0x0(%rax,%rax,1)
xor    %eax,%eax
call   1060 <random@plt>
xorps  %xmm0,%xmm0
cvtsi2ss %rax,%xmm0
divss  (%r14),%xmm0
mulss  0xe74(%rip),%xmm0
cvttss2si %xmm0,%eax
add    $0x41,%al
mov    %al,(%r15,%rbx,1)
add    $0x1,%rbx
cmp    $0x14,%rbx
jne    1170 <main+0x20>
movsbl (%r15),%esi
lea    0xe59(%rip),%r14
mov    %r14,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
movsbl 0x1(%r15),%esi
mov    %r14,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
movsbl 0x2(%r15),%esi
mov    %r14,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
movsbl 0x3(%r15),%esi
mov    %r14,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
movsbl 0x4(%r15),%esi
mov    %r14,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
movsbl 0x5(%r15),%esi
mov    %r14,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
movsbl 0x6(%r15),%esi
mov    %r14,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
movsbl 0x7(%r15),%esi
mov    %r14,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
movsbl 0x8(%r15),%esi
mov    %r14,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
movsbl 0x9(%r15),%esi
mov    %r14,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
movsbl 0xa(%r15),%esi
mov    %r14,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
movsbl 0xb(%r15),%esi
mov    %r14,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
movsbl 0xc(%r15),%esi
mov    %r14,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
movsbl 0xd(%r15),%esi
mov    %r14,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
movsbl 0xe(%r15),%esi
mov    %r14,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
movsbl 0xf(%r15),%esi
mov    %r14,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
movsbl 0x10(%r15),%esi
mov    %r14,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
movsbl 0x11(%r15),%esi
mov    %r14,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
movsbl 0x12(%r15),%esi
mov    %r14,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
movsbl 0x13(%r15),%esi
mov    %r14,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    $0xa,%edi
call   1040 <putchar@plt>
movsbl 0x8(%r15),%edx
lea    0xd20(%rip),%rdi
mov    $0x8,%esi
xor    %eax,%eax
call   1050 <printf@plt>
movsbl 0x7(%r15),%edx
lea    0xd1c(%rip),%r14
mov    %r14,%rdi
mov    $0x7,%esi
xor    %eax,%eax
call   1050 <printf@plt>
movsbl 0x9(%r15),%edx
mov    %r14,%rdi
mov    $0x9,%esi
xor    %eax,%eax
call   1050 <printf@plt>
movsbl 0x6(%r15),%edx
mov    %r14,%rdi
mov    $0x6,%esi
xor    %eax,%eax
call   1050 <printf@plt>
movsbl 0xa(%r15),%edx
mov    %r14,%rdi
mov    $0xa,%esi
xor    %eax,%eax
call   1050 <printf@plt>
movsbl 0x5(%r15),%edx
mov    %r14,%rdi
mov    $0x5,%esi
xor    %eax,%eax
call   1050 <printf@plt>
movsbl 0xb(%r15),%edx
mov    %r14,%rdi
mov    $0xb,%esi
xor    %eax,%eax
call   1050 <printf@plt>
movsbl 0x4(%r15),%edx
mov    %r14,%rdi
mov    $0x4,%esi
xor    %eax,%eax
call   1050 <printf@plt>
movsbl 0xc(%r15),%edx
mov    %r14,%rdi
mov    $0xc,%esi
xor    %eax,%eax
call   1050 <printf@plt>
mov    %r15,%rdi
call   1030 <free@plt>
xor    %eax,%eax
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@RAND_MAX = global float 0.000000e+00
@.str = [4 x i8] c"%c \00"
@.str.1 = [2 x i8] c"\0A\00"
@.str.2 = [27 x i8] c"Starting to look at %i|%c\0A\00"
@.str.3 = [7 x i8] c"%i|%c\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i8*
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%11 = call i8* @malloc(i32 20)
store i8* %11, i8** %7
store i32 0, i32* %6
br label %12
12: ; preds = %28, %2
%13 = load i32, i32* %6
%14 = icmp slt i32 %13, 20
br i1 %14, label %15, label %31
15: ; preds = %12
%16 = call i64 (...) @random()
%17 = sitofp i64 %16 to float
%18 = load float, float* @RAND_MAX
%19 = fdiv float %17, %18
%20 = fmul float 4.000000e+00, %19
%21 = fptosi float %20 to i32
%22 = add nsw i32 65, %21
%23 = trunc i32 %22 to i8
%24 = load i8*, i8** %7
%25 = load i32, i32* %6
%26 = sext i32 %25 to i64
%27 = getelementptr inbounds i8, i8* %24, i64 %26
store i8 %23, i8* %27
br label %28
28: ; preds = %15
%29 = load i32, i32* %6
%30 = add nsw i32 %29, 1
store i32 %30, i32* %6
br label %12
31: ; preds = %12
store i32 0, i32* %6
br label %32
32: ; preds = %43, %31
%33 = load i32, i32* %6
%34 = icmp slt i32 %33, 20
br i1 %34, label %35, label %46
35: ; preds = %32
%36 = load i8*, i8** %7
%37 = load i32, i32* %6
%38 = sext i32 %37 to i64
%39 = getelementptr inbounds i8, i8* %36, i64 %38
%40 = load i8, i8* %39
%41 = sext i8 %40 to i32
%42 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %41)
br label %43
43: ; preds = %35
%44 = load i32, i32* %6
%45 = add nsw i32 %44, 1
store i32 %45, i32* %6
br label %32
46: ; preds = %32
%47 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32 8, i32* %8
%48 = load i8*, i8** %7
%49 = getelementptr inbounds i8, i8* %48, i64 8
%50 = load i8, i8* %49
%51 = sext i8 %50 to i32
%52 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.2, i64 0, i64 0), i32 8, i32 %51)
store i32 8, i32* %9
store i32 0, i32* %6
br label %53
53: ; preds = %76, %46
%54 = load i32, i32* %6
%55 = load i32, i32* %8
%56 = icmp slt i32 %54, %55
br i1 %56, label %57, label %79
57: ; preds = %53
%58 = load i32, i32* %6
%59 = srem i32 %58, 2
%60 = mul nsw i32 2, %59
%61 = sub nsw i32 %60, 1
store i32 %61, i32* %10
%62 = load i32, i32* %6
%63 = add nsw i32 %62, 1
%64 = load i32, i32* %10
%65 = mul nsw i32 %63, %64
%66 = load i32, i32* %9
%67 = add nsw i32 %66, %65
store i32 %67, i32* %9
%68 = load i32, i32* %9
%69 = load i8*, i8** %7
%70 = load i32, i32* %9
%71 = sext i32 %70 to i64
%72 = getelementptr inbounds i8, i8* %69, i64 %71
%73 = load i8, i8* %72
%74 = sext i8 %73 to i32
%75 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0), i32 %68, i32 %74)
br label %76
76: ; preds = %57
%77 = load i32, i32* %6
%78 = add nsw i32 %77, 1
store i32 %78, i32* %6
br label %53
79: ; preds = %53
%80 = load i8*, i8** %7
%81 = call i32 @free(i8* %80)
ret i32 0
}

LLVM IR (-O2):
@RAND_MAX = global float 0.000000e+00
@.str = [4 x i8] c"%c \00"
@.str.2 = [27 x i8] c"Starting to look at %i|%c\0A\00"
@.str.3 = [7 x i8] c"%i|%c\0A\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = tail call dereferenceable_or_null(20) i8* @malloc(i32 20)
br label %4
4: ; preds = %2, %4
%5 = phi i64 [ 0, %2 ], [ %15, %4 ]
%6 = tail call i64 (...) @random()
%7 = sitofp i64 %6 to float
%8 = load float, float* @RAND_MAX
%9 = fdiv float %7, %8
%10 = fmul float %9, 4.000000e+00
%11 = fptosi float %10 to i32
%12 = trunc i32 %11 to i8
%13 = add i8 %12, 65
%14 = getelementptr inbounds i8, i8* %3, i64 %5
store i8 %13, i8* %14
%15 = add nuw nsw i64 %5, 1
%16 = icmp eq i64 %15, 20
br i1 %16, label %17, label %4
17: ; preds = %4
%18 = load i8, i8* %3
%19 = sext i8 %18 to i32
%20 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %19)
%21 = getelementptr inbounds i8, i8* %3, i64 1
%22 = load i8, i8* %21
%23 = sext i8 %22 to i32
%24 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %23)
%25 = getelementptr inbounds i8, i8* %3, i64 2
%26 = load i8, i8* %25
%27 = sext i8 %26 to i32
%28 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %27)
%29 = getelementptr inbounds i8, i8* %3, i64 3
%30 = load i8, i8* %29
%31 = sext i8 %30 to i32
%32 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %31)
%33 = getelementptr inbounds i8, i8* %3, i64 4
%34 = load i8, i8* %33
%35 = sext i8 %34 to i32
%36 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %35)
%37 = getelementptr inbounds i8, i8* %3, i64 5
%38 = load i8, i8* %37
%39 = sext i8 %38 to i32
%40 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %39)
%41 = getelementptr inbounds i8, i8* %3, i64 6
%42 = load i8, i8* %41
%43 = sext i8 %42 to i32
%44 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %43)
%45 = getelementptr inbounds i8, i8* %3, i64 7
%46 = load i8, i8* %45
%47 = sext i8 %46 to i32
%48 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %47)
%49 = getelementptr inbounds i8, i8* %3, i64 8
%50 = load i8, i8* %49
%51 = sext i8 %50 to i32
%52 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %51)
%53 = getelementptr inbounds i8, i8* %3, i64 9
%54 = load i8, i8* %53
%55 = sext i8 %54 to i32
%56 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %55)
%57 = getelementptr inbounds i8, i8* %3, i64 10
%58 = load i8, i8* %57
%59 = sext i8 %58 to i32
%60 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %59)
%61 = getelementptr inbounds i8, i8* %3, i64 11
%62 = load i8, i8* %61
%63 = sext i8 %62 to i32
%64 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %63)
%65 = getelementptr inbounds i8, i8* %3, i64 12
%66 = load i8, i8* %65
%67 = sext i8 %66 to i32
%68 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %67)
%69 = getelementptr inbounds i8, i8* %3, i64 13
%70 = load i8, i8* %69
%71 = sext i8 %70 to i32
%72 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %71)
%73 = getelementptr inbounds i8, i8* %3, i64 14
%74 = load i8, i8* %73
%75 = sext i8 %74 to i32
%76 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %75)
%77 = getelementptr inbounds i8, i8* %3, i64 15
%78 = load i8, i8* %77
%79 = sext i8 %78 to i32
%80 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %79)
%81 = getelementptr inbounds i8, i8* %3, i64 16
%82 = load i8, i8* %81
%83 = sext i8 %82 to i32
%84 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %83)
%85 = getelementptr inbounds i8, i8* %3, i64 17
%86 = load i8, i8* %85
%87 = sext i8 %86 to i32
%88 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %87)
%89 = getelementptr inbounds i8, i8* %3, i64 18
%90 = load i8, i8* %89
%91 = sext i8 %90 to i32
%92 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %91)
%93 = getelementptr inbounds i8, i8* %3, i64 19
%94 = load i8, i8* %93
%95 = sext i8 %94 to i32
%96 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %95)
%97 = tail call i32 @putchar(i32 10)
%98 = load i8, i8* %49
%99 = sext i8 %98 to i32
%100 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @.str.2, i64 0, i64 0), i32 8, i32 %99)
%101 = load i8, i8* %45
%102 = sext i8 %101 to i32
%103 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0), i32 7, i32 %102)
%104 = load i8, i8* %53
%105 = sext i8 %104 to i32
%106 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0), i32 9, i32 %105)
%107 = load i8, i8* %41
%108 = sext i8 %107 to i32
%109 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0), i32 6, i32 %108)
%110 = load i8, i8* %57
%111 = sext i8 %110 to i32
%112 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0), i32 10, i32 %111)
%113 = load i8, i8* %37
%114 = sext i8 %113 to i32
%115 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0), i32 5, i32 %114)
%116 = load i8, i8* %61
%117 = sext i8 %116 to i32
%118 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0), i32 11, i32 %117)
%119 = load i8, i8* %33
%120 = sext i8 %119 to i32
%121 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0), i32 4, i32 %120)
%122 = load i8, i8* %65
%123 = sext i8 %122 to i32
%124 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0), i32 12, i32 %123)
%125 = tail call i32 @free(i8* %3)
ret i32 0
}