#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 */
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int /*<<< orphan*/ fprintf(int /*<<< orphan*/ *, char *, ...);
int strlen(char *);
void print_n_chars(FILE *f, char *s, int n) {
  int len = strlen(s);
  int i;
  fprintf(f, "%s", s);
  for (i = len; i < n; i++)
    fprintf(f, " ");
}


x86 assembly (clang, -O0):
<print_n_chars>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,-0x18(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rdx
lea    0xeb2(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
mov    -0x18(%rbp),%eax
mov    %eax,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    1187 <print_n_chars+0x67>
mov    -0x8(%rbp),%rdi
lea    0xe91(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    115b <print_n_chars+0x3b>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<print_n_chars>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %edx,%ebx
mov    %rsi,%rbp
mov    %rdi,%r14
mov    %rsi,%rdi
call   1030 <strlen@plt>
mov    %eax,%r15d
mov    %rbp,%rdi
mov    %r14,%rsi
call   1040 <fputs@plt>
cmp    %ebx,%r15d
jge    1172 <print_n_chars+0x42>
sub    %r15d,%ebx
nopl   (%rax)
mov    $0x20,%edi
mov    %r14,%rsi
call   1050 <fputc@plt>
add    $0xffffffff,%ebx
jne    1160 <print_n_chars+0x30>
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
define void @print_n_chars(i32* nocapture %0, i8* %1, i32 %2) {
%4 = tail call i32 @strlen(i8* %1)
%5 = tail call i32 @fputs(i8* %1, i32* %0)
%6 = icmp slt i32 %4, %2
br i1 %6, label %7, label %12
7: ; preds = %3, %7
%8 = phi i32 [ %10, %7 ], [ %4, %3 ]
%9 = tail call i32 @fputc(i32 32, i32* %0)
%10 = add i32 %8, 1
%11 = icmp eq i32 %10, %2
br i1 %11, label %12, label %7
12: ; preds = %7, %3
ret void
}