#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*/ free(char *);
scalar_t__ json_util_allocStringByInteger(int const, char **);
int /*<<< orphan*/ printf(char *, int const, ...);
int /*<<< orphan*/ puts(char *);
void test_json_util_allocStringByInteger() {
  puts("Test json_util_allocStringByInteger");
  puts("======================================================================="
       "=========");
  const int a[] = {-1, 0, 1, 20, 3, 4, 100};
  int i;
  for (i = 0; i < 7; i++) {
    char *string;
    if (json_util_allocStringByInteger(a[i], &string) != 0) {
      printf("allocate string by integer (%d) failure\n", a[i]);
      continue;
    }
    printf("%d. %s\n", i + 1, string);
    free(string);
  }
  puts("======================================================================="
       "=========\n");
}


x86 assembly (clang, -O0):
<test_json_util_allocStringByInteger>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
lea    0xeb1(%rip),%rdi
call   1040 <puts@plt>
lea    0xec9(%rip),%rdi
call   1040 <puts@plt>
mov    0xf99(%rip),%rax
mov    %rax,-0x20(%rbp)
mov    0xf96(%rip),%rax
mov    %rax,-0x18(%rbp)
mov    0xf93(%rip),%rax
mov    %rax,-0x10(%rbp)
mov    0xf91(%rip),%eax
mov    %eax,-0x8(%rbp)
movl   $0x0,-0x24(%rbp)
cmpl   $0x7,-0x24(%rbp)
jge    1200 <test_json_util_allocStringByInteger+0xc0>
movslq -0x24(%rbp),%rax
mov    -0x20(%rbp,%rax,4),%edi
lea    -0x30(%rbp),%rsi
call   1060 <json_util_allocStringByInteger@plt>
cmp    $0x0,%rax
je     11d1 <test_json_util_allocStringByInteger+0x91>
movslq -0x24(%rbp),%rax
mov    -0x20(%rbp,%rax,4),%esi
lea    0xeb0(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
jmp    11f2 <test_json_util_allocStringByInteger+0xb2>
mov    -0x24(%rbp),%esi
add    $0x1,%esi
mov    -0x30(%rbp),%rdx
lea    0xebc(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x30(%rbp),%rdi
call   1030 <free@plt>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    1191 <test_json_util_allocStringByInteger+0x51>
lea    0xe9f(%rip),%rdi
call   1040 <puts@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<test_json_util_allocStringByInteger>:
push   %rax
lea    0xeb8(%rip),%rdi
call   1040 <puts@plt>
lea    0xed0(%rip),%rdi
call   1040 <puts@plt>
mov    %rsp,%rsi
mov    $0xffffffff,%edi
call   1060 <json_util_allocStringByInteger@plt>
test   %rax,%rax
je     1180 <test_json_util_allocStringByInteger+0x40>
lea    0xf03(%rip),%rdi
mov    $0xffffffff,%esi
xor    %eax,%eax
call   1050 <printf@plt>
jmp    11a0 <test_json_util_allocStringByInteger+0x60>
mov    (%rsp),%rdx
lea    0xf13(%rip),%rdi
mov    $0x1,%esi
xor    %eax,%eax
call   1050 <printf@plt>
mov    (%rsp),%rdi
call   1030 <free@plt>
mov    %rsp,%rsi
xor    %edi,%edi
call   1060 <json_util_allocStringByInteger@plt>
test   %rax,%rax
je     11c1 <test_json_util_allocStringByInteger+0x81>
lea    0xebf(%rip),%rdi
xor    %esi,%esi
xor    %eax,%eax
call   1050 <printf@plt>
jmp    11e1 <test_json_util_allocStringByInteger+0xa1>
mov    (%rsp),%rdx
lea    0xed2(%rip),%rdi
mov    $0x2,%esi
xor    %eax,%eax
call   1050 <printf@plt>
mov    (%rsp),%rdi
call   1030 <free@plt>
mov    %rsp,%rsi
mov    $0x1,%edi
call   1060 <json_util_allocStringByInteger@plt>
test   %rax,%rax
je     1208 <test_json_util_allocStringByInteger+0xc8>
lea    0xe7b(%rip),%rdi
mov    $0x1,%esi
xor    %eax,%eax
call   1050 <printf@plt>
jmp    1228 <test_json_util_allocStringByInteger+0xe8>
mov    (%rsp),%rdx
lea    0xe8b(%rip),%rdi
mov    $0x3,%esi
xor    %eax,%eax
call   1050 <printf@plt>
mov    (%rsp),%rdi
call   1030 <free@plt>
mov    %rsp,%rsi
mov    $0x14,%edi
call   1060 <json_util_allocStringByInteger@plt>
test   %rax,%rax
je     124f <test_json_util_allocStringByInteger+0x10f>
lea    0xe34(%rip),%rdi
mov    $0x14,%esi
xor    %eax,%eax
call   1050 <printf@plt>
jmp    126f <test_json_util_allocStringByInteger+0x12f>
mov    (%rsp),%rdx
lea    0xe44(%rip),%rdi
mov    $0x4,%esi
xor    %eax,%eax
call   1050 <printf@plt>
mov    (%rsp),%rdi
call   1030 <free@plt>
mov    %rsp,%rsi
mov    $0x3,%edi
call   1060 <json_util_allocStringByInteger@plt>
test   %rax,%rax
je     1296 <test_json_util_allocStringByInteger+0x156>
lea    0xded(%rip),%rdi
mov    $0x3,%esi
xor    %eax,%eax
call   1050 <printf@plt>
jmp    12b6 <test_json_util_allocStringByInteger+0x176>
mov    (%rsp),%rdx
lea    0xdfd(%rip),%rdi
mov    $0x5,%esi
xor    %eax,%eax
call   1050 <printf@plt>
mov    (%rsp),%rdi
call   1030 <free@plt>
mov    %rsp,%rsi
mov    $0x4,%edi
call   1060 <json_util_allocStringByInteger@plt>
test   %rax,%rax
je     12dd <test_json_util_allocStringByInteger+0x19d>
lea    0xda6(%rip),%rdi
mov    $0x4,%esi
xor    %eax,%eax
call   1050 <printf@plt>
jmp    12fd <test_json_util_allocStringByInteger+0x1bd>
mov    (%rsp),%rdx
lea    0xdb6(%rip),%rdi
mov    $0x6,%esi
xor    %eax,%eax
call   1050 <printf@plt>
mov    (%rsp),%rdi
call   1030 <free@plt>
mov    %rsp,%rsi
mov    $0x64,%edi
call   1060 <json_util_allocStringByInteger@plt>
test   %rax,%rax
je     1324 <test_json_util_allocStringByInteger+0x1e4>
lea    0xd5f(%rip),%rdi
mov    $0x64,%esi
xor    %eax,%eax
call   1050 <printf@plt>
jmp    1344 <test_json_util_allocStringByInteger+0x204>
mov    (%rsp),%rdx
lea    0xd6f(%rip),%rdi
mov    $0x7,%esi
xor    %eax,%eax
call   1050 <printf@plt>
mov    (%rsp),%rdi
call   1030 <free@plt>
lea    0xd5b(%rip),%rdi
call   1040 <puts@plt>
pop    %rax
ret

LLVM IR (-O0):
@.str = [36 x i8] c"Test json_util_allocStringByInteger\00"
@.str.1 = [81 x i8] c"================================================================================\00"
@__const.test_json_util_allocStringByInteger.a = [7 x i32] [i32 -1, i32 0, i32 1, i32 20, i32 3, i32 4, i32 100]
@.str.2 = [41 x i8] c"allocate string by integer (%d) failure\0A\00"
@.str.3 = [8 x i8] c"%d. %s\0A\00"
@.str.4 = [82 x i8] c"================================================================================\0A\00"
define void @test_json_util_allocStringByInteger() {
%1 = alloca [7 x i32]
%2 = alloca i32
%3 = alloca i8*
%4 = call i32 @puts(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str, i64 0, i64 0))
%5 = call i32 @puts(i8* getelementptr inbounds ([81 x i8], [81 x i8]* @.str.1, i64 0, i64 0))
%6 = bitcast [7 x i32]* %1 to i8*
store i32 0, i32* %2
br label %7
7: ; preds = %30, %0
%8 = load i32, i32* %2
%9 = icmp slt i32 %8, 7
br i1 %9, label %10, label %33
10: ; preds = %7
%11 = load i32, i32* %2
%12 = sext i32 %11 to i64
%13 = getelementptr inbounds [7 x i32], [7 x i32]* %1, i64 0, i64 %12
%14 = load i32, i32* %13
%15 = call i64 @json_util_allocStringByInteger(i32 %14, i8** %3)
%16 = icmp ne i64 %15, 0
br i1 %16, label %17, label %23
17: ; preds = %10
%18 = load i32, i32* %2
%19 = sext i32 %18 to i64
%20 = getelementptr inbounds [7 x i32], [7 x i32]* %1, i64 0, i64 %19
%21 = load i32, i32* %20
%22 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str.2, i64 0, i64 0), i32 %21)
br label %30
23: ; preds = %10
%24 = load i32, i32* %2
%25 = add nsw i32 %24, 1
%26 = load i8*, i8** %3
%27 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i64 0, i64 0), i32 %25, i8* %26)
%28 = load i8*, i8** %3
%29 = call i32 @free(i8* %28)
br label %30
30: ; preds = %23, %17
%31 = load i32, i32* %2
%32 = add nsw i32 %31, 1
store i32 %32, i32* %2
br label %7
33: ; preds = %7
%34 = call i32 @puts(i8* getelementptr inbounds ([82 x i8], [82 x i8]* @.str.4, i64 0, i64 0))
ret void
}

LLVM IR (-O2):
@.str = [36 x i8] c"Test json_util_allocStringByInteger\00"
@.str.1 = [81 x i8] c"================================================================================\00"
@.str.2 = [41 x i8] c"allocate string by integer (%d) failure\0A\00"
@.str.3 = [8 x i8] c"%d. %s\0A\00"
@.str.4 = [82 x i8] c"================================================================================\0A\00"
define void @test_json_util_allocStringByInteger() {
%1 = alloca i8*
%2 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([36 x i8], [36 x i8]* @.str, i64 0, i64 0))
%3 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([81 x i8], [81 x i8]* @.str.1, i64 0, i64 0))
%4 = bitcast i8** %1 to i8*
%5 = call i64 @json_util_allocStringByInteger(i32 -1, i8** %1)
%6 = icmp eq i64 %5, 0
br i1 %6, label %9, label %7
7: ; preds = %0
%8 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str.2, i64 0, i64 0), i32 -1)
br label %14
9: ; preds = %0
%10 = load i8*, i8** %1
%11 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i64 0, i64 0), i32 1, i8* %10)
%12 = load i8*, i8** %1
%13 = call i32 @free(i8* %12)
br label %14
14: ; preds = %9, %7
%15 = call i64 @json_util_allocStringByInteger(i32 0, i8** %1)
%16 = icmp eq i64 %15, 0
br i1 %16, label %19, label %17
17: ; preds = %14
%18 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str.2, i64 0, i64 0), i32 0)
br label %24
19: ; preds = %14
%20 = load i8*, i8** %1
%21 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i64 0, i64 0), i32 2, i8* %20)
%22 = load i8*, i8** %1
%23 = call i32 @free(i8* %22)
br label %24
24: ; preds = %19, %17
%25 = call i64 @json_util_allocStringByInteger(i32 1, i8** %1)
%26 = icmp eq i64 %25, 0
br i1 %26, label %29, label %27
27: ; preds = %24
%28 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str.2, i64 0, i64 0), i32 1)
br label %34
29: ; preds = %24
%30 = load i8*, i8** %1
%31 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i64 0, i64 0), i32 3, i8* %30)
%32 = load i8*, i8** %1
%33 = call i32 @free(i8* %32)
br label %34
34: ; preds = %29, %27
%35 = call i64 @json_util_allocStringByInteger(i32 20, i8** %1)
%36 = icmp eq i64 %35, 0
br i1 %36, label %39, label %37
37: ; preds = %34
%38 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str.2, i64 0, i64 0), i32 20)
br label %44
39: ; preds = %34
%40 = load i8*, i8** %1
%41 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i64 0, i64 0), i32 4, i8* %40)
%42 = load i8*, i8** %1
%43 = call i32 @free(i8* %42)
br label %44
44: ; preds = %39, %37
%45 = call i64 @json_util_allocStringByInteger(i32 3, i8** %1)
%46 = icmp eq i64 %45, 0
br i1 %46, label %49, label %47
47: ; preds = %44
%48 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str.2, i64 0, i64 0), i32 3)
br label %54
49: ; preds = %44
%50 = load i8*, i8** %1
%51 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i64 0, i64 0), i32 5, i8* %50)
%52 = load i8*, i8** %1
%53 = call i32 @free(i8* %52)
br label %54
54: ; preds = %49, %47
%55 = call i64 @json_util_allocStringByInteger(i32 4, i8** %1)
%56 = icmp eq i64 %55, 0
br i1 %56, label %59, label %57
57: ; preds = %54
%58 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str.2, i64 0, i64 0), i32 4)
br label %64
59: ; preds = %54
%60 = load i8*, i8** %1
%61 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i64 0, i64 0), i32 6, i8* %60)
%62 = load i8*, i8** %1
%63 = call i32 @free(i8* %62)
br label %64
64: ; preds = %59, %57
%65 = call i64 @json_util_allocStringByInteger(i32 100, i8** %1)
%66 = icmp eq i64 %65, 0
br i1 %66, label %69, label %67
67: ; preds = %64
%68 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str.2, i64 0, i64 0), i32 100)
br label %74
69: ; preds = %64
%70 = load i8*, i8** %1
%71 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i64 0, i64 0), i32 7, i8* %70)
%72 = load i8*, i8** %1
%73 = call i32 @free(i8* %72)
br label %74
74: ; preds = %69, %67
%75 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([82 x i8], [82 x i8]* @.str.4, i64 0, i64 0))
ret void
}