#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(void) {
  int n, fail;
  int sbsize = 80;
  int size;
  char *s;
  fail = syscon_number_of_symbols(&n);
  printf("number of symbols in the table : %d\n", n);
  printf("the symbols :");
  fail = syscon_write_symbols();
  printf("\n");
  size = n * 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
movl   $0x50,-0xc(%rbp)
lea    -0x4(%rbp),%rdi
call   1070 <syscon_number_of_symbols@plt>
mov    %eax,-0x8(%rbp)
mov    -0x4(%rbp),%esi
lea    0xe8b(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xea2(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    $0x0,%al
call   1050 <syscon_write_symbols@plt>
mov    %eax,-0x8(%rbp)
lea    0xe88(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x4(%rbp),%eax
imul   -0xc(%rbp),%eax
mov    %eax,-0x10(%rbp)
mov    -0x10(%rbp),%edi
mov    $0x1,%esi
call   1060 <calloc@plt>
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rsi
lea    -0x10(%rbp),%rdi
call   1040 <syscon_string_of_symbols@plt>
mov    %eax,-0x8(%rbp)
mov    -0x18(%rbp),%rsi
lea    0xe5b(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x10(%rbp),%esi
lea    0xe66(%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
lea    0xc(%rsp),%rdi
call   1080 <syscon_number_of_symbols@plt>
mov    0xc(%rsp),%esi
lea    0xe86(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xe9d(%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    0xc(%rsp),%eax
shl    $0x4,%eax
lea    (%rax,%rax,4),%edi
mov    %edi,0x8(%rsp)
mov    $0x1,%esi
call   1070 <calloc@plt>
mov    %rax,%rbx
lea    0x8(%rsp),%rdi
mov    %rax,%rsi
call   1050 <syscon_string_of_symbols@plt>
lea    0xe64(%rip),%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x8(%rsp),%esi
lea    0xe6b(%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() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8*
store i32 80, i32* %3
%6 = call i32 @syscon_number_of_symbols(i32* %1)
store i32 %6, i32* %2
%7 = load i32, i32* %1
%8 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str, i64 0, i64 0), i32 %7)
%9 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0))
%10 = call i32 (...) @syscon_write_symbols()
store i32 %10, i32* %2
%11 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%12 = load i32, i32* %1
%13 = load i32, i32* %3
%14 = mul nsw i32 %12, %13
store i32 %14, i32* %4
%15 = load i32, i32* %4
%16 = call i64 @calloc(i32 %15, i32 1)
%17 = inttoptr i64 %16 to i8*
store i8* %17, i8** %5
%18 = load i8*, i8** %5
%19 = call i32 @syscon_string_of_symbols(i32* %4, i8* %18)
store i32 %19, i32* %2
%20 = load i8*, i8** %5
%21 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.3, i64 0, i64 0), i8* %20)
%22 = load i32, i32* %4
%23 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str.4, i64 0, i64 0), i32 %22)
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() {
%1 = alloca i32
%2 = alloca i32
%3 = bitcast i32* %1 to i8*
%4 = bitcast i32* %2 to i8*
%5 = call i32 @syscon_number_of_symbols(i32* %1)
%6 = load i32, i32* %1
%7 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([37 x i8], [37 x i8]* @.str, i64 0, i64 0), i32 %6)
%8 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0))
%9 = call i32 (...) @syscon_write_symbols()
%10 = call i32 @putchar(i32 10)
%11 = load i32, i32* %1
%12 = mul nsw i32 %11, 80
store i32 %12, i32* %2
%13 = call i64 @calloc(i32 %12, i32 1)
%14 = inttoptr i64 %13 to i8*
%15 = call i32 @syscon_string_of_symbols(i32* %2, i8* %14)
%16 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([28 x i8], [28 x i8]* @.str.3, i64 0, i64 0), i8* %14)
%17 = load i32, i32* %2
%18 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([41 x i8], [41 x i8]* @.str.4, i64 0, i64 0), i32 %17)
ret void
}