#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 strlen(char *);
void printPadded(char *s, int n) {
  int d = n - strlen(s);
  if (d < 0)
    d = 0;
  printf("%s", s);
  {
    int y, z = d;
    for (y = 0; y < z; y++, printf(" "))
      ;
  };
}


x86 assembly (clang, -O0):
<printPadded>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    -0xc(%rbp),%eax
mov    %eax,-0x1c(%rbp)
mov    -0x8(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,%ecx
mov    -0x1c(%rbp),%eax
sub    %ecx,%eax
mov    %eax,-0x10(%rbp)
cmpl   $0x0,-0x10(%rbp)
jge    1159 <printPadded+0x39>
movl   $0x0,-0x10(%rbp)
mov    -0x8(%rbp),%rsi
lea    0xe9c(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x10(%rbp),%eax
mov    %eax,-0x18(%rbp)
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x18(%rbp),%eax
jge    11a5 <printPadded+0x85>
jmp    1189 <printPadded+0x69>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
lea    0xe6a(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    1178 <printPadded+0x58>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<printPadded>:
push   %rbp
push   %r14
push   %rbx
mov    %esi,%ebx
mov    %rdi,%r14
call   1040 <strlen@plt>
sub    %eax,%ebx
lea    0xeb9(%rip),%rdi
xor    %ebp,%ebp
mov    %r14,%rsi
xor    %eax,%eax
call   1050 <printf@plt>
test   %ebx,%ebx
cmovs  %ebp,%ebx
jle    116f <printPadded+0x3f>
nopw   0x0(%rax,%rax,1)
mov    $0x20,%edi
call   1030 <putchar@plt>
add    $0xffffffff,%ebx
jne    1160 <printPadded+0x30>
pop    %rbx
pop    %r14
pop    %rbp
ret

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

LLVM IR (-O2):
@.str = [3 x i8] c"%s\00"
define void @printPadded(i8* %0, i32 %1) {
%3 = tail call i32 @strlen(i8* %0)
%4 = sub nsw i32 %1, %3
%5 = icmp sgt i32 %4, 0
%6 = select i1 %5, i32 %4, i32 0
%7 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %0)
br i1 %5, label %8, label %13
8: ; preds = %2, %8
%9 = phi i32 [ %10, %8 ], [ 0, %2 ]
%10 = add nuw nsw i32 %9, 1
%11 = tail call i32 @putchar(i32 32)
%12 = icmp eq i32 %10, %6
br i1 %12, label %13, label %8
13: ; preds = %8, %2
ret void
}