#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 *, char *);
int strlen(char *);
void put_def_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, "#define %s \"%s\"\n", name, val);
}


x86 assembly (clang, -O0):
<put_def_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_def_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    -0x10(%rbp),%rdx
mov    -0x18(%rbp),%rcx
lea    0xe7c(%rip),%rsi
call   1040 <fprintf@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<put_def_string>:
push   %r15
push   %r14
push   %rbx
mov    %rdx,%rbx
mov    %rsi,%r14
mov    %rdi,%r15
mov    %rdx,%rdi
call   1030 <strlen@plt>
cmp    $0x2f,%eax
jl     1142 <put_def_string+0x22>
movl   $0x2e2e2e,0x2b(%rbx)
lea    0xeb7(%rip),%rsi
mov    %r15,%rdi
mov    %r14,%rdx
mov    %rbx,%rcx
pop    %rbx
pop    %r14
pop    %r15
jmp    1040 <fprintf@plt>

LLVM IR (-O0):
@.str = [17 x i8] c"#define %s \22%s\22\0A\00"
define void @put_def_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 i8*, i8** %5
%24 = load i8*, i8** %6
%25 = call i32 @fprintf(i32* %22, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0), i8* %23, i8* %24)
ret void
}

LLVM IR (-O2):
@.str = [17 x i8] c"#define %s \22%s\22\0A\00"
define void @put_def_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 = tail call i32 @fprintf(i32* %0, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0), i8* %1, i8* %2)
ret void
}