int main(void) {
  char fname[40];
  char lname[40];
  printf("What's your first name?\n");
  scanf("%s", fname);
  printf("What's your last name?\n");
  scanf("%s", lname);
  printf("%s %s\n", fname, lname);
  printf("%*zd %*zd\n", strlen(fname), strlen(fname), strlen(lname),
         strlen(lname));
  printf("%s %s\n", fname, lname);
  printf("%-*zd %-*zd\n", strlen(fname), strlen(fname), strlen(lname),
         strlen(lname));
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x90,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeb7(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    -0x30(%rbp),%rsi
lea    0xebe(%rip),%rdi
mov    $0x0,%al
call   1050 <scanf@plt>
lea    0xeb3(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    -0x60(%rbp),%rsi
lea    0xe9e(%rip),%rdi
mov    $0x0,%al
call   1050 <scanf@plt>
lea    -0x30(%rbp),%rsi
lea    -0x60(%rbp),%rdx
lea    0xea3(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    -0x30(%rbp),%rdi
call   1030 <strlen@plt>
mov    %rax,-0x90(%rbp)
lea    -0x30(%rbp),%rdi
call   1030 <strlen@plt>
mov    %rax,-0x88(%rbp)
lea    -0x60(%rbp),%rdi
call   1030 <strlen@plt>
mov    %rax,-0x80(%rbp)
lea    -0x60(%rbp),%rdi
call   1030 <strlen@plt>
mov    -0x90(%rbp),%rsi
mov    -0x88(%rbp),%rdx
mov    -0x80(%rbp),%rcx
mov    %rax,%r8
lea    0xe51(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    -0x30(%rbp),%rsi
lea    -0x60(%rbp),%rdx
lea    0xe34(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    -0x30(%rbp),%rdi
call   1030 <strlen@plt>
mov    %rax,-0x78(%rbp)
lea    -0x30(%rbp),%rdi
call   1030 <strlen@plt>
mov    %rax,-0x70(%rbp)
lea    -0x60(%rbp),%rdi
call   1030 <strlen@plt>
mov    %rax,-0x68(%rbp)
lea    -0x60(%rbp),%rdi
call   1030 <strlen@plt>
mov    -0x78(%rbp),%rsi
mov    -0x70(%rbp),%rdx
mov    -0x68(%rbp),%rcx
mov    %rax,%r8
lea    0xdf9(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x90,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x58,%rsp
lea    0xed0(%rip),%rdi
call   1030 <puts@plt>
lea    0xea2(%rip),%r15
lea    0x30(%rsp),%r14
mov    %r15,%rdi
mov    %r14,%rsi
xor    %eax,%eax
call   1060 <scanf@plt>
lea    0xec3(%rip),%rdi
call   1030 <puts@plt>
mov    %rsp,%r12
mov    %r15,%rdi
mov    %r12,%rsi
xor    %eax,%eax
call   1060 <scanf@plt>
lea    0xe70(%rip),%r15
mov    %r15,%rdi
mov    %r14,%rsi
mov    %r12,%rdx
xor    %eax,%eax
call   1050 <printf@plt>
mov    %r14,%rdi
call   1040 <strlen@plt>
mov    %rax,%rbx
mov    %r12,%rdi
call   1040 <strlen@plt>
lea    0xe4d(%rip),%rdi
mov    %rbx,%rsi
mov    %rbx,%rdx
mov    %rax,%rcx
mov    %rax,%r8
xor    %eax,%eax
call   1050 <printf@plt>
mov    %r15,%rdi
mov    %r14,%rsi
mov    %r12,%rdx
xor    %eax,%eax
call   1050 <printf@plt>
mov    %r14,%rdi
call   1040 <strlen@plt>
mov    %rax,%rbx
mov    %r12,%rdi
call   1040 <strlen@plt>
lea    0xe1b(%rip),%rdi
mov    %rbx,%rsi
mov    %rbx,%rdx
mov    %rax,%rcx
mov    %rax,%r8
xor    %eax,%eax
call   1050 <printf@plt>
xor    %eax,%eax
add    $0x58,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [25 x i8] c"What's your first name?\0A\00"
@.str.1 = [3 x i8] c"%s\00"
@.str.2 = [24 x i8] c"What's your last name?\0A\00"
@.str.3 = [7 x i8] c"%s %s\0A\00"
@.str.4 = [11 x i8] c"%*zd %*zd\0A\00"
@.str.5 = [13 x i8] c"%-*zd %-*zd\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [40 x i8]
%3 = alloca [40 x i8]
store i32 0, i32* %1
%4 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0))
%5 = getelementptr inbounds [40 x i8], [40 x i8]* %2, i64 0, i64 0
%6 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %5)
%7 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.2, i64 0, i64 0))
%8 = getelementptr inbounds [40 x i8], [40 x i8]* %3, i64 0, i64 0
%9 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %8)
%10 = getelementptr inbounds [40 x i8], [40 x i8]* %2, i64 0, i64 0
%11 = getelementptr inbounds [40 x i8], [40 x i8]* %3, i64 0, i64 0
%12 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0), i8* %10, i8* %11)
%13 = getelementptr inbounds [40 x i8], [40 x i8]* %2, i64 0, i64 0
%14 = call i64 @strlen(i8* %13)
%15 = getelementptr inbounds [40 x i8], [40 x i8]* %2, i64 0, i64 0
%16 = call i64 @strlen(i8* %15)
%17 = getelementptr inbounds [40 x i8], [40 x i8]* %3, i64 0, i64 0
%18 = call i64 @strlen(i8* %17)
%19 = getelementptr inbounds [40 x i8], [40 x i8]* %3, i64 0, i64 0
%20 = call i64 @strlen(i8* %19)
%21 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.4, i64 0, i64 0), i64 %14, i64 %16, i64 %18, i64 %20)
%22 = getelementptr inbounds [40 x i8], [40 x i8]* %2, i64 0, i64 0
%23 = getelementptr inbounds [40 x i8], [40 x i8]* %3, i64 0, i64 0
%24 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0), i8* %22, i8* %23)
%25 = getelementptr inbounds [40 x i8], [40 x i8]* %2, i64 0, i64 0
%26 = call i64 @strlen(i8* %25)
%27 = getelementptr inbounds [40 x i8], [40 x i8]* %2, i64 0, i64 0
%28 = call i64 @strlen(i8* %27)
%29 = getelementptr inbounds [40 x i8], [40 x i8]* %3, i64 0, i64 0
%30 = call i64 @strlen(i8* %29)
%31 = getelementptr inbounds [40 x i8], [40 x i8]* %3, i64 0, i64 0
%32 = call i64 @strlen(i8* %31)
%33 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.5, i64 0, i64 0), i64 %26, i64 %28, i64 %30, i64 %32)
ret i32 0
}

LLVM IR (-O2):
@.str.1 = [3 x i8] c"%s\00"
@.str.3 = [7 x i8] c"%s %s\0A\00"
@.str.4 = [11 x i8] c"%*zd %*zd\0A\00"
@.str.5 = [13 x i8] c"%-*zd %-*zd\0A\00"
@str = [24 x i8] c"What's your first name?\00"
@str.6 = [23 x i8] c"What's your last name?\00"
define i32 @main() {
%1 = alloca [40 x i8]
%2 = alloca [40 x i8]
%3 = getelementptr inbounds [40 x i8], [40 x i8]* %1, i64 0, i64 0
%4 = getelementptr inbounds [40 x i8], [40 x i8]* %2, i64 0, i64 0
%5 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @str, i64 0, i64 0))
%6 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %3)
%7 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @str.6, i64 0, i64 0))
%8 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %4)
%9 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0), i8* %3, i8* %4)
%10 = call i64 @strlen(i8* %3)
%11 = call i64 @strlen(i8* %4)
%12 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @.str.4, i64 0, i64 0), i64 %10, i64 %10, i64 %11, i64 %11)
%13 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0), i8* %3, i8* %4)
%14 = call i64 @strlen(i8* %3)
%15 = call i64 @strlen(i8* %4)
%16 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @.str.5, i64 0, i64 0), i64 %14, i64 %14, i64 %15, i64 %15)
ret i32 0
}