#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 uint32_t;

/* Variables and functions */
int /*<<< orphan*/ json_build(char *, char **, int *, int);
scalar_t__ malloc(int);
int /*<<< orphan*/ printf(char *, char *);
int main(void) {
  char *buff;
  char *toks[12];
  char *name[10] = {"v1", "v2", "v3"};
  uint32_t val[10] = {1, 2, 3};
  buff = (char *)malloc(512);
  json_build(buff, name, val, 3);
  printf("%s\n", buff);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0xf0,%rsp
movl   $0x0,-0x4(%rbp)
lea    -0xc0(%rbp),%rdi
xor    %esi,%esi
mov    $0x50,%edx
call   1040 <memset@plt>
lea    0xe94(%rip),%rax
mov    %rax,-0xc0(%rbp)
lea    0xe89(%rip),%rax
mov    %rax,-0xb8(%rbp)
lea    0xe7e(%rip),%rax
mov    %rax,-0xb0(%rbp)
lea    -0xf0(%rbp),%rdi
xor    %esi,%esi
mov    $0x28,%edx
call   1040 <memset@plt>
movl   $0x1,-0xf0(%rbp)
movl   $0x2,-0xec(%rbp)
movl   $0x3,-0xe8(%rbp)
mov    $0x200,%edi
call   1050 <malloc@plt>
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
lea    -0xc0(%rbp),%rsi
lea    -0xf0(%rbp),%rdx
mov    $0x3,%ecx
call   1060 <json_build@plt>
mov    -0x10(%rbp),%rsi
lea    0xe14(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0xf0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x80,%rsp
xorps  %xmm0,%xmm0
movaps %xmm0,0x40(%rsp)
movaps %xmm0,0x70(%rsp)
movaps %xmm0,0x60(%rsp)
movaps %xmm0,0x50(%rsp)
lea    0xeaa(%rip),%rax
mov    %rax,0x30(%rsp)
lea    0xea1(%rip),%rax
mov    %rax,0x38(%rsp)
lea    0xe98(%rip),%rax
mov    %rax,0x40(%rsp)
movaps %xmm0,(%rsp)
movaps %xmm0,0x10(%rsp)
movq   $0x0,0x20(%rsp)
movabs $0x200000001,%rax
mov    %rax,(%rsp)
movl   $0x3,0x8(%rsp)
mov    $0x200,%edi
call   1040 <malloc@plt>
mov    %rax,%rbx
lea    0x30(%rsp),%rsi
mov    %rsp,%rdx
mov    %rax,%rdi
mov    $0x3,%ecx
call   1050 <json_build@plt>
lea    0xe45(%rip),%rdi
mov    %rbx,%rsi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x80,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [3 x i8] c"v1\00"
@.str.1 = [3 x i8] c"v2\00"
@.str.2 = [3 x i8] c"v3\00"
@.str.3 = [4 x i8] c"%s\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i8*
%3 = alloca [12 x i8*]
%4 = alloca [10 x i8*]
%5 = alloca [10 x i32]
store i32 0, i32* %1
%6 = bitcast [10 x i8*]* %4 to i8*
%7 = bitcast i8* %6 to [10 x i8*]*
%8 = getelementptr inbounds [10 x i8*], [10 x i8*]* %7, i32 0, i32 0
store i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i32 0, i32 0), i8** %8
%9 = getelementptr inbounds [10 x i8*], [10 x i8*]* %7, i32 0, i32 1
store i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i32 0, i32 0), i8** %9
%10 = getelementptr inbounds [10 x i8*], [10 x i8*]* %7, i32 0, i32 2
store i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i32 0, i32 0), i8** %10
%11 = bitcast [10 x i32]* %5 to i8*
%12 = bitcast i8* %11 to [10 x i32]*
%13 = getelementptr inbounds [10 x i32], [10 x i32]* %12, i32 0, i32 0
store i32 1, i32* %13
%14 = getelementptr inbounds [10 x i32], [10 x i32]* %12, i32 0, i32 1
store i32 2, i32* %14
%15 = getelementptr inbounds [10 x i32], [10 x i32]* %12, i32 0, i32 2
store i32 3, i32* %15
%16 = call i64 @malloc(i32 512)
%17 = inttoptr i64 %16 to i8*
store i8* %17, i8** %2
%18 = load i8*, i8** %2
%19 = getelementptr inbounds [10 x i8*], [10 x i8*]* %4, i64 0, i64 0
%20 = getelementptr inbounds [10 x i32], [10 x i32]* %5, i64 0, i64 0
%21 = call i32 @json_build(i8* %18, i8** %19, i32* %20, i32 3)
%22 = load i8*, i8** %2
%23 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i8* %22)
ret i32 0
}

LLVM IR (-O2):
@.str = [3 x i8] c"v1\00"
@.str.1 = [3 x i8] c"v2\00"
@.str.2 = [3 x i8] c"v3\00"
@.str.3 = [4 x i8] c"%s\0A\00"
define i32 @main() {
%1 = alloca [10 x i8*]
%2 = alloca [10 x i32]
%3 = bitcast [10 x i8*]* %1 to i8*
%4 = getelementptr inbounds [10 x i8*], [10 x i8*]* %1, i64 0, i64 2
%5 = bitcast i8** %4 to i8*
%6 = getelementptr inbounds [10 x i8*], [10 x i8*]* %1, i64 0, i64 0
store i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8** %6
%7 = getelementptr inbounds [10 x i8*], [10 x i8*]* %1, i64 0, i64 1
store i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8** %7
%8 = getelementptr inbounds [10 x i8*], [10 x i8*]* %1, i64 0, i64 2
store i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i8** %8
%9 = bitcast [10 x i32]* %2 to i8*
%10 = getelementptr inbounds [10 x i32], [10 x i32]* %2, i64 0, i64 0
store i32 1, i32* %10
%11 = getelementptr inbounds [10 x i32], [10 x i32]* %2, i64 0, i64 1
store i32 2, i32* %11
%12 = getelementptr inbounds [10 x i32], [10 x i32]* %2, i64 0, i64 2
store i32 3, i32* %12
%13 = tail call i64 @malloc(i32 512)
%14 = inttoptr i64 %13 to i8*
%15 = call i32 @json_build(i8* %14, i8** %6, i32* %10, i32 3)
%16 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i8* %14)
ret i32 0
}