#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 convertToStringFromNumber(int, char *);
int /*<<< orphan*/ free(char *);
scalar_t__ malloc(int);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ puts(char *);
int /*<<< orphan*/ scanf(char *, int *);
int main(int argc, const char *argv[]) {
  int num;
  int N;
  char *str = (char *)malloc((N + 1) * sizeof(char));
  printf("Input Num: \n");
  scanf("%d", &num);
  printf("\nInput length of num\n");
  scanf("%d", &N);
  int check = convertToStringFromNumber(num, str);
  if (check) {
    puts(str);
  } else {
    printf("Something Wrong\n");
  }
  free(str);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x18(%rbp),%eax
add    $0x1,%eax
cltq
shl    $0x0,%rax
mov    %eax,%edi
call   1070 <malloc@plt>
mov    %rax,-0x20(%rbp)
lea    0xe6c(%rip),%rdi
call   1060 <printf@plt>
lea    0xe6d(%rip),%rdi
lea    -0x14(%rbp),%rsi
call   1080 <scanf@plt>
lea    0xe60(%rip),%rdi
call   1060 <printf@plt>
lea    0xe51(%rip),%rdi
lea    -0x18(%rbp),%rsi
call   1080 <scanf@plt>
mov    -0x14(%rbp),%edi
mov    -0x20(%rbp),%rsi
call   1050 <convertToStringFromNumber@plt>
mov    %eax,-0x24(%rbp)
cmpl   $0x0,-0x24(%rbp)
je     11ec <main+0x8c>
mov    -0x20(%rbp),%rdi
call   1040 <puts@plt>
jmp    11f8 <main+0x98>
lea    0xe33(%rip),%rdi
call   1060 <printf@plt>
mov    -0x20(%rbp),%rdi
call   1030 <free@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
push   %rax
call   1060 <malloc@plt>
mov    %rax,%rbx
lea    0xea0(%rip),%rdi
call   1040 <puts@plt>
lea    0xe91(%rip),%r14
mov    %rsp,%rsi
mov    %r14,%rdi
call   1070 <scanf@plt>
lea    0xe8e(%rip),%rdi
call   1040 <puts@plt>
lea    0x4(%rsp),%rsi
mov    %r14,%rdi
call   1070 <scanf@plt>
mov    (%rsp),%edi
mov    %rbx,%rsi
call   1050 <convertToStringFromNumber@plt>
test   %eax,%eax
je     11a7 <main+0x57>
mov    %rbx,%rdi
jmp    11ae <main+0x5e>
lea    0xe76(%rip),%rdi
call   1040 <puts@plt>
mov    %rbx,%rdi
call   1030 <free@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [13 x i8] c"Input Num: \0A\00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [22 x i8] c"\0AInput length of num\0A\00"
@.str.3 = [17 x i8] c"Something Wrong\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32
%8 = alloca i8*
%9 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%10 = load i32, i32* %7
%11 = add nsw i32 %10, 1
%12 = sext i32 %11 to i64
%13 = mul i64 %12, 1
%14 = trunc i64 %13 to i32
%15 = call i64 @malloc(i32 %14)
%16 = inttoptr i64 %15 to i8*
store i8* %16, i8** %8
%17 = call i32 @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0))
%18 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %6)
%19 = call i32 @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.2, i64 0, i64 0))
%20 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %7)
%21 = load i32, i32* %6
%22 = load i8*, i8** %8
%23 = call i32 @convertToStringFromNumber(i32 %21, i8* %22)
store i32 %23, i32* %9
%24 = load i32, i32* %9
%25 = icmp ne i32 %24, 0
br i1 %25, label %26, label %29
26: ; preds = %2
%27 = load i8*, i8** %8
%28 = call i32 @puts(i8* %27)
br label %31
29: ; preds = %2
%30 = call i32 @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.3, i64 0, i64 0))
br label %31
31: ; preds = %29, %26
%32 = load i8*, i8** %8
%33 = call i32 @free(i8* %32)
ret i32 0
}

LLVM IR (-O2):
@.str.1 = [3 x i8] c"%d\00"
@str = [12 x i8] c"Input Num: \00"
@str.4 = [21 x i8] c"\0AInput length of num\00"
@str.5 = [16 x i8] c"Something Wrong\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca i32
%4 = alloca i32
%5 = bitcast i32* %3 to i8*
%6 = bitcast i32* %4 to i8*
%7 = tail call i64 @malloc(i32 undef)
%8 = inttoptr i64 %7 to i8*
%9 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @str, i64 0, i64 0))
%10 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %3)
%11 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @str.4, i64 0, i64 0))
%12 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %4)
%13 = load i32, i32* %3
%14 = call i32 @convertToStringFromNumber(i32 %13, i8* %8)
%15 = icmp eq i32 %14, 0
br i1 %15, label %18, label %16
16: ; preds = %2
%17 = call i32 @puts(i8* dereferenceable(1) %8)
br label %20
18: ; preds = %2
%19 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @str.5, i64 0, i64 0))
br label %20
20: ; preds = %18, %16
%21 = call i32 @free(i8* %8)
ret i32 0
}