#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 */
int /*<<< orphan*/ add_action(char *);
int /*<<< orphan*/ format_pinpoint_message(char *, char const *);
int /*<<< orphan*/ sprintf(char *, char *, char const *, int);
scalar_t__ strlen(char const *);
void action_define(const char *defname, int value) {
  char buf[2048];
  if ((int)strlen(defname) > 2048 / 2) {
    format_pinpoint_message(("name \"%s\" ridiculously long"), defname);
    return;
  }
  sprintf(buf, "#define %s %d\n", defname, value);
  add_action(buf);
}


x86 assembly (clang, -O0):
<action_define>:
push   %rbp
mov    %rsp,%rbp
sub    $0x810,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    -0x8(%rbp),%rdi
call   1030 <strlen@plt>
cmp    $0x400,%eax
jle    117b <action_define+0x3b>
mov    -0x8(%rbp),%rsi
lea    0xe8f(%rip),%rdi
call   1040 <format_pinpoint_message@plt>
jmp    11a1 <action_define+0x61>
lea    -0x810(%rbp),%rdi
mov    -0x8(%rbp),%rdx
mov    -0xc(%rbp),%ecx
lea    0xe8c(%rip),%rsi
call   1050 <sprintf@plt>
lea    -0x810(%rbp),%rdi
call   1060 <add_action@plt>
add    $0x810,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<action_define>:
push   %rbp
push   %r14
push   %rbx
sub    $0x800,%rsp
mov    %esi,%ebp
mov    %rdi,%rbx
call   1030 <strlen@plt>
cmp    $0x401,%eax
jl     1176 <action_define+0x36>
lea    0xe9d(%rip),%rdi
mov    %rbx,%rsi
add    $0x800,%rsp
pop    %rbx
pop    %r14
pop    %rbp
jmp    1040 <format_pinpoint_message@plt>
lea    0xe9f(%rip),%rsi
mov    %rsp,%r14
mov    %r14,%rdi
mov    %rbx,%rdx
mov    %ebp,%ecx
call   1050 <sprintf@plt>
mov    %r14,%rdi
call   1060 <add_action@plt>
add    $0x800,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@.str = [28 x i8] c"name \22%s\22 ridiculously long\00"
@.str.1 = [15 x i8] c"#define %s %d\0A\00"
define void @action_define(i8* %0, i32 %1) {
%3 = alloca i8*
%4 = alloca i32
%5 = alloca [2048 x i8]
store i8* %0, i8** %3
store i32 %1, i32* %4
%6 = load i8*, i8** %3
%7 = call i64 @strlen(i8* %6)
%8 = trunc i64 %7 to i32
%9 = icmp sgt i32 %8, 1024
br i1 %9, label %10, label %13
10: ; preds = %2
%11 = load i8*, i8** %3
%12 = call i32 @format_pinpoint_message(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str, i64 0, i64 0), i8* %11)
br label %20
13: ; preds = %2
%14 = getelementptr inbounds [2048 x i8], [2048 x i8]* %5, i64 0, i64 0
%15 = load i8*, i8** %3
%16 = load i32, i32* %4
%17 = call i32 @sprintf(i8* %14, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.1, i64 0, i64 0), i8* %15, i32 %16)
%18 = getelementptr inbounds [2048 x i8], [2048 x i8]* %5, i64 0, i64 0
%19 = call i32 @add_action(i8* %18)
br label %20
20: ; preds = %13, %10
ret void
}

LLVM IR (-O2):
@.str = [28 x i8] c"name \22%s\22 ridiculously long\00"
@.str.1 = [15 x i8] c"#define %s %d\0A\00"
define void @action_define(i8* %0, i32 %1) {
%3 = alloca [2048 x i8]
%4 = getelementptr inbounds [2048 x i8], [2048 x i8]* %3, i64 0, i64 0
%5 = tail call i64 @strlen(i8* dereferenceable(1) %0)
%6 = trunc i64 %5 to i32
%7 = icmp sgt i32 %6, 1024
br i1 %7, label %8, label %10
8: ; preds = %2
%9 = tail call i32 @format_pinpoint_message(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str, i64 0, i64 0), i8* %0)
br label %13
10: ; preds = %2
%11 = call i32 @sprintf(i8* %4, i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @.str.1, i64 0, i64 0), i8* %0, i32 %1)
%12 = call i32 @add_action(i8* %4)
br label %13
13: ; preds = %10, %8
ret void
}