#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 fix_string_quote(char *, char *, int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/ *, char *, char *, char *);
void put_def_string(FILE *fp, char *name, char *val0) {
  int len;
  char val[46 + 3];
  len = fix_string_quote(val0, val, 46 + 2);
  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    $0x50,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
lea    -0x50(%rbp),%rsi
mov    $0x30,%edx
call   1030 <fix_string_quote@plt>
mov    %eax,-0x1c(%rbp)
cmpl   $0x2e,-0x1c(%rbp)
jle    116a <put_def_string+0x4a>
movb   $0x0,-0x22(%rbp)
movb   $0x2e,-0x23(%rbp)
movb   $0x2e,-0x24(%rbp)
movb   $0x2e,-0x25(%rbp)
movl   $0x2e,-0x1c(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rdx
lea    -0x50(%rbp),%rcx
lea    0xe83(%rip),%rsi
call   1040 <fprintf@plt>
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<put_def_string>:
push   %r14
push   %rbx
sub    $0x38,%rsp
mov    %rsi,%r14
mov    %rdi,%rbx
mov    %rsp,%rsi
mov    %rdx,%rdi
mov    $0x30,%edx
call   1030 <fix_string_quote@plt>
cmp    $0x2f,%eax
jl     114a <put_def_string+0x2a>
movl   $0x2e2e2e,0x2b(%rsp)
lea    0xeaf(%rip),%rsi
mov    %rsp,%rcx
mov    %rbx,%rdi
mov    %r14,%rdx
call   1040 <fprintf@plt>
add    $0x38,%rsp
pop    %rbx
pop    %r14
ret

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
%8 = alloca [49 x i8]
store i32* %0, i32** %4
store i8* %1, i8** %5
store i8* %2, i8** %6
%9 = load i8*, i8** %6
%10 = getelementptr inbounds [49 x i8], [49 x i8]* %8, i64 0, i64 0
%11 = call i32 @fix_string_quote(i8* %9, i8* %10, i32 48)
store i32 %11, i32* %7
%12 = load i32, i32* %7
%13 = icmp sgt i32 %12, 46
br i1 %13, label %14, label %19
14: ; preds = %3
%15 = getelementptr inbounds [49 x i8], [49 x i8]* %8, i64 0, i64 46
store i8 0, i8* %15
%16 = getelementptr inbounds [49 x i8], [49 x i8]* %8, i64 0, i64 45
store i8 46, i8* %16
%17 = getelementptr inbounds [49 x i8], [49 x i8]* %8, i64 0, i64 44
store i8 46, i8* %17
%18 = getelementptr inbounds [49 x i8], [49 x i8]* %8, i64 0, i64 43
store i8 46, i8* %18
store i32 46, i32* %7
br label %19
19: ; preds = %14, %3
%20 = load i32*, i32** %4
%21 = load i8*, i8** %5
%22 = getelementptr inbounds [49 x i8], [49 x i8]* %8, i64 0, i64 0
%23 = call i32 @fprintf(i32* %20, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0), i8* %21, i8* %22)
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 = alloca [49 x i8]
%5 = getelementptr inbounds [49 x i8], [49 x i8]* %4, i64 0, i64 0
%6 = call i32 @fix_string_quote(i8* %2, i8* %5, i32 48)
%7 = icmp sgt i32 %6, 46
br i1 %7, label %8, label %13
8: ; preds = %3
%9 = getelementptr inbounds [49 x i8], [49 x i8]* %4, i64 0, i64 46
store i8 0, i8* %9
%10 = getelementptr inbounds [49 x i8], [49 x i8]* %4, i64 0, i64 45
store i8 46, i8* %10
%11 = getelementptr inbounds [49 x i8], [49 x i8]* %4, i64 0, i64 44
store i8 46, i8* %11
%12 = getelementptr inbounds [49 x i8], [49 x i8]* %4, i64 0, i64 43
store i8 46, i8* %12
br label %13
13: ; preds = %8, %3
%14 = call i32 @fprintf(i32* %0, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0), i8* %1, i8* %5)
ret void
}