#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 */
int /*<<< orphan*/ printf(char *, ...);
void fig06_05() {
  int s[20];
  size_t j;
  for (j = 0; j < 20; ++j) {
    s[j] = 2 + 2 * j;
  }
  printf("%s%13s\n", "Element", "Value");
  for (j = 0; j < 20; ++j) {
    printf("%7u%13d\n", j, s[j]);
  }
}


x86 assembly (clang, -O0):
<fig06_05>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
movq   $0x0,-0x58(%rbp)
cmpq   $0x14,-0x58(%rbp)
jae    1152 <fig06_05+0x42>
mov    -0x58(%rbp),%rax
shl    $0x1,%rax
add    $0x2,%rax
mov    %eax,%ecx
mov    -0x58(%rbp),%rax
mov    %ecx,-0x50(%rbp,%rax,4)
mov    -0x58(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x58(%rbp)
jmp    1120 <fig06_05+0x10>
lea    0xea7(%rip),%rdi
lea    0xea8(%rip),%rsi
lea    0xea9(%rip),%rdx
mov    $0x0,%al
call   1030 <printf@plt>
movq   $0x0,-0x58(%rbp)
cmpq   $0x14,-0x58(%rbp)
jae    11ac <fig06_05+0x9c>
mov    -0x58(%rbp),%rsi
mov    -0x58(%rbp),%rax
mov    -0x50(%rbp,%rax,4),%edx
lea    0xe82(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x58(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x58(%rbp)
jmp    1176 <fig06_05+0x66>
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<fig06_05>:
push   %rbx
lea    0xee8(%rip),%rdi
lea    0xee9(%rip),%rsi
lea    0xeea(%rip),%rdx
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xee2(%rip),%rbx
mov    %rbx,%rdi
xor    %esi,%esi
mov    $0x2,%edx
xor    %eax,%eax
call   1030 <printf@plt>
mov    $0x1,%esi
mov    %rbx,%rdi
mov    $0x4,%edx
xor    %eax,%eax
call   1030 <printf@plt>
mov    $0x2,%esi
mov    %rbx,%rdi
mov    $0x6,%edx
xor    %eax,%eax
call   1030 <printf@plt>
mov    $0x3,%esi
mov    %rbx,%rdi
mov    $0x8,%edx
xor    %eax,%eax
call   1030 <printf@plt>
mov    $0x4,%esi
mov    %rbx,%rdi
mov    $0xa,%edx
xor    %eax,%eax
call   1030 <printf@plt>
mov    $0x5,%esi
mov    %rbx,%rdi
mov    $0xc,%edx
xor    %eax,%eax
call   1030 <printf@plt>
mov    $0x6,%esi
mov    %rbx,%rdi
mov    $0xe,%edx
xor    %eax,%eax
call   1030 <printf@plt>
mov    $0x7,%esi
mov    %rbx,%rdi
mov    $0x10,%edx
xor    %eax,%eax
call   1030 <printf@plt>
mov    $0x8,%esi
mov    %rbx,%rdi
mov    $0x12,%edx
xor    %eax,%eax
call   1030 <printf@plt>
mov    $0x9,%esi
mov    %rbx,%rdi
mov    $0x14,%edx
xor    %eax,%eax
call   1030 <printf@plt>
mov    $0xa,%esi
mov    %rbx,%rdi
mov    $0x16,%edx
xor    %eax,%eax
call   1030 <printf@plt>
mov    $0xb,%esi
mov    %rbx,%rdi
mov    $0x18,%edx
xor    %eax,%eax
call   1030 <printf@plt>
mov    $0xc,%esi
mov    %rbx,%rdi
mov    $0x1a,%edx
xor    %eax,%eax
call   1030 <printf@plt>
mov    $0xd,%esi
mov    %rbx,%rdi
mov    $0x1c,%edx
xor    %eax,%eax
call   1030 <printf@plt>
mov    $0xe,%esi
mov    %rbx,%rdi
mov    $0x1e,%edx
xor    %eax,%eax
call   1030 <printf@plt>
mov    $0xf,%esi
mov    %rbx,%rdi
mov    $0x20,%edx
xor    %eax,%eax
call   1030 <printf@plt>
mov    $0x10,%esi
mov    %rbx,%rdi
mov    $0x22,%edx
xor    %eax,%eax
call   1030 <printf@plt>
mov    $0x11,%esi
mov    %rbx,%rdi
mov    $0x24,%edx
xor    %eax,%eax
call   1030 <printf@plt>
mov    $0x12,%esi
mov    %rbx,%rdi
mov    $0x26,%edx
xor    %eax,%eax
call   1030 <printf@plt>
mov    $0x13,%esi
mov    %rbx,%rdi
mov    $0x28,%edx
xor    %eax,%eax
pop    %rbx
jmp    1030 <printf@plt>

LLVM IR (-O0):
@.str = [8 x i8] c"%s%13s\0A\00"
@.str.1 = [8 x i8] c"Element\00"
@.str.2 = [6 x i8] c"Value\00"
@.str.3 = [9 x i8] c"%7u%13d\0A\00"
define void @fig06_05() {
%1 = alloca [20 x i32]
%2 = alloca i64
store i64 0, i64* %2
br label %3
3: ; preds = %13, %0
%4 = load i64, i64* %2
%5 = icmp ult i64 %4, 20
br i1 %5, label %6, label %16
6: ; preds = %3
%7 = load i64, i64* %2
%8 = mul i64 2, %7
%9 = add i64 2, %8
%10 = trunc i64 %9 to i32
%11 = load i64, i64* %2
%12 = getelementptr inbounds [20 x i32], [20 x i32]* %1, i64 0, i64 %11
store i32 %10, i32* %12
br label %13
13: ; preds = %6
%14 = load i64, i64* %2
%15 = add i64 %14, 1
store i64 %15, i64* %2
br label %3
16: ; preds = %3
%17 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0))
store i64 0, i64* %2
br label %18
18: ; preds = %27, %16
%19 = load i64, i64* %2
%20 = icmp ult i64 %19, 20
br i1 %20, label %21, label %30
21: ; preds = %18
%22 = load i64, i64* %2
%23 = load i64, i64* %2
%24 = getelementptr inbounds [20 x i32], [20 x i32]* %1, i64 0, i64 %23
%25 = load i32, i32* %24
%26 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.3, i64 0, i64 0), i64 %22, i32 %25)
br label %27
27: ; preds = %21
%28 = load i64, i64* %2
%29 = add i64 %28, 1
store i64 %29, i64* %2
br label %18
30: ; preds = %18
ret void
}

LLVM IR (-O2):
@.str = [8 x i8] c"%s%13s\0A\00"
@.str.1 = [8 x i8] c"Element\00"
@.str.2 = [6 x i8] c"Value\00"
@.str.3 = [9 x i8] c"%7u%13d\0A\00"
define void @fig06_05() {
%1 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0))
%2 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @.str.3, i64 0, i64 0), i64 0, i32 2)
%3 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @.str.3, i64 0, i64 0), i64 1, i32 4)
%4 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @.str.3, i64 0, i64 0), i64 2, i32 6)
%5 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @.str.3, i64 0, i64 0), i64 3, i32 8)
%6 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @.str.3, i64 0, i64 0), i64 4, i32 10)
%7 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @.str.3, i64 0, i64 0), i64 5, i32 12)
%8 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @.str.3, i64 0, i64 0), i64 6, i32 14)
%9 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @.str.3, i64 0, i64 0), i64 7, i32 16)
%10 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @.str.3, i64 0, i64 0), i64 8, i32 18)
%11 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @.str.3, i64 0, i64 0), i64 9, i32 20)
%12 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @.str.3, i64 0, i64 0), i64 10, i32 22)
%13 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @.str.3, i64 0, i64 0), i64 11, i32 24)
%14 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @.str.3, i64 0, i64 0), i64 12, i32 26)
%15 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @.str.3, i64 0, i64 0), i64 13, i32 28)
%16 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @.str.3, i64 0, i64 0), i64 14, i32 30)
%17 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @.str.3, i64 0, i64 0), i64 15, i32 32)
%18 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @.str.3, i64 0, i64 0), i64 16, i32 34)
%19 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @.str.3, i64 0, i64 0), i64 17, i32 36)
%20 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @.str.3, i64 0, i64 0), i64 18, i32 38)
%21 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @.str.3, i64 0, i64 0), i64 19, i32 40)
ret void
}