#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 *, ...);
void writemsg(FILE *fdst, char *src, char alphabet, int size) {
  int i;
  fprintf(fdst, "%s : ", src);
  for (i = 1; i <= size; i++) {
    fprintf(fdst, "%c", alphabet);
  }
  fprintf(fdst, "\n");
}


x86 assembly (clang, -O0):
<writemsg>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %dl,%al
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %al,-0x11(%rbp)
mov    %ecx,-0x18(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rdx
lea    0xec9(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
movl   $0x1,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0x18(%rbp),%eax
jg     1175 <writemsg+0x65>
mov    -0x8(%rbp),%rdi
movsbl -0x11(%rbp),%edx
lea    0xea6(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    1145 <writemsg+0x35>
mov    -0x8(%rbp),%rdi
lea    0xe89(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<writemsg>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %ecx,%ebp
mov    %edx,%r14d
mov    %rsi,%rdx
mov    %rdi,%r15
lea    0xec7(%rip),%rsi
xor    %eax,%eax
call   1040 <fprintf@plt>
test   %ebp,%ebp
jle    115f <writemsg+0x3f>
movsbl %r14b,%ebx
nopl   0x0(%rax,%rax,1)
mov    %ebx,%edi
mov    %r15,%rsi
call   1030 <fputc@plt>
add    $0xffffffff,%ebp
jne    1150 <writemsg+0x30>
mov    $0xa,%edi
mov    %r15,%rsi
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <fputc@plt>

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

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