struct person {
  char name[30];
  char address[40];
  int birthyear;
} main() {
  int i;
  struct person friends[3];
  for (i = 0; i < 3; i++) {
    printf("What is the name of friend #%i?\n", i);
    scanf("%s", friends[i].name);
    printf("What is the address of %s?\n", friends[i].name);
    scanf("%s", friends[i].address);
  }
  printf("\n");
  for (i = 0; i < 3; i++) {
    printf("Friend #%d: %s, ", i, friends[i].name);
    printf("lives in %s\n", friends[i].address);
  }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x100,%rsp
mov    %rdi,-0xf8(%rbp)
movl   $0x0,-0x4(%rbp)
cmpl   $0x3,-0x4(%rbp)
jge    11c6 <main+0xa6>
mov    -0x4(%rbp),%esi
lea    0xeb3(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movslq -0x4(%rbp),%rax
lea    -0xf0(%rbp),%rsi
imul   $0x4c,%rax,%rax
add    %rax,%rsi
lea    0xeb4(%rip),%rdi
mov    $0x0,%al
call   1040 <scanf@plt>
movslq -0x4(%rbp),%rax
lea    -0xf0(%rbp),%rsi
imul   $0x4c,%rax,%rax
add    %rax,%rsi
lea    0xe97(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movslq -0x4(%rbp),%rax
lea    -0xf0(%rbp),%rsi
imul   $0x4c,%rax,%rax
add    %rax,%rsi
add    $0x1e,%rsi
lea    0xe70(%rip),%rdi
mov    $0x0,%al
call   1040 <scanf@plt>
mov    -0x4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x4(%rbp)
jmp    1139 <main+0x19>
lea    0xe52(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x4(%rbp)
cmpl   $0x3,-0x4(%rbp)
jge    123a <main+0x11a>
mov    -0x4(%rbp),%esi
movslq -0x4(%rbp),%rax
lea    -0xf0(%rbp),%rdx
imul   $0x4c,%rax,%rax
add    %rax,%rdx
lea    0xe3f(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movslq -0x4(%rbp),%rax
lea    -0xf0(%rbp),%rsi
imul   $0x4c,%rax,%rax
add    %rax,%rsi
add    $0x1e,%rsi
lea    0xe2c(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x4(%rbp)
jmp    11db <main+0xbb>
mov    -0xf8(%rbp),%rax
add    $0x100,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0xf8,%rsp
mov    %rdi,0x8(%rsp)
lea    0xeb3(%rip),%r14
mov    %r14,%rdi
xor    %esi,%esi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xec1(%rip),%rbx
lea    0x10(%rsp),%rbp
mov    %rbx,%rdi
mov    %rbp,%rsi
xor    %eax,%eax
call   1050 <scanf@plt>
lea    0xeab(%rip),%r15
mov    %r15,%rdi
mov    %rbp,%rsi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0x2e(%rsp),%rsi
mov    %rbx,%rdi
xor    %eax,%eax
call   1050 <scanf@plt>
mov    %r14,%rdi
mov    $0x1,%esi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0x5c(%rsp),%r13
mov    %rbx,%rdi
mov    %r13,%rsi
xor    %eax,%eax
call   1050 <scanf@plt>
mov    %r15,%rdi
mov    %r13,%rsi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0x7a(%rsp),%rsi
mov    %rbx,%rdi
xor    %eax,%eax
call   1050 <scanf@plt>
mov    %r14,%rdi
mov    $0x2,%esi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xa8(%rsp),%r12
mov    %rbx,%rdi
mov    %r12,%rsi
xor    %eax,%eax
call   1050 <scanf@plt>
mov    %r15,%rdi
mov    %r12,%rsi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xc6(%rsp),%r14
mov    %rbx,%rdi
mov    %r14,%rsi
xor    %eax,%eax
call   1050 <scanf@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
lea    0xe17(%rip),%rbx
mov    %rbx,%rdi
xor    %esi,%esi
mov    %rbp,%rdx
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xe12(%rip),%rbp
mov    %rbp,%rdi
lea    0x2e(%rsp),%rsi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %rbx,%rdi
mov    $0x1,%esi
mov    %r13,%rdx
xor    %eax,%eax
call   1040 <printf@plt>
mov    %rbp,%rdi
lea    0x7a(%rsp),%rsi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %rbx,%rdi
mov    $0x2,%esi
mov    %r12,%rdx
xor    %eax,%eax
call   1040 <printf@plt>
mov    %rbp,%rdi
mov    %r14,%rsi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x8(%rsp),%rax
add    $0xf8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.person = type { [30 x i8], [40 x i8], i32 }
@.str = [33 x i8] c"What is the name of friend #%i?\0A\00"
@.str.1 = [3 x i8] c"%s\00"
@.str.2 = [28 x i8] c"What is the address of %s?\0A\00"
@.str.3 = [2 x i8] c"\0A\00"
@.str.4 = [17 x i8] c"Friend #%d: %s, \00"
@.str.5 = [13 x i8] c"lives in %s\0A\00"
define void @main(%struct.person* noalias sret(%struct.person) align 4 %0) {
%2 = alloca i32
%3 = alloca [3 x %struct.person]
store i32 0, i32* %2
br label %4
4: ; preds = %28, %1
%5 = load i32, i32* %2
%6 = icmp slt i32 %5, 3
br i1 %6, label %7, label %31
7: ; preds = %4
%8 = load i32, i32* %2
%9 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str, i64 0, i64 0), i32 %8)
%10 = load i32, i32* %2
%11 = sext i32 %10 to i64
%12 = getelementptr inbounds [3 x %struct.person], [3 x %struct.person]* %3, i64 0, i64 %11
%13 = getelementptr inbounds %struct.person, %struct.person* %12, i32 0, i32 0
%14 = getelementptr inbounds [30 x i8], [30 x i8]* %13, i64 0, i64 0
%15 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %14)
%16 = load i32, i32* %2
%17 = sext i32 %16 to i64
%18 = getelementptr inbounds [3 x %struct.person], [3 x %struct.person]* %3, i64 0, i64 %17
%19 = getelementptr inbounds %struct.person, %struct.person* %18, i32 0, i32 0
%20 = getelementptr inbounds [30 x i8], [30 x i8]* %19, i64 0, i64 0
%21 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.2, i64 0, i64 0), i8* %20)
%22 = load i32, i32* %2
%23 = sext i32 %22 to i64
%24 = getelementptr inbounds [3 x %struct.person], [3 x %struct.person]* %3, i64 0, i64 %23
%25 = getelementptr inbounds %struct.person, %struct.person* %24, i32 0, i32 1
%26 = getelementptr inbounds [40 x i8], [40 x i8]* %25, i64 0, i64 0
%27 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %26)
br label %28
28: ; preds = %7
%29 = load i32, i32* %2
%30 = add nsw i32 %29, 1
store i32 %30, i32* %2
br label %4
31: ; preds = %4
%32 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
store i32 0, i32* %2
br label %33
33: ; preds = %50, %31
%34 = load i32, i32* %2
%35 = icmp slt i32 %34, 3
br i1 %35, label %36, label %53
36: ; preds = %33
%37 = load i32, i32* %2
%38 = load i32, i32* %2
%39 = sext i32 %38 to i64
%40 = getelementptr inbounds [3 x %struct.person], [3 x %struct.person]* %3, i64 0, i64 %39
%41 = getelementptr inbounds %struct.person, %struct.person* %40, i32 0, i32 0
%42 = getelementptr inbounds [30 x i8], [30 x i8]* %41, i64 0, i64 0
%43 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.4, i64 0, i64 0), i32 %37, i8* %42)
%44 = load i32, i32* %2
%45 = sext i32 %44 to i64
%46 = getelementptr inbounds [3 x %struct.person], [3 x %struct.person]* %3, i64 0, i64 %45
%47 = getelementptr inbounds %struct.person, %struct.person* %46, i32 0, i32 1
%48 = getelementptr inbounds [40 x i8], [40 x i8]* %47, i64 0, i64 0
%49 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.5, i64 0, i64 0), i8* %48)
br label %50
50: ; preds = %36
%51 = load i32, i32* %2
%52 = add nsw i32 %51, 1
store i32 %52, i32* %2
br label %33
53: ; preds = %33
ret void
}

LLVM IR (-O2):
%struct.person = type { [30 x i8], [40 x i8], i32 }
@.str = [33 x i8] c"What is the name of friend #%i?\0A\00"
@.str.1 = [3 x i8] c"%s\00"
@.str.2 = [28 x i8] c"What is the address of %s?\0A\00"
@.str.4 = [17 x i8] c"Friend #%d: %s, \00"
@.str.5 = [13 x i8] c"lives in %s\0A\00"
define void @main(%struct.person* noalias nocapture readnone sret(%struct.person) align 4 %0) {
%2 = alloca [3 x %struct.person]
%3 = getelementptr inbounds [3 x %struct.person], [3 x %struct.person]* %2, i64 0, i64 0, i32 0, i64 0
%4 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([33 x i8], [33 x i8]* @.str, i64 0, i64 0), i32 0)
%5 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %3)
%6 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([28 x i8], [28 x i8]* @.str.2, i64 0, i64 0), i8* %3)
%7 = getelementptr inbounds [3 x %struct.person], [3 x %struct.person]* %2, i64 0, i64 0, i32 1, i64 0
%8 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %7)
%9 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([33 x i8], [33 x i8]* @.str, i64 0, i64 0), i32 1)
%10 = getelementptr inbounds [3 x %struct.person], [3 x %struct.person]* %2, i64 0, i64 1, i32 0, i64 0
%11 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %10)
%12 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([28 x i8], [28 x i8]* @.str.2, i64 0, i64 0), i8* %10)
%13 = getelementptr inbounds [3 x %struct.person], [3 x %struct.person]* %2, i64 0, i64 1, i32 1, i64 0
%14 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %13)
%15 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([33 x i8], [33 x i8]* @.str, i64 0, i64 0), i32 2)
%16 = getelementptr inbounds [3 x %struct.person], [3 x %struct.person]* %2, i64 0, i64 2, i32 0, i64 0
%17 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %16)
%18 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([28 x i8], [28 x i8]* @.str.2, i64 0, i64 0), i8* %16)
%19 = getelementptr inbounds [3 x %struct.person], [3 x %struct.person]* %2, i64 0, i64 2, i32 1, i64 0
%20 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %19)
%21 = call i32 @putchar(i32 10)
%22 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @.str.4, i64 0, i64 0), i32 0, i8* %3)
%23 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @.str.5, i64 0, i64 0), i8* %7)
%24 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @.str.4, i64 0, i64 0), i32 1, i8* %10)
%25 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @.str.5, i64 0, i64 0), i8* %13)
%26 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @.str.4, i64 0, i64 0), i32 2, i8* %16)
%27 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @.str.5, i64 0, i64 0), i8* %19)
ret void
}