#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 *, char *, ...);
int strlen(char *);
void put_string(FILE *fp, char *name, char *val) {
  int len;
  len = strlen(val);
  if (len > 46) {
    val[46] = '\0';
    val[46 - 1] = '.';
    val[46 - 2] = '.';
    val[46 - 3] = '.';
    len = 46;
  }
  fprintf(fp, "%scharacter*%d %s\n", "        ", len, name);
  fprintf(fp, "%sparameter (%s=\'%s\')\n", "        ", name, val);
}


x86 assembly (clang, -O0):
<put_string>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,-0x1c(%rbp)
cmpl   $0x2e,-0x1c(%rbp)
jle    1171 <put_string+0x51>
mov    -0x18(%rbp),%rax
movb   $0x0,0x2e(%rax)
mov    -0x18(%rbp),%rax
movb   $0x2e,0x2d(%rax)
mov    -0x18(%rbp),%rax
movb   $0x2e,0x2c(%rax)
mov    -0x18(%rbp),%rax
movb   $0x2e,0x2b(%rax)
movl   $0x2e,-0x1c(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x1c(%rbp),%ecx
mov    -0x10(%rbp),%r8
lea    0xe7d(%rip),%rsi
lea    0xe89(%rip),%rdx
mov    $0x0,%al
call   1040 <fprintf@plt>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rcx
mov    -0x18(%rbp),%r8
lea    0xe78(%rip),%rsi
lea    0xe68(%rip),%rdx
mov    $0x0,%al
call   1040 <fprintf@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<put_string>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    %rdx,%rbx
mov    %rsi,%r14
mov    %rdi,%r15
mov    %rdx,%rdi
call   1030 <strlen@plt>
cmp    $0x2f,%eax
jl     114a <put_string+0x2a>
movl   $0x2e2e2e,0x2b(%rbx)
mov    $0x2e,%eax
lea    0xeaf(%rip),%rsi
lea    0xebb(%rip),%r12
mov    %r15,%rdi
mov    %r12,%rdx
mov    %eax,%ecx
mov    %r14,%r8
xor    %eax,%eax
call   1040 <fprintf@plt>
lea    0xeab(%rip),%rsi
mov    %r15,%rdi
mov    %r12,%rdx
mov    %r14,%rcx
mov    %rbx,%r8
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
jmp    1040 <fprintf@plt>

LLVM IR (-O0):
@.str = [19 x i8] c"%scharacter*%d %s\0A\00"
@.str.1 = [9 x i8] c" \00"
@.str.2 = [23 x i8] c"%sparameter (%s='%s')\0A\00"
define void @put_string(i32* %0, i8* %1, i8* %2) {
%4 = alloca i32*
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca i32
store i32* %0, i32** %4
store i8* %1, i8** %5
store i8* %2, i8** %6
%8 = load i8*, i8** %6
%9 = call i32 @strlen(i8* %8)
store i32 %9, i32* %7
%10 = load i32, i32* %7
%11 = icmp sgt i32 %10, 46
br i1 %11, label %12, label %21
12: ; preds = %3
%13 = load i8*, i8** %6
%14 = getelementptr inbounds i8, i8* %13, i64 46
store i8 0, i8* %14
%15 = load i8*, i8** %6
%16 = getelementptr inbounds i8, i8* %15, i64 45
store i8 46, i8* %16
%17 = load i8*, i8** %6
%18 = getelementptr inbounds i8, i8* %17, i64 44
store i8 46, i8* %18
%19 = load i8*, i8** %6
%20 = getelementptr inbounds i8, i8* %19, i64 43
store i8 46, i8* %20
store i32 46, i32* %7
br label %21
21: ; preds = %12, %3
%22 = load i32*, i32** %4
%23 = load i32, i32* %7
%24 = load i8*, i8** %5
%25 = call i32 (i32*, i8*, i8*, ...) @fprintf(i32* %22, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), i32 %23, i8* %24)
%26 = load i32*, i32** %4
%27 = load i8*, i8** %5
%28 = load i8*, i8** %6
%29 = call i32 (i32*, i8*, i8*, ...) @fprintf(i32* %26, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), i8* %27, i8* %28)
ret void
}

LLVM IR (-O2):
@.str = [19 x i8] c"%scharacter*%d %s\0A\00"
@.str.1 = [9 x i8] c" \00"
@.str.2 = [23 x i8] c"%sparameter (%s='%s')\0A\00"
define void @put_string(i32* nocapture %0, i8* %1, i8* %2) {
%4 = tail call i32 @strlen(i8* %2)
%5 = icmp sgt i32 %4, 46
br i1 %5, label %6, label %11
6: ; preds = %3
%7 = getelementptr inbounds i8, i8* %2, i64 46
store i8 0, i8* %7
%8 = getelementptr inbounds i8, i8* %2, i64 45
store i8 46, i8* %8
%9 = getelementptr inbounds i8, i8* %2, i64 44
store i8 46, i8* %9
%10 = getelementptr inbounds i8, i8* %2, i64 43
store i8 46, i8* %10
br label %11
11: ; preds = %6, %3
%12 = phi i32 [ 46, %6 ], [ %4, %3 ]
%13 = tail call i32 (i32*, i8*, i8*, ...) @fprintf(i32* %0, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), i32 %12, i8* %1)
%14 = tail call i32 (i32*, i8*, i8*, ...) @fprintf(i32* %0, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), i8* %1, i8* %2)
ret void
}