#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 */
struct json_writer {
  int dummy;
};
typedef scalar_t__ int64_t;

/* Variables and functions */
int /*<<< orphan*/ json_emits(struct json_writer *, char *);
int /*<<< orphan*/ json_value_end(struct json_writer *);
int /*<<< orphan*/ json_value_start(struct json_writer *);
int /*<<< orphan*/ sprintf(char *, char *, long long);
void json_emit_i64(struct json_writer *writer, int64_t number) {
  char buf[sizeof("-18446744073709551616")];
  sprintf(buf, "%lld", (long long)number);
  json_value_start(writer);
  json_emits(writer, buf);
  json_value_end(writer);
}


x86 assembly (clang, -O0):
<json_emit_i64>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    -0x30(%rbp),%rdi
mov    -0x10(%rbp),%rdx
lea    0xea1(%rip),%rsi
call   1050 <sprintf@plt>
mov    -0x8(%rbp),%rdi
call   1030 <json_value_start@plt>
mov    -0x8(%rbp),%rdi
lea    -0x30(%rbp),%rsi
call   1040 <json_emits@plt>
mov    -0x8(%rbp),%rdi
call   1060 <json_value_end@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<json_emit_i64>:
push   %r14
push   %rbx
sub    $0x18,%rsp
mov    %rsi,%rdx
mov    %rdi,%rbx
lea    0xeac(%rip),%rsi
mov    %rsp,%r14
mov    %r14,%rdi
call   1050 <sprintf@plt>
mov    %rbx,%rdi
call   1030 <json_value_start@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
call   1040 <json_emits@plt>
mov    %rbx,%rdi
call   1060 <json_value_end@plt>
add    $0x18,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
%struct.json_writer = type { i32 }
@.str = [5 x i8] c"%lld\00"
define void @json_emit_i64(%struct.json_writer* %0, i64 %1) {
%3 = alloca %struct.json_writer*
%4 = alloca i64
%5 = alloca [22 x i8]
store %struct.json_writer* %0, %struct.json_writer** %3
store i64 %1, i64* %4
%6 = getelementptr inbounds [22 x i8], [22 x i8]* %5, i64 0, i64 0
%7 = load i64, i64* %4
%8 = call i32 @sprintf(i8* %6, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i64 %7)
%9 = load %struct.json_writer*, %struct.json_writer** %3
%10 = call i32 @json_value_start(%struct.json_writer* %9)
%11 = load %struct.json_writer*, %struct.json_writer** %3
%12 = getelementptr inbounds [22 x i8], [22 x i8]* %5, i64 0, i64 0
%13 = call i32 @json_emits(%struct.json_writer* %11, i8* %12)
%14 = load %struct.json_writer*, %struct.json_writer** %3
%15 = call i32 @json_value_end(%struct.json_writer* %14)
ret void
}

LLVM IR (-O2):
%struct.json_writer = type { i32 }
@.str = [5 x i8] c"%lld\00"
define void @json_emit_i64(%struct.json_writer* %0, i64 %1) {
%3 = alloca [22 x i8]
%4 = getelementptr inbounds [22 x i8], [22 x i8]* %3, i64 0, i64 0
%5 = call i32 @sprintf(i8* %4, i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i64 %1)
%6 = tail call i32 @json_value_start(%struct.json_writer* %0)
%7 = call i32 @json_emits(%struct.json_writer* %0, i8* %4)
%8 = call i32 @json_value_end(%struct.json_writer* %0)
ret void
}