#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 *);
int /*<<< orphan*/ write_named_array_i32(int /*<<< orphan*/ *, char *,
                                         int const *, unsigned int const);
void write_data_as_json(FILE *f, const int *a, const int *b, const int *y,
                        const unsigned int len) {
  fprintf(f, "{");
  write_named_array_i32(f, "a", a, len);
  fprintf(f, ",");
  write_named_array_i32(f, "b", b, len);
  fprintf(f, ",");
  write_named_array_i32(f, "expected", y, len);
  fprintf(f, "}");
}


x86 assembly (clang, -O0):
<write_data_as_json>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    %r8d,-0x24(%rbp)
mov    -0x8(%rbp),%rdi
lea    0xeb9(%rip),%rsi
call   1030 <fprintf@plt>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rdx
mov    -0x24(%rbp),%ecx
lea    0xea4(%rip),%rsi
call   1040 <write_named_array_i32@plt>
mov    -0x8(%rbp),%rdi
lea    0xe96(%rip),%rsi
call   1030 <fprintf@plt>
mov    -0x8(%rbp),%rdi
mov    -0x18(%rbp),%rdx
mov    -0x24(%rbp),%ecx
lea    0xe81(%rip),%rsi
call   1040 <write_named_array_i32@plt>
mov    -0x8(%rbp),%rdi
lea    0xe6f(%rip),%rsi
call   1030 <fprintf@plt>
mov    -0x8(%rbp),%rdi
mov    -0x20(%rbp),%rdx
mov    -0x24(%rbp),%ecx
lea    0xe5c(%rip),%rsi
call   1040 <write_named_array_i32@plt>
mov    -0x8(%rbp),%rdi
lea    0xe55(%rip),%rsi
call   1030 <fprintf@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<write_data_as_json>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %r8d,%ebp
mov    %rcx,%r14
mov    %rdx,%r15
mov    %rsi,%r12
mov    %rdi,%rbx
mov    $0x7b,%edi
mov    %rbx,%rsi
call   1030 <fputc@plt>
lea    0xeb5(%rip),%rsi
mov    %rbx,%rdi
mov    %r12,%rdx
mov    %ebp,%ecx
call   1040 <write_named_array_i32@plt>
mov    $0x2c,%edi
mov    %rbx,%rsi
call   1030 <fputc@plt>
lea    0xe96(%rip),%rsi
mov    %rbx,%rdi
mov    %r15,%rdx
mov    %ebp,%ecx
call   1040 <write_named_array_i32@plt>
mov    $0x2c,%edi
mov    %rbx,%rsi
call   1030 <fputc@plt>
lea    0xe77(%rip),%rsi
mov    %rbx,%rdi
mov    %r14,%rdx
mov    %ebp,%ecx
call   1040 <write_named_array_i32@plt>
mov    $0x7d,%edi
mov    %rbx,%rsi
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <fputc@plt>

LLVM IR (-O0):
@.str = [2 x i8] c"{\00"
@.str.1 = [2 x i8] c"a\00"
@.str.2 = [2 x i8] c",\00"
@.str.3 = [2 x i8] c"b\00"
@.str.4 = [9 x i8] c"expected\00"
@.str.5 = [2 x i8] c"}\00"
define void @write_data_as_json(i32* %0, i32* %1, i32* %2, i32* %3, i32 %4) {
%6 = alloca i32*
%7 = alloca i32*
%8 = alloca i32*
%9 = alloca i32*
%10 = alloca i32
store i32* %0, i32** %6
store i32* %1, i32** %7
store i32* %2, i32** %8
store i32* %3, i32** %9
store i32 %4, i32* %10
%11 = load i32*, i32** %6
%12 = call i32 @fprintf(i32* %11, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%13 = load i32*, i32** %6
%14 = load i32*, i32** %7
%15 = load i32, i32* %10
%16 = call i32 @write_named_array_i32(i32* %13, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0), i32* %14, i32 %15)
%17 = load i32*, i32** %6
%18 = call i32 @fprintf(i32* %17, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%19 = load i32*, i32** %6
%20 = load i32*, i32** %8
%21 = load i32, i32* %10
%22 = call i32 @write_named_array_i32(i32* %19, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0), i32* %20, i32 %21)
%23 = load i32*, i32** %6
%24 = call i32 @fprintf(i32* %23, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%25 = load i32*, i32** %6
%26 = load i32*, i32** %9
%27 = load i32, i32* %10
%28 = call i32 @write_named_array_i32(i32* %25, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.4, i64 0, i64 0), i32* %26, i32 %27)
%29 = load i32*, i32** %6
%30 = call i32 @fprintf(i32* %29, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0))
ret void
}

LLVM IR (-O2):
@.str.1 = [2 x i8] c"a\00"
@.str.3 = [2 x i8] c"b\00"
@.str.4 = [9 x i8] c"expected\00"
define void @write_data_as_json(i32* %0, i32* %1, i32* %2, i32* %3, i32 %4) {
%6 = tail call i32 @fputc(i32 123, i32* %0)
%7 = tail call i32 @write_named_array_i32(i32* %0, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0), i32* %1, i32 %4)
%8 = tail call i32 @fputc(i32 44, i32* %0)
%9 = tail call i32 @write_named_array_i32(i32* %0, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0), i32* %2, i32 %4)
%10 = tail call i32 @fputc(i32 44, i32* %0)
%11 = tail call i32 @write_named_array_i32(i32* %0, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.4, i64 0, i64 0), i32* %3, i32 %4)
%12 = tail call i32 @fputc(i32 125, i32* %0)
ret void
}