#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*/ fprintf(int /*<<< orphan*/, char *, char const *);
int /*<<< orphan*/ fputc(char, int /*<<< orphan*/);
int /*<<< orphan*/ stderr;
int strlen(char const *);
void print_underline(const char *text, int c) {
  int a;
  fprintf(stderr, "%s\n", text);
  for (a = 0; a < strlen(text); a++)
    fputc(c, stderr);
  fputc('\n', stderr);
}


x86 assembly (clang, -O0):
<print_underline>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    0x2e9a(%rip),%rax
mov    (%rax),%edi
mov    -0x8(%rbp),%rdx
lea    0xead(%rip),%rsi
call   1050 <fprintf@plt>
movl   $0x0,-0x10(%rbp)
mov    -0x10(%rbp),%eax
mov    %eax,-0x14(%rbp)
mov    -0x8(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,%ecx
mov    -0x14(%rbp),%eax
cmp    %ecx,%eax
jge    119d <print_underline+0x6d>
mov    -0xc(%rbp),%eax
mov    0x2e5b(%rip),%rcx
mov    (%rcx),%esi
movsbl %al,%edi
call   1040 <fputc@plt>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    115f <print_underline+0x2f>
mov    0x2e3c(%rip),%rax
mov    (%rax),%esi
mov    $0xa,%edi
call   1040 <fputc@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<print_underline>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %esi,%ebp
mov    %rdi,%r15
mov    0x2e9d(%rip),%r14
mov    (%r14),%edi
lea    0xeb3(%rip),%rsi
mov    %r15,%rdx
call   1050 <fprintf@plt>
mov    %r15,%rdi
call   1030 <strlen@plt>
test   %eax,%eax
jle    1189 <print_underline+0x59>
xor    %ebx,%ebx
movsbl %bpl,%ebp
nopw   0x0(%rax,%rax,1)
mov    (%r14),%esi
mov    %ebp,%edi
call   1040 <fputc@plt>
add    $0x1,%ebx
mov    %r15,%rdi
call   1030 <strlen@plt>
cmp    %eax,%ebx
jl     1170 <print_underline+0x40>
mov    (%r14),%esi
mov    $0xa,%edi
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
jmp    1040 <fputc@plt>

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

LLVM IR (-O2):
@stderr = global i32 0
@.str = [4 x i8] c"%s\0A\00"
define void @print_underline(i8* %0, i32 %1) {
%3 = load i32, i32* @stderr
%4 = tail call i32 @fprintf(i32 %3, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* %0)
%5 = tail call i32 @strlen(i8* %0)
%6 = icmp sgt i32 %5, 0
br i1 %6, label %7, label %16
7: ; preds = %2
%8 = trunc i32 %1 to i8
br label %9
9: ; preds = %7, %9
%10 = phi i32 [ 0, %7 ], [ %13, %9 ]
%11 = load i32, i32* @stderr
%12 = tail call i32 @fputc(i8 signext %8, i32 %11)
%13 = add nuw nsw i32 %10, 1
%14 = tail call i32 @strlen(i8* %0)
%15 = icmp slt i32 %13, %14
br i1 %15, label %9, label %16
16: ; preds = %9, %2
%17 = load i32, i32* @stderr
%18 = tail call i32 @fputc(i8 signext 10, i32 %17)
ret void
}