void usage(char *exec) {
  int length = 0;
  length = (int)strlen(exec);
  printf("%s (v%s)\n\n", "ws2txt", "1.0.2");
  printf("Usage: %s <in.doc> [<out.txt>]\n", exec);
  printf("%*s [-h,--help]\n", length + 7, " ");
}


x86 assembly (clang, -O0):
<usage>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
mov    -0x8(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,-0xc(%rbp)
lea    0xeba(%rip),%rdi
lea    0xebe(%rip),%rsi
lea    0xebe(%rip),%rdx
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x8(%rbp),%rsi
lea    0xeb2(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0xc(%rbp),%esi
add    $0x7,%esi
lea    0xebe(%rip),%rdi
lea    0xec8(%rip),%rdx
mov    $0x0,%al
call   1040 <printf@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<usage>:
push   %r14
push   %rbx
push   %rax
mov    %rdi,%r14
call   1030 <strlen@plt>
mov    %rax,%rbx
lea    0xeca(%rip),%rdi
lea    0xece(%rip),%rsi
lea    0xece(%rip),%rdx
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xec6(%rip),%rdi
mov    %r14,%rsi
xor    %eax,%eax
call   1040 <printf@plt>
add    $0x7,%ebx
lea    0xed2(%rip),%rdi
lea    0xedc(%rip),%rdx
mov    %ebx,%esi
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
jmp    1040 <printf@plt>

LLVM IR (-O0):
@.str = [11 x i8] c"%s (v%s)\0A\0A\00"
@.str.1 = [7 x i8] c"ws2txt\00"
@.str.2 = [6 x i8] c"1.0.2\00"
@.str.3 = [32 x i8] c"Usage: %s <in.doc> [<out.txt>]\0A\00"
@.str.4 = [17 x i8] c"%*s [-h,--help]\0A\00"
@.str.5 = [2 x i8] c" \00"
define void @usage(i8* %0) {
%2 = alloca i8*
%3 = alloca i32
store i8* %0, i8** %2
store i32 0, i32* %3
%4 = load i8*, i8** %2
%5 = call i64 @strlen(i8* %4)
%6 = trunc i64 %5 to i32
store i32 %6, i32* %3
%7 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0))
%8 = load i8*, i8** %2
%9 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.3, i64 0, i64 0), i8* %8)
%10 = load i32, i32* %3
%11 = add nsw i32 %10, 7
%12 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.4, i64 0, i64 0), i32 %11, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0))
ret void
}

LLVM IR (-O2):
@.str = [11 x i8] c"%s (v%s)\0A\0A\00"
@.str.1 = [7 x i8] c"ws2txt\00"
@.str.2 = [6 x i8] c"1.0.2\00"
@.str.3 = [32 x i8] c"Usage: %s <in.doc> [<out.txt>]\0A\00"
@.str.4 = [17 x i8] c"%*s [-h,--help]\0A\00"
@.str.5 = [2 x i8] c" \00"
define void @usage(i8* %0) {
%2 = tail call i64 @strlen(i8* dereferenceable(1) %0)
%3 = trunc i64 %2 to i32
%4 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0))
%5 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([32 x i8], [32 x i8]* @.str.3, i64 0, i64 0), i8* %0)
%6 = add nsw i32 %3, 7
%7 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @.str.4, i64 0, i64 0), i32 %6, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0))
ret void
}