#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_03() {
  int n[10];
  size_t i;
  for (i = 0; i < 10; ++i) {
    n[i] = 0;
  }
  printf("%s%13s\n", "Element", "Value");
  for (i = 0; i < 10; ++i) {
    printf("%7u%13d\n", i, n[i]);
  }
}


x86 assembly (clang, -O0):
<fig06_03>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movq   $0x0,-0x38(%rbp)
cmpq   $0xa,-0x38(%rbp)
jae    1148 <fig06_03+0x38>
mov    -0x38(%rbp),%rax
movl   $0x0,-0x30(%rbp,%rax,4)
mov    -0x38(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x38(%rbp)
jmp    1120 <fig06_03+0x10>
lea    0xeb1(%rip),%rdi
lea    0xeb2(%rip),%rsi
lea    0xeb3(%rip),%rdx
mov    $0x0,%al
call   1030 <printf@plt>
movq   $0x0,-0x38(%rbp)
cmpq   $0xa,-0x38(%rbp)
jae    11a2 <fig06_03+0x92>
mov    -0x38(%rbp),%rsi
mov    -0x38(%rbp),%rax
mov    -0x30(%rbp,%rax,4),%edx
lea    0xe8c(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x38(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x38(%rbp)
jmp    116c <fig06_03+0x5c>
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<fig06_03>:
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
xor    %edx,%edx
xor    %eax,%eax
call   1030 <printf@plt>
mov    $0x1,%esi
mov    %rbx,%rdi
xor    %edx,%edx
xor    %eax,%eax
call   1030 <printf@plt>
mov    $0x2,%esi
mov    %rbx,%rdi
xor    %edx,%edx
xor    %eax,%eax
call   1030 <printf@plt>
mov    $0x3,%esi
mov    %rbx,%rdi
xor    %edx,%edx
xor    %eax,%eax
call   1030 <printf@plt>
mov    $0x4,%esi
mov    %rbx,%rdi
xor    %edx,%edx
xor    %eax,%eax
call   1030 <printf@plt>
mov    $0x5,%esi
mov    %rbx,%rdi
xor    %edx,%edx
xor    %eax,%eax
call   1030 <printf@plt>
mov    $0x6,%esi
mov    %rbx,%rdi
xor    %edx,%edx
xor    %eax,%eax
call   1030 <printf@plt>
mov    $0x7,%esi
mov    %rbx,%rdi
xor    %edx,%edx
xor    %eax,%eax
call   1030 <printf@plt>
mov    $0x8,%esi
mov    %rbx,%rdi
xor    %edx,%edx
xor    %eax,%eax
call   1030 <printf@plt>
mov    $0x9,%esi
mov    %rbx,%rdi
xor    %edx,%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_03() {
%1 = alloca [10 x i32]
%2 = alloca i64
store i64 0, i64* %2
br label %3
3: ; preds = %9, %0
%4 = load i64, i64* %2
%5 = icmp ult i64 %4, 10
br i1 %5, label %6, label %12
6: ; preds = %3
%7 = load i64, i64* %2
%8 = getelementptr inbounds [10 x i32], [10 x i32]* %1, i64 0, i64 %7
store i32 0, i32* %8
br label %9
9: ; preds = %6
%10 = load i64, i64* %2
%11 = add i64 %10, 1
store i64 %11, i64* %2
br label %3
12: ; preds = %3
%13 = 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 %14
14: ; preds = %23, %12
%15 = load i64, i64* %2
%16 = icmp ult i64 %15, 10
br i1 %16, label %17, label %26
17: ; preds = %14
%18 = load i64, i64* %2
%19 = load i64, i64* %2
%20 = getelementptr inbounds [10 x i32], [10 x i32]* %1, i64 0, i64 %19
%21 = load i32, i32* %20
%22 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.3, i64 0, i64 0), i64 %18, i32 %21)
br label %23
23: ; preds = %17
%24 = load i64, i64* %2
%25 = add i64 %24, 1
store i64 %25, i64* %2
br label %14
26: ; preds = %14
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_03() {
%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 0)
%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 0)
%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 0)
%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 0)
%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 0)
%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 0)
%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 0)
%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 0)
%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 0)
%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 0)
ret void
}