#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*/ mem;

/* Variables and functions */
int /*<<< orphan*/ mem_use(char *, int);
int /*<<< orphan*/ printf(char *, char const *, ...);
void form_json_results(const char *name, long long iter, long long usec,
                       const char *err) {
  char mem[16];
  mem_use(mem, sizeof(mem));
  if (NULL != err) {
    printf("{\"name\":\"%s\",\"err\":\"%s\"}\n", name, err);
  } else {
    printf("{\"name\":\"%s\",\"usec\":%lld,\"iter\":%lld,\"mem\":\"%s\"}\n",
           name, usec, iter, mem);
  }
}


x86 assembly (clang, -O0):
<form_json_results>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
lea    -0x30(%rbp),%rdi
mov    $0x10,%esi
call   1030 <mem_use@plt>
xor    %eax,%eax
cmp    -0x20(%rbp),%rax
je     116d <form_json_results+0x4d>
mov    -0x8(%rbp),%rsi
mov    -0x20(%rbp),%rdx
lea    0xe9f(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    118b <form_json_results+0x6b>
mov    -0x8(%rbp),%rsi
mov    -0x18(%rbp),%rdx
mov    -0x10(%rbp),%rcx
lea    -0x30(%rbp),%r8
lea    0xe96(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<form_json_results>:
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %rcx,%rbx
mov    %rdx,%r15
mov    %rsi,%r14
mov    %rdi,%r12
mov    %rsp,%rdi
mov    $0x10,%esi
call   1030 <mem_use@plt>
test   %rbx,%rbx
je     115f <form_json_results+0x3f>
lea    0xeb0(%rip),%rdi
mov    %r12,%rsi
mov    %rbx,%rdx
xor    %eax,%eax
call   1040 <printf@plt>
jmp    1179 <form_json_results+0x59>
lea    0xeb4(%rip),%rdi
mov    %rsp,%r8
mov    %r12,%rsi
mov    %r15,%rdx
mov    %r14,%rcx
xor    %eax,%eax
call   1040 <printf@plt>
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [26 x i8] c"{\22name\22:\22%s\22,\22err\22:\22%s\22}\0A\00"
@.str.1 = [50 x i8] c"{\22name\22:\22%s\22,\22usec\22:%lld,\22iter\22:%lld,\22mem\22:\22%s\22}\0A\00"
define void @form_json_results(i8* %0, i64 %1, i64 %2, i8* %3) {
%5 = alloca i8*
%6 = alloca i64
%7 = alloca i64
%8 = alloca i8*
%9 = alloca [16 x i8]
store i8* %0, i8** %5
store i64 %1, i64* %6
store i64 %2, i64* %7
store i8* %3, i8** %8
%10 = getelementptr inbounds [16 x i8], [16 x i8]* %9, i64 0, i64 0
%11 = call i32 @mem_use(i8* %10, i32 16)
%12 = load i8*, i8** %8
%13 = icmp ne i8* null, %12
br i1 %13, label %14, label %18
14: ; preds = %4
%15 = load i8*, i8** %5
%16 = load i8*, i8** %8
%17 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str, i64 0, i64 0), i8* %15, i8* %16)
br label %24
18: ; preds = %4
%19 = load i8*, i8** %5
%20 = load i64, i64* %7
%21 = load i64, i64* %6
%22 = getelementptr inbounds [16 x i8], [16 x i8]* %9, i64 0, i64 0
%23 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([50 x i8], [50 x i8]* @.str.1, i64 0, i64 0), i8* %19, i64 %20, i64 %21, i8* %22)
br label %24
24: ; preds = %18, %14
ret void
}

LLVM IR (-O2):
@.str = [26 x i8] c"{\22name\22:\22%s\22,\22err\22:\22%s\22}\0A\00"
@.str.1 = [50 x i8] c"{\22name\22:\22%s\22,\22usec\22:%lld,\22iter\22:%lld,\22mem\22:\22%s\22}\0A\00"
define void @form_json_results(i8* %0, i64 %1, i64 %2, i8* %3) {
%5 = alloca [16 x i8]
%6 = getelementptr inbounds [16 x i8], [16 x i8]* %5, i64 0, i64 0
%7 = call i32 @mem_use(i8* %6, i32 16)
%8 = icmp eq i8* %3, null
br i1 %8, label %11, label %9
9: ; preds = %4
%10 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str, i64 0, i64 0), i8* %0, i8* %3)
br label %13
11: ; preds = %4
%12 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([50 x i8], [50 x i8]* @.str.1, i64 0, i64 0), i8* %0, i64 %2, i64 %1, i8* %6)
br label %13
13: ; preds = %11, %9
ret void
}