#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 */
scalar_t__ calloc(int, int);
int /*<<< orphan*/ printf(char *, ...);
int syscon_number_of_symbols(int *);
int syscon_string_of_symbols(int *, char *);
int syscon_write_symbols();
void test_symbol_table(int *nvr) {
  int fail;
  int sbsize = 80;
  int size;
  char *s;
  fail = syscon_number_of_symbols(nvr);
  printf("number of symbols in the table : %d\n", *nvr);
  printf("the symbols :");
  fail = syscon_write_symbols();
  printf("\n");
  size = (*nvr) * sbsize;
  s = (char *)calloc(size, sizeof(char));
  fail = syscon_string_of_symbols(&size, s);
  printf("the string of symbols : %s\n", s);
  printf("number of characters in the string : %d\n", size);
}


x86 assembly (clang, -O0):
<test_symbol_table>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
movl   $0x50,-0x10(%rbp)
mov    -0x8(%rbp),%rdi
call   1070 <syscon_number_of_symbols@plt>
mov    %eax,-0xc(%rbp)
mov    -0x8(%rbp),%rax
mov    (%rax),%esi
lea    0xe84(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe9b(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    $0x0,%al
call   1050 <syscon_write_symbols@plt>
mov    %eax,-0xc(%rbp)
lea    0xe81(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x8(%rbp),%rax
mov    (%rax),%eax
imul   -0x10(%rbp),%eax
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%edi
mov    $0x1,%esi
call   1060 <calloc@plt>
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rsi
lea    -0x14(%rbp),%rdi
call   1040 <syscon_string_of_symbols@plt>
mov    %eax,-0xc(%rbp)
mov    -0x20(%rbp),%rsi
lea    0xe51(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x14(%rbp),%esi
lea    0xe5c(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<test_symbol_table>:
push   %rbx
sub    $0x10,%rsp
mov    %rdi,%rbx
call   1080 <syscon_number_of_symbols@plt>
mov    (%rbx),%esi
lea    0xe8a(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xea1(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
xor    %eax,%eax
call   1060 <syscon_write_symbols@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
mov    (%rbx),%eax
shl    $0x4,%eax
lea    (%rax,%rax,4),%edi
mov    %edi,0xc(%rsp)
mov    $0x1,%esi
call   1070 <calloc@plt>
mov    %rax,%rbx
lea    0xc(%rsp),%rdi
mov    %rax,%rsi
call   1050 <syscon_string_of_symbols@plt>
lea    0xe6a(%rip),%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0xc(%rsp),%esi
lea    0xe71(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [37 x i8] c"number of symbols in the table : %d\0A\00"
@.str.1 = [14 x i8] c"the symbols :\00"
@.str.2 = [2 x i8] c"\0A\00"
@.str.3 = [28 x i8] c"the string of symbols : %s\0A\00"
@.str.4 = [41 x i8] c"number of characters in the string : %d\0A\00"
define void @test_symbol_table(i32* %0) {
%2 = alloca i32*
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i8*
store i32* %0, i32** %2
store i32 80, i32* %4
%7 = load i32*, i32** %2
%8 = call i32 @syscon_number_of_symbols(i32* %7)
store i32 %8, i32* %3
%9 = load i32*, i32** %2
%10 = load i32, i32* %9
%11 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str, i64 0, i64 0), i32 %10)
%12 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0))
%13 = call i32 (...) @syscon_write_symbols()
store i32 %13, i32* %3
%14 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%15 = load i32*, i32** %2
%16 = load i32, i32* %15
%17 = load i32, i32* %4
%18 = mul nsw i32 %16, %17
store i32 %18, i32* %5
%19 = load i32, i32* %5
%20 = call i64 @calloc(i32 %19, i32 1)
%21 = inttoptr i64 %20 to i8*
store i8* %21, i8** %6
%22 = load i8*, i8** %6
%23 = call i32 @syscon_string_of_symbols(i32* %5, i8* %22)
store i32 %23, i32* %3
%24 = load i8*, i8** %6
%25 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.3, i64 0, i64 0), i8* %24)
%26 = load i32, i32* %5
%27 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str.4, i64 0, i64 0), i32 %26)
ret void
}

LLVM IR (-O2):
@.str = [37 x i8] c"number of symbols in the table : %d\0A\00"
@.str.1 = [14 x i8] c"the symbols :\00"
@.str.3 = [28 x i8] c"the string of symbols : %s\0A\00"
@.str.4 = [41 x i8] c"number of characters in the string : %d\0A\00"
define void @test_symbol_table(i32* %0) {
%2 = alloca i32
%3 = bitcast i32* %2 to i8*
%4 = tail call i32 @syscon_number_of_symbols(i32* %0)
%5 = load i32, i32* %0
%6 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([37 x i8], [37 x i8]* @.str, i64 0, i64 0), i32 %5)
%7 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0))
%8 = tail call i32 (...) @syscon_write_symbols()
%9 = tail call i32 @putchar(i32 10)
%10 = load i32, i32* %0
%11 = mul nsw i32 %10, 80
store i32 %11, i32* %2
%12 = tail call i64 @calloc(i32 %11, i32 1)
%13 = inttoptr i64 %12 to i8*
%14 = call i32 @syscon_string_of_symbols(i32* %2, i8* %13)
%15 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([28 x i8], [28 x i8]* @.str.3, i64 0, i64 0), i8* %13)
%16 = load i32, i32* %2
%17 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([41 x i8], [41 x i8]* @.str.4, i64 0, i64 0), i32 %16)
ret void
}