#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 */
char *C_mkDefine(char *, char *);
char *UTIL_mallocStr(size_t);
int /*<<< orphan*/ free(char *);
int /*<<< orphan*/ strcat(char *, char *);
int /*<<< orphan*/ strcpy(char *, char *);
int strlen(char *);
char *C_mkNumConsts(char *num) {
  char *def = C_mkDefine("PERV_CONST_NUM", num);
  size_t length =
      strlen(def) + strlen("//total number pervasive constants\n") + 5;
  char *numConsts = UTIL_mallocStr(length);
  strcpy(numConsts, "//total number pervasive constants\n");
  strcat(numConsts, def);
  free(def);
  strcat(numConsts, "\n\n");
  return numConsts;
}


x86 assembly (clang, -O0):
<C_mkNumConsts>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rsi
lea    0xe89(%rip),%rdi
call   1050 <C_mkDefine@plt>
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
call   1060 <strlen@plt>
mov    %eax,-0x24(%rbp)
lea    0xe7c(%rip),%rdi
call   1060 <strlen@plt>
mov    %eax,%ecx
mov    -0x24(%rbp),%eax
add    %ecx,%eax
add    $0x5,%eax
cltq
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
call   1070 <UTIL_mallocStr@plt>
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rdi
lea    0xe4f(%rip),%rsi
call   1040 <strcpy@plt>
mov    -0x20(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1080 <strcat@plt>
mov    -0x10(%rbp),%rdi
call   1030 <free@plt>
mov    -0x20(%rbp),%rdi
lea    0xe4d(%rip),%rsi
call   1080 <strcat@plt>
mov    -0x20(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<C_mkNumConsts>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    %rdi,%rsi
lea    0xe8e(%rip),%rdi
call   1050 <C_mkDefine@plt>
mov    %rax,%r12
mov    %rax,%rdi
call   1060 <strlen@plt>
mov    %eax,%r14d
lea    0xe83(%rip),%r15
mov    %r15,%rdi
call   1060 <strlen@plt>
add    %r14d,%eax
add    $0x5,%eax
movslq %eax,%rdi
call   1070 <UTIL_mallocStr@plt>
mov    %rax,%rbx
mov    %rax,%rdi
mov    %r15,%rsi
call   1040 <strcpy@plt>
mov    %rbx,%rdi
mov    %r12,%rsi
call   1080 <strcat@plt>
mov    %r12,%rdi
call   1030 <free@plt>
lea    0xe69(%rip),%rsi
mov    %rbx,%rdi
call   1080 <strcat@plt>
mov    %rbx,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [15 x i8] c"PERV_CONST_NUM\00"
@.str.1 = [36 x i8] c"//total number pervasive constants\0A\00"
@.str.2 = [3 x i8] c"\0A\0A\00"
define i8* @C_mkNumConsts(i8* %0) {
%2 = alloca i8*
%3 = alloca i8*
%4 = alloca i64
%5 = alloca i8*
store i8* %0, i8** %2
%6 = load i8*, i8** %2
%7 = call i8* @C_mkDefine(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0), i8* %6)
store i8* %7, i8** %3
%8 = load i8*, i8** %3
%9 = call i32 @strlen(i8* %8)
%10 = call i32 @strlen(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.1, i64 0, i64 0))
%11 = add nsw i32 %9, %10
%12 = add nsw i32 %11, 5
%13 = sext i32 %12 to i64
store i64 %13, i64* %4
%14 = load i64, i64* %4
%15 = call i8* @UTIL_mallocStr(i64 %14)
store i8* %15, i8** %5
%16 = load i8*, i8** %5
%17 = call i32 @strcpy(i8* %16, i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.1, i64 0, i64 0))
%18 = load i8*, i8** %5
%19 = load i8*, i8** %3
%20 = call i32 @strcat(i8* %18, i8* %19)
%21 = load i8*, i8** %3
%22 = call i32 @free(i8* %21)
%23 = load i8*, i8** %5
%24 = call i32 @strcat(i8* %23, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
%25 = load i8*, i8** %5
ret i8* %25
}

LLVM IR (-O2):
@.str = [15 x i8] c"PERV_CONST_NUM\00"
@.str.1 = [36 x i8] c"//total number pervasive constants\0A\00"
@.str.2 = [3 x i8] c"\0A\0A\00"
define i8* @C_mkNumConsts(i8* %0) {
%2 = tail call i8* @C_mkDefine(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0), i8* %0)
%3 = tail call i32 @strlen(i8* %2)
%4 = tail call i32 @strlen(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.1, i64 0, i64 0))
%5 = add i32 %3, 5
%6 = add i32 %5, %4
%7 = sext i32 %6 to i64
%8 = tail call i8* @UTIL_mallocStr(i64 %7)
%9 = tail call i32 @strcpy(i8* %8, i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.1, i64 0, i64 0))
%10 = tail call i32 @strcat(i8* %8, i8* %2)
%11 = tail call i32 @free(i8* %2)
%12 = tail call i32 @strcat(i8* %8, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
ret i8* %8
}