#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 *, int, int);
void anotherWay(void) {
  int vect[10];
  int i;
  for (i = 0; i < 10; i++)
    vect[i] = i + 1;
  for (i = 0; i < 10; i++)
    printf("i = %2d  vect[i] = %2d\n", i, vect[i]);
}


x86 assembly (clang, -O0):
<anotherWay>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x34(%rbp)
cmpl   $0xa,-0x34(%rbp)
jge    1145 <anotherWay+0x35>
mov    -0x34(%rbp),%ecx
add    $0x1,%ecx
movslq -0x34(%rbp),%rax
mov    %ecx,-0x30(%rbp,%rax,4)
mov    -0x34(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x34(%rbp)
jmp    111f <anotherWay+0xf>
movl   $0x0,-0x34(%rbp)
cmpl   $0xa,-0x34(%rbp)
jge    117b <anotherWay+0x6b>
mov    -0x34(%rbp),%esi
movslq -0x34(%rbp),%rax
mov    -0x30(%rbp,%rax,4),%edx
lea    0xe98(%rip),%rdi
call   1030 <printf@plt>
mov    -0x34(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x34(%rbp)
jmp    114c <anotherWay+0x3c>
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<anotherWay>:
push   %rbx
lea    0xee8(%rip),%rbx
mov    %rbx,%rdi
xor    %esi,%esi
mov    $0x1,%edx
call   1030 <printf@plt>
mov    %rbx,%rdi
mov    $0x1,%esi
mov    $0x2,%edx
call   1030 <printf@plt>
mov    %rbx,%rdi
mov    $0x2,%esi
mov    $0x3,%edx
call   1030 <printf@plt>
mov    %rbx,%rdi
mov    $0x3,%esi
mov    $0x4,%edx
call   1030 <printf@plt>
mov    %rbx,%rdi
mov    $0x4,%esi
mov    $0x5,%edx
call   1030 <printf@plt>
mov    %rbx,%rdi
mov    $0x5,%esi
mov    $0x6,%edx
call   1030 <printf@plt>
mov    %rbx,%rdi
mov    $0x6,%esi
mov    $0x7,%edx
call   1030 <printf@plt>
mov    %rbx,%rdi
mov    $0x7,%esi
mov    $0x8,%edx
call   1030 <printf@plt>
mov    %rbx,%rdi
mov    $0x8,%esi
mov    $0x9,%edx
call   1030 <printf@plt>
mov    %rbx,%rdi
mov    $0x9,%esi
mov    $0xa,%edx
pop    %rbx
jmp    1030 <printf@plt>

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

LLVM IR (-O2):
@.str = [24 x i8] c"i = %2d vect[i] = %2d\0A\00"
define void @anotherWay() {
%1 = tail call i32 @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0), i32 0, i32 1)
%2 = tail call i32 @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0), i32 1, i32 2)
%3 = tail call i32 @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0), i32 2, i32 3)
%4 = tail call i32 @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0), i32 3, i32 4)
%5 = tail call i32 @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0), i32 4, i32 5)
%6 = tail call i32 @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0), i32 5, i32 6)
%7 = tail call i32 @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0), i32 6, i32 7)
%8 = tail call i32 @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0), i32 7, i32 8)
%9 = tail call i32 @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0), i32 8, i32 9)
%10 = tail call i32 @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0), i32 9, i32 10)
ret void
}